akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int n;
  cin >> n;


  int sum[10][10];
  for(int i = 0; i < 10; i++){
    fill(sum[i], sum[i] + 10, 0);
  }

  string s;
  for(int i = 1; i <= n; i++){
    s = to_string(i);
    int j = 0;
    while(j < s.length() && s[j] == '0') ++j;
    int x = s[s.length()- 1] - '0';
    int y = s[j] - '0';
    sum[x][y]++;
  }

  int count = 0;
  for(int i = 1; i <= n; i++){
    s = to_string(i);
    int j = 0;
    while(j < s.length() && s[j] == '0') ++j;
    int x = s[s.length()- 1] - '0';
    int y = s[j] - '0';
    count += sum[y][x];
  }

  cout << count << endl;

  return 0;
}


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

int main(){
int n;
cin >> n;
int i;
long ans=1;

for(i=1;i<n+1;i++){
ans *= i;
while(ans>1000000007) ans -= 1000000007;
}
cout << ans<<endl;

}


Measured memory_bytes: 256
n = int(input())
dp=[100000]*100003
dp[0] = 0
for i in range(1,n+1):
    p = 1
    while p <= i:
        dp[i] = min(dp[i], dp[i - p] + 1)
        p *= 6
    q = 1
    while q <= i:
        dp[i] = min(dp[i], dp[i - q] + 1)
        q *= 9
print(dp[n])

Measured memory_bytes: 3828
N=int(input())
a=list(map(int,input().split()))
b=[0 for _ in range(100002)]
for i in range(N):
    b[a[i]-1],b[a[i]],b[a[i]+1]=b[a[i]-1]+1,b[a[i]]+1,b[a[i]+1]+1
b.sort(reverse=True)
print(b[0])

Measured memory_bytes: 13964
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
template<class T> il T Max(T a,T b){return a>b?a:b;}
template<class T> il T Min(T a,T b){return a<b?a:b;}
int n,s,sq,k,ans,a[505],b[505];
il vd check(int x){
    long long sum=0,cnt=0;
    rep(j,1,n) sum+=(b[j]=((a[j]-1)/x+1)*x-a[j]);
    sort(b+1,b+n+1);
    int t=sum/(long long)x;
    rep(i,n-t+1,n){
        cnt+=x-b[i];
        if(cnt>k) return;
    }
    ans=Max(ans,x);
}
int main(){
    n=rd(),k=rd();
    rep(i,1,n) a[i]=rd(),s+=a[i];
    sq=sqrt(s);
    if(sq*sq>s) --sq;
    rep(i,1,sq) if(!(s%i)){
        check(i),check(s/i);
    }
    printf("%d",ans);
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

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

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define N 200005
int n, a[N], sum[N], xr[N];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        sum[i] = sum[i - 1] + a[i];
        xr[i] = xr[i - 1] ^ a[i];
    }
    long long ans = 0;
    for (int i = 1, j = 1; i <= n; ++i) {
        while (j < n && sum[j + 1] - sum[i - 1] == (xr[j + 1] ^ xr[i - 1])) j++;
        //printf("%d %d\n", i, j);
        ans += j - i + 1;
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i=0; i<N; i++) cin >> a[i];

  // v(i,j) = value at the left position is i and right position is j
  // initially, i=0 and j=N-1
  vector< vector<long long> > v(N);
  for (int i=0; i<N; i++) v[i].resize(N);

  /*
  For first mover,
  v(i,j) = max { v(i+1, j) + a(i), v(i, j-1) + a(j) }  if i < j
         = a(i)                                        if i = j
  For second mover,
  v(i,j) = min { v(i+1, j) - a(i), v(i, j-1) - a(j) }  if i < j
         = a(i)                                        if i = j
  */
  for (int i=N-1; i >= 0; i--) {
    for (int j=i; j < N; j++) {
      // when i + j = N-1 mod 2, first player's turn.
      bool first = ((i + j) % 2) == ((N - 1) % 2);
      if (i == j) {
        v[i][j] = first ? a[i] : -a[i];
      } else {
        if (first) {
          v[i][j] = max(v[i+1][j] + a[i], v[i][j-1] + a[j]);
        } else {
          v[i][j] = min(v[i+1][j] - a[i], v[i][j-1] - a[j]);
        }
      }
    }
  }

  /*
  for (int i=0; i < N; i++) {
    for (int j=0; j < N; j++) {
      cout << v[i][j] << " ";
    }
    cout << "\n";
  }
  */
  
  cout << v[0][N-1] << "\n";
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;

bool bingo[3][3];
int main(void)
{
    ll x,n; cin>>x>>n;
    ll p[110];
    rep(i,n) cin>>p[i];
    sort(p,p+n);
    ll ans=-1,tmp=1e9;
    map<ll,ll> mp;
    rep(i,n) mp[ p[i] ]++;
    for(int i=0;i<=101;i++){
        if(mp[i]>0) continue;
        if(abs(x-i)<tmp){
            ans=i;
            tmp=abs(x-i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  //
  ll mod = 1000000007;
  int n ; cin >> n;
  int m ; cin >> m;
  // vi a(m);
  unordered_set<int> broken;
  rep(i, m) {
    int a; cin>>a;
    broken.insert(a);
  };
  vl cnt(n+1, 0);
  cnt[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (broken.find(i) != broken.end()) {
      cnt[i] = -1;
    } else {
      if (cnt[i-1] > 0) cnt[i] = (cnt[i]+cnt[i-1])%mod;
      if (i >= 2 && cnt[i-2] > 0) cnt[i] = (cnt[i]+cnt[i-2])%mod;
    }
  }
  cout << cnt[n] << endl;
  return 0;
}


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

int main(){
	
	int r, g, b, n, i, j, k, ans = 0;
	
	scanf("%d %d %d %d", &r, &g, &b, &n);
	
	for(i = 0; i * r <= n; i++){
		for(j = 0; i * r + j * g <= n; j++){
			if((n - (i * r + j * g)) % b == 0)
				ans++;
		}
	
	}
	
	printf("%d", ans);
	
}

Measured memory_bytes: 128
import heapq
import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, namedtuple, UserDict
from functools import cmp_to_key, lru_cache, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**6+1)
write = sys.stdout.write
# input = sys.stdin.buffer.readline

MOD = 10**9 + 7


if __name__ == "__main__":
    n = int(input())
    arr = [int(ch) for ch in input().split()]
    ans = [0] * (n+1)
    for i in arr:
        ans[i] += 1
    print(*ans[1:], sep='\n')

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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i < M; i++) cin >> y[i];
	x.push_back(X);
	y.push_back(Y);
	sort(x.begin(), x.end(), greater<int>());
	sort(y.begin(), y.end());

	if (x[0] < y[0]) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}

const char unit[] = {'i', 'x', 'c', 'm'};

int decode(string s)
{
    int sum = 0;

    for(int i=0, d=1; i<4; i++, d*=10) {
        auto p = s.find(unit[i]);
        if (p == 0) {
            sum += d;
        } else if (p != string::npos) {
            char c = s[p-1];
            if (isdigit(c)) {
                sum += (c - '0') * d;
            } else {
                sum += d;
            }
        }
    }

    return sum;
}

string encode(int n)
{
    stringstream ss;

    for(int i=1000, idx=3; i >= 1; i/=10, idx--) {
        int d = n/i;
        if (d != 0) {
            if (d > 1) {
                ss << d;
            }

            ss << unit[idx];
        }
        n%=i;
    }

    return ss.str();
}

void solve()
{
    int n;
    cin >> n;

    rep(i, n) {
        string s1, s2;
        cin >> s1 >> s2;

        cout << encode(decode(s1) + decode(s2)) << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N, X;
	cin >> N >> X;

	vector<int> L( N );
	for( auto& v: L ) { cin >> v; }

	int result = 0;
	int D = 0;
	for( int i = 0; i < N; ++i ) {
		if( D > X ) { break; }

		result += 1;
		D += L[i];
	}

	cout << result + (D <= X) << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//これはひどい提出だ

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[100001];
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	const int cm = 1 << 21;
	char cn[cm], * ci = cn;
	fread(cn, 1, cm, stdin);

	int N = 0;
	while (*ci >= '0') N = N * 10 + *ci++ - '0';
	ci++;

	ll are[26];
	are[0] = 1;
	rep(i, 25) are[i + 1] = are[i] * 11;

	ll s[100000];
	rep(i, N) {
		ll k = 0;
		rep(j, 10) k += are[*ci++ - 'a'];
		ci++;
		s[i] = k;
	}

	pakuri_sort(N, s);

	ll kotae = 0;
	ll mae = -1;
	ll kazu = 0;
	rep(i, N) {
		if (mae != s[i]) {
			kotae += kazu * (kazu - 1) / 2;
			mae = s[i];
			kazu = 1;
		}
		else kazu++;
	}

	kotae += kazu * (kazu - 1) / 2;

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long A, B, C;



bool check(int num){
	int D, E, F, G, H, I;
	D = num; 
	int sum = A + B + D;
	H = sum - B - C;
	G = sum - C - D;
	I = sum - G - H;
	F = sum - D - I;
	E = sum - C - F;

	if(A + B + D == E + C + F &&
		A + B + D == G + H + I &&
		A + B + D == A + E + G &&
		A + B + D == B + C + H &&
		A + B + D == D + F + I &&
		A + B + D == A + C + I && 
		A + B + D == G + C + D){

		cout << A << " " << B << " " << D << endl;
		cout << E << " " << C << " " << F << endl;
		cout << G << " " << H << " " << I << endl;


		return true;
	}
	return false;
}



int main(){
	cin >> A >> B >> C;

	for(int i = 0; i < 100000; i++){
		if(check(i)){
			return 0;
		}
	}
	return 1;
}


Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

a,b = rl()

a -= 1
b -= 1

print("{} {}".format(100,100))
for i in range(100):
    s = ''
    for j in range(100):
        if j < 50:
            if j%2==0 and i%2==0 and j<49 and a>0:
                s += '.'
                a -= 1
            else:
                s += '#'
        else:
            if j%2==0 and i%2==0 and j>51 and b>0:
                s += '#'
                b -= 1
            else:
                s += '.'
    print(s)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, a;
	cin >> n >> a;
	int r = n % 500;
	if (r <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

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

    int h, w, k;
    cin >> h >> w >> k;
    int si, sj;
    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
            if (a[i][j] == 'S') {
                si = i;
                sj = j;
            }
        }
    }

    vector<vector<int>> cost(h, vector<int>(w, 1000)); // 最短距離
    cost[si][sj] = 0;
    queue<pair<int, int>> que;
    que.push({si, sj});
    vector<int> di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1};
    int ans = 1000;
    while (que.size() > 0) {
        auto pos = que.front();
        que.pop();
        int i = pos.first, j = pos.second;
        for (int l = 0; l < 4; l++) {
            int ni = i + di[l], nj = j + dj[l];
            if (0 <= ni and ni < h and 0 <= nj and nj < w) {
                if (a[ni][nj] == '.' and cost[i][j] + 1 < cost[ni][nj]) {
                    cost[ni][nj] = cost[i][j] + 1;
                    que.push({ni, nj});
                } else if (a[ni][nj] == '#') {
                    int dist = max(k, cost[i][j]) + min({i, h - i - 1, j, w - j - 1});
                    ans = min(ans, (dist + k - 1) / k);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _1 in range(n)]
for bingo in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == bingo:
                a[i][j] = 0
triple_pair =[a[0][t1]+a[1][t1]+a[2][t1] for t1 in range(3)] + [a[t2][0]+a[t2][1]+a[t2][2] for t2 in range(3)] + [a[0][0]+a[1][1]+a[2][2]] + [a[0][2]+a[1][1]+a[2][0]]
if 0 in triple_pair:
    print("Yes")
else:
    print("No")


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  unsigned a, b;
  while (cin >> a >> b) {
    unsigned gcd = euclidean_gcd(a, b);
    unsigned lcm = a / gcd * b;
    cout << gcd << " " << lcm << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << "-1\n";
	} else {
		cout << a * b << "\n";
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s,ans="";
	cin >> n >> s;
	vector<char>c;
	rep(i, s.length()) {
		c.push_back((char)(((s[i] + n - 65) % 26)+65));
	}
	rep(i, s.length()) {
		ans += c[i];
	}
	cout << ans << endl;
}





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

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

	long long sum = 0;
	int mini = 1e9, minus_count = 0;

	for(int i=0; i<N; ++i){
		int a; cin>>a;
		if(a<0){ a = -a; ++minus_count; }
		if(a<mini) mini = a;
		sum += a;
	}

	cout<< (minus_count%2? sum - mini*2: sum) <<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
  int n,b,f,r,v;
  int a[4][3][10] = {0};
  cin >> n;
  for (int i=0;i<n;i++){
      cin >> b >> f >> r >> v;
      a[b-1][f-1][r-1] += v;
  }
  for (int i=0;i<4;i++) {
    for (int j=0;j<3;j++) {
        for (int k=0;k<10;k++) {
          cout << " " << a[i][j][k];
        }
        cout << endl;
    }
    if (i==3) break;
    cout << "####################" << endl;
  }
}


Measured memory_bytes: 3120
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

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

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, K;
int a[100];
int m[100001][2];

void init()
{
}

int rec(int v, int t)
{
    //cout << "!" << v << " " << t << endl;
    if(v < 0){
        return (t == 0 ? 1 : 0);
        //int ret = -1;
        //ret = (t == 0 ? 1 : 0);
        //cout << v << " " << ret << endl;
        //return ret;
    }
    if(m[v][t] != -1) return m[v][t];
    //cout << "!!" << v << " " << t << endl;
    int ret = -1;
    if(v == 0){
        return m[v][t] = (t == 0 ? 0 : 1);
        //ret = (t == 0 ? 0 : 1);
        //cout << v << " " << ret << endl;
        //return m[v][t] = ret;
    }
    //if(v <= a[N-1]){
    //    REP(i, N){
    //        if(v == a[i]){
    //            ret = (t == 0 ? 1 : 0);
    //            break;
    //        }
    //    }
    //    if(ret == -1) ret = (t == 0 ? 0 : 1);
    //}else{
        if(t == 0){
            REP(i, N){
                if(rec(v-a[i], (t+1)%2) == 1){
                    ret = 1;
                    break;
                }
            }
            if(ret == -1) ret = 0;
        }else{
            REP(i, N){
                if(rec(v-a[i], (t+1)%2) == 0){
                    ret = 0;
                    break;
                }
            }
            if(ret == -1) ret = 1;
        }
    //}
    //cout << v << " " << ret << endl;
    return m[v][t] = ret;
}

void solve()
{
    REP(i, K+1) REP(j, 2) m[i][j] = -1;
    cout << (rec(K, 0) == 1 ? "First" : "Second") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5760
// go:generate go-assets-builder > assets.go

package main

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

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	t := readInt()
	x := readInt()
	fmt.Println(float32(t) / float32(x))
}

//便利関数群
var sc = bufio.NewScanner(os.Stdin)

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

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	if x-y > 0 {
		return x - y
	}
	return -(x - y)
}

type XY struct {
	x, y int
}

type Points []XY

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p Points) remove(i int) Points {
	if i >= len(p) {
		return p
	}
	return append(p[:i], p[i+1:]...)
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; ++i){
        if(~i & 1){
            if(a & 1)
                --a;
            b += (a /= 2);
        }else{
            if(b & 1)
                --b;
            a += (b /= 2);
        }
    }
    cout << a << " " << b << endl;
}


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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a,b,c;
    cin>>a>>b;
    long long sum=0;
    for(long long i=0;i<b;i++){
        cin>>c;
       sum+=c;
    }
    if(sum<=a)cout<<a-sum;
    else cout<<-1;
}

Measured memory_bytes: 3664
d,g = map(int,input().split())
l = [list(map(int,input().split())) for i in range(d)]
# t番目の問題でスコアsをとるための最小値
def f(t,s):
    if t==-1:
        return float('inf')
    num = min(l[t][0],s//((t+1)*100))
    k = num*(t+1)*100
    if num==l[t][0]:
        k += l[t][1]
    if k<s:
        num += f(t-1,s-k)
    return min(num,f(t-1,s))

print(f(d-1,g))

Measured memory_bytes: 3064
N,K=map(int,input().split())
H=[int(x) for x in input().split()]
INF=10**10

dp=[INF for x in range(N)]
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
        else:
            break

print(dp[N-1])

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

using namespace std;

const string s = "CODEFESTIVAL2016";

int main() {
  string t;
  cin >> t;
  int answer = 0;
  for(int i=0;i<(int)t.size();++i) answer += ( s[i] != t[i] );
  cout << answer << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n, d;
	cin>>n;
	d = n % 10;
	if (d == 3) cout<<"bon";
	else if (d == 0 || d == 1 || d == 6 || d == 8) cout<<"pon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
a_li = list(map(int, input().split()))

loop_li = []
loop_set = set([])
a = 1 

while a not in loop_set:
    loop_li.append(a)
    loop_set.add(a)
    a = a_li[a-1]

length = len(loop_li)
if k<length:
    print(loop_li[k])
else:
    bp = a_li[loop_li[-1]-1] # back point
    bp_idx = loop_li.index(bp)
    t = length - bp_idx
    amari = (k-bp_idx)%t
    print(loop_li[bp_idx+amari])

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

static const int64_t R = 1000000007;

int64_t f[200010] = { 1 };
int64_t inv_f[200010];

int64_t pow_mod(int64_t m, int64_t e)
{
	int64_t v = 1ll;
	for (; e > 0; e >>= 1) {
		if (e & 1)
			v = v * m % R;
		m = m * m % R;
	}
	return v;
}

void init()
{
	for (int i = 1; i < 200010; ++i) {
		f[i] = f[i - 1] * i % R;
	}
	for (int i = 0; i < 200010; ++i) {
		inv_f[i] = pow_mod(f[i], R - 2);
	}
}

int64_t comb(int64_t n, int64_t r)
{
	return f[n] * inv_f[r] % R * inv_f[n - r] % R;
}

int main()
{
	init();
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int64_t ans = 0;
	int const h = H - A, w = W - B;
	for (int i = 1; i <= w; ++i) {
		int x1 = B + i - 1;
		int x2 = w - i;
		auto v = comb(h - 1 + x1, x1) * comb(A - 1 + x2, x2) % R;
		ans = (ans + v) % R;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a=0;
    string s;
    cin>>s;
    n=s.size();
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n-(i+1)])a=a+1;
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [0]*N
for i in range(N):
    p[i]=input()

print("AC x " + str(p.count("AC")))
print("WA x " + str(p.count("WA")))
print("TLE x " + str(p.count("TLE")))
print("RE x " + str(p.count("RE")))


Measured memory_bytes: 78184
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

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

  int ans = a;
  if (b < a) ans--;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s;
	cin >> s;
	cout << s.substr(0, 3) << en;



	return 0;
}



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

int main() {
  int N;
  int data[101] = {0};
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> data[i];
  }
  
  int count = 0;
  
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0 && data[i] % 2 == 1) {
      count++;
    }
  }
  
  cout << count << endl;
}
  

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#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 all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n;
	cin >> n;
	vi t(n), v(n);
	vi t2(n + 1);
	rep(i, n) {
		cin >> t[i];
		t2[i + 1] = t2[i] + t[i];
	}
	rep(i, n) {
		cin >> v[i];
	}
	vector<double> s(2 * t2[n] + 1);
	s[0] = 0;
	double now = 1;
	int idx = 0;
	/*
	DEBUG_VEC(t);
	DEBUG_VEC(v);
	DEBUG_VEC(t2);
	//*/
	while (now < 2 * t2[n]) {
		s[now] = min(s[now - 1] + 0.5, (double)v[idx]);
		if (idx < t2.size() - 1 && now / 2 == t2[idx + 1]) {
			idx++;
		}
		now++;
	}
	/*
	rep(i, s.size()) {
		cout << i / 2.0 << " : " << s[i] << endl;
	}
	cout << endl;
	//*/
	s[2 * t2[n]] = 0;
	now = 2 * t2[n] - 1;
	idx = v.size() - 1;
	while (now > 0) {
		s[now] = min(s[now + 1] + 0.5, min(s[now], (double)v[idx]));
		if (idx > 0 && now / 2 == t2[idx]) {
			idx--;
		}
		now--;
	}

	/*
	rep(i, s.size()) {
		cout << i / 2.0 << " : " << s[i] << endl;
	}
	cout << endl;
	//*/
	double ans = 0;
	rep(i, s.size() - 1) {
		ans += 0.5*(s[i] + s[i + 1]) / 2.0;
	}
	Sp(ans);
}

Measured memory_bytes: 512
#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 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) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
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(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int 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;
pair<string, int>A[101];
signed main() {
  long long r,D,x; cin>>r>>D>>x;
  rep(i,10){
    cout<<x*r-D<<endl;
    x=x*r-D;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
    FixPoint(F&& f):F(forward<F>(f)){}
    template<typename... Args>
    decltype(auto) operator()(Args&&... args) const{
        return F::operator()(*this,forward<Args>(args)...);
    }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
    return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin>>n;
    vector<int> cs(n);
    for(int i=0;i<n;i++) cin>>cs[i],cs[i]--;

    vector<vector<int>> G(n);
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    using ll = long long;
    ll all=0;
    vector<ll> cnt(n,0),sub(n,0);

    vector<ll> ans(n,(ll)n*(n-1)/2);
    MFP([&](auto dfs,int v,int p)->int{
        sub[v]=1;//nodes
        ll bfr=cnt[cs[v]];
        int soncnt = 0;
        for(int u:G[v]){
            if(u==p) continue;
            soncnt++;
            ll precv = cnt[cs[v]];
            //if (1==soncnt && pre)
            sub[v]+=dfs(u,v);
            ll nxt=sub[u]-(cnt[cs[v]]-precv);
            ans[cs[v]]-=(nxt)*(nxt-1)/2;//subtree of u which not go throw color cs[v]
        }
        cnt[cs[v]]=bfr+sub[v];
        all++;
        return sub[v];
    })(0,-1);

    for(int c=0;c<n;c++){
        ll pre=0,nxt=n-cnt[c];
        ans[c]-=(nxt-pre)*(nxt-pre-1)/2;
    }
    for(int c:cs) ans[c]++;

    for(ll a:ans) cout<<a<<newl;
    return 0;
}


Measured memory_bytes: 47760
#include <stdio.h>
int main()
{
    int x, y;
    scanf("%d %d", &x, &y);
    while ((x != 0) || (y != 0)) {
        if (x < y) {
            printf("%d %d\n", x, y);
        } else {
            printf("%d %d\n", y, x);
        }
        scanf("%d %d", &x, &y);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int N, X, Y, Z;

const ll MOD = 1000000007;

ll dp[41][1 << 17];

ll modpow(ll a, ll b) {
	ll base = 1, kakeru = a;
	while (b > 0) {
		if (b & 1) {
			base *= kakeru, base %= MOD;
		}
		kakeru *= kakeru, kakeru %= MOD;
		b >>= 1;
	}
	return base;
}

int main() {
	cin >> N >> X >> Y >> Z;

	ll ans = modpow(10, N);

	int forbidden = (1 << (Z - 1)) + (1 << (Z + Y - 1)) + (1 << (Z + Y + X - 1));
	int mask = (1 << (X + Y + Z)) - 1;

	dp[0][0] = 1;
	
	for (int i = 0; i < N; i++) {
		for (int bit = 0; bit < (1 << (X + Y + Z)); bit++) {
			if ((bit & forbidden) == forbidden) continue;

			//cout << i << " " << bit <<

			for (int cur = 1; cur <= 10; cur++) {

				int nxt = (bit << cur) + (1 << (cur - 1));

				nxt &= mask;

				if ((nxt & forbidden) == forbidden)continue;
				
				dp[i + 1][nxt] += dp[i][bit];
				dp[i + 1][nxt] %= MOD;
			}
		}
	}

	for (int bit = 0; bit < (1 << (X + Y + Z)); bit++) {
		ans = ans + MOD - dp[N][bit];
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

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

namespace abc163a
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            int input = int.Parse(Console.ReadLine());

            //==========================================================================================================================
            //2) output
            double output = 2*input* Math.PI;
            Console.WriteLine(output);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ll MOD(ll x, ll m) {
    ll r = x % m;
    if (r < 0) {
        r += m;
    }
    return r;
}

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll x = 0;
    FOR(i, 2, n) {
        x ^= a[i];
    }
    ll s = a[0] + a[1];
    if ((s - x) < 0 || (s - x) % 2 == 1) {
        cout << "-1\n";
        return;
    }
    ll d = (s - x) / 2;
    if (d < 0 || (d & x) != 0) {
        cout << "-1\n";
        return;
    }

    bitset<64> res;
    bitset<64> b1(a[0]);
    bitset<64> b2(a[1]);
    bitset<64> d1(d);
    bitset<64> x1(x);
    REP(i, 64) {
        if (d1[i] == 1) {
            assert(x1[i] == 0);
            res[i] = 1;
        }
    }
    REPREV(i, 63) {
        if (d1[i] == 0 && x1[i] == 0) {
            res[i] = 0;
        } else if (d1[i] == 0 && x1[i] == 1) {
            res[i] = 1;
            if (res.to_ullong() > a[0]) {
                res[i] = 0;
            }
        }
    }

    ll res2 = res.to_ullong();
    if (res2 > a[0] || res2 == 0) {
        cout << "-1\n";
        return;
    }

    cout << a[0] - res2 << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
 
int n;

double p[3100],memo[3100][3100];

double rek(int i, int x) {
	//printf("%d %d\n",i,x);
	if(x == 0) return 1.0;
	if(i == n) return 0.0;
	if(memo[i][x] != -1.0) return memo[i][x];
	
	return memo[i][x] = p[i] * rek(i + 1, x - 1) + (1.0 - p[i]) * rek(i + 1, x);
}

int main() {
	
	scanf("%d", &n);
	
	for(int i = 0; i < 3050; i++) for(int j = 0; j < 3050; j++) memo[i][j] = -1.0;
	
	for(int i = 0; i < n; i++) {
		scanf("%lf",&p[i]);
	}
	//printf("kurac");
	printf("%.9lf",rek(0,(n + 1)/2));
	
	return 0;
}

Measured memory_bytes: 74368
# 初期入力
S = input()

# Sを前半ー中心ー後半に分ける
S_mae = ""
S_mae_gyaku = ""
S_usiro =""
S_usiro_gyaku =""
S_tyusin_num =0
if len(S) % 2 ==1:
    S_tyusin_num =(len(S) )//2
    S_mae =S[:S_tyusin_num]
    S_mae_gyaku = S_mae[::-1]
    S_usiro = S[(-1)*S_tyusin_num:]
    S_usiro_gyaku = S_usiro[::-1]
    if S_mae == S_mae_gyaku and S_usiro == S_usiro_gyaku and S_mae == S_usiro: 
        print("Yes") # 前半だけで回文→S_mae == S_mae_gyaku
    else:
        print("No")

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

int main(){
  string S, T;
  cin >> S >> T;
  
  bool judge = true;
  
  if( S.size() + 1 != T.size() ) judge = false;
  
  int N = S.size();
  
  for(int i=0; i<N; i++){
    if(S.at(i)!=T.at(i)) judge = false;
  }
  
  if(judge) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
H, W = map(int, input().split())
field = []
for i in range(0, H):
	S = input()
	lst = []
	for j in range(0, W):
		lst.append(S[j])
	if '#' in lst:
		field.append(lst)
for i in range(0, W):
	flag = True
	for j in range(0, len(field)):
		if field[j][i] == '#':
			flag = False
			break
	if flag:
		for j in range(0, len(field)):
			field[j][i] = ''
for i in range(0, len(field)):
	ans = ''
	for j in range(0, W):
		ans = ans + field[i][j]
	print(ans)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int dp[100010];
int lim;

int f(int pos, int h[])
{
	if (pos == 0) return 0;
	int &ret = dp[pos];
	if (ret != -1) return ret;
	ret = 1000000001;
	for (int k = 1; k <= lim; ++k)
	{
		if (pos-k >= 0) ret = min(ret, abs(h[pos]-h[pos-k]) + f(pos-k, h));
	}
	return ret;
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	int n; cin >> n >> lim;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	memset(dp, -1, sizeof dp);
	cout << f(n-1, h);
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
     
using namespace std;
#define ll long long 
#define ld long double
 
int main()
{   string s;
    string t;
    cin>>s;
    cin>>t;
    ll m=s.size();
    ll n=t.size();
    ll k=m;
    ll l=n;
    vector <char> crr={};
    string s1="";
    ll arr[m+1][n+1]={};
    for (int i=0;i<n+1;i++){
        arr[0][i]=0;
    }
    for (int i=0;i<m+1;i++){
        arr[i][0]=0;
    }
    for (int i=1;i<m+1;i++){
        for (int j=1;j<n+1;j++){
            if (s[i-1]==t[j-1]){
                arr[i][j]=1+arr[i-1][j-1];
            }
            else{
                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
            }
        }
    }
    while (k>0 && l>0){
        if (s[k-1]==t[l-1]){
            crr.push_back(s[k-1]);
            k--;
            l--;
        }
        else{
            if (arr[k-1][l]>arr[k][l-1]){
                k--;
            }
            else{
                l--;
            }
        }
    }
    for (int i=crr.size()-1;i>=0;i--){
        s1=s1+crr[i];
    }
    cout<<s1<<endl;
    
    
    return 0;
}
 

Measured memory_bytes: 73988
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
inline void read(int &jqk)
{
        jqk = 0;char c = 0;int p = 1;while (c < '0' || c > '9')
        {if (c == '-'){p = -1;}c = getchar();}
        while (c >= '0' && c <= '9'){jqk = (jqk << 3) + (jqk << 1) + c - '0';c = getchar();}jqk *= p;
}
ll mod=1e9+7;
stack<int> sta;
ll n,a,b;
int main()
{
        cin >> n >> a >> b;
        //cout<<a*b<<endl;
        if(a+b-1>n)
        {
                cout<<-1<<endl;
                return 0;
        }
        if(a*b<n)
        {
                cout<<-1<<endl;
                return 0;
        }
        int k=1;
        for(int i=1;i<=a;i++)
        {
                for(int j=1;j<=b&&a-i+k<=n;j++)
                {
                sta.push(k++);
                }
                while(!sta.empty())
                {
                        cout<<sta.top()<<" ";
                        sta.pop();
                }
        }
}


Measured memory_bytes: 2788
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N; cin >> N; pair<ll, ll>P[N];
  rep(i, N){
    ll a, b; cin >> a >> b; 
    ll x = a-b; ll y = a+b; P[i] = {y, x};
  }
  sort(P, P+N);
  ll t=P[0].second, cnt=0;
  rep(i, N){
    if(P[i].second<t) continue;
    cnt++; t=P[i].first;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c,d[3];
cin>>a>>b>>c;
d[0]=a;
d[1]=b;
d[2]=c;
sort(d,d+3);
cout<<d[0]+d[1]<<endl;

return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
//#define mp make_pair
#define pb push_back
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pdi pair<double, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 2e5 + 5;
char s[N];
int suf[N][2], n;
int main() {
    scanf("%d", &n);
    scanf("%s", s+1);
    for (int i = n; i >= 1; --i) {
        suf[i][1] = suf[i+1][1] + (s[i] == '#');
        suf[i][0] = suf[i+1][0] + (s[i] == '.');
    }
    int ans = n;
    ans = min(ans, suf[1][0]);
    ans = min(ans, suf[1][1]);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        ans = min(ans, cnt+suf[i][0]);
        cnt += s[i] == '#';
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2048