akhauriyash/Code-Regression huggingface dataset:
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

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

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

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

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

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

signed main() {
  int n;cin>>n;
  map<string, int> d;
  vi t(n);
  rep(i,n){
    string s;cin>>s;
    d[s] = i;
    cin>>t[i];
  }
  string x;cin>>x;
  int k = d[x];
  int ans = 0;
  rep(i, k+1, n){
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    char a, b;
    cin >> a >> b;

    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
vector<string> divide={"dream", "dreamer", "erase", "eraser"};

int main() {
  string S;
  cin>>S;
  
  reverse(S.begin(),S.end());
  for(int i=0;i<4;i++)
  reverse(divide.at(i).begin(),divide.at(i).end());
  bool ok=true;
  for(int i=0;i<S.size();){
    bool flag=false;
    for(int j=0;j<4;j++){
      string tmp=divide.at(j);
      if(S.substr(i,tmp.size())==tmp){
      	i+=tmp.size();flag=true;
      }
    }
    if(!flag){ok=false;break;}
    
  }
  cout<<(ok?"YES":"NO")<<endl;
  
}



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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

struct UnionFind{
	vi rank,par;
	void Init(int n){
		rank.assign(n,0);
		par.assign(n,-1);
	}
	int Find(int i){
		return par[i]==-1?i:(par[i]=Find(par[i]));
	}
	bool Same(int a,int b){
		return Find(a)==Find(b);
	}
	bool Unite(int a,int b){
		a=Find(a);
		b=Find(b);
		if(a==b)
			return false;
		if(rank[a]<rank[b])
			swap(a,b);
		par[b]=a;
		if(rank[a]==rank[b])
			rank[a]++;
		return true;
	}
} uf;

#define int ll

struct Pos{
	int x,y,w;
};

#define double ld

double Dist(Pos a,Pos b){
	return sqrt(double(Sq(a.x-b.x)+Sq(a.y-b.y)));
};

signed main(){
	int n=read();
	vector<Pos> p;
	REP(i,n){
		int x=read(),y=read(),w=read();
		p.PB(Pos{x,y,w});
	}
	vector<pair<double,pii>> es;
	REP(i,p.size())
		REP(j,i)
			es.PB(MP(Dist(p[i],p[j]),MP(i,j)));
	sort(ALL(es));
	vector<double> dp(1<<n,0);
	REP(i,n)
		dp[1<<i]=p[i].w;
	REP(bit,(1<<n)){
		double z=0;
		int k=0;
		REP(i,n)if((bit>>i)&1){
			z+=p[i].w;
			k++;
		}
		uf.Init(n);
		for(auto e:es){
			double d=e.first;
			int u=e.second.first,v=e.second.second;
			if(((bit>>u)&1)&&((bit>>v)&1)&&!uf.Same(u,v)){
				z-=d;
				uf.Unite(u,v);
			}
		}
		dp[bit]=z/k;
		int cur=bit;
		do{
			chmax(dp[bit],min(dp[cur],dp[bit^cur]));
			cur=(cur-1)&bit;
		}while(cur!=bit);
	}
	cout<<fixed<<setprecision(19)<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 768
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int i,x,ans;
	rep(i,5){
		cin>>x;
		if(x==0){
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 3636
n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
d = 0
for i in range(n):
    l = [0] * n
    for j in range(n):
        l[j] = ((L[i][0] - L[j][0]) ** 2 + (L[i][1] - L[j][1]) ** 2) ** 0.5
    d += sum(l)
print(d / n)

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

int main() {
	string s;
	cin >> s;
	if ((s[0] != s[1])||(s[1]!=s[2])) {
			cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")   //Comment optimisations for an interatcive problem - use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int qq;
ll ff[13];
ld sum=0;
vpll v;
ld x,y;
ll n;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//

int main(){
	fastio;randomINIT;

	ff[1]=1;
	ff[0]=0;
	foo(i,2,10)ff[i]=ff[i-1]*i;
	cin>>n;
	fo(i,n){
		cin>>x>>y;
		v.pb({x,y});
	}
	fo(i,n)fo(j,n)sum+=sqrt((v[i].f-v[j].f)*(v[i].f-v[j].f)+(v[i].s-v[j].s)*(v[i].s-v[j].s));

	cout<<(ff[n-1]*sum)/ff[n];


   
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

bool checkOverflow(ll a, ll b) {
    ll MAX = (ll)1e18;
    return (a > MAX / b)?true:false;
}

int main() {
    int N;
    cin >> N;
    vec<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    if(A[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(auto e:A){
        if(checkOverflow(e,ans)){
            cout << -1 << endl;
            return 0;
        }
        ans*=e;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3944
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int A = Integer.parseInt(W);
		W = in.readLine();
		int B = Integer.parseInt(W);



		System.out.println(6-(A+B));



	}


}


Measured memory_bytes: 21844
def showertime(n , t , tl):
    ans = 0
    for i in range(n):
        ans += t
        if i != 0 and tl[i] - tl[i-1] < t:
            ans -= t - (tl[i] - tl[i-1])

    return ans

def main():
    n , t = map(int , input().split())
    tl = list(map(int , input().split()))
    print(showertime(n , t , tl))

if __name__ == '__main__':
    main()


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

// 頂点fromから頂点toへのコストcostの辺 
struct edge { long long from, to, cost; };
edge e[5005];
vector<long long> to[3000];
bool from_zero[3000];
vector<long long> ot[3000];
bool from_n[3000];
long long ans[3000];
long long N, M, P; 

// from zero
void dfs(long long start){
	if(from_zero[start]){
		return;
	}
	from_zero[start] = true;
	for(auto p : to[start]){
		dfs(p);
	}
}

// from n - 1
void rdfs(long long start){
	if(from_n[start]){
		return;
	}
	from_n[start] = true;
	for(auto p : ot[start]){
		rdfs(p);
	}
}

int main(){
	cin >> N >> M >> P;
	for(long long i = 0; i < M; i++){
		long long a,b,c;
		cin >> a >> b >> c;a--;b--;
		e[i].from = a;
		e[i].to = b;
		e[i].cost = - (c - P); //最短経路を求めるためにマイナスにして置く
		to[a].push_back(b);
		ot[b].push_back(a);
	}

	dfs(0);
	rdfs(N-1);
	for(long long i = 0; i < N; i++){
		ans[i] = LONG_MAX;
	}
	ans[0] = 0;

	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < M; j++){
			edge ee = e[j];
			long long from = ee.from;
			long long to = ee.to;
			long long cost = ee.cost;
			if(!from_zero[from] || !from_zero[to] || !from_n[from] || !from_n[to]) continue;
			if(ans[from] != LONG_MAX && ans[to] > ans[from] + cost){
				ans[to] = ans[from] + cost;
				if(i == N-1){
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	cout << max(0LL, -1 * ans[N-1]) << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 2005;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tree_set;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    map<string,int> m;
    for (int i = 0; i < n; ++i)
    {
        string x;
        cin>>x;
        m[x]++;
    }
    vector<pair<int,string>> v;
    int cur = -1;
    for(auto x : m)
    {
        cur = max(cur,x.ss);
    }
    set<string> t;
    for(auto x : m)
        if(x.ss==cur)
            t.insert(x.ff);

    for(auto x : t)
        cout<<x<<endl;
    printclock;
    return 0;
}


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

int bubbleSort(int a[], int n) {
    int total_swap = 0;
    int swap_;

    do {
        swap_ = 0;

        for (int j = n - 1; j > 0; j--) {
            if (a[j -1] > a[j]) {
                swap(a[j -1], a[j]);
                swap_++;
            }
        }

        total_swap += swap_;
    } while (swap_ > 0);

    return total_swap;
}

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

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

    int count = bubbleSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }

    cout << endl << count << endl;

    return 0;
}


Measured memory_bytes: 3132
H,W,N=map(int,input().split())
sr,sc=map(lambda x:int(x)-1,input().split())
S=input()
T=input()

tmove=[(0,-1),(0,1),(-1,0),(1,0)]
amove=[(0,1),(0,-1),(1,0),(-1,0)]
m=[('L','R'),('R','L'),('U','D'),('D','U')]
for i in range(4):
    nh,nw=sr,sc
    t,a=tmove[i],amove[i]
    for k in range(N):
        if S[k]==m[i][0]:
            nh,nw=nh+t[0],nw+t[1]
        if nh<0 or nw<0 or nh>=H or nw>=W:
            print('NO')
            exit()
        gh,gw=nh+a[0],nw+a[1]
        if T[k]==m[i][1]:
            if gh>=0 and gh<H and gw>=0 and gw<W:
                nh,nw=gh,gw
print('YES')

Measured memory_bytes: 74080
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	a.push_back(0);
	ll kane = 1000;
	ll kabu = 0;
	vector<int> kyoku(n+2);
	rep2(i,1,n+1){
		if(a[i-1] < a[i]){
			kyoku[i] = 1;
		} else if(a[i-1] > a[i]){
			kyoku[i] = -1;
		}
	}
	// print(kyoku);
	int b = 0;
	int ind = 0;
	vector<pair<int,int>> res;
	rep(i, n+1)
	{
		

		if (b == -1){
			if(kyoku[i] == 1){
				res.push_back(pair<int, int>(ind, -1));
			}
		} if (b == 1){
			if (kyoku[i] == -1)
			{
				res.push_back(pair<int, int>(ind, 1));
			}
		}
		if (kyoku[i] != 0)
		{
			b = kyoku[i];
			ind = i;
		}
	}
	// for (auto x : res)
	// {
	// 	cout << x.first << " " << x.second << endl;

	// }
	// if(res.size() == 0){
	// 	cout << 1000 << endl;
	// 	return 0;
	// }
	if(res.size()){
	if (res[0].second == 1){
		kabu = kane / a[0];
		kane = kane % a[0];
	}
	}
	rep(i,res.size()){
		int f = 0;
		rep2(j, i + 1, res.size())
		{
			if(res[j].second == 1)
				f = 1;
		}
		if(res[i].second == 1){
			kane += kabu * a[res[i].first];
			kabu = 0;
		}
		if(res[i].second == -1 && f == 1){
			kabu = kane / a[res[i].first];
			kane = kane % a[res[i].first];
		}
	}
	cout << kane << endl;


	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;
 
int main() {
    int n = 0;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i=0; i<n; i++) { 
        cin >> a.at(i) >> b.at(i);
    }
    vector<pair<ll, int>> sum(n);
    for (int i=0; i<n; i++) {
        sum.at(i) = make_pair(a.at(i) + b.at(i), i);
    } 
    sort(sum.begin(), sum.end());
    reverse(sum.begin(), sum.end());
    ll ans = 0;
    for (int i=0; i<n; i++) {
        int cur = sum.at(i).second;
        if (i%2 == 0) {
            ans += a.at(cur);
        } else {
            ans -= b.at(cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int gcd(int a, int b){
        if(a>b) swap(a,b);
        while(b%a!=0){
                int t = b%a;
                b = a;
                a = t;
        }
        return a;
}

int main(){
        int i,j,k,K,tmp,ans=0;
        cin >> K;
        for(i=1;i<=K;++i){
                for(j=1;j<=K;++j){
                        for(k=1;k<=K;++k){
                                tmp = gcd(i,j);
                                ans += gcd(tmp,k);
                        }
                }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3628
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=2e5+4;

void max_self(ll &x,ll y)
{
    x=max(x,y);
}

int h[N],a[N];

//dp[i] tells the maximum beauty if the last element of the monotonically increasing
//sequence is i.

ll dp[N];

ll tree[4*N];

void update(int node,int st,int end,ll val,int ind)
{
    if(st==end)
    {
        tree[node]=val;
        
        return;
    }
    
    int mid=(st+end)/2;
    
    if(ind<=mid)
    update(2*node,st,mid,val,ind);
    else
    update(2*node+1,mid+1,end,val,ind);
    
    tree[node]=max(tree[2*node],tree[2*node+1]);
}

ll query(int node,int st,int end,int l,int r)
{
    if(st>r or end<l)
    return 0;
    
    if(st>=l and end<=r)
    return tree[node];
    
    int mid=(st+end)/2;
    
    ll x,y;
    
    x=query(2*node,st,mid,l,r);
    
    y=query(2*node+1,mid+1,end,l,r);
    
    return max(x,y);
}


int main()                  
{
    int n;
    
    scn(n);
    
    rep(i,1,n+1)
    scn(h[i]);
    
    rep(i,1,n+1)
    scn(a[i]);
    
    for(int flower=1;flower<=n;flower++)
    {
        ll here=query(1,0,n,0,h[flower]);
        
        dp[h[flower]]=here+a[flower];
        
        update(1,0,n,dp[h[flower]],h[flower]);
    }
    
    ll ans=0;
    
    rep(i,1,n+1)
    max_self(ans,dp[i]);
    
    printf("%lld ",ans);
} 


Measured memory_bytes: 9600
#include <iostream>
#include <cstdlib>
#include <vector>

int main(int argc, char** argv) {
  int a;
  std::cin >> a;
  
  int vec[20];
  for (int i=0; i<a; i++) {
    std::cin >> vec[i];
  }

  bool can[100];
  can[0] = true;
  for (int i=1; i<a; i++) can[i] = false;
  
  for (int i=0; i<a; i++) {
    if (can[i]) {
      for (int j=i+1; j<a; j++) {
    	if (vec[i] <= vec[j]) {
           can[j] = true;
        } else {
          can[j] = false;
        }
      }
    }
  }
  
  int sum = 0;
  for (int i=0; i<a; i++) {
    if (can[i] == true) {
      sum++;
    }
  }
  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	const int days = 365;
	int d;
	std::cin >> d;

	int c[26];
	int s[days][26];

	for (int i = 0; i < 26; ++i)
		std::cin >> c[i];

	for (int i = 0; i < days; ++i)
		for (int j = 0; j < 26; ++j)
			std::cin >> s[i][j];

	int t[days];
	for (int i = 0; i < days; ++i)
	{
		std::cin >> t[i];
		t[i]--;
	}

	// 満足度の計算
	//int score = 0;
	for (int i = 0; i < days; ++i)
	{
		int maxDelta = 0;

		for (int f = 0; f < 26; ++f)
		{
			int delta = s[i][f];
			//score += s[i][t[i]];

			for (int j = 0; j < 26; ++j)
			{
				for (int k = i; k >= 0; --k)
				{
					if (t[k] != j)
						delta -= c[j];
				}
			}

			if (maxDelta == 0 || maxDelta < delta)
			{
				maxDelta = delta;
				t[i] = f;
			}
		}
	}

	// 最適化
	for (int se = 0; se < 10; ++se)
	{
		for (int i = 0; i < days; ++i)
		{
			int maxDelta = 0;

			for (int f = 0; f < 26; ++f)
			{
				if (f == t[i]) continue;

				// もともとの増える量
				int delta = s[i][f];

				{
					// 前に何日分あるか
					int cnt1 = 0;
					for (int k = i; k >= 0; --k)
					{
						if (t[k] != f)
							cnt1++;
						else break;
					}

					// 後に何日分あるか
					int cnt2 = 0;
					for (int k = i; k < days; ++k)
					{
						if (t[k] != f)
							cnt2++;
						else break;
					}

					// 削減出来る量
					int sum = cnt2 * cnt1;

					// 合計の削減量
					delta += sum * c[f];
				}

				if (maxDelta == 0 || maxDelta < delta)
				{
					maxDelta = delta;
					t[i] = f;
				}
			}
		}
	}

	for (int i = 0; i < days; ++i)
		std::cout << t[i] + 1 << std::endl;
}

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

const int MAX = 110;
int mat[MAX][MAX];

int main()
{
  int n; cin >> n;
  memset(mat, 0, sizeof(mat));
  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
    u--;
    while(k--) {
      int v; cin >> v; v--;
      mat[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      cout << mat[i][j] << (j==n-1?'\n':' ');
  }
  return EXIT_SUCCESS;
}




Measured memory_bytes: 3132
var
  a,b:boolean;
  n:string;
  i:longint;
begin
  readln(n);
  for i:=1 to length(n) do
    begin
      if n[i]='C' then a:=true;
      if (n[i]='F') and a then b:=true;
    end;
  if a and b then writeln('Yes')
    else writeln('No');
end.

Measured memory_bytes: 128
'use strict'

const main = arg => {
    const input = arg.trim().split("\n");
    const num = parseInt(input[0], 10);
    const info = input.slice(1).slice(0, num);
    
    const builds = [...Array(4)].map((a, l) => {
        return (
            [...Array(3)].map((b, m) => {
                return [...Array(10)].map((c, n) => (0));
            })
        )
    });

    //b, f, r, v
    info.forEach(inout => {
        const data = inout.split(" ").map(num => parseInt(num, 10));

        const b = data[0]-1;
        const f = data[1]-1;
        const r = data[2]-1;
        const v = data[3];

        builds[b][f][r] += v;
    });

    const result = builds.map((a, l) => {
        return builds[l].map((b, m) => {
            return " " + builds[l][m].join(" ");
        }).join("\n");
    });
    
    console.log(result.join("\n####################\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
    string a,b;
    string ans="No";
    cin >> a >> b;
    int c=stoi(a+b);
    int d=pow(c,0.5);
    if(d*d==c){
            ans="Yes";
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, n, x;
	scanf("%d%d", &n, &x);
	int L[n], d[n+1];
	rep(i,n) scanf("%d", &L[i]);

	d[0] = 0;
	
	loop(i, 1, n+1){
		d[i] = d[i-1] + L[i-1];
		if(d[i] > x) break;
	}
	printf("%d", i);
	return 0;
}

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

struct data {
  long long a, b;
};
bool operator<(const data &l, const data &r) {
  return l.b - l.a > r.b - r.a;
}

long long n;
vector<data> v;

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, num = (long long)1e10;
  bool ch = 1;
  for(int i = 0; i < n; ++i)
    if(v[i].a != v[i].b) ch = 0;
  if(ch) return 0;
  for(int i = 0; i < n; ++i) {
    ans += v[i].b;
    if(v[i].a > v[i].b) num = min(num, v[i].b);
  }
  return ans - num;
}

Measured memory_bytes: 512
a, b = map(int, input().split())
n = input()

s1 = n[:a]
s2 = n[a]
s3 = n[a+1:]

if s1.isdigit() and s2=='-' and s3.isdigit():
    print('Yes' , flush=True)
else:
    print('No' , flush=True)


Measured memory_bytes: 61756
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
using namespace std;
#define ll long long
#define N 1000
#define MOD 1000000007
ll h,w;
ll a[N][N],dp[N][N];
ll f(ll i,ll j){
	if(i<0 || j<0){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(!a[i][j]){
		dp[i][j]=0;
	}
	else if(!i && !j){
		dp[i][j]=1;
	}
	else{
		dp[i][j]=(f(i-1,j)+f(i,j-1))%MOD;
	}
	return dp[i][j];
}
void solve(){
	ll h,w;
	cin >> h >> w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			char c;
			cin >> c;
			if(c=='.'){
				a[i][j]=1;
			}
			else{
				a[i][j]=0;
			}
			dp[i][j]=-1;
		}
	}
	cout << f(h-1,w-1) << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 19324
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
using namespace std;
int main()
{
    long long int a,b,l,r,p,q,s1,s2,sum2,sum1,lcm,g,c,s3,temp,a_left,a_right,b_left,b_right,s_left,s_right;
    cin>>l>>r>>a>>b;
    lcm=__gcd(a,b);
    lcm=(a*b)/lcm;
    if(l%a==0)
        a_left=l;
    else
    {
        c=l/a;
        a_left=(c+1)*a;
        if(a_left>r)
            a_left=0;
    }
    if(r%a==0)
        a_right=r;
    else
    {
        c=r/a;
        a_right=c*a;
        if(a_right<l)
            a_right=0;
    }
    if(l%b==0)
        b_left=l;
    else
    {
        c=l/b;
        b_left=(c+1)*b;
        if(b_left>r)
            b_left=0;
    }
    if(r%b==0)
        b_right=r;
    else
    {
        c=r/b;
        b_right=c*b;
        if(b_right<l)
            b_right=0;
    }
    if(l%lcm==0)
        s_left=l;
    else
    {
        c=l/lcm;
        s_left=(c+1)*lcm;
        if(s_left>r)
            s_left=0;
    }
    if(r%lcm==0)
        s_right=r;
    else
    {
        c=r/lcm;
        s_right=c*lcm;
        if(s_right<l)
            s_right=0;
    }
    p=((a_right-a_left)/a)+1;
    q=((b_right-b_left)/b)+1;
    g=((s_right-s_left)/lcm)+1;
    if(a_right==0 && a_left==0)
        p=0;
    if(b_right==0 && b_left==0)
        q=0;
    if(s_right==0 && s_left==0)
        g=0;
    sum1=(r-l+1)-(p+q-g);
    cout << sum1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define db "BSF"
#define fi first
#define se second
#define endl '\n'
#define int long long
const int INF = 1e15 + 1;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<PII, int> PII2;
typedef pair<int, PII> PII3;
typedef pair<PII, PII> PII4;

void docfile()
{
    if (ifstream("FORM.inp"))
    {
        freopen("FORM.inp", "r", stdin);
        freopen("FORM.out", "w", stdout);
    }
    else if (ifstream(db".inp"))
    {
        freopen(db".inp", "r", stdin);
        freopen(db".out", "w", stdout);
    }
}

//---------------------------------------------------------------------------
const int N = 16 + 5;
int n, a[N][N];
int dp[100000];
int p[100000];

void input()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
    cin >> a[i][j];
}

void solve()
{
    int m = (1<<n);
    for(int mask = 0; mask < m; mask++)
    {
        vector <int> v;
        for(int i = 0; i < n; i++)
        {
            if(((1<<i)&mask) != 0) v.push_back(i+1);
        }
        for(int i = 0; i < v.size(); i++)
        for(int j = i + 1; j < v.size(); j++)
        dp[mask] += a[v[i]][v[j]];
    }
    for(int mask = 0; mask < m; mask++)
    {
        for(int i = mask; i; i = (i-1)&mask)
        {
            dp[mask] = max(dp[mask], dp[i] + dp[mask^i]);
        }
    }
    cout << dp[m-1];
}

int32_t main()
{
    docfile();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    //int test = 1; cin >> test; while(test--) {input(); solve();}
    input(); solve();
}


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

/*
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
*/


Measured memory_bytes: 4192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  int count = 0;
  sort(a.begin(), a.end());
  int j = 0;
  vector<bool>dup(1000010,false);
  while(j+1 < n) {
    if(a[j] == a[j+1]) {
      int tmp = a[j];
      dup[j] = true;
      while(tmp == a[j+1]) {
        dup[j+1] = true;
        j++;
      }
    }
    j++;
  }
  vector<bool>b(1000010, false);
  rep(i, n) {
    vector<ll>res = enum_divisors(a[i]);
    bool can = true;
    for(auto p: res) {
      if(b[p]) {can = false;}
    }
    if(can && !dup[i]) {count++;}
    b[a[i]] = true;
  }
  cout << count << endl;
}

Measured memory_bytes: 4324
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type intList []int

func (a intList) Len() int           { return len(a) }
func (a intList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a intList) Less(i, j int) bool { return a[i] < a[j] }
func (a *intList) Push(x interface{}) {
	*a = append(*a, x.(int))
}
func (a *intList) Pop() interface{} {
	old := *a
	n := len(*a)
	x := old[n-1]
	*a = old[:n-1]

	return x
}

func makeFormer(A *intList) (intList, int) {
	M := len(*A)
	N := M / 3

	B, sum := make(intList, N), 0
	copy(B, (*A)[:N])
	for _, b := range B {
		sum += b
	}

	return B, sum
}

func makeLatter(A *intList) (intList, int) {
	M := len(*A)
	N := M / 3

	C := make(intList, N)
	copy(C, (*A)[2*N:])

	sum := 0
	for i, c := range C {
		sum += c
		C[i] = -c
	}

	return C, sum
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make(intList, 3*N)
	for i := 0; i < 3*N; i++ {
		A[i] = scanInt()
	}

	Former, Fsum := makeFormer(&A)
	heap.Init(&Former)
	FsumList := make(intList, N+1)
	FsumList[0] = Fsum
	for i := 1; i <= N; i++ {
		heap.Push(&Former, A[N-1+i])
		poped := heap.Pop(&Former).(int)

		Fsum = Fsum + A[N-1+i] - poped
		FsumList[i] = Fsum
	}

	Latter, Lsum := makeLatter(&A)
	heap.Init(&Latter)
	LsumList := make(intList, N+1)
	LsumList[N] = Lsum
	for i := N - 1; i >= 0; i-- {
		heap.Push(&Latter, -A[N+i])
		poped := -heap.Pop(&Latter).(int)

		Lsum = Lsum + A[N+i] - poped
		LsumList[i] = Lsum
	}

	ans := FsumList[0] - LsumList[0]
	for i := 0; i <= N; i++ {
		ans = intMax(ans, FsumList[i]-LsumList[i])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 11868
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

string kcomb[]={"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts"};
int main(){
	vs klet;
	REP(i,26){
		klet.push_back("");
		klet[i].push_back('a'+i);
	}
	REP(i,12){
		klet.push_back(kcomb[i]);
	}
	vvi follows(38,vi(38,0));
	vi whole;
	int n;
	cin>>n;

	REP(i,n){
		string line;
		if(i==0)getline(cin,line,'\n');
		getline(cin,line,'\n');
		REP(j,line.size()){
			if(line[j]==' '){
				whole.push_back(-1);
			}else{
				bool flag=false;
				FOR(k,26,38){
					if(line[j]==klet[k][0]&&j<line.size()-1&&line[j+1]==klet[k][1]){
						whole.push_back(k);
						j++;
						flag=true;
						break;
					}
				}
				if(!flag){
					whole.push_back(line[j]-'a');
				}
			}
		}
		whole.push_back(-1);
	}

	REP(i,whole.size()-1){
		int f=whole[i];
		int s=whole[i+1];
		if(f!=-1&&s!=-1){
			follows[f][s]++;
		}
	}

	REP(i,38){
		int maxlet=0;
		int maxcnt=0;
		REP(j,38){
			if(maxcnt<follows[i][j]){
				maxlet=j;
				maxcnt=follows[i][j];
			}
		}
		cout<<klet[i]<<" "<<klet[maxlet]<<" "<<maxcnt<<endl;
	}

}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    Vvec<int> a(N, vector<int>(N));
    for(auto& v: a){
        for(auto& x: v) cin >> x;
    }

    const ll MOD = 1e9+7;
    vector<ll> dp(1<<N);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<(1<<N); j++){
            bitset<21> b(j);
            if(b.count()!=i) continue;
            for(int k=0; k<N; k++){
                if(a[i][k]==1 && !b[k]){
                    dp[j | (1<<k)] += dp[j];
                    dp[j | (1<<k)] %= MOD;
                }
            }
        }
    }

    cout << dp[(1<<N)-1] << endl;
    // debug(dp);
}

Measured memory_bytes: 16640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( (ll)( 1e9 + 7 ) )

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

	int k;
	vector<vector<int>> s( M );
	vector<bitset<10>> b( M );
	rep( i, M )
	{
		cin >> k;
		s[i].resize( k );
		rep( j, k )
		{
			// 各電球についてのマスクビットを作る
			cin >> s[i][j];
			b[i].set( s[i][j] - 1 );
		}
	}

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

	ll count = 0;
	const int loop = pow( 2, N );
	rep( i, loop )
	{
		bool chk = true;
		rep( j, M )
		{
			bitset<10> tmp = i;
			auto res = b[j] & tmp;
			if ( ( res.count() % 2 ) != p[j] )
			{
				chk = false;
				break;
			}
		}
		if ( chk ) count++;
	}

	cout << count << endl;

	return ( 0 );
}


Measured memory_bytes: 888
import java.util.*

private class ModInt(x: Long) {

    companion object {
        const val MOD = 1e9.toLong() + 7
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

private fun fact(n: ModInt): ModInt {
    return (2..n.x).fold(ModInt(1L)) { acc, l -> acc * ModInt(l) }
}

private fun comb(n: ModInt, k: ModInt): ModInt {
    return fact(n) / fact(k) / fact(n - k)
}

fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }
    var comb1 = ModInt(1)
    for (i in 0 until a) {
        comb1 = comb1 * ModInt(n - i) / ModInt(a - i)
    }
    var comb2 = ModInt(1)
    for (i in 0 until b) {
        comb2 = comb2 * ModInt(n - i) / ModInt(b - i)
    }
    val ans = ModInt(2).pow(n) - ModInt(1) - comb1 - comb2
    println(ans)
}

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();
            var a = s[0];
            var b = s[1];

            var flag = true;
            foreach(var i in Enumerable.Range(1, 1000)){
                var ap = i * 8 / 100;
                var bp = i * 10 / 100;
                if(a == ap && b == bp){
                    Console.WriteLine(i);
                    flag = false;
                    break;
                }
            }
            if(flag){
                Console.WriteLine(-1);
            }
        }
    }
}


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

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

    int a=N/100;
    int b=(N-a*100)/10;
    int c=N-100*a-10*b;

    if(a==7||b==7||c==7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
//
// Created by Hideaki Imamura on 2020-03-12.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, K, p[200010];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> p[i];

    double e[200010];
    for (int i = 0; i < N; ++i) e[i] = ((double) p[i] + 1) / 2;

    double s[200010];
    s[0] = 0;
    for (int i = 0; i < N; ++i) {
        s[i + 1] = s[i] + e[i];
    }

    double ans = 0;
    for (int i = 0; i < N - K + 1; ++i) {
        ans = max(ans, s[i + K] - s[i]);
    }

    printf("%f\n", ans);
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> c(n-1),s(n-1),f(n-1);
  REP(i,n-1) cin>>c[i]>>s[i]>>f[i];

  REP(i,n-1){
    int temp=s[i]+c[i];
    REP2(j,i+1,n-1){
      if(temp<=s[j]) temp=s[j]+c[j];
      else temp=s[j]+((temp-s[j]+f[j]-1)/f[j])*f[j]+c[j];
    }
    cout<<temp<<endl;
  }
  cout<<0<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigDecimal X = sc.nextBigDecimal();
    BigDecimal Y = sc.nextBigDecimal();
    int i =1;
    while (true) {
      X = X.multiply(BigDecimal.valueOf(2));
      if (X.compareTo(Y) > 0) {
        System.out.println(i);
        return;
      } else {
        i++;
      }
    }
  }
}

Measured memory_bytes: 24404
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
queue<int>q;
int n,l,x,y,ans,sum,d[2001],a[2001][2001];
bool vis[2001];
void tot()
{
	for (int i=1;i<=n;i++)
		if (d[i]>l/2)sum++;
}
void bfs(int x,int y)
{
	memset(d,0,sizeof(d));
	memset(vis,0,sizeof(vis));
	vis[y]=true;
	d[x]=0;
	vis[x]=true;
	q.push(x);
	while (!q.empty())
	{
		int k=q.front();
		q.pop();
		for (int i=1;i<=a[k][0];i++)
			if (!vis[a[k][i]])
			{
				d[a[k][i]]=d[k]+1;
				vis[a[k][i]]=true;
				q.push(a[k][i]);
			}
	}
}
int main()
{
	scanf("%d%d",&n,&l);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		a[x][++a[x][0]]=y;
		a[y][++a[y][0]]=x;
	}
	ans=0xFFFFFFF;
	for (int i=1;i<=n;i++)
	{
		if (!(l%2))
		{
			bfs(i,-1);
			sum=0;
			tot();
			ans=min(ans,sum);
			continue;
		}
		for (int j=1;j<=a[i][0];j++)
		{
			sum=0;
			bfs(i,a[i][j]);
			tot();
			bfs(a[i][j],i);
			tot();
			ans=min(ans,sum);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF;
const ll MOD=998244353;
const int MAX=300010;
//SegmentTree
template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }
 
  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

signed main(){
    ll n,k;cin>>n>>k;
    SegmentTree<ll>seg(MAX+2,[](ll a,ll b){return max(a,b);},0LL);
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        ll ma=seg.query(a[i],min(a[i]+k+1,300001LL));
        ma=max(ma,seg.query(max(0LL,a[i]-k),a[i]+1));
        seg.update(a[i],ma+1);
    }
    cout<<seg.query(0,MAX+1)<<endl;
}

Measured memory_bytes: 13820