akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
using ll = long long;
#define P pair<int,int>
struct E{
    int from;
    int to;
};
int main(){
    int N;cin>>N;
    int M = N*(N-1)/2;
    vector<vector<vector<E>>> graph(N,vector<vector<E>>(N,vector<E>()));
    vector<vector<int>> inNums(N,vector<int>(N,0));
    
    for(int i = 0;i < N;i++){
        E last = E{0,0};
        for(int j = 0;j < N-1;j++){

            int a;cin>>a;a--;
            int b = min(i,a);
            int c = max(i,a);
            if(last.from!=0 || last.to != 0){
                graph[last.from][last.to].push_back(E{b,c});
                inNums[b][c]++;
                // cout << "!" << endl;
            }
            last = E{b,c};
        }
    }
    queue<pair<E,int>> q;
    for(int i = 0;i < N-1;i++){
        for(int j = i+1;j < N;j++){
            if(inNums[i][j]==0){
                q.push(pair<E,int>{E{i,j},1});
            }
        }
    }
    int cnt = 0;
    int ret = 0;
    while(q.size()>0){
        pair<E,int> p = q.front();q.pop();
        E point = p.first;int length = p.second;
        // cout<<point.from<<","<<point.to<<","<<length<<" ";
        ret = max(ret,length);
        cnt++;
        for(int i = 0;i < graph[point.from][point.to].size();i++){
            E next = graph[point.from][point.to][i];
            inNums[next.from][next.to]--;
            if(inNums[next.from][next.to] == 0){
                q.push(pair<E,int>{next, length+1});
            }
        }
    }
    // for(int i = 0;i < N;i++){
    //     for(int j = 0;j < N;j++){
    //         for(int k = 0;k < graph[i][j].size();k++){
    //             cout<<graph[i][j][k].from<<","<<graph[i][j][k].to<<" ";
    //         }cout<<endl;
    //     }
    // }
    if(cnt != M){
        // cout<<cnt<<endl;
        cout<<"-1"<<endl;
        return 0;
    }
    cout << ret << endl;

}

Measured memory_bytes: 43264
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    int a[n];
    rep(i,0,n)cin>>a[i];
    int d=0,u=1000000001;
    ll uu=n*(n+1);
    uu/=2;
    uu=(uu+1)/2;
    while(u-d>1){
        int mid=(u+d)/2;
        int b[n];
        rep(i,0,n){
            if(a[i]>=mid)b[i]=1;
            else b[i]=-1;
        }
        ll cnt[n+1];
        cnt[0]=0;
        vector<pll> v;
        v.push_back({0,1});
        rep(i,0,n){
            cnt[i+1]=cnt[i]+b[i];
            v.push_back({cnt[i+1],i+2});
        }
        bitinit(100010);
        ll ssum=0;
        sort(v.begin(),v.end());
        rep(i,0,n+1){
            ll y=v[i].second;
            ssum+=sum(y);
            add(y,1);
        }
        if(ssum>=uu)d=mid;
        else u=mid;
    }
    cout<<d<<endl;
}


Measured memory_bytes: 7108
# -*- coding: utf-8 -*-
"""
Created on Thu May  9 23:00:25 2019

@author: Yamazaki Kenichi
"""
import sys

N = int(input())

for i in range(111):
    if N % 111 == 0:
        print(N)
        sys.exit()
    else:
        N += 1


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


void solve(long long X){
    ll val = 100;
    ll year = 0;
    while(1){
        val += val * 0.01;
        year++;
        if (val >= X)
            break;
    }
    cout << year << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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


void print_vector(vector<ll>& a){
    REP(i, a.size()){
        cout << a.at(i);
        if(i + 1 < a.size()){
            cout << ' ';
        }
    }
    cout << endl;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    ll count = 0;
    for(ll i = 0; i < n; ++i){
        ll minj = i;
        for(ll j = i + 1; j < n; ++j){
            if(a.at(j) < a.at(minj)){
                minj = j;
            }
        }
        if(minj != i){
            swap(a.at(i), a.at(minj));
            count++;
        }
    }

    print_vector(a);
    cout << count << endl;
    return 0;
}



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

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;


int main() {
    int n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? 0 : 1) << endl;
}


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

using namespace std;

using ll = long long;

ll find_nearest(vector<ll> &vs, ll x) {
  auto it1 = lower_bound(vs.begin(), vs.end(), x);
  auto it2 = lower_bound(vs.rbegin(), vs.rend(), x, greater<ll>());
  if (it1 == vs.end() || it2 == vs.rend()) {
    return it1 != vs.end() ? *it1 : *it2;
  } else {
    ll p1 = *it1, p2 = *it2;
    return (p1 - x < x - p2) ? p1 : p2;
  }
}

ll solve(vector<ll> &vs, vector<ll> &vt, ll x) {
  // まず右に進むとき
  ll dist_r = -1;
  auto rit_s = lower_bound(vs.begin(), vs.end(), x);
  auto rit_t = lower_bound(vt.begin(), vt.end(), x);
  if (rit_s != vs.end() || rit_t != vt.end()) {
    ll rp_s = rit_s == vs.end() ? 1e13 : *rit_s;
    ll rp_t = rit_t == vt.end() ? 1e13 : *rit_t;
    dist_r = min(rp_s - x, rp_t - x);
    if (rp_s - x < rp_t - x) {
      dist_r += abs(find_nearest(vt, rp_s) - rp_s);
    } else {
      dist_r += abs(find_nearest(vs, rp_t) - rp_t);
    }
  }

  // まず左に進むとき
  ll dist_l = -1;
  auto lit_s = lower_bound(vs.rbegin(), vs.rend(), x, greater<ll>());
  auto lit_t = lower_bound(vt.rbegin(), vt.rend(), x, greater<ll>());
  if (lit_s != vs.rend() || lit_t != vt.rend()) {
    auto lp_s = lit_s == vs.rend() ? 0 : *lit_s;
    auto lp_t = lit_t == vt.rend() ? 0 : *lit_t;

    dist_l = min(x - lp_s, x - lp_t);
    if (x - lp_s < x - lp_t) {
      dist_l += abs(find_nearest(vt, lp_s) - lp_s);
    } else {
      dist_l += abs(find_nearest(vs, lp_t) - lp_t);
    }
  }

  if (dist_l < 0 || dist_r < 0) {
    return dist_l < 0 ? dist_r : dist_l;
  } else {
    return min(dist_l, dist_r);
  }
}

int main(int argc, const char *argv[]) {
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> vs(a), vt(b), vx(q);
  for (auto &s : vs) cin >> s;
  for (auto &t : vt) cin >> t;
  for (auto &x : vx) cin >> x;

  sort(vs.begin(), vs.end());
  sort(vt.begin(), vt.end());

  for (auto &x : vx) {
    cout << solve(vs, vt, x) << '\n';
  }
  return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }

    set<int> s;
    rep(i, k)
    {
        s.insert(p[i]);
    }

    int len = 0;
    int m = 0;
    vector<bool> inc(n, false);
    rep(i, n)
    {
        if (m < p[i]) {
            len++;
        } else {
            len = 1;
        }

        if (len >= k) {
            inc[i - k + 1] = true;
        }
        m = p[i];
    }

    int result = 1;
    bool b = inc[0];
    for (int i = 1; i <= n - k; i++) {
        s.erase(s.find(p[i - 1]));
        if (*s.begin() < p[i - 1] || *s.rbegin() > p[i + k - 1]) {
            if (!(b && inc[i])) {
                result++;
            }
        }
        b = b || inc[i];
        s.insert(p[i + k - 1]);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;

int main(void) {
	ll n; cin >> n;
	vector<P> p(n);
	int cnt = 1;
	rep(i, n) {
		int x, y; cin >> x >> y;
		p[i].first = x + y;
		p[i].second = x - y;
	}
	sort(p.begin(), p.end());
	ll l=p[0].first;

	for (int i = 1; i < n; i++) {
		if (p[i].second < l) {
			continue;
		}
		else {
			cnt++;
			l = p[i].first;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

long long n,p,j[65000],s,a;
int main(){
	for(;;){
		scanf("%lld",&n);
		if(n==0)break;
		s=a=0;
		rep(i,n){
			scanf("%lld",&p);
			s+=p;
		}
		rep(i,n-1)scanf("%lld",j+i);
		sort(j,j+n-1);
		rep(i,n){
			a=max((n-i)*s,a);
			if(i!=n-1)s+=j[n-i-2];
		}
		printf("%lld\n",a);
	}
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------
// べき乗を計算　指数を計算
ll llpow(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll all = 0;
    REP(i, n) {
        cin >> a[i];
        all ^= a[i];
    }
    
    REP(i, n){
        cout << (all ^ a[i]);
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
    ll a=lD();
    char c;
    cin>>c;
    ll b=lD();
    if(c=='+')
        cout<<a+b<<endl;
    else
        cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

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

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    int ans = N - M;
    while(M--) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        if(!uf.unite(--X, --Y)) ++ans;
    }

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


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

  int pos = 3000;
  vector<vector<ll>> cnt(N + 1, vector<ll> (6000, 0));
  cnt[0][pos] = 1LL;
  REP(i,N) {
    REP(j,6000) {
      if(j + x[i] < 0 || j + x[i] >= 6000) continue;
      cnt[i + 1][j + x[i]] += cnt[i][j];
      cnt[i + 1][j] += cnt[i][j];
    }
  }

  cout << cnt[N][pos] - 1LL << endl;


  return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int main() {
	int n; read(n);
	cout << 360 / __gcd(n, 360) << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

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

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

int main(){
  int N;
  cin >> N;
  vector<long long> T(N);
  for(int i=0;i<N;i++)  cin >> T.at(i);

  long long ans=1;
  for(int i=0;i<N;i++){
    ans=lcm(ans,T.at(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct edge{
	int to;
	long long cost;
};
typedef pair<long long, int> P;
vector<edge> G[100000];
long long d[100000];

vector<edge> G2[100000];
long long d2[100000];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	for(int i=0;i<100000;i++) d[i] = 100000000000000000;
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0;i<G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v]+e.cost){
				d[e.to] = d[v]+e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void dijkstra2(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	for(int i=0;i<100000;i++) d2[i] = 100000000000000000;
	d2[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d2[v] < p.first) continue;
		for(int i=0;i<G2[v].size(); i++){
			edge e = G2[v][i];
			if(d2[e.to] > d2[v]+e.cost){
				d2[e.to] = d2[v]+e.cost;
				que.push(P(d2[e.to], e.to));
			}
		}
	}
}


int main(){
	int n,m,s,t;
	scanf("%d %d %d %d", &n, &m, &s, &t);

	for(int i=0;i<m;i++){
		int u,v;
		long long a,b;
		scanf("%d %d %lld %lld", &u, &v, &a, &b);
		u--;
		v--;
		struct edge e;
		e.to = v; e.cost = a;
		G[u].push_back(e);
		e.to = u; e.cost = a;
		G[v].push_back(e);
		e.to = v; e.cost = b;
		G2[u].push_back(e);
		e.to = u; e.cost = b;
		G2[v].push_back(e);
	}

	dijkstra(s-1);
	dijkstra2(t-1);

	P dis[100000];
	for(int i=0;i<n;i++){
		dis[i].first = d[i] + d2[i];
		dis[i].second = i;
	}
	
	sort(dis,dis+n);

	int min = 0;
	for(int i=0;i<n;i++){
		long long coin = 1000000000000000;
		if(i<=dis[min].second){
			printf("%lld\n", coin-dis[min].first);
		}else{
			while(i>dis[min].second) min++;
			printf("%lld\n", coin-dis[min].first);
		}
	}

	return 0;
}


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

/* nC2 */
ll choose2(ll n){
  return n*(n-1)/2;
}

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
 
	string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
  else cout<<"No";
  

  return 0;
}



Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int n;
    readf("%d\n",&n);
    for(int i=0;i<n;i++){
	string s1,s2;
	s1 = chomp(readln());
	s2 = chomp(readln());
	BigInt a = s1;
	BigInt b = s2;
	BigInt c = "10";
	c ^^= 80;
	c -= 1;
	auto res = a + b;
	if(res > c) writeln("overflow");
	else writeln(a + b);
    }
}

Measured memory_bytes: 2528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i;
     int p=0,k=0;
    for(i=0;i<3;i++)
    {
    cin>>a[i];
    if(a[i]==5)
    p++;
    else 
    k++;
    }
    if(p==2&&k==1)
    cout<<"YES"<<endl;
    else 
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

int x,n;
int p[110];
int a[110]={};

int ab(int a){
  if(a>0) return a;
  return -a;}

int main(){
  scanf("%d%d",&x,&n);
  int ans=x;
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
    a[p[i]]=1;}
  int sa=0;
  for(int sa=0;sa<=100;sa++){
    if(ans-sa>0){
      if(a[ans-sa]==0){
	ans=ans-sa; break;}
    }
    else{
      ans=ans-sa;break;}
    if(ans+sa<=100){
      if(a[ans+sa]==0){
	ans=ans+sa;
	break;}
    }
    else{
      ans=ans+sa;break;}
  }
    
  
  
  printf("%d\n",ans);
  
  return 0;
}


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

int main() {
  int a,b;
  cin >>a>>b;
  if(a%b==0){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=a;i<=1000000000;i=i+a){
    if(i%b!=0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

int main() {
  int x;
  cin >> x;
  
  if(x<600){
    cout << 8 << endl;
  }else if(x<800){
    cout << 7 << endl;
  }else if(x<1000){
    cout << 6 << endl;
  }else if(x<1200){
    cout << 5 << endl;
  }else if(x<1400){
    cout << 4 << endl;
  }else if(x<1600){
    cout << 3 << endl;
  }else if(x<1800){
    cout << 2 << endl;
  }else if(x<2000){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // Educational DP Contest I - coins
  // dp[i][j]:i枚目のコインをみたときにj枚が表である確率
  // 初期値は全て0
  // dp[1][1] = p1
  // dp[1][0] = 1-p1
  // 遷移（配るDPの方が良い。もらうDPだと場合分けが必要）
  // dp[i+1][j+1] += dp[i][j]*p(i+1)
  // dp[i+1][j] += dp[i][j]*(1-p(i+1))
  // ループは1からn-1まで
  int N;
  cin >> N;
  vector<double> p(N+1, 0);
  for(int i = 1; i <= N; i++){
    cin >> p.at(i);
  }
  vector<vector<double> > dp(N+1, vector<double>(N+2, 0));
  // 最後の遷移用にN+2まで確保
  dp[1][1] = p[1];
  dp[1][0] = 1 - p[1];
  for(int i = 1; i <= N -1; i++){
    for(int j = 0; j <= N; j++){
      dp[i+1][j+1] += dp[i][j]*p[i+1];
      dp[i+1][j] += dp[i][j]*(1-p[i+1]);
    }
  }
  double ans =0;
  for(int i = N/2+1; i <= N; i++){
    ans += dp[N][i];
  }
  cout << setprecision(10) << ans << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int X;int V[4];
int Y,Z;
int T[55],E[55];

double dp[55][5010];

signed main(){
    while(cin>>X>>Y>>Z,X||Y||Z){
        memset(T,0,sizeof(T));
        memset(dp,0,sizeof(dp));
        rep(i,X)cin>>V[i];
        rep(i,Z){
            int a;cin>>a;
            cin>>T[a]>>E[a];
        }

        double ans=0;

        dp[0][0]=1;
        rep(i,Y){
            for(int j=Y-1;j>=i;j--){
                rep(k,i*100+1){
                    if(dp[j][k]<(1e-9))continue;
                    rep(l,X){
                        int t=j+V[l];
                        int c=k;
                        chmin(t,Y);
                        if(T[t]==1){
                            t+=E[t];
                            chmin(t,Y);
                        }
                        else if(T[t]==2){
                            c+=E[t];
                        }
                        else if(T[t]==3){
                            c-=E[t];
                            if(c<0)c=0;
                        }
                        dp[t][c]+=dp[j][k]/X;
                    }
                    dp[j][k]=0;
                }
            }
        }
        rep(i,5000+1)ans+=dp[Y][i]*i;
        printf("%lld\n",(int)ans);
    }
    return 0;
}

Measured memory_bytes: 3308
n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = []
for i in range(n):
    s = a[i]
    b.append(s)
    for j in range(i+1, n):
        s += a[j]
        b.append(s)

MAX = 40
ans = 0
for t in range(MAX, 0, -1):
    x = ans + (1 << (t-1))
    cnt = 0
    for v in b:
        if x & v == x:
            cnt += 1
    if cnt >= k:
        ans = x

print(ans)

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

#define lld long long

int main() {
    lld N;
    cin >> N;
    printf("%.8Lf\n",2 * M_PI * (long double)N);
    return 0;
}

Measured memory_bytes: 3764
def shuffle_deck(deck,command_list):
    for command in command_list:
        deck = deck[command:]+deck[0:command]
        
    return deck


def run():
    
    deck_list=[]
    deck_command_list=[]
    command_list=[]
    
    
    while True:
        line=input()
        
        if line=="-":
            break
        
        command_list=[]
        deck_list.append(line)
        command_num=int(input())
        
        for i in range(command_num):
            command=int(input())
            command_list.append(command)
            
        deck_command_list.append(command_list)
        
    
    
    #シャッフルの開始
    for deck,command_list in zip(deck_list,deck_command_list):
        shuffled_deck=shuffle_deck(deck,command_list)
        print(shuffled_deck)

run()


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long int lli;
int main()
{
    lli A, B, k, x, a1, b1;
    double y, z;
    cin >> x;
    for(A = -120; A <= 120; A++)
		for(B = -120; B <= 120; B++) {
			if (A * A * A * A * A - B * B * B * B * B == x){
				cout << A << " " << B << endl;
				return 0;
			}
    }
    return 0;
}


Measured memory_bytes: 3608
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N= 1e5 +5;
m(int,int) hight;
v(int) g[N];
int n,m,x,y;



void Solve()
{
 
	cin>>n>>m;
	
	f(i,1,n)
	{
		cin>>x;
		hight[i]=x;
	}

	f(i,1,m)
	{
		cin>>x>>y;
		g[x].pub(y);
		g[y].pub(x);	
	}
 	
 	int ans=0;
 	
 	f(i,1,n)
 	{
 		if(g[i].sz==0) ans++;
		else
		{
			bool f=true;
			fe(x,g[i])
			{
				if(hight[x]>= hight[i])f=false;
			}
			if(f) ans++;	
		}	
	}
	cout<<ans;
	
}

signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 13420
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <cmath>
#include <limits>

using namespace std;

class edge{
	public:
	int vtx, dist;
	edge(){ vtx=0, dist=0; };
	edge(int a, int b){ vtx=a, dist=b; };
};

using Graph = vector<vector<edge>>;

vector<bool> seen;
vector<int> color;

void dfs(Graph &G, int v){
	seen[v] = true;

	for(auto e : G[v]){
		auto next_v = e.vtx;
		auto dist = e.dist;
		if(next_v==0 || seen[next_v]) continue;
		if(dist%2==0){
			color[next_v] = color[v]%2;
		}
		else{
			color[next_v] = (color[v]+1)%2;
		}
		dfs(G, next_v);
	}
}

int main(int argc, char* argv[]){
	int N;
	cin >> N;

	Graph G(N+1);

	for(int i=1; i<N; i++){
		int u, v, w;
		cin >> u >> v >> w;
		G[u].push_back(edge(v, w));
		G[v].push_back(edge(u, w));
	}

	seen.assign(N+1, false);
	color.assign(N+1, -1);
	color[1] = 0;
	dfs(G, 1);

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


Measured memory_bytes: 8192
/*
 * @Author: Kaizyn
 * @Date: 2020-05-10 20:58:30
 * @LastEditTime: 2020-05-10 21:07:39
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 20;

int n, m, x, res = INF;
int c[N];
int a[N][N], sum[N];

void dfs(const int &u, const int cost) {
  if (u > n) {
    for (int i = 1; i <= m; ++i) {
      if (sum[i] < x) return;
    }
    res = min(res, cost);
    return;
  }
  dfs(u+1, cost);
  for (int i = 1; i <= m; ++i) {
    sum[i] += a[u][i];
  }
  dfs(u+1, cost+c[u]);
  for (int i = 1; i <= m; ++i) {
    sum[i] -= a[u][i];
  }
}

inline void solve() {
  cin >> n >> m >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      sum[j] += a[i][j];
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (sum[i] < x) return void(cout << -1 << endl);
    sum[i] = 0;
  }
  dfs(1, 0);
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3696
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}

fn main(){
    let n: usize = read();
    let m: usize = read();
    let mut from1 = vec![false; n + 1];
    let mut fromn = vec![false; n + 1];
    let mut flg = false;
    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        from1[b] |= a == 1;
        from1[a] |= b == 1;
        fromn[b] |= a == n;
        fromn[a] |= b == n;
    }
    let flg = from1.iter().zip(fromn.iter()).fold(false, |acc, (&a, &b)| acc || a && b);
    println!("{}", if flg { "POSSIBLE" } else { "IMPOSSIBLE" });
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	map<int,int> kazu;
	vint kind;
	scan(N);
	rep(i,N){
		int a;
		scan(a);
		if(kazu[a]==0){
			kind.push_back(a);
		}
		kazu[a]++;
	}
	sort(kind.begin(),kind.end());
	int flag=0;
	if(kind.size()==1&&kind[0]==0){
		flag=1;
	}
	else if(N%3==0&&kind.size()==2){
		if(kind[0]==0&&kazu[0]==N/3&&kazu[kind[1]]==2*N/3) flag=1;
	}
	else if(N%3==0&&kind.size()==3){
		if(kazu[kind[0]]==N/3&&kazu[kind[1]]==N/3&&kazu[kind[2]]==N/3&&(kind[0]^kind[1]^kind[2])==0) flag=1;
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 4216
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  ld a,b;
  int h,m;
  ci(a,b,h,m);
  ld c = abs((30 * h + 0.5 * m) - (6 * m));
  c > 180 ? c = 360 - c : c = c;
  ld d = c * (pi / 180);
  sp(20);
  co(sqrt(a * a + b * b - 2 * a * b * cos(d)));
}

Measured memory_bytes: 4204
#include<iostream>
#include <algorithm>

using namespace std;

int n, W, v[110], w[110], dp[110][10010];
int calc() {
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i])dp[i][j] = dp[i + 1][j];
			else dp[i][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	return dp[0][W];
}
int main() {
	int ans;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	ans = calc();
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 6976
#include <iostream>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using namespace std;
using namespace boost;
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q, k, a, b, c;
    cin >> n;
    // undirectedS は無向グラフ、directedS は有向グラフ
    adjacency_list<listS, vecS, undirectedS, no_property,
                   property<edge_weight_t, int>>
        graph1(n);
    REP(i, n - 1) {
        cin >> a >> b >> c;
        add_edge(a - 1, b - 1, c, graph1);
    }
    cin >> q >> k;
    --k;
    vector<pair<int, int>> v(q);

    REP(i, q) {
        cin >> a >> b;
        v[i] = {a - 1, b - 1};
    }

    // k からの最短距離を求める
    vector<long long> distances1(n);
    vector<int> parents1(n);
    dijkstra_shortest_paths(
        graph1, k,
        distance_map(distances1.data()).predecessor_map(parents1.data()));
    for (auto a : v) {
        cout << distances1[a.first] + distances1[a.second] << '\n';
    }
    return 0;
}

Measured memory_bytes: 20600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            new Main().solve(in);
        }
    }

    private void solve(Scanner in) {
        int N = in.nextInt(), K = in.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = in.nextInt();
        }
        java.util.Arrays.sort(a);

        int from = -1;
        int to = N;
        while (from + 1 < to) {
            int n = (to + from) / 2;
            if (a[n] >= K) {
                to = n;
                continue;// necessary
            }
            boolean[][] dp = new boolean[N + 1][K];
            dp[0][0] = true;
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < K; j++) {
                    if (n != i && a[i] + j < K) {
                        dp[i + 1][a[i] + j] |= dp[i][j];
                    }
                    dp[i + 1][j] |= dp[i][j];
                }
            }
            boolean nece = false;
            for (int j = K - a[n]; j < K; j++) {
                if (dp[N][j]) {
                    nece = true;
                    break;
                }
            }
            if (nece) {
                to = n;
            } else {
                from = n;
            }
        }
        int ans = to;
        System.out.println(ans);
    }
}

Measured memory_bytes: 207636
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b);
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[] q){Scanner c=new Scanner(System.in);for(;;){int n=c.nextInt(),s=c.nextInt();if(n==0&&s==0)break;System.out.println(f(0,0,s,n));}}static int f(int x,int a,int t,int n){return n==0?x==t?1:0:a>9?0:f(x+a,a+1,t,n-1)+f(x,a+1,t,n);}}

Measured memory_bytes: 26148
#include<iostream>
#include<vector>

int main() {
	int n, m, c, count = 0;
	std::cin >> n >> m >> c;

	std::vector<int> v(m);
	for (int& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < n; i++) {
		int g = 0;
		std::vector<int> a(m);

		for (int& x : a) {
			std::cin >> x;
		}

		for (int j = 0; j < m; j++) {
			g += v[j] * a[j];
		}

		if (g + c > 0) {
			count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int largestPower(int n, int p) 
{ 
	// Initialize result 
	int x = 0; 

	// Calculate x = n/p + n/(p^2) + n/(p^3) + .... 
	while (n) 
	{ 
		n /= p; 
		x += n; 
	} 
	return x; 
} 

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> prime;
	prime.push_back(2);
	for(int i = 3; i<=n;i++)
	{
		int j=2;
		for(;j<i;j++)
			if(i%j==0)
				break;
		if(i==j)
			prime.push_back(i);
	}
	ll ans = 1;
	for(auto it:prime)
	{
		int g = largestPower(n,it);
		ans = ans *(g+1)%mod;
	}
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = [S() for _ in range(m)]
    b = [0] * (n+1)
    c = [0] * (n+1)
    for i in range(n):
        for j in range(m):
            if a[j][i] == 'W':
                b[i] += 1
            else:
                c[i] += 1

    for i in range(n):
        c[i+1] += c[i]

    for i in range(n-2,-1,-1):
        b[i] += b[i+1]

    m = b[0]
    r = 0
    for i in range(n):
        tm = b[i+1] + c[i]
        if m > tm:
            r = i + 1
            m = tm

    return '{} {}'.format(r,r+1)


print(main())




Measured memory_bytes: 10732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> sws(m, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            sws[i][s - 1] = 1;
        }
    }
    vector<int> ps(m);
    for (int i = 0; i < m; i++)
    {
        cin >> ps[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        bitset<10> s(i);
        int total = 0;
        for (int k = 0; k < m; k++)
        {
            int cnt = 0;
            for (int j = 0; j < n; j++)
            {
                if (s.test(j) && sws[k][j] == 1)
                {
                    cnt++;
                }
            }
            if (cnt % 2 == ps[k])
            {
                total++;
            }
        }
        if (total == m)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		no2();
	}

	static void no2() {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			long[] a = new long[N];

			for (int i = 0; i < N; i++) {
				a[i] = sc.nextLong();
			}

			int flg = 0;
			int ans = -1;
			for (int i = 0; i < 100; i++) {
				ans++;
				for (int n = 0; n < N; n++) {
					if (a[n] % 2 == 0) {
						a[n] = a[n] / 2;
					} else {
						flg = 1;
					}
				}
				if (flg == 1) {
					break;
				}
			}
			System.out.println(ans);
		}
	}

	static void no1() {
		try (Scanner sc = new Scanner(System.in)) {
			String t = sc.next();

			int a = Integer.parseInt(t.substring(0, 1));
			int b = Integer.parseInt(t.substring(1, 2));
			int c = Integer.parseInt(t.substring(2, 3));

			System.out.println(a + b + c);
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int n;
    cin >> n;

    vector<double> x(n);
    vector<double> y(n);

    rep(i,n){
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    rep(i,n){
        rep(j, n){
            if(i==j) continue;
            ans +=  sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }

    ans = ans / n;

    cout << fixed << setprecision(6) << ans;

    return 0;
}

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


int main(void){
  string a,b,c;
  cin>>a>>b>>c;
  char x=a.at(0)-32,y=b.at(0)-32,z=c.at(0)-32;
  cout<<x<<y<<z<<endl;



  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]
dp = [[100000]*W for _ in range(H)]
dp[0][0] = int(S[0][0]=="#")
for x in range(1, W):
    dp[0][x] = dp[0][x-1] + (int(S[0][x]=="#") if S[0][x-1]=="." else 0)
for y in range(1, H):
    dp[y][0] = dp[y-1][0] + (int(S[y][0]=="#") if S[y-1][0]=="." else 0)
    for x in range(1, W):
        dp[y][x] = min(
            dp[y][x-1] + (int(S[y][x]=="#") if S[y][x-1]=="." else 0),
            dp[y-1][x] + (int(S[y][x]=="#") if S[y-1][x]=="." else 0)
        )
print(dp[-1][-1])


Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int  a[26];
int main()
{
	string S;
	cin>>S;
	memset(a,0,sizeof(a));
	for(int i=0;i<S.size();i++)
	{
		char t=S[i];
		a[t-'a']++;
	}
	int t=0,i;
	for( i=0;i<26;i++)
	{
		if(!a[i])
			break;
	}
	if(i==26)
		cout<<"None";
	else
		cout<<(char)(i+'a');
	cout<<endl;
	return 0;	
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;

	ll ans = max({a*c,a*d,b*c,b*d}); 

	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
#define INF 2000000001
int heap[250];
int size;

void maxHeapInsert(int);
void heapIncreaseKey(int);
int main (){
    int n,i,tmp;
    scanf("%d",&n);
    size=0;
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        maxHeapInsert(tmp);
    }
    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,heap[i]);
        if(i/2>0){
            printf("parent key = %d, ",heap[i/2]);
        }
        if(i*2<=n){
            printf("left key = %d, ",heap[i*2]);
        }
        if(i*2+1<=n){
            printf("right key = %d, ",heap[i*2+1]);
        }
        printf("\n");
    }
    return 0;
}
void maxHeapInsert(int key){
    size++;
    heap[size]=key;
    /*
    heap[size]=-INF;
    heapIncreaseKey(key);
    */
}
void heapIncreaseKey(int key){
    int i,tmp;
    i=size;
    heap[i]=key;
    while(i>1 && heap[i/2]<heap[i]){
        tmp=heap[i];
        heap[i]=heap[i/2];
        heap[i/2]=tmp;
        i=i/2;
    }
}


Measured memory_bytes: 2112
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class CStones {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        string s;
        in>>n>>s;
        int res = n;
        std::vector<int> sumw(n, 0), sumb(n, 0);
        for(int i = 0; i < n; ++i){
            if(s[i] == '.'){
                sumw[i] = 1;
            }
            else {
                sumb[i] = 1;
            }
            if(i){
                sumw[i] += sumw[i-1];
                sumb[i] += sumb[i-1];
            }
        }
        if(n >= 2) {
            for (int i = 1; i < n; ++i) {
                if (s[i] != s[i - 1]) {
//                    res = min(res, sumb[i] + sumw[n-1] - sumw[i]);
                    res = min(res, sumb[i-1] + sumw[n-1] - sumw[i-1]);
                }
            }
        }
//        cerr << sumb[n-1] << ' ' << sumw[n-1] << endl;
        res = min(res, min(n-sumb[n-1], n-sumw[n-1]));
        out<<res<<endl;
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CStones solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 2196
a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ret = 2**60
for _ in range(m):
  x,y,c = map(int,input().split())
  x -= 1
  y -= 1
  ret = min(ret, A[x]+B[y]-c)
print( min(ret, min(A)+min(B)) )


Measured memory_bytes: 24784
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function (chunk) {
  const input = chunk.split(' ').map(Number)
  const area = input[0] * input[1]
  const outer = input[0] * 2 +  input[1] * 2
  console.log(area + ' ' + outer)
})

Measured memory_bytes: 15508
function main(input){
  input = input.split('\n');
  var N = Number(input[0]);
  var S = input[1];
  
  var tmp = '';
  var result = '';
  for(var i = 0;i < N;i++){
  	if(tmp !== S[i]){
      result += S[i];
    }
    tmp = S[i];
  }
  console.log(result.length);
  
}

main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 15436
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 102;
int D[N][3];

int main(){
   int n;
   cin>>n;
   int i;
   for(i=1;i<=n;++i){
      cin>>D[i][1]>>D[i][2];
   }
   for(i=1;i<=n-2;++i){
      if(D[i][1]==D[i][2]&&D[i+1][1]==D[i+1][2]&&D[i+2][1]==D[i+2][2]){
         cout<<"Yes";
         return 0;
      }
   }
   cout<<"No";
}

Measured memory_bytes: 3608