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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll h,w;
    cin>>h>>w;

    if(h%3==0||w%3==0){
        cout<<0<<endl;
        return  0;
    }
    ll ans=INF;

    rep(j,2){
        if(j==1)swap(h,w);
        REP(x,1,w){
            Vec v(3);
            v[0] = x*h;
            if((w-x)%2==0){
                v[1] = v[2] = h*(w-x)/2;
            }else{
                v[1] = (w-x)*(h/2);
                v[2] = (w-x)*(h-h/2);
            }
            sort(ALL(v));
            chmin(ans,v[2]-v[0]);
        }
    }


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


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM = 
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k,n;
	cin>>k>>n;
	vector<ll>huh;
	for(ll i=0;i<n;i++)
	{
	    ll tmp;
	    cin>>tmp;
	    tmp%=k;
	    huh.eb(tmp);
	}
	sort(huh.begin(),huh.end());
	ll hi=0;
	for(ll i=0;i<n;i++)
	{
	    ll j=(i-1+n)%n;
	    ll diff=(huh[i]-huh[j]+k)%k;
	    hi=max(hi,diff);
	}
	cout<<(k-hi);
    return 0;
}


//252908XL

/*
comments:-

*/


Measured memory_bytes: 2420
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 310

struct Info{
	void set(int arg_rev_from,int arg_rev_index){
		rev_from = arg_rev_from;
		rev_index = arg_rev_index;
	}

	int rev_from,rev_index;
};


struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int V,E;

vector<Edge> G[NUM];
Info info[1010];
int dist[NUM];
int cheked_index[NUM];


void add_edge(int index,int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,capacity,G[from].size()-1));
	info[index].set(to,G[to].size()-1);
}


void bfs(int source){
	for(int i = 0; i < V; i++)dist[i] = -1;
	queue<int> Q;
	dist[source] = 0;
	Q.push(source);

	while(!Q.empty()){
		int node_id = Q.front();
		Q.pop();
		for(int i = 0; i < G[node_id].size(); i++){
			Edge &e = G[node_id][i];
			if(e.capacity > 0 && dist[e.to] < 0){
				dist[e.to] = dist[node_id]+1;
				Q.push(e.to);
			}
		}
	}
}


int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow;

	for(int &i = cheked_index[node_id]; i < G[node_id].size(); i++){
		Edge &e = G[node_id][i];
		if(e.capacity > 0 && dist[node_id] < dist[e.to]){
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity));
			if(tmp_flow > 0){
				e.capacity -= tmp_flow;
				G[e.to][e.rev_index].capacity = 1;
				return tmp_flow;
			}
		}
	}
	return 0;
}



int max_flow(int source,int sink){
	int flow = 0,add;
	while(true){
		bfs(source);
		if(dist[sink] < 0)break;
		for(int i = 0; i < V; i++)cheked_index[i] = 0;
		while((add = dfs(source,sink,BIG_NUM)) > 0){
			flow += add;
		}
	}
	return flow;
}


int main(){

	scanf("%d %d",&V,&E);

	int from,to;

	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		add_edge(loop,from,to,1);
	}

	int source,sink;
	scanf("%d %d",&source,&sink);
	source--;
	sink--;

	int flow = max_flow(source,sink);

	queue<int> Q;
	for(int loop = 0; loop < E; loop++){
		if(G[info[loop].rev_from][info[loop].rev_index].capacity == 0){
			Q.push(loop+1);
		}
	}

	printf("%d\n",flow);
	printf("%lld\n",Q.size());
	while(!Q.empty()){
		printf("%d\n",Q.front());
		Q.pop();
	}


	return 0;
}



Measured memory_bytes: 3268
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    int n; cin >> n;
    int a[n]; for (int i =0; i < n; i++) cin >> a[i];
    bool ans = true;
    for (int i = 0; i < n; i++)
    {
        if (a[i]%2==0&&(a[i]%5==0||a[i]%3==0)) continue;
        if (a[i]%2) continue;
        //nout(a[i]);
        ans = false; break;
    }
    if (ans) nout("APPROVED");
    else nout("DENIED");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int n;
    bool flag = false;
    string s;
    cin >> n;
    cin >> s;

    if(n%2==0 && s.substr(0,n/2) == s.substr(n/2,n/2)){
        flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

int const N=1e6+100;
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
int const BN = 31;

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

void bfs(int r, string str[], int n, vvint &dst){
	vint vst(n,1);
	queue<int> q;
	q.push(r);
	dst[r][r]=0;
	vst[r]=0;
	while(!q.empty()){
		int j=q.front();
		q.pop();
		for(int k=0; k<n; k++){
			if(str[j][k]=='1'){
				if(vst[k]==1){
					q.push(k);
					// if(r==k) cout<<j<<" "<<r<<" "<<k<<endl;
					dst[r][k]=dst[r][j]+1;
					vst[k]=0;
				}
			}
		}
	}
}

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

	int n;
	cin>>n;
	vint arr(n+1);
	for(int i=0; i<n; i++) cin>>arr[i];
	int s=0, e=1, ans=0;
	while(e<n){
		if(arr[e]>arr[e-1]){
			ans=max(ans,e-s-1);
			s=e;
		}
		e++;
	}
	ans=max(ans,e-s-1);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
from itertools import permutations
N = int(input())
ps = permutations([i for i in range(1, N+1)])
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
a = None
b = None
for i,p in enumerate(ps):
    if P == p:
        a = i+1
    if Q == p:
        b = i+1
print(abs(a-b))

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    u=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if(a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i] and abs(a[i]-a[j])<a[k] and abs(a[j]-a[k])<a[i] and abs(a[i]-a[k])<a[j] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]){
                    u++;
                }
            }
        }
    }
    cout<<u<<endl;


}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10688
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

for cx in range(0,101) :
    for cy in range(0,101) :
        h = 0
        bF = True
        for x,y,z in aData :
            d = abs(x-cx)+abs(y-cy)
            if z > 0 :
                if h == 0 :
                    h = z + d
                else :
                    if h != z + d:
                        bF = False
                        break
            else :
                if h > d:
                    bF = False
                    break
        if bF :
            print(cx,cy,h)
            exit()


Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
  long long n=0,a[400],b[400],c[400],d[400],i,e;
  double f,h,j,g;
  cin>>n;
  for( i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    e=i;
      f=((a[e]*c[e])+(b[e]*d[e]))*0.8;
      g=(a[e]*c[e]) + (b[e]*d[e]);
      h=((a[e]*c[e])+(b[e]*2))*0.8;
      j=((a[e]*5)+(b[e]*d[e]))*0.8;
      if(c[e]>=5 && d[e]>=2){
	cout<<f<<"\n";
      }
      else
	if(c[e]<5 && d[e]<2){
	  cout<<g<<"\n";
	}

      else

      if(c[e]>=5 && d[e]<2){
	if(g>h){
	  cout<<h<<"\n";
	}
	else{
	  cout<<g<<"\n";
	}
      }
      else
	if(c[e]<5 && d[e]>=2){
	  if(g>j){
	    cout<<j<<"\n";
	  }
	  else{
	    cout<<g<<"\n";
	  }
	}
     

  }

  return 0;
}



Measured memory_bytes: 3304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
int n;

void maxHeapify(int A[], int i){
    int l = i*2+1;
    int r = i*2+2;
    ll largest = 0;
    if(l < n && A[l] > A[i]){
        largest = l;
    }else{
        largest = i;
    }
    if(r < n && A[r] > A[largest]){
        largest = r;
    }
    if(largest != i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int A[]){
    for(int i = n/2; i >= 0 ;i--){
        maxHeapify(A,i);
    }
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int A[n];
    for(int i = 0; i < n;i++){
        cin >> A[i];
    }
    buildMaxHeap(A);
    for(int i = 0; i < n;i++){
        cout << " " << A[i];
    }
    cout << endl;
    
    

    return 0;
}


Measured memory_bytes: 5088
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<usize>();
    for i in 0..5 {
        if line[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <set>

using namespace std;

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

    vector<string> gifts(N);
    for (int i = 0; i < N; i++) {
        cin >> gifts.at(i);
    }

    set<string> kind_of_gifts;
    for (string s: gifts) {
        kind_of_gifts.insert(s);
    }

    cout << kind_of_gifts.size() << endl;
}


Measured memory_bytes: 25080
import java.util.Scanner;

public class Main {

    static int MOD = 1_000_000_007;
    static int H;
    static int W;
    static int K;
    static int[] fib = {1, 1, 2, 3, 5, 8, 13, 21, 34};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        K = sc.nextInt();
        sc.close();
        // dp[i][j]：ｉ段目の時にｊ番にいる経路の組み合わせ mod 1000000007
        long[][] dp = new long[H+1][W+1];
        dp[0][1] = 1L;
        if(W == 1){
            System.out.println(1);
        }else{
            for(int i = 1; i <= H; i++){
                for(int j = 1; j <= W; j++){
                    if(j == 1) dp[i][j] = (dp[i-1][2] * fib[W-2] + dp[i-1][1] * fib[W-1])% MOD;
                    else if(j == W) dp[i][j] = (dp[i-1][W-1] * fib[W-2] + dp[i-1][W] * fib[W-1])% MOD;
                    else dp[i][j] = (dp[i-1][j-1] * fib[j-2] * fib[W-j] + dp[i-1][j+1] * fib[j-1] * fib[W-(j+1)] + dp[i-1][j] * fib[j-1] * fib[W-j])% MOD;
                }
            }
            System.out.println(dp[H][K]);
        }
    }

}


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

int main() {
  string S,T;
  cin >> S >> T;
  
  int size1 = S.length();
  int size2 = T.length();
  
  string substr = T.substr(size2 - 1);
  
  if (1 <= size1 <= 10 && T == S + substr) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
package main

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

func main() {
	a, b := getInt(), getInt()
	x := a - 1
	y := b - 1

	ans := (y + x - 1) / x
	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<P> abx, cdx, aby, cdy;
    rep(i, n){
        int x, y;
        cin >> x >> y;
        abx.push_back(make_pair(x, y));
        aby.push_back(make_pair(y, x));
    }
    rep(i, n){
        int x, y;
        cin >> x >> y;
        cdx.push_back(make_pair(x, y));
        cdy.push_back(make_pair(y, x));
    }
   
    sort(aby.rbegin(), aby.rend());
    sort(cdx.begin(), cdx.end());

    int cnt = 0;
    vector<int> used(n+1, -1);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(used.at(j)!=-1) continue;
            if(aby.at(i).first<cdx.at(j).second && aby.at(i).second < cdx.at(j).first){
                cnt++; 
                used.at(j) = 1;
                break;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int D, T, S;

  std::cin >> D >> T >> S;

  std::cout << ((D + S - 1) / S <= T ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int x,i;
        i=1;
        while(true){
            x=sc.nextInt();
            if(x==0) break;
            if(x!=0){
                System.out.printf("Case %d: %d\n",i,x);
            }
            i++;
        }
    }
}


Measured memory_bytes: 67096
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(0, n - 1):
    if a[i + 1] - a[i] == 1:
        ans += c[a[i] - 1]

for i in range(n):
    ans += b[a[i] - 1]

print(ans)


Measured memory_bytes: 61792
#include <stdio.h>

int main(){
  int i,N,A[100],con=0,j,tmp,minj ; 
  scanf("%d",&N);
  for (i = 0;i <= N-1; i++){
    scanf("%d",&A[i]); 
  }
  for (i = 0; i <= N-1; i++){
    minj = i;
    for (j = i; j <= N-1; j++){
      if (A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj!=i){
    tmp = A[i];
    A[i] =  A[minj];
    A[minj] = tmp;
    con++;
    }
  }

for (i = 0; i < N-1; i++){  
  printf("%d ",A[i]);
 }
printf("%d\n",A[N-1]);


   printf("%d\n",con);
 
   



  return 0;
}

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

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

  int n;
  long long a;
  int one = 0, two = 0, four = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 4 == 0) four++;
    else if (a % 2 == 0) two++;
    else one++;
  }

  //cout << "dbg " << one << ' ' << two << ' ' << four << endl;

  if (two == 0) {
    if (one <= four + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    if (one <= four) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int vx[4]={1,0,-1,0},vy[4]={0,1,0,-1};

int main(){
  queue<pii> sta;
  int H,W;
  cin>>H>>W;
  char field[H][W];
  int went[H][W];
  int black=0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin>>field[i][j];
      if(field[i][j]=='#'){went[i][j]=1;black++;}
      else went[i][j]=0;
    }
  }

  sta.push(mp(0,0));
  while(!sta.empty()){
    pii coor=sta.front();
    sta.pop();
    for (int i = 0; i < 4; i++) {
      int x=coor.first+vx[i];
      int y=coor.second+vy[i];
      if(0<=x&&x<H&&0<=y&&y<W&&went[x][y]==0){
        went[x][y]=went[coor.first][coor.second]+1;
        sta.push(mp(x,y));
      }
      if(x==H-1&&y==W-1){cout<<H*W-2-went[coor.first][coor.second]-black<<endl; return 0;}
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
import math
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = 0
b = 0
for p in itertools.permutations(xy, n):
    for i in range(n-1):
        ans += math.sqrt((p[i][0]-p[i+1][0])**2 + (p[i][1]-p[i+1][1])**2)
    b += 1
print(ans/b)


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

int main() {
  int A[3]; cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  int answer = (A[1]-A[0]) + (A[2]-A[1]);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int dp[11010];


int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
  FOR(i,0,11000){
    dp[i]=mod;
  }
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  vector<int> b(m);
  int c[1010][22]={};
  priority_queue<pii> pq;
  FOR(i,0,m){
    cin>>a[i]>>b[i];
    int msk=0;
    FOR(j,0,b[i]){
      cin>>c[i][j];
      c[i][j]--;
      msk|=(1<<c[i][j]);
    }
    //cerr<<i<<" "<<msk<<endl;
    if(dp[msk]==mod||dp[msk]>a[i]){
      dp[msk]=min(dp[msk],a[i]);
      pq.push(MP(-a[i],msk));
    }
  }
  while (pq.size()) {
    /* code */
    auto pr=pq.top();
    pq.pop();
    int sc=-pr.ST,msk=pr.ND;
    if(dp[msk]!=sc){
      continue;
    }
    //cerr<<bitset<15>(msk)<<" "<<sc<<endl;
    FOR(i,0,m){
      int t=msk,nxsc=sc+a[i];
      FOR(j,0,b[i]){
        t|=(1<<c[i][j]);
      }
      if(t==msk){
        continue;
      }else{
        //cerr<<msk<<" "<<i<<" "<<bitset<15>(t)<<" "<<nxsc<<endl;
        if(dp[t]==mod||dp[t]>nxsc){

          dp[t]=min(dp[t],nxsc);
          pq.push(MP(-nxsc,t));
        }
      }
    }
  }



  if(dp[(1<<n)-1]==mod){
    cout<<-1<<endl;
  }else{
    cout<<dp[(1<<n)-1]<<endl;

  }
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
    a[i]=(a[i]+i)%n;
  }
  vi used(n,0),v(n,0);
  int ans=0,t=1;
  rep(i,n)if(used[i]==0){
    int now=a[i],j=i;
    v[j]=t;
    used[j]=1;
    while(1){
      if(used[now]){
	if(v[now]==v[j])ans+=used[j]+1-used[now];
	break;
      }else{
	used[now]=used[j]+1;
	v[now]=v[j];
	j=now;
	now=a[j];
      }
    }
    t++;
    //    cout<<i<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int n;
  string s;
  cin >> n >> s;
  for(char & c : s){
    int val = c - 'A';
    val += n;
    val %= 26;
    c = 'A' + val;
  }
  cout << s << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;
 
void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}
 
struct point {
    ll next;
    ll score;
};
 
ll get_cluster_result(vector<point>& points, vector<bool>& done, ll start, ll K) {
    ll loop_score = 0;
    vector<ll> cluster;
    for (point p = points[start]; true; p = points[p.next]) {
        cluster.push_back(p.next);
        done[p.next] = true;
        loop_score += points[p.next].score;
        if (p.next == start) {
            break;
        }
    }
 
    ll size = cluster.size();
    ll shu = 0;
    ll rest_move;
    if (loop_score > 0) {
        shu = max(0LL, K / size - 1LL);
        rest_move = K - shu * size;
    } else {
        rest_move = min(K, size);
    }

    ll max_rest = -INF;
    for (ll c : cluster) {
        ll rest_score = 0;
        point p = points[c];
        for (ll j = 0; j < rest_move; j++) {
            rest_score += points[p.next].score;
            p = points[p.next];
            max_rest = max(max_rest, rest_score);
        }
    }
    return max_rest + shu * loop_score;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<point> points(N + 1, {-1,0});
    for (ll i = 1; i <= N; i++) {
        cin >> points[i].next;
    }
    for (ll i = 1; i <= N; i++) {
        cin >> points[i].score;
    }
    vector<bool> done(N + 1, false);
 
    ll gresult = -INF;
    for (ll i = 1; i <= N; i++) {
        if (!done[i]) {
            gresult = max(gresult, get_cluster_result(points, done, i, K));
        }
    }
    print(gresult);
}


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

using namespace std;

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //freopen("outp.out", "w", stdout);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for(int i=0; i<n; i++) scanf("%d", &v[i]);
    int ans=0;
    int ctr=0;
    for(int i=0; i<n; i++)
    {
        bool last=true;
        if(i+1<n && v[i]==v[i+1]) last=false;
        ctr++;
        if(last)
        {
            ans += ctr/2;
            ctr=0;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n, done[3010][3010];
ll dp[3010][3010], a[3010];

ll solve(int l, int r){
  if(l > r) return 0;
  ll &R = dp[l][r];
  if(done[l][r]) return R;
  done[l][r] = true;
  return R = max(a[l]-solve(l+1,r), a[r]-solve(l,r-1));
}

int main(){FIN;
  cin >> n;
  fore(i,0,n) cin >> a[i];
  cout << solve(0,n-1) << "\n";
}

Measured memory_bytes: 105472
N,M=map(int,input().split())

dp=[True]*(N+2)
S=list(int(input()) for _ in range(M))
for i in S:
    dp[i]=False
num=[0]*(N+2)
MOD=1000000007
num.insert(0,1)
for i in range(0,N):
    if dp[i]:
        num[i+1]+=num[i]
        num[i+1]%=MOD
        num[i+2]+=num[i]
        num[i+2]%=MOD
print(num[N])

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

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    for(;;) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = br.readLine();
		String[] strNumArray = strNum.split(" ");
		Integer a = Integer.parseInt(strNumArray[0]);
		Integer b = Integer.parseInt(strNumArray[1]);
		if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}

}

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

using namespace std;

int main(){
  vector<int> a;
  int n,num;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    a.push_back(num);
    //cout << num << endl;
  }

  int q,k;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k;
    auto itr_b = a.begin();
    auto itr_e = a.end();
    auto itr = equal_range(itr_b, itr_e, k);
    size_t pos1 = distance(itr_b, itr.first);
    size_t pos2 = distance(itr_b, itr.second);
    cout << pos1 << " " << pos2 << endl;
  }

  return 0;
}



Measured memory_bytes: 3548
K = input()
d = int(input())
mod = 10**9+7
n = len(K)
dp = [[[0 for k in range(2)] for i in range(d)] for j in range(n+1)]
dp[0][0][0] = 1
for i in range(1,n+1):
  s = int(K[i-1])
  for j in range(d):
    for k in range(10):
      r = (j+k)%d
      dp[i][r][1] += dp[i-1][j][1]
      if k < s:
        dp[i][r][1] += dp[i-1][j][0]
      dp[i][r][1] %= mod
    dp[i][(j+s)%d][0] = dp[i-1][j][0]
print((sum(dp[n][0])-1)%mod)

Measured memory_bytes: 129756
# -*- coding: utf-8 -*-
import sys
import cmath
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
eps=1e-8
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    x,y=[0]*N,[0]*N
    for i in range(N):
        x[i],y[i]=map(int,input().split())
    
    def get_Intersection(c1,c2,R):
        mid=(c1+c2)/2
        if R<abs(c1-mid):
            return None,None
        d=(R**2-abs(c1-mid)**2)**0.5
        p=cmath.polar((c1-c2)*1j)
        v=cmath.rect(d,p[1])
        i1=mid+v
        i2=mid-v
        return i1,i2
    
    def nibutan(ok,ng):
        for _ in range(100):
            mid = (ok + ng) / 2
            if solve(mid):
                ok = mid
            else:
                ng = mid
        return ok
    
    def solve(mid):
        for i in range(N):
            for j in range(N):
                if i==j:
                    continue
                c1=x[i]+y[i]*1j
                c2=x[j]+y[j]*1j
                i1,i2=get_Intersection(c1,c2,mid)
                if i1 is None:
                    continue
                for k in range(N):
                    i3=x[k]+y[k]*1j
                    if abs(i3-i1)>mid+eps:
                        break
                else:
                    return True
                for k in range(N):
                    i3=x[k]+y[k]*1j
                    if abs(i3-i2)>mid+eps:
                        break
                else:
                    return True
        return False
    
    print(nibutan(2000,0))
    


    

if __name__ == '__main__':
    main()


Measured memory_bytes: 50264
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <map>

namespace
{
  struct Room
  {
    int cost = 1000000;
    int mejirushi = -1;
    bool fixed = false;
  };
  static std::array<Room, 200001> rooms = {};

  static std::array<std::vector<int>, 200001> way = {};
}

namespace ABC168
{

  class D
  {
  public:
    D() = default;
    ~D() = default;


    void Run()
    {

      int N = 0;
      int M = 0;
      std::cin >> N;
      std::cin >> M;

      std::vector<std::pair<int, int>> next_rooms = {};

      for (int i = 0; i < M; ++i)
      {
        int A, B;
        std::cin >> A;
        std::cin >> B;

        way[A].push_back(B);
        way[B].push_back(A);

        if (A == 1)
        {
          rooms[A].cost = 1;
          rooms[A].fixed = true;
          next_rooms.push_back(std::make_pair(A, B));
        }
        else if (B == 1)
        {
          rooms[B].cost = 1;
          rooms[B].fixed = true;
          next_rooms.push_back(std::make_pair(B, A));
        }
      }

      while (next_rooms.size() > 0)
      {
        std::vector<std::pair<int, int>> next_rooms_tmp = {};

        for (auto p : next_rooms)
        {
          auto& infoA = rooms[p.first];
          auto& infoB = rooms[p.second];

          if (!infoB.fixed) {
            infoB.cost = infoA.cost + 1;
            infoB.mejirushi = p.first;
            infoB.fixed = true;
          }

          for (auto w : way[p.second])
          {
            if (!rooms[w].fixed) {
              next_rooms_tmp.push_back(std::make_pair(p.second, w));
            }
          }
        }

        std::sort(next_rooms_tmp.begin(), next_rooms_tmp.end());
        auto itr = std::unique(next_rooms_tmp.begin(), next_rooms_tmp.end());
        next_rooms_tmp.erase(itr, next_rooms_tmp.end());

        next_rooms = next_rooms_tmp;
      }

      bool is_ok = true;
      for (int i = 1; i <= N; ++i)
      {
        if (!rooms[i].fixed) {
          is_ok = false;
          break;
        }
      }

      if (!is_ok)
      {
        std::cout << "No" << std::endl;
      }
      else
      {
        std::cout << "Yes" << std::endl;
        for (int i = 2; i <= N; ++i)
        {
          std::cout << rooms[i].mejirushi << std::endl;
        }
      }

    }
  };

}
int main()
{

  ABC168::D prob;
  prob.Run();

  return 0;
}




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

typedef long long LL;

char s[100050];

int work() {
    scanf("%s", s);
    int n = strlen(s);
    if (s[0] == s[n-1]) n++;
    if (n % 2 == 0) printf("Second\n");
    else printf("First\n");
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <tuple>



using namespace std;


using ll = long long;


int main()
{
    vector<tuple<ll, ll, ll>> sts;
    ll N;

    cin >> N;
    for (ll i = 0; i < N - 1; i++) {
        ll c, s, f;
        cin >> c >> s >> f;
        sts.push_back(make_tuple(c, s, f));
    }

    for (ll i = 0; i < N; i++) {
        ll t = 0;
        for (ll j = i; j < N - 1; j++) {
            auto now = sts[j];
            ll c, s, f;
            c = get<0>(now); s = get<1>(now); f = get<2>(now);
            if (t < s) {
                t = s;
            } else if (t % f == 0) {
                ;
            } else {
                t = t + f - t % f;
            }
            t += c;
        }
        cout << t << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/*
Nの階乗の10^9+7のあまりを求める問題。
i=n-1のとき、
(n-1)! = p * (10^9+7) + c
cはあまり。
 
i = nのとき、
n * (n-1)! = n * p * (10^9+7) + n * c
 
よってn!のあまりは、n * cを(10^9+7)でわったときのあまりを計算すればよい。
したがったあまりはそのつど計算できる。
*/
 
int main() {
    int N;
    cin >> N;
 
    long dev = 1e9 + 7;
    long mod = 1;
    for (int i = 1; i <= N; i++)
    {
        mod = mod * i % dev;
    }
    cout << mod << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c;
  int n = 0;

  scanf("%d %d %d", &a, &b, &c);

  while(a<=b){
    if(c % a == 0){
      n++;
    }
    a++;
  }

  printf("%d\n", n);

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int mod=1e9+7;
int e[1<<15],f[1<<15],g[1<<15];
int p[300];
inline int E(int a,int b) { return e[a|b]-e[a]-e[b]; }
int main()
{
	int n=gi(),m=gi(),i,s,t,a,b,all=(1<<n)-1,ans;
	for (i=p[0]=1;i<=m;i++) p[i]=(p[i-1]<<1)%mod;
	while (m--) {
		a=gi()-1,b=gi()-1;
		for (s=0;s<1<<n;s++)
			if ((s>>a&1)&&(s>>b&1))
				e[s]++;
	}
	for (s=1;s<1<<n;s++)
		if (s&1) {
			f[s]=p[e[s]];
			for (t=s;(--t)&=s;)
				if (t&1)
					f[s]=(f[s]-1LL*f[t]*p[e[s^t]])%mod;
		}
	for (s=1;s<1<<n;s++)
		if (s&2) {
			g[s]=p[e[s]];
			for (t=s;(--t)&=s;)
				if (t&2)
					g[s]=(g[s]-1LL*g[t]*p[e[s^t]])%mod;
		}

	ans=p[e[all]];
	for (s=1;s<1<<n;s++)
		if (s&1)
			for (t=all^s;t;(--t)&=all^s)
				if (t&2)
					if (!E(s,t))
						ans=(ans-1LL*f[s]*g[t]%mod*p[e[all^s^t]])%mod;
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 768
N,K= map(int, input().split())
x = list(map(int, input().split()))
x = list(set(x))
x.sort()
t = max(x)
y = x[0]
s = [1000000000000]
o=0
if x[0] == K:o=1
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
    if x[i] == K:o = 1
s.sort()
m = min(y,s[0])
if (t>= K and K%m==0) or o==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 14224
// abc065_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {cin >> A[i]; A[i]--;}

    int a = 0;
    int ans = -1;
    REP(i, N){
        a = A[a];
        if (a == 1){
            ans = i+1;
            break;
        }
    }

    print(ans);



    return 0;
}


Measured memory_bytes: 640
S = input()
n = len(S) - 1

ans = 0

for bit in range(1 << n):
	L = []
	f = 0
	s = 0
	for i in range(n):
		if bit & (1 << i):
			s = i + 1
			L.append(int(S[f:s]))
			f = s
	L.append(int(S[s:]))
	ans += sum(L)

print(ans)

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

signed main() {
  int n,m; cin >>n >>m;
  vector<vector<int>> s(m);
  rep(i,m) {
    int k; cin >> k;
    s[i].resize(k);
    rep(j, k) cin >> s[i][j];
  }
  vector<int> p(m);
  rep(i,m) cin >> p[i];

  int ans = 0;
  rep(b, 1<<n) {
    bool ok = true;
    rep(i, m) {
      int count = 0;
      for(auto ss : s[i]) if(b & 1<< (ss-1)) count++;
      ok=(count%2 == p[i]);
      if(!ok) break;
    }
    ans += ok;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,arr[200005];
LL ans=10000000000000000LL,sum1=0,sum2=0;
int main()
{
	scan(n);
	for(int i=0;i<n;i++)
		scan(arr[i]),sum1+=arr[i];
	for(int i=n-1;i>=1;i--)
	{
		sum1-=arr[i];
		sum2+=arr[i];
		ans=min(ans,abs(sum2-sum1));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/
int n,a,b;
int h[114514];
P max_h(){
    P re=P(h[0],0);
    for(int i=1;i<n;i++){
        if(re.first<h[i]){
            re=P(h[i],i);
        }
    }
    return re;
}

signed main(){
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    COMinit();
    int a,b;
    a=y-(x+y)/3; b=x-(x+y)/3;
    cout<<COM(a+b,a)<<endl;
}



Measured memory_bytes: 16896