akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 101000
using namespace std;
struct KSD
{
    int v,next;
}e[N<<1];
int head[N],cnt;
inline void add(int u,int v)
{
    e[++cnt].v=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
int n;
int sg[N];
void dfs(int x,int p)
{
    int i,v;
    sg[x]=0;
    for(i=head[x];i;i=e[i].next)
    {
        v=e[i].v;
        if(v==p)continue;
        dfs(v,x);
        sg[x]^=(sg[v]+1);
    }
}
int main()
{
    int i,j,T;
    int a,b;


        cnt=1;
        memset(head,0,sizeof(head));
        scanf("%d",&n);
        for(i=1;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            add(a,b),add(b,a);
        }
        dfs(1,0);
        if(sg[1])puts("Alice");
        else puts("Bob");

    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;

const ll mod =1e9 + 7;

ll dp[22][1<<22]={};
bool dpb[22][1<<22]={};
int con[21][21];
short n;
ll a(int m,ll w){
	if(dpb[m][w])return dp[m][w];
	dpb[m][w]=1;
	bool b=0;
	rep(i,n){
		if((1<<i)&w)continue;
		if(!con[m][i])continue;
		dp[m][w]+=a(m+1,w+(1<<i));
		dp[m][w]%=mod;
	}
	return dp[m][w];
	

}

int main(){
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>con[i][j];
		}
	}
	dpb[n][(1<<n)-1]=1;
	dp[n][(1<<n)-1]=1;
	cout<<a(0,0)<<endl;
}

Measured memory_bytes: 391424
/*
 * Ankit Raj, NIT Agartala
 */
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define MAX_RANGE 10000007
#define BOOST ios_base::sync_with_stdio(0) 
#define NITRO cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main()
{
	BOOST;
	NITRO;
	//clock_t t1,t2;
	//t1 = clock();
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	*/ 
	//Main Code
	string s;
	cin>>s;
	int n = s.length();
	string req = "keyence";
	if(s==req)
	{
		cout<<"YES"<<"\n";
	}
	else
	{
		int window = n - req.length();
		string first = "";
		string last = s.substr(window,n-window);
		//cout<<first<<" "<<last<<"\n";
		for(int i=0;i+window<n;i++)
		{
			string tp = first + last;
			if(tp==req)
			{
				cout<<"YES"<<"\n";
				return 0;
			}
			first += s[i];
			last.erase(0,1);
			//cout<<first<<" "<<last<<"\n";
		}
		cout<<"NO"<<"\n";
	}

	//t2 = clock();
	//float diff = (float)t2 - (float)t1;
	//float execution_time = diff/CLOCKS_PER_SEC;
	//cout<<"\n"<<execution_time;
	//system("pause");
}


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

#define int long long

struct Combination
{
  int mod;
  vector<int> mfact;
  vector<int> rfact;

  /*
    constructor : O(sz+log(mod))    
   */
  Combination(int sz, int mod) : mfact(sz+1), rfact(sz+1), mod(mod) {
    mfact[0] = 1;
    for ( int i = 1; i < (int)mfact.size(); i++ ) {
      mfact[i] = mfact[i-1]*i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      rfact[i] = rfact[i+1]*(i+1) % mod;
    }
  }

  int fact(int k) const {
    return (mfact[k]);
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int inv(int x) const {
    return (pow(x, mod - 2));
  }

  /*
    permutation
   */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return (mfact[n]*rfact[n-r] % mod);
  }

  /*
    combination
   */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return (mfact[n]*rfact[r]%mod * rfact[n-r] % mod);    
  }  

  /*
    combination with repetition
   */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
   */
  int S(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      int add = C(r, i)*pow(i, n)%mod;      
      if ( (r-i)&1 ) ret += mod-add;
      else ret += add;
      ret %= mod;      
    }
    (ret *= rfact[r]) %= mod;
    return ret;
  }

  /*
    bell number
   */
  int B(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      (ret += S(n, i)) %= mod;      
    }
    return ret;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  if ( n > k ) cout << 0 << endl;
  else cout << 1 << endl;
  
  return 0;
}



Measured memory_bytes: 3168
#include <atcoder/lazysegtree>
#include <iostream>
#include <vector>

struct S {
    int64_t zeros, ones, inversion;
};

using F = bool;

S op(S x, S y)
{
    return S{x.zeros + y.zeros, x.ones + y.ones,
             x.inversion + y.inversion + x.ones * y.zeros};
}

S e() { return S{0, 0, 0}; }

S mapping(F f, S s)
{
    return f ? S{s.ones, s.zeros, s.zeros * s.ones - s.inversion} : s;
}

F composition(F f, F g) { return f != g; }

F id() { return 0; }

int main()
{
    int N, Q;
    std::cin >> N >> Q;

    std::vector<S> A(N);
    for (auto& a : A) {
        int x;
        std::cin >> x;
        a = S{1 - x, x, 0};
    }

    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> lst(A);
    for (int i = 0; i < Q; i++) {
        int t, l, r;
        std::cin >> t >> l >> r;

        if (t == 1) {
            lst.apply(l - 1, r, 1);
        } else {
            std::cout << lst.prod(l - 1, r).inversion << '\n';
        }
    }
}

Measured memory_bytes: 20340
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, m;
  vector<int> vec_a;
  
  while (1) {
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    
    vec_a.clear();
    while (n--) {
      int a;
      cin >> a;
      vec_a.push_back(a);
    }
    
    sort(vec_a.begin(), vec_a.end());

    int max_value = 0;
    for (int i = 0; i != vec_a.size(); i++) {
      for (int j = i + 1; j != vec_a.size(); j++) {
        int value = vec_a.at(i) + vec_a.at(j);
        if (value > m) break;
        if (value > max_value) max_value = value;
      }
    }

    max_value ? cout << max_value << endl : cout << "NONE" << endl;
  }
}
        



Measured memory_bytes: 3120
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
vector< vector<pll> > Adj(100005);
int color[100005];
void dfs(ll u, ll dist)
{
    color[u] = dist % 2 + 1;
    for(auto it : Adj[u])
        if(!color[it.F])
            dfs(it.F, dist + it.S);
}
int main()
{
    IO
    ll n, a, b, c;
    cin >> n;
    REP(i, 0, n - 1)
    {
        cin >> a >> b >> c;
        Adj[a].push_back({b, c});
        Adj[b].push_back({a, c});
    }
    dfs(1, 0);
    REP(i, 1, n + 1)
        cout << color[i] - 1 << NL;
    return 0;
}


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

using namespace std;

int h[100010],c[100010];

int d(int i){
    if(i==1){
        return 0;
    }
    if(i==2){
        return abs(h[2]-h[1]);
    }
    if(i==3){
        return abs(h[3]-h[1]);
    }
    if(c[i]!=-1){
        return c[i];
    }
    c[i]=min(abs(h[i]-h[i-1])+d(i-1),abs(h[i]-h[i-2])+d(i-2));
    return c[i];
}

int main()
{
    int n;
    for(int i=0;i<100010;i++){
        c[i]=-1;
    }
    cin>>n;
    for(int a=1;a<=n;a++){
        cin>>h[a];
    }
    cout<<d(n);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int a[200001],b[2020],c[200001],d[200001];
int main(){
	int n=0,len,sum=0,summ;
	string s;
	cin>>s;
	len=s.size();
	d[0]=1;
	for(int i=1;i<=len;i++){
		d[i]=(d[i-1]*10)%2019;
	}
	for(int i=0;i<len;i++){
		a[i+1]=s[i]-'0';
		sum=(sum*10+a[i+1])%2019;
		c[i+1]=(sum*d[len-i])%2019;
		b[c[i+1]]++;
//		cout<<c[i+1]<<endl;
	}
	summ=b[0];
	b[0]++;
	sum=0;
	for(int i=0;i<2019;i++){
		if(b[i]>1) sum+=b[i]*(b[i]-1)/2;
//		if(b[i]!=0) cout<<i<<" "<<b[i]<<" "<<b[i]*(b[i]-1)/2<<endl;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 6024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


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

  unordered_map<int, int> mp;
  int temp;
  REP(i, 0, M){
    cin >> temp;
    mp[temp] = 0;
  }

  ll dp[N+1];
  REP(i, 0, N+1)
    dp[i] = 0;

  REP(i, 0, N+1){
    if ((i==0) or (i==1)){
      auto itr = mp.find(i);
      if(itr != mp.end()){
        dp[i] = 0;
      }
      else
        dp[i] = 1;
      continue;
    }

    auto itr = mp.find(i);
    if(itr != mp.end()){
      dp[i] = 0;
    }
    else{
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] = dp[i] % (ll)1000000007;
      // cout << "dp[" << i << "] : " << dp[i] << endl;
    }
  }

  cout << dp[N] % (ll)1000000007 << endl;

  return 0;
}
 

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int gcd(int x, int y){ return y ? gcd(y, x%y) : x; }
int n, a[100005], k;

int main(){
	scanf("%d %d",&n,&k);
	int g = 0, mx = 0;
	for(int i=0; i<n; i++){
		int x; scanf("%d",&x);
		mx = max(mx,x);
		g = gcd(x, g);
	}
	if(k % g || mx < k) puts("IMPOSSIBLE");
	else printf("POSSIBLE");
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
mod=10**9+7
for i in range(0,a[0]+1):
    dp[i]=1
for i in range(1,len(a)):
    for j in range(1,k+1):
        dp[j]=(dp[j]+dp[j-1])%mod
    for j in range(k,a[i],-1):
        dp[j]=(dp[j]-dp[j-a[i]-1]+mod)%mod
print(dp[k])

Measured memory_bytes: 42876
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 998244353;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1003455
ll fact[tam],invfact[tam];
ll pot(ll base,ll exp)
{
    base%=MOD;
    ll res=1;
    while(exp)
    {
        if (exp&1)
            res*=base,res%=MOD;
        base*=base;base%=MOD;
        exp/=2;
    }
    return res;
}
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    fact[0]=1;
    forr(i,1,tam)    
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
    

    invfact[tam-1]=pot(fact[tam-1],MOD-2);
    for(int i=tam-2;i>=0;i--)
        invfact[i]=invfact[i+1]*(i+1),invfact[i]%=MOD;
    ll n,m,k;
    cin>>n>>m>>k;
    if (n==1)
    {
        cout<<m<<endl;
    }
    else
    {
        ll atot=0,tot;
        forr(kp,0,k+1)
        {
            ll Ca=(n-1);
            ll Cb=(kp);
            tot=fact[Ca]*invfact[Cb];tot%=MOD;
            tot*=invfact[Ca-Cb],tot%=MOD;
            tot*=m;tot%=MOD;
            tot*=pot(m-1,n-kp-1);tot%=MOD;
            atot+=tot;atot%=MOD;
            //cout<<atot<<' ';
        }        
        //cout<<endl;
        cout<<atot<<endl;
    }

}
// PLUS ULTRA!!

Measured memory_bytes: 19328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
typedef pair<ll,P> lP;
typedef pair<P,ll> Pl;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){

    int h,w;
    char a[1010][1010];
    ll D[1010][1010];
    cin>>h>>w;

    priority_queue<lP,vector<lP>,greater<lP>> pq;
    bool vis[1010][1010]={};
    fr(i,h){
        fr(j,w){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                pq.push(mp(0,mp(i,j)));
            }
        }
    }
    while(!pq.empty()){
        lP lp=pq.top();
        ll d=lp.ft;
        P p=lp.sd;
        pq.pop();
        ll i=p.ft,j=p.sd;
        if(vis[i][j]) continue;
        vis[i][j]=1;
        //cout<<i<<" "<<j<<endl;
        D[i][j]=d;
        if(i){
            if(!vis[i-1][j]) pq.push(mp(d+1,mp(i-1,j)));
        }
        if(j){
            if(!vis[i][j-1]) pq.push(mp(d+1,mp(i,j-1)));
        }
        if(i<h-1){
            if(!vis[i+1][j]) pq.push(mp(d+1,mp(i+1,j)));
        }
        if(j<w-1){
            if(!vis[i][j+1]) pq.push(mp(d+1,mp(i,j+1)));
        }
    }
    ll ans=0;
    fr(i,h) fr(j,w) ans=max(ans,D[i][j]);
    cout<<ans<<endl;
}

Measured memory_bytes: 57312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, M; cin >> N >> M;
	vector<P> V; // first : カードの値
				 // second : カードの枚数
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		V.push_back(P(tmp, 1));
	}

	for (int i = 0; i < M; i++) {
		int b, c; cin >> b >> c;
		V.push_back(P(c, b));
	}

	sort(V.begin(), V.end(), greater<P>());

	//cout << "debug" << endl;
	//for (int i = 0; i < V.size(); i++) cout << V[i].first << " " << V[i].second << endl;

	ll ans = 0LL;
	for (int i = 0; i < V.size() && N > 0; i++) {
		ll num;
		if (V[i].second <= N) num = ll(V[i].second);
		else num = N;
		ans += ll(V[i].first)*num;
		N -= num;
		//cout << V[i].first << " " << num << endl;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii              pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define PI              3.14159265
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define __              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) 		for(int i=a;i<b;i++)
#define repb(i,a,b) 	for(int i=a;i>=b;i--)
#define endl			"\n"
#define m(a)		    memset(a,0,sizeof(a))
#define all(x)          begin(x), end(x)

/*
// warning this works with cpp14 only...register depricated in 17
void fastscan(int &x){
bool neg = false;register int c;
x = 0;c = getchar();
if(c=='-'){neg = true;c = getchar();}
for(; (c>47 && c<58); c=getchar()){x = x *10 + c - 48;}
if(neg){x *= -1;}}

*/

void file(){
	#ifndef ONLINE_JUDGE
	freopen("in.txt" , "r" , stdin);
	freopen("out.txt" , "w" , stdout);
	#endif
}

int bs(int a[] , int s , int e, int x){
	if(s<=e){
		int m = (s+e)/2;
		if(a[m]==x)
			return m;
		else if(a[m] > x)
			return bs(a,s,m-1,x);
		else return bs(a,m+1,e,x);
	}
	return -1;
}

#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
#define deba(a) for(auto &x:a) cout<<x<<" ";

#define sd(x) cin >> x;
#define sd2(x,y) cin >> x >> y;
#define sd3(x,y,z) cin >> x >> y >> z;
#define sd4(w,x,y,z) cin >> w >> x >> y >> z;

bool is_pal(string s) {return equal(all(s), s.rbegin());}

int fxp(int a, int b ,int p){       //(logn) fast exponentiation
    int res = 1;            		// call int x = fxp(2,5);
    while (b > 0) {
        if (b & 1)
            res = (res * a)%p;
        a = (a * a)%p;
        b >>= 1;
    }
    return (res%p);
}

void solve(){
	int n; cin >> n;
	int a[n]; for(int i=0 ; i<n ; ++i) cin >> a[i];
	int dp[n];
	dp[0]=0;
	dp[1] = abs(a[1]-a[0]) + dp[0];
	for(int i=2 ; i<n ; ++i){
		dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]));
	}
	cout << dp[n-1] << endl;
}

int32_t main(){	
	__;
	file();
	solve();
	return 0;
}






Measured memory_bytes: 5220
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

// a^n mod を計算する, O(log(n))
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;
}

int main(){
  int N; cin >> N;
  ll c[60][2] = {};
  rep(i,N) {
    ll A; cin >> A;
    bitset<60> s(A);
    rep(j,60) c[j][s.test(j)]++;
  }
  ll MOD = 1000000007;

  ll ans = 0;
  rep(i,60){
    ll comb = c[i][0]*c[i][1]%MOD;
    (ans += comb*modpow(2,i,MOD)%MOD) %= MOD;
  }
  cout << ans << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3596
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())

lis = [1 if s=='#' else 0 for s in S]
from itertools import accumulate
lis = list(accumulate(lis))

ans = 10**18
cnt = 0
for i in range(N-1, -1, -1):
    s = S[i]
    ans = min(ans, cnt+lis[i])
    if s=='.':
        cnt += 1
ans = min(ans, cnt)

print(ans)

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

struct Data{
  int num,id;
  char ch;
};

int Partition(Data A[],int p,int r){
  Data x = A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j].num<=x.num){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

void Quicksort(Data A[],int p,int r){
  if(p<r){
    int q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}

void check(Data A[],int n){
  for(int i=1;i<n;i++){
    if(A[i-1].num<A[i].num)continue;
    if(A[i-1].id<A[i].id)continue;
    cout<<"Not stable"<<endl;
    return;
  }
  cout<<"Stable"<<endl;
}

int main(){
  int n;
  Data A[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].ch>>A[i].num;
    A[i].id=i;
  }
  
  Quicksort(A,0,n-1);
  check(A,n); 
  for(int i=0;i<n;i++){
    cout<<A[i].ch<<' '<<A[i].num<<endl;
  }
  
  return 0;
}


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

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

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

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

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

string s;

int main() {
  string d;
  cin >> d >> s >> d;
  cout << "A" << s[0] << "C";
}


Measured memory_bytes: 3608
k = int(input())

s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(s[k - 1])


Measured memory_bytes: 2940
#include<cstdio> 
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int a[maxn],b[maxn],c[maxn],i,n;
long long anss,ans[maxn];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	sort(b+1,b+n+1);
	for (i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(c+1,c+n+1);
	int ptr=1;
	for (i=1;i<=n;i++)
	{
		while (c[ptr]<=b[i]&&ptr<n) ptr++;
		if (c[ptr]>b[i])
		{
			ans[i]=ans[i-1]+n-ptr+1;;
		}
		else ans[i]=ans[i-1];
	}
	ptr=1;
	for (i=1;i<=n;i++)
	{
		while (b[ptr]<=a[i]&&ptr<n) ptr++;
		if (b[ptr]>a[i])
		{
			anss+=ans[n]-ans[ptr-1];
		}
	}
	printf("%lld\n",anss);
}

Measured memory_bytes: 2176
/*
    Print test cases
 */

#include <stdio.h>

int main(void)
{
    int i, x;

    for(i = 0; i < 10000; i++)
    {
        scanf("%d", &x);
        if (x == 0)
        {
            return (0);
        }
        else
        {
            printf("Case %d: %d\n", i + 1, x);
        }
    }
    return (0);
}


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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

    int sm = 0;
    rep(i,n.length()) sm += ctoi(n[i]);    

    cout<< ( (stoi(n)%sm == 0) ? "Yes" : "No") <<endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray().ToList();
        bool f = false;
        var alon = 0;
        while (!f)
        {
            s.RemoveAt(s.Count - 1);
            if (s.Count % 2 != 0) continue;
            var s1 = new List<char>();
            var s2 = new List<char>();
            for (var i = 0; s.Count / 2 > i; i++)
            {
                s1.Add(s[i]);
            }
            for (var i = s.Count / 2; s.Count > i; i++)
            {
                s2.Add(s[i]);
            }
            alon = s.Count;
            var t1 = new String(s1.ToArray());
            var t2 = new String(s2.ToArray());
            if (t1 == t2) f = true;
        }
        Console.WriteLine(alon);
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ld = long double;

int main()
{
	cout << fixed << setprecision(10);	// https://qiita.com/a4rcvv/items/05febcf410c51009a29a

	ld l; cin >> l;

	ld ans;
	ans = l * l * l / 27.0L;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
	int A,B,C,D,L,max,result;
	int Acnt = 0,Bcnt = 0;
	scanf("%d",&L);
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	for (A; A > 0; A = A - C) {
		Acnt = Acnt + 1;
	}
	for (B; B > 0; B = B - D) {
		Bcnt = Bcnt + 1;
	}
	if (Acnt > Bcnt) {
		max = Acnt;
	} else {
		max = Bcnt;
	}
	result = L - max;
	printf("%d\n",result);
}

Measured memory_bytes: 1024
n, d = gets.chomp.split(' ').map(&:to_i)

tables = []
n.times { |_i| tables << gets.chomp.split(' ').map(&:to_i) }

count = 0
n.times do |i_idx|
  j = i_idx + 1
  j.upto(n-1) do |j_idx|
    total = []
    d.times { |k| total << (tables[i_idx][k] - tables[j_idx][k])**2  }
    
    ans = total.inject(:+)**(1/2.0)
    
    count += 1 if ans == ans.to_i
  end
end


puts count

Measured memory_bytes: 1788
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n, k, q;
        scanf("%d%d%d", &n, &k, &q);
        q --;
        vector<int> a(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
        }
        long long ans = 100000000000000LL;
        for (int hoge = 0; hoge < n; hoge ++) {
                int mi = a[hoge];
                vector<vector<int>> segs;
                vector<int> seg;
                for (int i = 0; i < n; i ++) {
                        if (a[i] < mi) {
                                if (seg.empty()) continue;
                                segs.push_back(seg);
                                seg.clear();
                        } else {
                                seg.push_back(a[i]);
                        }
                }
                if (!seg.empty()) segs.push_back(seg);
                for (auto &seg : segs) {
                        sort(seg.begin(), seg.end());
                }
                vector<int> oks;
                for (auto seg : segs) {
                        int len = (int) seg.size();
                        for (int i = 0; i < len - k + 1; i ++) {
                                oks.push_back(seg[i]);
                        }
                }
                sort(oks.begin(), oks.end());
                if (oks.size() < q + 1) continue;
                ans = min(ans, (long long) oks[q] - mi);
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
# cnt->size
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.reverse()    # 逆から考える

ans_list = [-1 for i in range(M)]
ans_list[M-1] = N*(N-1)//2

# parent(親)
par = [i for i in range(N+1)]
# rank(深さ)
rank = [0 for i in range(N+1)]
# 同グループの頂点数
size = [1 for i in range(N+1)]

# 木の根を求める
def root(x):
    if par[x] == x:             # 根の時
        return x
    else:
        par[x] = root(par[x])   # 経路圧縮
        return par[x]

# xとyの属する集合を併合(ランク有)
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
        size[y] += size[x]
    else:
        par[y] = x
        size[x] += size[y]
        if rank[x] == rank[y]:
            rank[x] += 1

for i in range(M-1):
    a,b = AB[i][0],AB[i][1]
    # 答えはans_list[M-2-i]を書き換える
    if root(a) == root(b):
        ans_list[M-2-i] = ans_list[M-1-i]
        continue
    else:
        ans_list[M-2-i] = ans_list[M-1-i] - size[root(a)]*size[root(b)]
        unite(a,b)
print('\n'.join(map(str,ans_list)))



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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 1e9;


int res;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );
    int n;
    cin >> n;
    cout << 500 * (n / 500 * 2) + ((( n % 500 ) / 5) * 5) ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

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

int main(){
    int x;
    cin>>x;
    ll ans=0;
    for(int i=1;i<=x;++i){
        for(int j=1;j<=x;++j){
            ll t=gcd(i,j);
            for(int k=1;k<=x;++k){
                ans+=gcd(t,k);
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(){

    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<string> s(n);
        for(int i = 0; i < n; i++){
            string input; cin >> input;
            s[i] = input[0];
            for(int j = 1; j < input.size(); j++){
                char c = input[j - 1];
                if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
                    s[i] = s[i] + input[j];
                }
            }
        }

        int ans = -1;

        for(int k = 1; k <= 100; k++){
            set<string> S;

            for(int i = 0; i < n; i++){
                if(s[i].size() > k){
                    //cout << s[i].substr(0, k) << endl;
                    S.insert(s[i].substr(0, k));
                }
                else S.insert(s[i]);
            }

                //cout << S.size() << endl;
                if(S.size() == n){
                    ans = k;
                    break;
                }
            
        }

        cout << ans << endl;
        
    }

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <utility>

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

int N, M;
P minS[10005], maxS[10005];

int main(void)
{
	while(1){
		cin >> N >> M;
		if(N == 0 && M == 0) break;
		
		for(int i = 0; i < N; i++){
			minS[i] = maxS[i] = make_pair(0, i);
		}
		
		for(int i = 0; i < M; i++){
			int S, k, c;
			cin >> S >> k;
			for(int j = 0; j < k; j++){
				cin >> c;
				c--;
				if(k == 1) minS[c].first += S;
				maxS[c].first += S;
			}
		}
		
		sort(minS, minS+N);
		sort(maxS, maxS+N);
		reverse(maxS, maxS+N);
		
		int ans = 0;
		if(minS[0].second == maxS[0].second){
			ans = max(maxS[1].first - minS[0].first, maxS[0].first - minS[1].first);
		}else{
			ans = maxS[0].first - minS[0].first;
		}
		cout << ans + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3236
import collections
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
A = LI()
count = collections.Counter(A)
sum = 0
for x in count.values():
    sum += x*(x-1)//2
for x in A:
    print(sum-(count[x]-1))

Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int count(int N, vector<int>& P) {
  vector<int> ve;
  int fact = 1;
  rep(i, N) {
    ve.push_back(i+1);
    fact *= (i+1);
  }
  int cnt = 0;
  rep(i, N) {
    fact /= (N-i);
    auto pos = lower_bound(all(ve), P[i]);
    cnt += (pos - ve.begin()) * fact;
    ve.erase(pos);
  }
  return cnt;
}
int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  int cntP = count(N, P);
  int cntQ = count(N, Q);
  cout << abs(cntP - cntQ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll>v;
    v.push_back(s[0]-'a');
    for(ll i=1;i<s.length();i++)
    {
        ll num=s[i]-'a';
        if(v[v.size()-1]!=num)
        {
            v.push_back(num);
        }
    }
    cout<<v.size();
}

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

int top = 0;
int N[10000];

void push(int x)
 {
   top++;
   N[top] = x;
 }

int pop()
 {
   top--;
   return N[top + 1];
 }

int main()
 {
   string a;
   while(cin >> a)
     { 
       //cout << a << endl;
       if( a == "+") //?¶???????
         {
           int A,B,C;
            A = pop();
            B = pop();
            C = A + B;
           push(C);
          // cout << A << endl;
           //cout << B << endl;
           //cout << C << endl;
         } 

       else if( a == "-") //?????????
         {
           int E,F,G;
            E = pop();
            F = pop();
            G = F - E;
           push(G);
          // cout << E << endl;
         }

       else if( a == "*") //?????????
         {
           int H,I,J;
            H = pop();
            I = pop();
            J = H * I;
           //cout << H << endl;
           push(J);
         }

       else //??°???
         {
           push(atoi(a.c_str()));
          // cout << a << endl;
         }
     }
    cout << pop() << endl;
    return 0;
 }

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    string ans;
    sort(S.begin(),S.end());
    (S[0]==S[1] and S[2]==S[3] and S[0]!=S[3])?ans=YES:ans=NO;
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

template <typename T>
class Dice {
 public:
  vector<T> numbers;

  explicit Dice(vector<T> nums) : numbers(nums.begin(), nums.end()){};

  T get() const { return numbers[0]; }
  void roll(char op);
};

template <typename T>
void Dice<T>::roll(char op) {
  auto tmp = numbers[0];
  switch (op) {
    case 'N':
      numbers[0] = numbers[1];
      numbers[1] = numbers[5];
      numbers[5] = numbers[4];
      numbers[4] = tmp;
      break;
    case 'E':
      numbers[0] = numbers[3];
      numbers[3] = numbers[5];
      numbers[5] = numbers[2];
      numbers[2] = tmp;
      break;
    case 'W':
      numbers[0] = numbers[2];
      numbers[2] = numbers[5];
      numbers[5] = numbers[3];
      numbers[3] = tmp;
      break;
    case 'S':
      numbers[0] = numbers[4];
      numbers[4] = numbers[5];
      numbers[5] = numbers[1];
      numbers[1] = tmp;
      break;
    default:
      break;
  }
}
int main() {
  vector<int> numbers(6);
  string operations;
  for (size_t i = 0; i < 6; i++) {
    cin >> numbers[i];
  }

  cin >> operations;
  Dice<int> d{numbers};
  for (size_t i = 0; i < operations.size(); i++) {
    d.roll(operations[i]);
  }
  cout << d.get() << endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <functional>

using namespace std;

int n, k;
string s;

void solve() {
  deque<int> cnt;
  deque<char> v;
  char prev = '2';
  int cur = 0;
  for (int i=0;i<n;i++) {
    if (prev != s[i]) {
      cnt.push_back(cur);
      v.push_back(prev);
      cur = 1;
      prev = s[i];
    } else {
      cur++;
    }
  }
  cnt.pop_front();
  v.pop_front();
  cnt.push_back(cur);
  v.push_back(prev);
  vector<int> ans;
  int sum = 0;
  int l = 0, len = 0;
  int size = cnt.size();
  while(l+len < size) {
    while (l+len < size && len < 2 * k + v.at(l) - '0') {
      sum += cnt.at(l+len);
      len++;
    }
    ans.push_back(sum);
    sum -= cnt.at(l);
    l++;
    len--;
  }
  sort(ans.begin(), ans.end(), greater<int>());
  cout << ans.front() << endl;
}

int main() {
  cin >> n >> k;
  cin >> s;
  solve();
}


Measured memory_bytes: 1532
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H1= sc.nextInt();
		int M1= sc.nextInt();
		int H2 = sc.nextInt();
		int M2= sc.nextInt();
		int K = sc.nextInt();
		int start = H1*60+M1;
		int end = H2*60+M2;
		System.out.println(end-start-K);
	}
}

Measured memory_bytes: 35780
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        k: i32,
    }
    if k % 2 == 1 {
        let mut cnt = 0i64;
        for i in 1..n+1 {
            if i % k == 0 {
                cnt += 1;
            }
        }
        println!("{}", cnt.pow(3));
    } else {
        let mut half_k = 0i64;
        let mut k_cnt = 0i64;
        for i in 1..n+1 {
            if i % k == 0 {
                k_cnt += 1;
            } else if i % (k/2) == 0 {
                half_k += 1;
            }
        }
        println!("{}", half_k.pow(3) + k_cnt.pow(3));
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    int N, M;
    List<Tuple<int, int>>[] es;
    long[] pos;
    bool[] check;

    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        M = cin.nextInt();
        es = new List<Tuple<int, int>>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<Tuple<int, int>>();
        }
        for (int i = 0; i < M; i++)
        {
            int l, r, d;
            l = cin.nextInt() - 1;
            r = cin.nextInt() - 1;
            d = cin.nextInt();
            es[l].Add(Tuple.Create(r, d));
            es[r].Add(Tuple.Create(l, -d));
        }

        pos = new long[N];
        check = new bool[N];
        for (int i = 0; i < N; i++)
        {
            if (check[i]) continue;
            pos[i] = 0;
            if (!dfs(i))
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }
    
    bool dfs(int a)
    {
        check[a] = true;
        foreach (var next in es[a])
        {
            int p = next.Item1;
            long npos = next.Item2 + pos[a];
            if (check[p])
            {
                if (npos != pos[p]) return false;
                continue;
            }
            else
            {
                pos[p] = npos;
                if (!dfs(p)) return false;
            }
        }
        return true;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

// edit by  (xcode)

using namespace std;

#define int         long long
#define ll          long long
#define double      long double
#define pb          push_back
#define in          insert
#define mp          make_pair
#define f           first
#define s           second
//#define x           first
//#define y           second
#define all(el)     el.begin(), el.end()
#define allr(el)    el.rbegin(), el.rend()
#define sz(el)      (int)el.size()
#define endl        "\n"

inline int chkmax(int &x, int y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

inline int chkmin(int &x, int y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int> (m));
    vector<int> val(n);
    for (int i = 0; i < n; i++) {
        cin >> val[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 1e18;
    for (int i = 0; i < (1LL << n); i++) {
        vector<int> now;
        int need = 0;
        for (int j = 0; j < n; j++) {
            if ((1LL << j) & i) {
                now.pb(j);
                need += val[j];
            }
        }
        vector<int> check(m);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < sz(now); j++) {
                check[i] += a[now[j]][i];
            }
        }
        int ok = 1;
        for (int i = 0; i < m; i++) {
            if (check[i] < x) {
                ok = 0;
            }
        }
        if (ok) {
            chkmin(ans, need);
        }
    }
    if (ans != 1e18) {
        cout << ans;
    } else {
        cout << -1;
    }
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout << "Bad"<<endl;
  }else{
    cout << "Good"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, a[200], count=0;
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    while(1) {
        for(int i=0; i<n; i++) {
            if(a[i]%2!=0) {
                cout << count << endl;
                return 0;
            } else{
                a[i] /= 2;
            }
        }
        count++;
    }
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<int> x(n),y(n),a(n);
  rep(i,n){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  vector<vector<bool>> tile(h,vector<bool>(w));
  rep(k,n){
    rep(i,h){
      rep(j,w){
        switch(a.at(k)){
          case 1:
            if(j < x.at(k)){
              tile.at(i).at(j) = true;
            }
            break;
          case 2:
            if(j >= x.at(k)){
              tile.at(i).at(j) = true;
            }
            break;
          case 3:
            if(i < y.at(k)){
              tile.at(i).at(j) = true;
            }
            break; 
          case 4:
            if(i >= y.at(k)){
              tile.at(i).at(j) = true;
            }
            break;
          default:
            break;
        }
      }
    }
  }
  int64_t cnt = 0;
  rep(i,h){
    rep(j,w){
      //cout << tile.at(i).at(j);
      if(tile.at(i).at(j)){
        cnt++;
      }
    }
    //cout << endl;
  }
  cout << h*w-cnt << endl;
      

    
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	int x;
	cin >> x;
	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

}






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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }
  
  int A=0, B=0;
  int count=0;
  
  for(int i=1; i<n-1; i++){
    A = p.at(i-1)-p.at(i); 
    B = p.at(i+1)-p.at(i);
    if((A>0&&B<0)||(A<0&&B>0)){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256