akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
void print_array(int*,int);

void insertionSort(int* A,int N){
    print_array(A,N);
    for(int i=1;i!=N;++i){
        int v=A[i];
        int j=i-1;
      
        
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
            A[j+1]=v;
        }
          print_array(A,N);
    }
    
}

void print_array(int *A,int N){
    for(int i=0;i!=N;++i){
        std::cout<<A[i];
        if(i!=N-1){
            std::cout<<" ";
        }else{
            std::cout<<std::endl;
        }
    }
}

int main(int argc, const char * argv[]) {
    
    int N;
    cin>>N;
    
    int A[N];
    
    for(int i=0;i!=N;++i){
        cin>>A[i];
    }
    
    insertionSort(A, N);
    
    
    
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin>>s;
    cout << "ABC"+s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll N[200100];
ll preSumN[200100];
ll M[200100];
ll preSumM[200100];
int binarySearch(ll arr[],int low,int high,ll target){
    int mid;
    while(low<=high){
        mid=(low+high)/2;
        if(arr[mid]==target)
            return mid;
        else if(arr[mid]>target)
            high = mid-1;
        else
            low = mid+1;
    }
    return low;
}
int main(){
    int n,m,i;
    ll k,other;
    cin>>n>>m>>k;
    for(i=0;i<n;i++){
        cin>>N[i];
    }
    for(i=0;i<m;i++){
        cin>>M[i];
    }
    for(i=0;i<n;i++)
        preSumN[i+1] = preSumN[i]+N[i];
    for(i=0;i<m;i++)
        preSumM[i+1] = preSumM[i]+M[i];
    int total=0;
    for(i=0;i<=n;i++){
        other = k-preSumN[i];
        if(other < 0)
            continue;
        int j = binarySearch(preSumM,0,m,other);
        if(preSumM[j] > other || j > m)
            j--;
        total = max(total,i+j);
    }
    cout<<total;
    return 0;
}


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

const int MAX_N = int(1e5) + 10;
const int mod = 998244353;

int n, m, base;

struct Graph {
	int sg[MAX_N], cnt[MAX_N], ext[MAX_N];
	std::vector<int> edges[MAX_N];

	void addEdge(int x, int y) {
		if (x > y) std::swap(x, y);
		edges[x].emplace_back(y);
	}

	void getSG(int x) {
		for (auto p : edges[x]) ext[sg[p]] = 1;
		while (ext[sg[x]]) ++sg[x];
		for (auto p : edges[x]) ext[sg[p]] = 0;
	}

	void init() {
		int x = 1;
		for (int i = 1; i <= n; ++i) {
			x = 1LL * base * x % mod;
			(cnt[sg[i]] += x) %= mod;
		}
	}
} g[3];

int main() {
	base = 1;
	for (int i = 1; i <= 18; ++i) {
		base = 1LL * base * 10 % mod;
	}
	
	scanf("%d", &n);
	for (int i = 0; i < 3; ++i) {
		scanf("%d", &m);
		while (m--) {
			int x, y;
			scanf("%d%d", &x, &y);
			g[i].addEdge(x, y);
		}
		for (int j = n; j; --j) {
			g[i].getSG(j);
		}
		g[i].init();
	}
	
	int ans = 0;
	for (int i = 0; i < 512; ++i) {
		for (int j = 0; j < 512; ++j) {
			int d = 1LL * g[0].cnt[i] * g[1].cnt[j] % mod * g[2].cnt[i ^ j] % mod;
			(ans += d) %= mod;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 17420
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  while(getline(cin,s)){
  	int NA=1;
    for(int i=0;i<10;++i){
      string tmp=s;
      for(int j=0;j<tmp.size();++j) if(tmp[j]=='X') tmp[j]='0'+i;
      char a[125],b[125],c[125];
      sscanf(tmp.c_str(),"%[^+]%*c%[^=]%*c%s",a,b,c);
      string sa(a),sb(b),sc(c),res;
      reverse(sa.begin(),sa.end());
      reverse(sb.begin(),sb.end());
      reverse(sc.begin(),sc.end());
      for(int k=0,sum,carry=0;k<((sa.size()<sb.size())?sb.size()+1:sa.size()+1);++k){
      	if(sa.size()>k&&sb.size()>k){
	      	sum=(sa[k]-'0'+sb[k]-'0'+carry)%10;
	      	carry=(sa[k]-'0'+sb[k]-'0'+carry)/10;
	      	res+=(char)(sum+'0');
      	}else{
      		if(k<sa.size()||k<sb.size()){
      			int tmp=(sa.size()>sb.size())?sa[k]-'0':sb[k]-'0';
      			sum=(tmp+carry)%10;
      			carry=(tmp+carry)/10;
      			res+=(char)(sum+'0');
      		}
      		if(sa.size()<=k&&sb.size()<=k&&carry){
      			res+=carry+'0';
      			carry=0;
      		}
      	}
      }
      if(res==sc){NA=0;cout<<i<<endl;break;}
    }
    if(NA)cout<<"NA"<<endl;
  }
}

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

int main(){
	int n,lt;
	cin>>n>>lt;
	
	int nw=1001;
	int ans=0;
	for(int i=0;i<n;i++){
		int c,t;
		cin>>c>>t;
		
		if(t<=lt) if(c<nw) nw=c;
	}
	if(nw>=1001) cout<<"TLE"<<endl;
	else cout<<nw<<endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
  IOS;
  int t, x;
  cin >> t >> x;
  int ans=0;
  for (int q=0; q<t; q++)
    {
      double a, b;
      cin >> a >> b;
      double w=sqrt(a*a+b*b);
      //cout << w << endl;
      //cout << "-----"<< endl;
      if (w<=x)
	ans++;
    }
  cout << ans << endl;
  return 0;
}
	
      


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

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


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n,K; cin>>n>>K;
    int a[n],dp[n];
    loop(i,n) cin>>a[i];
    dp[0]=0; 
    for(int i=1; i<n; i++){
    	dp[i]=inf;
    	for(int k=1; k<=K;k++){
    		if(i-k<0) break;
    		dp[i]=min(dp[i],abs(a[i]-a[i-k])+dp[i-k]);
    	}
    }
    pt(dp[n-1]);
}


/*


*/





Measured memory_bytes: 4400
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;	//(x, y)

int w, h, t, p;
int d[20], c[20];
int x[20], y[20];

void solve() {
	map<P, int> mp[21];
	map<P, int>::iterator it;
	int i, j;
	
	rep(i, w) rep(j, h) mp[0][P(i, j)] = 1;
	rep(i, t) {
		for (it = mp[i].begin(); it != mp[i].end(); it++) {
			P pos = it->first;
			int px = pos.first;
			int py = pos.second;
			if (d[i] == 1) {
				if (px < c[i]) {
					px = 2 * c[i] - px - 1;
				}
			}
			if (d[i] == 2) {
				if (py < c[i]) {
					py = 2 * c[i] - py - 1;
				}
			}
			if (mp[i + 1].find(P(px, py)) == mp[i + 1].end()) {
				mp[i + 1][P(px, py)] = 0;
			}
			//cout << "px, py = " << px << ", " << py << endl;
			mp[i + 1][P(px, py)] += it->second;
		}
		
		//mp[i+1]の相対座標に変換
		int minX = 114514;
		int minY = 114514;
		map<P, int> tmp;
		for (it = mp[i + 1].begin(); it != mp[i + 1].end(); it++) {
			P pos = it->first;
			int px = pos.first;
			int py = pos.second;
			minX = min(minX, px);
			minY = min(minY, py);
		}
		for (it = mp[i + 1].begin(); it != mp[i + 1].end(); it++) {
			P pos = it->first;
			tmp[P(pos.first - minX, pos.second - minY)] = it->second;;
		}
		mp[i + 1] = tmp;
		
		/*cout << endl;
		for (it = mp[i + 1].begin(); it != mp[i + 1].end(); it++) {
			cout << (it->first).first << ", " << (it->first).second << " -> " << it->second << endl;
		}*/
	}
	
	rep(i, p) {
		cout << mp[t][P(x[i], y[i])] << endl;
	}
}

int main() {
	while (cin >> w >> h >> t >> p) {
		if (!w) break;
		int i;
		rep(i, t) cin >> d[i] >> c[i];
		rep(i, p) cin >> x[i] >> y[i];
		solve();
	}
	return 0;
}


Measured memory_bytes: 3524
// ------------------------------------
// Date:2018/ 3/12
// Problem:ABC 071 MealDelivery a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int x, a, b;
  string ans;
  cin >> x >> a >> b;
  if (abs(x - a) > abs(x - b)) {
    ans = "B";
  } else {
    ans = "A";
  }

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



Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char s[200001];

int main(void) {
	size_t A, B;

	scanf("%zu %zu", &A, &B);

	A = (A + 11) % 13;
	B = (B + 11) % 13;

	if (B < A) {
		puts("Alice");
	}
	else if (A == B) {
		puts("Draw");
	}
	else {
		puts("Bob");
	}

	return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vi a(n);
    VIN(a);


    k = min(k, 50);
    REP(lp,k){
        vi imos(n+1);
        REP(i,n){
            int l = max(0,i-a[i]);
            int r = i+a[i];
            //DEBUG2(l,r);
            imos[l]++;
            if(r<n) imos[r+1]--;
        }
        //DEBUG_VEC(imos);
        vi b(n+1,0);
        REP(i,n){
            b[i+1] = b[i]+imos[i];
        }
        //DEBUG_VEC(b);
        copy(b.begin()+1,b.end(), a.begin());
        //a = b;
    }
    VOUT(a, " ");
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

ll n;
ll a[311111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n*3)cin>>a[i];
  sort(a,a+n*3);
  ll sum=0;
  for(ll i=n*3-2;i>=n;i-=2)sum+=a[i];
  cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l)
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    string S; cin >> S;
    int ans = 0;
    int count = 0;
    rep(i, 3) {
        if (S.at(i) == 'R')ans++;
        else {
            count = max(count, ans); ans = 0;
        }
    }
    cout << max(count, ans) << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        Map<Integer, Integer> map = new TreeMap<>();
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            map.put(A[i], i+1);
        }
        sc.close();

        for(Integer key: map.keySet()){
            System.out.print(map.get(key) + " ");
        }
        
    }
}

Measured memory_bytes: 73320
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;




int main() {
	ll l[5];
	ll k;
	rep(i, 5) {
		cin >> l[i];
	}
	cin >> k;
	for(ll i=0;i<5;i++)
		for (ll j = i + 1; j < 5; j++) 
			if (abs(l[i] - l[j]) > k) {
				cout << ":(" << endl;
				exit(0);
		}
	cout << "Yay!" << endl;
}

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

using namespace std;

int main()
{
  int n, m;
  while(cin >> n >> m, n || m){
    int s[100], t[100];
    for(int i = 0; i < n; i++) cin >> s[i];
    for(int i = 0; i < m; i++) cin >> t[i];
    int ans1 = 114514, ans2 = 114514;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	swap(s[i], t[j]);
	if(accumulate(s, s + n, 0) == accumulate(t, t + m, 0)){
	  if(ans1 + ans2 > s[i] + t[j]) ans1 = t[j], ans2 = s[i];
	}
	swap(s[i], t[j]);
      }
    }
    if(ans1 == 114514) cout << -1 << endl;
    else cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100005
//---------------------

ll x ;
ll mn[6];
bool dp[6][MAXN];
int main(){
	cin >> x;
	REP(i,6) mn[i] = 100 + i;
	ZERO(dp);
	REP(i,x+1) dp[0][i] = (i%mn[0] == 0);
	REP(i,6) dp[i][0] = true;
	REP1(i,5) REP1(j,x) {
		if(j-mn[i]>=0) dp[i][j] = dp[i-1][j] || dp[i][j-mn[i]];
		else dp[i][j] = dp[i-1][j];
	}
	if(dp[5][x]) PRT(1);
	else PRT(0);
	return 0;
}









Measured memory_bytes: 896
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double btc = 380000.0;
		int i;
		double x;
		double sum = 0.0;
		for(i = 0; i < n; i++) {
			x = sc.nextDouble();
			if(sc.next().equals("JPY")) {
				sum += x;
			} else {
				sum += x * btc;
			}
		}
		sc = null;
		System.out.println(sum);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
    s.pb('u');
  int cu=0;
  int ans=0;
  rep(i,s.size()){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      cu++;
    }
    else {
      ans=max(ans,cu);
      cu=0;
    }
  }
  COUT(ans);
}
  


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

 
int main() {

    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;

    if((v-w)*t>=abs(b-a)) {
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
    

 return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       MX                 1000006
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
ll f[MX];
int main(void)
{
   optimize
   ll n;
   cin>>n;
   if(n<2)
   {
      cout<<0<<endl;
      return 0;
   }
   ll ans=modPow(10,n);
   ans=modSub(ans,modMul(2,modPow(9,n)));
   ans=modAdd(ans,modPow(8,n));
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3648
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut used = std::collections::HashSet::new();
    let mut res = 0;
    for p in 0..(1 << N) {
        let mut s = vec![];
        let mut tail = vec![];
        for i in 0..N {
            if (p >> i) & 1 == 1 {
                s.push(S[i]);
            } else {
                tail.push(S[i]);
            }
        }
        while let Some(c) = tail.pop() {
            s.push(c);
        }
        if !used.contains(&s) {
            let mut dp = vec![vec![0; N + 1]; N + 1];
            dp[0][0] = 1i64;
            for i in 0..(N + 1) {
                for j in 0..(N + 1) {
                    let k = i + j;
                    if i > 0 && S[k - 1] == s[i - 1] {
                        dp[i][j] += dp[i - 1][j]
                    }
                    if j > 0 && S[k - 1] == s[N - j] {
                        dp[i][j] += dp[i][j - 1]
                    }
                }
            }
            res += dp[N][N];
            used.insert(s);
        }
    }
    let ans = res;

    println!("{}", ans);
}

Measured memory_bytes: 30972
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)//不用绕，使出吃奶的劲儿都到不了
        {
            printf("No\n");
            return 0;
        }
        /*#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool flag=true;
    int n,a,b,c,d=0,e=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a>>b>>c;
    	if(b+c-d-e>a)
    	{
    		cout<<"No"<<endl;
    		return 0;
		}
    	else if((b+c-d-e)%2!=a%2)
    	{
    		cout<<"No"<<endl;
    		return 0;
		}
    	d=b;
    	e=c;
	}
	cout<<"Yes"<<endl;
	return 0;
}*/
        if((x+y)%2==0&&t%2==1)//如果最优路径与时间的积偶不一，一定到不了
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)//同理
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");//因为如果No就都return 0了，所以剩下一定是Yes。
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
vector<int> h(n);
for(int i = 0; i < n; i++){
    cin >> h[i];
}
// we have the heights as a vector now.
// initially it is at standing at stone 1. h0.
vector<int> dp(n);
dp[0] = 0;
if(n==1){
    cout << 0 << endl;
    return 0;
}
dp[1] = abs(h[1] - h[0]);
if(n==2) {
    cout << dp[1];
    return 0;
}
for(int i = 2; i < n; i++){
   dp[i] = min(dp[i-1]+ abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
}


cout << dp[n-1] << endl;
    return 0;

}













Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cassert>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define fi first
#define se second

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
  Edge(int src, int dst) :
    src(src), dst(dst), weight(0) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  REP(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u]) );
  return match;
}

int main(){
	int N;
	while(cin >> N && N){
		set<int> w;
		int a,b;
		cin >> a;
		vector<int> day;
		for(int i = 0 ; i < a ; i++){
			cin >> b;
			b--;
			w.insert(b);
			day.push_back(b);
		}
		Edges edge;
		for(int i = 0 ; i < N ; i++){
			int t;
			cin >> t;
			for(int j = 0 ; j < t ; j++){
				int s;
				cin >> s;
				s--;
				if(w.count(s)) edge.push_back(Edge(i,s));
				day.push_back(s);
			}
		}
		sort(day.begin(),day.end());
		day.erase(unique(day.begin(),day.end()),day.end());
		int ub = max(N,(int)day.size());
		Graph g(2*ub);
		for(int i = 0 ; i < edge.size() ; i++){
			int a = edge[i].src;
			int b = ub + lower_bound(day.begin(),day.end(),edge[i].dst) - day.begin();
			g[a].push_back(Edge(a,b));
			g[b].push_back(Edge(b,a));
			//cout << a << " " << b << endl;
		}
		Edges tmp;
		cout << bipartiteMatching(g,ub,tmp) << endl;
		
		
	}
}

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

using namespace std;

const int N = 210;
const int LOG = 63;

int n;
long long a[N];
char s[N];
long long basis[LOG];

void add(long long u) {
    for (int i = LOG - 1; i >= 0; i--) {
        if (u >> i & 1) {
            if (!basis[i]) {
                basis[i] = u;
                return;
            }
            u ^= basis[i];
        }
    }
}

bool check(long long u) {
    for (int i = LOG - 1; i >= 0; i--) {
        if (u >> i & 1) {
            if (!basis[i]) {
                return 0;
            }
            u ^= basis[i];
        }
    }
    return u == 0;
}

void solve(int test) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cin >> (s + 1);
    for (int i = 0; i < LOG; i++) {
        basis[i] = 0;
    }

    for (int i = n; i; i--) {
        if (s[i] == '0') {
            add(a[i]);
        } else {
            if (!check(a[i])) {
                cout << 1 << '\n';
                return;
            }
        }
    }
    cout << 0 << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc;
    cin >> tc;
    for (int test = 1; test <= tc; test++) {
        solve(test);
    }
    return 0;
}

Measured memory_bytes: 3608
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月22日 星期一 23时51分36秒
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;
const ll INF=1e18;
int a[N*3];
ll sum[2][N*2];

multiset<int>st;

void solve(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++) scanf("%d",a+i);

	sum[0][1]=0;
	for(int i=1;i<=n;i++) st.insert(a[i]),sum[0][1]+=a[i];

	for(int i=n+1;i<=2*n;i++){
		int cur=a[i];
		st.insert(a[i]);
		cur-=*st.begin();
		st.erase(st.begin());
		sum[0][i-n+1]=sum[0][i-n]+cur;
	}

	st.clear();
	sum[1][1]=0;
	for(int i=3*n;i>=2*n+1;i--) st.insert(a[i]),sum[1][1]+=a[i];
	for(int i=2*n;i>=n+1;i--){
		int cur=a[i];
		st.insert(a[i]);
		cur-=*(--st.end());
		st.erase(--st.end());
		sum[1][2*n-i+2]=sum[1][2*n-i+1]+cur;
	}

	ll ans=-INF;
	for(int i=1;i<=n+1;i++) ans=max(ans,sum[0][i]-sum[1][n+2-i]);
	printf("%lld\n",ans);

}

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


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int k; cin >> k;
    rep(i, k) cout << "ACL";
    cout << endl;
}

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

#define int long long

signed main(){
  int n , ans = 0; 
  cin >> n;
  string s; map <string  , int> m;
  for(int i = 1; i <= n; i++){
          cin >> s;
          sort(s.begin() , s.end());
          m[s]++;
  }
  auto it = m.begin();
  while(it!=m.end()){
      int x = it->second;
      ans = ans + (x*(x-1))/2;it++;
  }
  cout << ans << endl;
}




Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef string::const_iterator state;
class parse_error {};

void cmpinc(state &it, char expected) {
	if (*it == expected) {
		it++;
	}
	else {
		cerr << "Expected '" << expected << "',";
		cerr << "got '" << *it << "'";

		cout << endl;
		throw parse_error();
	}
}

/*

BNF

<equation> ::= <formula> "=" <formula>
<formula>  ::= "T" | "F" |
"a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" |
"-" <formula> |
"(" <formula> "*" <formula> ")" |
"(" <formula> "+" <formula> ")" |
"(" <formula> "->" <formula> ")"

*/

int i; //?????°??¨

bool formula(state &it) {
	bool ret, L, R;

	//while (true) {
	switch (*it) {

	case 'T':
		it++;
		ret = true;
		break;
	case 'F':
		it++;
		ret = false;
		break;
	case '(':
		it++;
		L = formula(it);

		switch (*it) {
		case '*':
			it++;
			R = formula(it);
			ret = L&R;
			break;
		case '+':
			it++;
			R = formula(it);
			ret = L | R;
			break;
		default: //->
			it++; it++;
			R = formula(it);

			if (L && !R)ret = false;
			else ret = true;

			break;
		}

		cmpinc(it, ')'); //)
		break;
	case '-':
		it++;
		ret = !formula(it);
		break;
	default:
		if (*it >= 'a'&&*it <= 'k') {
			ret = (bool)(i >> (*it - 'a') & 1);
			it++;
		}
		break;
	}
	//}

	return ret;
}

int main() {
	for (string s; getline(cin, s), s != "#"; ) {

		bool a = false;

		for (i = 0; i < 2048; i++) {
			state it = s.begin();

			int L, R;
			L = formula(it);
			cmpinc(it, '=');
			R = formula(it);
			
			//cerr << L << " " << R << endl;
			
			if (L == R)
				a = true;
			else {
				a = false;
				break;
			}
		}

		if (a)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}
	return 0;
}

Measured memory_bytes: 1220
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  else{
    if (N % 2 == 0) return Pow(A * A % nmax, N / 2) % nmax;
    else return A * Pow(A * A % nmax, N / 2) % nmax;
  }
}

ll nCr(ll N, ll R){
  ll ans = 1;
  for (ll i = 1; i <= R; i++){
    ans *= N + 1 - i; ans %= nmax;
    ans *= Pow(i, nmax - 2); ans %= nmax;
  }
  return ans;
}

int main(){
  ll N, K; cin >> N >> K;

  if (K >= N - 1){
    cout << nCr(2 * N - 1, N - 1) << endl;
    return 0;
  }

  ll DP[K + 1], DP2[K + 1];
  DP[0] = 1; DP2[0] = 1;
  for (ll i = 1; i < K + 1; i++){
    DP[i] = DP[i - 1] * (N + 1 - i); DP[i] %= nmax;
    DP[i] *= Pow(i, nmax - 2); DP[i] %= nmax;

    DP2[i] = DP2[i - 1] * (N - i); DP2[i] %= nmax;
    DP2[i] *= Pow(i, nmax - 2); DP2[i] %= nmax;
  }
  
  ll ans = 1;
  for (ll i = 1; i <= K; i++){
    ll now = DP[i] * DP2[i];
    now %= nmax;
    ans += now; ans %= nmax;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define N 105
typedef long long LL;

char s[N];

int main()
{
    int t,cur,mmin,n,af,i;
    scanf("%d%s", &n, s);
    t=0;cur=0;mmin=0;
    while(cur!=n){
        if(s[cur]=='('){
            t++;
        }else t--;
        if (t<mmin)mmin=t;
        cur++;
    }
    af=t-mmin;
    for(i=0;i<(-mmin);i++){
        printf("(");
    }
    for(i=0;i<n;i++){
        printf("%c",s[i]);
    }
    for(i=0;i<af;i++){
        printf(")");
    }
    return 0;
}


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

map<int, vi> g;
int a[N];
int b[N];
map<int,int> vis;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	cin >> n;
	int x = 0;
	multiset<int> A;
	fo(i, n) cin >> a[i+1], x ^= a[i+1], A.insert(a[i+1]);
	a[0] = x;
	A.insert(x);
	fo(i, n) {
		cin >> b[i+1];
		if(A.find(b[i+1]) == A.end()){
			cout << -1 << endl;
			return 0;
		}
		A.erase(A.find(b[i+1]));
	}
	b[0] = *A.begin();
	fo(i, n+1){
		g[b[i]].pb(a[i]);
	}
	int ans = max(1,dfs(a[0])) - 1;
	if(a[0] == b[0] and ans) ans++;
	Fo(i, 1, n+1) {
		if(!vis[a[i]]){
			x = dfs(a[i]);
			if(x) ans += x+1;
		}
	}
	cout << ans << endl;
	
	return 0;
} 

int dfs(int u){
	vis[u] = 1;
	int ans = 0;
	for(int v:g[u]){
		if(v == u) continue;
		ans++;
		if (vis[v]) continue;
		ans += dfs(v);
	}
	return ans;
}

Measured memory_bytes: 26112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		while (true) {
			int a = sc1.nextInt();
			String op = sc1.next();
			int b = sc1.nextInt();

			if (op.equals("+")) {
				System.out.println(a + b);
			}
			else if (op.equals("-")) {
				System.out.println(a - b);
			}
			else if (op.equals("*")) {
				System.out.println(a * b);
			}
			else if (op.equals("/")) {
				System.out.println(a / b);
			}
			else {
				break;
			}
		}

		sc1.close();

	}

}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
using namespace std;
string s;
set<char> ss;
int main(){
//freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> s;
    for(int i = 0; i < s.length(); i++)
        ss.insert(s[i]);
    if(ss.size() != s.length()) cout << "no" << endl;
    else cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1e9;

int main() {

  long long int x, y;
  cin >> x >> y;

  int cnt = 0;
  while(x <= y){
    cnt++;
    x *= 2;
  }
  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()


class WarshallFloyd():
    def __init__(self,N):  # Nは頂点の個数
        self.N = N
        self.d = [[float('inf')]*N for i in range(N)]  # d[i][j] = iからjへの最短距離,0-indexed
    def add(self,u,v,c,directed = False):
        if directed is False:  # 無向グラフの場合
            self.d[u][v] = c
            self.d[v][u] = c
        else:  # 有向グラフの場合
            self.d[u][v] = c
    def WarshallFloyd_search(self):
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(self.d[i][j],self.d[i][k] + self.d[k][j])
        return self.d


W = WarshallFloyd(N)
edges = [0]*M
for i in range(M):
    a,b,c = MI()
    W.add(a-1,b-1,c,directed=False)
    edges[i] = (a-1,b-1,c)
for i in range(N):
    W.add(i,i,0)

W.WarshallFloyd_search()

ans = 0
for i in range(M):
    a = 0
    for j in range(N):
        for k in range(N):
            if W.d[j][k] == W.d[j][edges[i][0]] + edges[i][2] + W.d[edges[i][1]][k]:
                a = 1
    if a == 0:
        ans += 1

print(ans)


Measured memory_bytes: 74932
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main()
{
	char c;
	scanf("%c",&c);
	
	if(c=='a' ||c=='i' ||c=='u' ||c=='e' ||c=='o' )printf("vowel\n");
	else printf("consonant\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int n, A[20];
int search(int i, int m){
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = (search(i+1, m)||search(i+1, m - A[i]));
  return res;
}

int main(){
  int q, i, m, ans = 1;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&m);
    ans = search(0, m);
    if(ans == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[110];
    int count = 0;
    int acount = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%2 == 0){
            count++;
            if(a[i]%3 == 0) acount++;
            else if(a[i]%5 == 0) acount++;
        }
    }
    
    if(count == acount) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a;
vector<pair<int,int>> v;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        v.pb(mp(a,i+1));
    }
    sort(all(v));
    rep(i,n) cout << v[i].se << " ";
    cout << endl;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		vector<vi> v(4, vi(8));
		auto goal = v;
		REP(i, 4)REP(j, 7) goal[i][j] = (i+1) * 10 + j + 1;
		REP(i, 4)FOR(j, 1, 8)
		{
			cin >> v[i][j];
			if (v[i][j] % 10 == 1)
			{
				v[v[i][j] / 10 - 1][0] = v[i][j];
				v[i][j] = 0;
			}
		}
		queue<pair<vector<vi>, int>> que;
		set<vector<vi>> st;
		que.push(make_pair(v, 0));
		bool f = true;
		while (que.size())
		{
			auto tmp = que.front().first;
			int cnt = que.front().second;
			que.pop();
			if (tmp == goal)
			{
				f = false;
				cout << cnt << endl;
				break;
			}
			REP(i, 4)FOR(j, 1, 8)
			{
				if (tmp[i][j] == 0 && tmp[i][j - 1] != 0 && tmp[i][j - 1] % 10 != 7)
				{
					auto nx = tmp;
					int t = tmp[i][j - 1] + 1;
					REP(ii, 4)REP(jj, 8)
					{
						if (tmp[ii][jj] == t)
						{
							nx[ii][jj] = 0;
						}
					}
					nx[i][j] = t;
					if (st.count(nx)) continue;
					else
					{
						st.insert(nx);
						que.push(make_pair(nx, cnt + 1));
					}
				}
			}
		}
		if (f) puts("-1");
	}
	return 0;
}

Measured memory_bytes: 26364
N = int(input())
Li = list(map(int,input().split()))
cnt=0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if Li[i]!=Li[j] and Li[j]!=Li[k] and Li[k]!=Li[i]:
        if abs(Li[i]-Li[j])<Li[k] and Li[k]<Li[i]+Li[j]:
          cnt+=1
print(int(cnt/6))

Measured memory_bytes: 9212
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long LL;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

#define ordered_set tree<LL, null_type, less<LL>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e5;

LL n, a[MaxN], kq, x;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    LL k = 1;
    for(int i = 0 ; i < n ; ++i){
        cin >> x;
        if(x == k){
            k++;
            continue;
        }
        kq++;
    }
    if(k > 1) cout << kq << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;int x,y,z,e,b;main(){while(true){cin>>e;if(!e)break;int ans=e;for(z=0;z*z*z<=e;z++){for(y=0;y*y+z*z*z<=e;y++){b=e-(y*y+z*z*z);ans=min(ans,b+y+z);}}cout<<ans<<endl;}}

Measured memory_bytes: 1160