akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

ll v[200005];
map<ll, int> tab;

int main() {
	int n,k;

	scanf("%d%d", &n, &k);

	for(int i = 1; i <= n; i++) {
		scanf("%lld", &v[i]);
		v[i] += v[i-1];
		v[i]%=k;
	}


	tab[0] = 1;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i >= k) {
			ll aux = (v[i-k] - (i-k))%k;
			if(aux < 0) aux += k;
			tab[aux]--;
		}
		ll cur = (v[i] - i)%k;
		if(cur < 0) cur += k;
		ans += tab[cur];
		tab[cur]++;
		// printf("%d: %lld, %lld\n", i, ans, cur);
	}

	printf("%lld\n", ans);

    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

const int MAX_N = 200000;

struct UF{
	int par[MAX_N];
	int rank[MAX_N];
	int si[MAX_N];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			si[y] += si[x];
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
			si[x] += si[y];
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
} uf[2];

int n, k, l;
map<P,int> ma;

int main(){
    cin >> n >> k >> l;
    rep(i,2) uf[i].init(n);
    rep(i,k) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf[0].unite(p,q);
    }
    rep(i,l) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        uf[1].unite(r,s);
    }
    rep(i,n) {
        P x = P(uf[0].find(i), uf[1].find(i));
        ma[x]++;
    }
    rep(i,n) {
        P x = P(uf[0].find(i), uf[1].find(i));
        cout << ma[x];
        if (i != n-1) cout << " ";
        else cout << endl;
    }
}
































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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a, b;
	pii ab[114514];
	cin>>n>>m;
	REP(i, m){
		cin>>a>>b;
		ab[i]=make_pair(a-1, b-2);
	}
	sort(ab, ab+m);
	int l=0, r=m;
	int ans=1;
	REP(i, m){
		if(r>=ab[i].first){
			l=max(l, ab[i].first);
			r=min(r, ab[i].second);
		}
		else{
			l=ab[i].first;
			r=ab[i].second;
			++ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    string s,t;cin>>s>>t;
    f(i,0,n){
        cout<<s[i]<<t[i];
    }
    return 0;
}   

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 1010 , mod = 1e9 + 7;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
char G[N][N];
int dp[N][N];

void solve(){
    scanf("%d %d" , &n , &m);
    for(int i = 0 ; i < n ; i ++){
        scanf("%s" , G[i]);
    }

    dp[0][0] = 1;
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < m ; j ++){
            if(G[i][j] == '#')continue;
            if(i - 1 >= 0){
                    dp[i][j] += dp[i-1][j];
                    dp[i][j] %= mod;
            }
            if(j - 1 >= 0){
                    dp[i][j] += dp[i][j-1];
                    dp[i][j] %= mod;
            }
        }
    }

    printf("%d\n" , dp[n-1][m-1]);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}






Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7, maxn = (1e5) + 10;  
const long double PI = acos(-1);
vector<pii> adj[maxn];
vector<int> vis(maxn, -1);

void dfs(int v, int color){
    vis[v] = color;
    // cout << v << " " << color << endl;

    for (auto it: adj[v]){
        if (vis[it.ff] == -1) dfs(it.ff, (it.ss & 1) ^ (color));
    }
}

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

    for (int i=0; i<n-1;i++){
        int w, a, b;
        cin >>a >> b >> w;
        adj[a].push_back({b, w});
        adj[b].push_back({a, w});
    }

    dfs(1, 1);

    for (int i=1; i<=n; i++){
        cout << vis[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 11824
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int modinverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        int q = a / m; 
        int t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x%mod; 
} 
int ncr(int n,int r)
{
    if(n<r)
    return 0;
    int numerator=1,denominator=1,i;
    if(r<n-r)
    r=n-r;
    for(i=n;i>r;i--)
    {
        numerator*=i;
        numerator%=mod;
    }
    for(i=1;i<=n-r;i++)
    {
        denominator*=i;
        denominator%=mod;
    }
    int ans=(numerator*modinverse(denominator,mod))%mod;
    return ans;
}
signed main()
{
    int n,k,i;
    cin>>n>>k;
    int blue=k,red=n-k;
    for(i=1;i<=k;i++)
    {
        int red_balls=red-(i-1),blue_balls=blue-i;
        int red_boxes=i+1,blue_boxes=i;
        int ans1=ncr(red_balls+red_boxes-1,red_boxes-1);
        int ans2=ncr(blue_balls+blue_boxes-1,blue_boxes-1);
        int ans=(ans1*ans2)%mod;
        cout<<ans<<endl;
    }
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 10;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    vector<ll> pos[26];
    ll N = s.length();
    for(int i = 0; i < N; i++) {
        pos[s[i] - 'a'].push_back(i);
    }
    ll cur = 0;
    ll ans = 0;
    for(char c : t) {
        // debug(c);
        int i = c - 'a';
        if(!pos[i].size()) {
            ans = -1;
            break;
        }
        ll j = lower_bound(pos[i].begin(), pos[i].end(), cur) - pos[i].begin();
        if(j == pos[i].size()) {
            ans += N + pos[i][0] - cur + 1;
            cur = pos[i][0] + 1;
        } else {
            ans += pos[i][j] - cur + 1;
            cur = pos[i][j] + 1;
        }
        // debug(ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1736
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

string s;
int n = 0;

signed main(){
    io();

    cin>>s;
    rep(i,s.size()){
        if(s[i]=='+') n++;
        else n--;
    }

    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct UnionFind {
	vector<int> data;
	/* constructor */
	UnionFind(int sz) { data.assign(sz, -1); }
	/* merge the set to which x belongs and the set to which y belongs */
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	/* find the root of k */
	int find(int k) {
		if (data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	/* calculate the size of the set to which k belongs */
	int size(int k) { return -data[find(k)]; }
};

int main() {
	UnionFind uf(2 * 100000);
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		int x, y; cin >> x >> y;
		--x, y += 100000 - 1;
		uf.unite(x, y);
	}
	map<int, pair<int, int>> cnt;
	for (int i = 0; i < 100000; ++i)
		++cnt[uf.find(i)].first;
	for (int i = 100000; i < 2 * 100000; ++i)
		++cnt[uf.find(i)].second;
	ll res = -N;
	for (auto& e : cnt) {
		int X_side = e.second.first;
		int Y_side = e.second.second;
		res += (ll)X_side * (ll)Y_side;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 13568
def main():
    N, D = map(int, input().split())
    cnt = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        d = (X**2 + Y**2)**0.5
        if d <= D:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 70536
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll cnt = 0;
	ll res = 0;
	rep(i, n-1) {
		if (a[i] >= a[i + 1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		chmax(res, cnt);
	}
	cout << res << endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  double dis1, dis2, dis3, dis4, a = 0;
  cin >> n;
  
  vector<int> xin(n,0);		vector<int> yin(n,0);
  for(int i = 0; i < n; i++){
    cin >> xin.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> yin.at(i);
    a = max(yin.at(i) - xin.at(i), xin.at(i) - yin.at(i));
    dis1 += a;
    dis2 += a * a;
    dis3 += a * a * a;
 	dis4 = max(a, dis4);
  }
  dis2 = sqrt(dis2);
  dis3 = pow(dis3, 0.333333333333);
  
  
  printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n", dis1, dis2, dis3, dis4);

}


Measured memory_bytes: 3356
def kaibun(s):
	for i in range( len(s) //2 ):
		#print(s[i], s[(-1*i) -1])
		if (s[i] != s[(-1*i) -1]):
			return False
	return True

s = input()		# 文字列の入力  abcdefg...


if kaibun(s):
	print(0)
	exit(0)

t = s.replace('x', '')

if not kaibun(t):
	print(-1)
	exit(0)


a=0
b=len(s)-1
ans=0

while a < b:
	A=s[a]
	B=s[b]
	#print(a,A, b,B)
	
	if A==B:
		a+=1
		b-=1
		continue
	
	if B=='x':
		b-=1
		ans+=1
		continue
	
	a+=1
	ans+=1


print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  int n;
  cin >> n;
  int ans = 0;
  for(int a = 1; a <= sqrt(n); a++ ){
    for(int b = a; b <= n/a; b++ ){
      if( a*b < n ){
        ans++;
        if( a != b ){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3700
// Author: Ishaan Gupta

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
#define endl '\n'
#define pb push_back
#define DEB(x) cout << '>' << #x << ':' << x << endl;
inline ll add(ll a,ll b){return (a%MOD+b%MOD)%MOD;}
inline ll sub(ll a,ll b){return (a%MOD-b%MOD+MOD)%MOD;}
inline ll mult(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll power(ll a,ll b){a%=MOD;ll r=1;while(b){if(b&1)r=mult(r,a);a=mult(a,a);b>>=1;}return r;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
#ifdef IG_PC
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif
    ll n,k;
    cin >> n>>k;
    vector<ll>h(n);
    for(ll &i : h)
    {
        cin >> i;
    }
    vector<ll>dp(n,MOD);
    for(ll i=0;i<k;++i)
    {
        dp[i]=abs(h[i]-h[0]);
    }
    for(ll i=k;i<n;++i)
    {
        for(ll j = 1;j<=k;++j)
        {
            dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    if(n>=1800)
        cout<<"1"<<endl;
    else if(n>=1600)
        cout<<"2"<<endl;
    else if(n>=1400)
        cout<<"3"<<endl;
    else if(n>=1200)
        cout<<"4"<<endl;
    else if(n>=1000)
        cout<<"5"<<endl;
    else if(n>=800)
        cout<<"6"<<endl;
    else if(n>=600)
        cout<<"7"<<endl;
    else
        cout<<"8"<<endl;
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  int n;
  cin >> n;
  vvi g(n,vi(n,-1));
  rep(i,n){
    int m;
    cin >> m;
    rep(j,m){
      int a,x;
      cin >> a >> x;
      a--;
      g[i][a] = x;
    }
  }

  int ans = 0;
  rep(i,1<<n){
    vi d(n);
    rep(j,n){
      if(i>>j&1){
        d[j] = 1;
      }
    }
    bool ok = true;
    rep(j,n){
      if(d[j]){
        rep(k,n){
          if(g[j][k] == -1) continue;
          if(g[j][k] != d[k]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  
  cout << ans << endl;
}

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;
using P = pair<int, int>;
// sort(A.begin(), A.end(), cmp)
bool cmp(P a, P b) { return a.second < b.second; }
#ifdef DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
#else
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; }
#endif
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e4+10; // 10^5
ll dp[MAX_ITEM] = {0};

int main() {
  int h,n;
  cin >> h >> n;
  vector<P> p(n);

  rep (i, n) {
    double a,b;
    cin >> a >> b;
    p[i] = P(a,b);
  }

  // 最小化問題なので、INF で埋める
  rep(i,h+1) dp[i] = INF;
  // 最初はzero
  dp[0] = 0;

  // あるHPまでに最小の魔力をDPしていく
  // dp[<HP>] = <COST> 
  rep(i,h+1) {
    // 選択肢の数だけ試す
    rep(j,n) {
      int damage = p[j].first;
      int cost = p[j].second;
      chmin(dp[ min(h, i+damage) ], dp[i] + cost);
    }
  }

  cout << dp[h] << endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    bool x = 1;
    for(int i = 0; i < 3; i++){
        if(S.at(i) == S.at(i + 1)){
            x = 0;
        }
    }
    if(x){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
}

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

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

int ans[12][1024];

void dfs(int bit,int d,int s){
	ans[d][s]++;
	for(int i=0;i<10;i++){
		if(bit&(1<<i))
			dfs(bit-(1<<i),d+1,s+(i*(d+1)));
	}
}

int main(){
	int n,s;
	dfs((1<<10)-1,0,0);
	while(cin>>n>>s)cout<<(s>1023?0:ans[n][s])<<endl;
}

Measured memory_bytes: 1200
n = int(input())
mod = 10 ** 9 + 7
s = [list(input()) for _ in range(2)]
ans = 1
i = 0
while i < n:
    if s[1][i] == s[0][i]:
        if i == 0:
            ans *= 3
            i += 1
        else:
            if s[0][i - 1] == s[1][i - 1]:
                ans = (ans * 2) % mod
            i += 1
    else:
        if i == 0:
            ans *= 6
        else:
            if s[0][i - 1] == s[1][i - 1]:
                ans = (ans * 2) % mod
            else:
                ans = (ans * 3) % mod
        i += 2
        
    
print(ans)

Measured memory_bytes: 9216
h,w = gets.chomp.split(" ").map(&:to_i)
s = Array.new{Array.new}
h.times do |i|
  s[i] = gets.chomp
  s[i] = s[i] + "#"
end
s[h] = ""
w.times do
  s[h] = s[h] + "#"
end
yoko = Array.new(h){Array.new(w,0)}
tate = Array.new(h){Array.new(w,0)}
h.times do |i|
  j = 0
  while j <= w-1
    from = j
    count = 0
    while s[i][j] == '.' && j <= w-1
      j += 1
      count += 1
    end
    from.upto(j-1) do |k|
      yoko[i][k] = count
    end
    j += 1
  end
end
w.times do |i|
  j = 0
  while j <= h-1
    from = j
    count = 0
    while s[j][i] == '.' && j <= h-1
      j += 1
      count += 1
    end
    from.upto(j-1) do |k|
      tate[k][i] = count
    end
    j += 1
  end
end
max = 0
for i in 0..h-1
  for j in 0..w-1
    max = yoko[i][j] + tate[i][j] - 1 if max < yoko[i][j] + tate[i][j] - 1
  end
end
puts max

Measured memory_bytes: 85636
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int>> calc_next(const string &s) {
    int n = s.size();
    vector<vector<int>> nxt(n + 1, vector<int>(26, n));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i] - 'a'] = i;
    }
    return nxt;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    auto nxt = calc_next(s);
    vector<int> dp(n + 2, INF);
    vector<pair<char, int>> recon(n + 1, {'?', n});
    dp[n] = 1, dp[n + 1] = 0;
    for (int i = n - 1; i >= 0; i--) for (int j = 0; j < 26; j++) {
        if (chmin(dp[i], dp[nxt[i][j] + 1] + 1)) {
            recon[i] = {'a' + j, nxt[i][j] + 1};
        }
    }
    string res = "";
    int idx = 0;
    while (idx < n) {
        auto p = recon[idx];
        res += p.first;
        idx = p.second;
    }
    cout << res << endl;
}

Measured memory_bytes: 29316
/* ex4_1
   shu_t */

#include<stdio.h>
#include<math.h>

int main(void){
  int tree_num, d;
  int ans;
  //input N and D
  scanf("%d %d",&tree_num,&d);
  //answer: round up to tree_num divided by 2*D+1
  ans = ceil((double) tree_num/(2*d+1));
  //output the answer
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;

int main() {
    int n, ans = 1;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i)
        cin >> d[i];
    sort(d.begin(), d.end());
    for (int i = 0; i < d.size() - 1; ++i)
        if (d[i] != d[i + 1])
            ++ans;
    cout << ans;
}


Measured memory_bytes: 256
//    >File Name: at.cpp
//    > Author: Webwei

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k,s;
	cin>>k>>s;
	int z;
	int sum=0;
	for(int x=0;x<=k;x++)
	{
		for(int y=0;y<=k;y++)
		{
			z=s-(x+y);
			if(0<=z&&z<=k) sum++;
		}
	}
	cout<<sum<<'\n';
}


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

typedef pair<int,int> P;
P dt[101000];
int n,m;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
        scanf("%d%d",&dt[i].first,&dt[i].second);
    sort(dt,dt+m);
    int rit,i=0,tp,ans=0;
    while(i<m)
    {
        tp=dt[i].second;
        while(dt[i].first<tp)
        {
            tp=min(tp,dt[i].second);
            i++;
        }
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, W, v[101], w[101];
ll mx;
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n >> W;
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
        mx += v[i];
    }
    vector<ll> dp(mx+1, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int rem = mx; rem>= v[i]; --rem) {
            dp[rem] = min(dp[rem], w[i]+dp[rem-v[i]]);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= mx; ++i) {
        if (dp[i] <= W) {
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

#define M 1046527

int dic[M] = {0};

int toInt(std::string str){
	int ret, i, pow;
	char ch;
	ret = 0;
	pow = 1;
	for(i=0; i<(int)str.size(); i++){
		ch = str[i];
		if(ch=='A') ret += pow;
		else if(ch=='C') ret += pow*2;
		else if (ch=='G') ret += pow*3;
		else ret += pow*4;
		pow *= 5;
	}
	//std::cout << ret << std::endl;
	return ret;
}

int hash1(int key){
	return key % M;
}

int hash2(int key){
	return (1 + key % (M-1));
}

void insert(std::string str){
	int i, key, h, h1, h2;
	i = 0;
	key =  toInt(str);
	h1 = hash1(key);
	h2 = hash2(key);
	while(1){
		h = (h1 + i*h2) % M;
		//std::cout << h << std::endl;
		if(dic[h] == 0){
			dic[h] = key+1;
			break;
		}
		else if(dic[h] == key+1){
			break;
		}
		else i++;
	}
}

bool find(std::string str){
	int i, h1, h2, key, h;
	bool flag;
	i = 0;
	key =  toInt(str);
	h1 = hash1(key);
	h2 = hash2(key);
	while(1){
		h = (h1 + i*h2) % M;
		if(dic[h] == 0){
			flag = false;
			break;
		}
		else if(dic[h] == key+1){
			flag = true;
			break;
		}
		else i++;
	}
	return flag;

}

int main(){
	int i,n;
	std::string op, str;
	std::cin >> n;
	for(i=0; i<n;i++){
		std::cin >> op >> str;
		if(op == "insert"){
			insert(str);
		}
		else{
			if (find(str)) std::cout << "yes" << std::endl;
			else std::cout << "no" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7128
import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)

Measured memory_bytes: 16240
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  int i;
  in(ll,n);
  ll d[212345]={};
  rep(i,n)cin>>d[i];
  in(ll,m);
  ll t[212345]={};
  rep(i,m)cin>>t[i];
  sort(d,d+n);
  sort(t,t+m);
  int j;
  i=j=0;

  while(j<m)
    {
      if(d[i]==t[j])
	j++;
      i++;
      if(i==n)
	break;
    }
  if(j==m)puts("YES");
  else
    puts("NO");
  return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String a2 = a.substring(0,1);
    String b = sc.next();
    String b2 = b.substring(1,2);
    String c = sc.next();
    String c2 = c.substring(2,3);
    System.out.println(a2 + b2 + c2);
  }
}

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

int main(){
  int K, S;
  cin >> K >> S;
  int cnt = 0; 
  for (int i=0; i< K+1;i++){
    for(int j=0; j<K+1;j++){
      int Z = S - i -j;
      if (Z >= 0 && Z<= K) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>V(N);
  vector<int>C(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>C.at(i);
    if(V.at(i)-C.at(i)>0)ans+=V.at(i)-C.at(i);
  }
   cout<<ans<<endl;
  }


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

int table[10][7] = {
    {0,1,1,1,1,1,1},//0
    {0,0,0,0,1,1,0},//1
    {1,0,1,1,0,1,1},//2
    {1,0,0,1,1,1,1},//3
    {1,1,0,0,1,1,0},//4
    {1,1,0,1,1,0,1},//5
    {1,1,1,1,1,0,1},//6
    {0,1,0,0,1,1,1},//7
    {1,1,1,1,1,1,1},//8
    {1,1,0,1,1,1,1} //9
};

int main(void){
    // Your code here!
    int n;
    while(true) {
        cin >> n;
        if(n == -1) break;
        
        int k;
        int display[7] = {0,0,0,0,0,0,0};
        for(int i = 0; i < n; i++){
            cin >> k;
            for(int j = 0; j < 7; j++) {
                if(display[j] == table[k][j]) {
                    cout << 0;
                } else {
                    display[j] = table[k][j];
                    cout << 1;
                }
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3080
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  REP(b, k + 1, n + 1) {
    ans += (n / b) * (b - 1 - k + 1);
    if (n % b >= k) {
      ans += (n % b - k + 1);
    }
    if (k == 0) ans--;
    // cout << b << ":" << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for _ in range(N)]
ok = False
cost = 10**10
for i in range(N):
    if ct[i][1] <= T and cost > ct[i][0]:
        cost = ct[i][0]
        ok = True
print(cost if ok else 'TLE')

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n;
	cin >> n;
	int sum = 0;
	if(n < 4){
		cout << "No" << endl;
		return 0;
	}
	REP(i,25){
		REP(j,15){
			if(4*i + 7*j == n){
				cout << "Yes" << endl;
				return 0;
			}else if(4*i + 7*j > n) break;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	char s[100];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N , K ;
  cin >> N >> K;
  int data[N] = {};
  for(int i = 0;i < K;i++){
    int a;
    cin >> a ;
    for(int j = 0 ; j < a; j++){
      int b;
      cin >> b;
      data[b-1] ++;
    }
  }
  int ans = 0 ;
  for(int i = 0; i < N;i++){
    if(data[i]==0){
      ans++;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  






void solve(){
	string s ; 
	cin >> s ; 
	int q ; 
	cin >> q ;
	bool ok = false ;
	deque<char>kyu(all(s));
	while(q--){
		int ty ; 
		cin >> ty ;
		if(ty==1) ok^=1;
		if(ty==2){
			int fy ;
			cin >> fy ;
			char c ;
			cin >> c;
			if(fy==1){
				if(ok) kyu.pb(c);
				else{
					kyu.push_front(c);
				}
			}
			else{
				if(ok) kyu.push_front(c);
				else{
					kyu.pb(c);
				}
			}
		}
	}
	if(ok) reverse(all(kyu));
	trav(si,kyu)cout << si;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 4056
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	strconv.Atoi(input())
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())

	if (b-a)%2 == 0 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Borys")
	}
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.parents = [-1] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_n_groups(self):
        return len(self.get_parent_list())


def main():
    N, M = map(int, input().split())
    tree = UnionFind(N)
    for _ in range(M):
        x, y, z = map(int, input().split())
        x -= 1
        y -= 1
        tree.unite(x, y)
    n_groups = tree.get_n_groups()
    print(n_groups)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7896
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=305;
int h,w,k;
char s[N][N];
int ans[N][N];
bool book[N];
int main()
{
	scanf("%d%d%d",&h,&w,&k);
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	book[0]=book[h+1]=true;
	int tot=0;
	for(int i=1;i<=h;i++)
	{
		vector<int>pos;
		for(int j=1;j<=w;j++)
			if(s[i][j]=='#') pos.push_back(j);
		if(pos.empty())
		{
			book[i]=true;
			continue;
		}
		for(int l=1;l<pos.size();l++)
		{
			tot++;
			for(int j=pos[l-1];j<pos[l];j++)
				ans[i][j]=tot;
		}
		ans[i][pos.back()]=++tot;
		for(int j=pos.front()-1;j>=1;j--)
			if(!ans[i][j]) ans[i][j]=ans[i][j+1];
		for(int j=pos.front()+1;j<=w;j++)
			if(!ans[i][j]) ans[i][j]=ans[i][j-1];
	}
	for(int i=1;i<=h;i++)
		if(book[i]&&!book[i-1])
		{
			for(int j=1;j<=w;j++)
				ans[i][j]=ans[i-1][j];
			book[i]=false;
		}
	for(int i=h;i>=1;i--)
		if(book[i]&&!book[i+1])
		{
			for(int j=1;j<=w;j++)
				ans[i][j]=ans[i+1][j];
			book[i]=false;
		}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
//const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,mod;
vi dp(4096);

int main(){
	cin>>n>>mod;
	for(int j=0;j<4096;j++){
		int a=j%2,b=j/2%2,c=j/4%2,d=j/8%2,e=j/16%2,f=j/32%2,g=j/64%2,h=j/128%2,x=j/256%2,y=j/512%2,z=j/1024%2,t=j/2048%2;
		if(x!=t) continue;
		if(x==0&&a==1&&b==1&&c==0&&d==1&&e==1&&f==0&&g==1&&h==1) dp[j]++;
		if(x==1&&a==1&&b==0&&c==1&&d==1&&e==1&&f==1&&g==0&&h==1) dp[j]++;
	}
	for(int i=1;i<n;i++){
		vi DP(4096);
		for(int j=0;j<4096;j++) for(int k=0;k<8;k++){
			int a=j%2,b=j/2%2,c=j/4%2,d=j/8%2,e=j/16%2,f=j/32%2,g=j/64%2,h=j/128%2,x=j/256%2,y=j/512%2,z=j/1024%2,t=j/2048%2;
			int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,X=k%2,Y=k/2%2,Z=k/4%2;
			if(x==0&&y==0&&z==0&&X==1||x==1&&y==1&&z==1&&X==0) continue;
			if(a==1&&y==1) A=1;
			if(b==1&&z==0) B=1;
			if(A==1&&X==0) B=1;
			if(B==1&&X==1) A=1;
			if(c==1&&y==1) C=1;
			if(d==1&&z==0) D=1;
			if(C==1&&X==0) D=1;
			if(D==1&&X==1) C=1;
			if(e==1&&y==0) E=1;
			if(f==1&&z==1) F=1;
			if(E==1&&X==1) F=1;
			if(F==1&&X==0) E=1;
			if(g==1&&y==0) G=1;
			if(h==1&&z==1) H=1;
			if(G==1&&X==1) H=1;
			if(H==1&&X==0) G=1;
			if(i==n-1){
				if(A==1&&Y==1||B==1&&Z==0&&t==1) continue;
				if(D==1&&Z==0||C==1&&Y==1&&t==0) continue;
				if(E==1&&Y==0||F==1&&Z==1&&t==0) continue;
				if(H==1&&Z==1||G==1&&Y==0&&t==1) continue;
				if(X==0&&Y==0&&Z==0&&t==1) continue;
				if(X==1&&Y==1&&Z==1&&t==0) continue;
			}
			(DP[A+B*2+C*4+D*8+E*16+F*32+G*64+H*128+X*256+Y*512+Z*1024+t*2048]+=dp[j])%=mod;
		}
		dp=DP;
	}
	int res=0;
	for(auto i:dp) (res+=i)%=mod;
	cout<<res<<endl;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  return 0;
}

Node treeMaximum(Node x){

  return 0;
}

Node treeSearch(Node u, int k){

  return 0;
}

Node treeSuccessor(Node x){

  return 0;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if((z->key) < (x->key)){
      x=(x->left);
    }
    else{
      x=(x->right);
    }
  }
  (z->parent) = y;

  if(y==NIL){
    root=z;
  }
  else if((z->key) < (y->key)){
    (y->left) = z;
  }
  else{
    (y->right) = z;
  }
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",(u->key));
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",(u->key));
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}




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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

struct Edge {int to, cost; };
typedef pair<int, int> pint;

// #define INF (1000L * 1000L * 1000L * 1000L)
#define INF (LONG_MAX)

class Dikstra {
private:
    int N;
    vector<vector<Edge>> edge_list;

public:
    Dikstra(vector< vector<Edge>> &edge_list) {
        this->edge_list = edge_list;
        this->N = edge_list.size();
    }

    Dikstra(int N) {
        this->edge_list = vector< vector< Edge>>(N, vector<Edge>());
        this->N = N;
    }

    void addEdge(int i, Edge e) {
        this->edge_list[i].pb(e);
    }

    vector<int> search(int s) {
        priority_queue<pint, vector<pint>, greater<pint> > que;
        vector<int> d(N, INF);
        d[s] = 0;
        que.push(make_pair(0, s));

        while (!que.empty()) {
            pint p = que.top();
            que.pop();

            int v = p.second;
            if (d[v] < p.first) continue;

            for (Edge e: edge_list[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }

        return d;
    }
};

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

    Dikstra d(N);
    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        d.addEdge(a, {b, c});
        d.addEdge(b, {a, c});
    }

    Dikstra d2(N);
    REP(i, N) {
        vector<int> dist = d.search(i);
        REP(j, N) {
            if (i == j) continue;

            if (dist[j] <= L) {
                d2.addEdge(i, {j, 1});
            }
        }
    }

    vector<vector <int>> ans(N, vector<int>(N, -1));
    REP(i, N) {
        vector<int> dist = d2.search(i);

        REP(j, N) {
            ans[i][j] = (dist[j] == INF) ? -1 : dist[j] - 1;
        }
    }

    int Q;
    cin >> Q;

    REP(i, Q) {
        int s, t;
        cin >> s >> t;
        s--; t--;

        cout << ans[s][t] << endl;
    }

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i = 0; i < h; ++i)
  {
    cin >> a[i];
  }

  vector<bool> col(w, false);
  vector<bool> row(h, false);
  for(int i = 0; i < h; ++i)
  {
    for(int j = 0; j < w; ++j)
    {
      if (a[i][j] == '#')
      {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for(int i = 0; i < h; ++i)
  {
    if (!row[i]) continue;
    for(int j = 0; j < w; ++j)
    {
      if (col[j]) cout << a[i][j];
    }
    cout << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2,tune=native")

#include <x86intrin.h>
#include <bits/stdc++.h>

using namespace std;

vector<int> l;

int N, A, B, C;

const int INF = 1000000007;

int dfs (int index, int a, int b, int c) {
    if (index == N)
	return (a && b && c) ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
	// Remove the extra 10MP from each of A, B, C.
    int branch0 = dfs(index + 1, a, b, c);
    int branchA = dfs(index + 1, a + l[index], b, c) + 10;
    /* +10MP for every bamboo piece. 
     * Note that this causes an extra 10 points (merges = pieces - 1). */
    int branchB = dfs(index + 1, a, b + l[index], c) + 10;
    int branchC = dfs(index + 1, a, b, c + l[index]) + 10;
    return min({branch0, branchA, branchB, branchC});
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B >> C;
    l.resize(N);
    for (int i = 0; i < N; i++) cin >> l[i];
    cout << dfs(0, 0, 0, 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <set>
#include <list>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <bitset>
#include <array>
#include <stdlib.h>
#include <thread>
#include <chrono>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <fenv.h>
using namespace std;

using namespace std;

template<class T>
void printVector(const std::vector<T>& vs)
{
    for(auto t : vs)
        std::cout << t << " ";
    std::cout << std::endl;
}




int main()
{

    string code("CODEFESTIVAL2016");
    string tmp;
    std::cin>>tmp;
    int cnt = 0;
    for(int i=0; i<16;++i)
    {
        if(tmp[i] != code[i])
            ++cnt;
    }
    std::cout << cnt;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
        
    vector<int> a(n);
    rep(i,n) {
     cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    
    string ans = "YES";
    
    rep(i,n - 1) {
    if(a.at(i) == a.at(i +1)) {
    ans = "NO";
    break;
    }
    }
    
    cout << ans;
    

    }

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,M; cin >> N >> M;
	vector<pair<int,int>> V(M);
	repp(i,0,M) cin >> V[i].first >> V[i].second;
	sort(V.begin(),V.end());
	int ans = 0;
	int p = 0;
	int q = N+1;
	repp(i,1,N+1){
		if(q == i){
			++ans;
			q = N+1;
		}
		while(p < M && V[p].first == i){
			q = min(q,V[p].second);
			++p;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024