akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1e6 + 12; //check the limits, dummy

ll bit[62];

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

    ll n;
    cin >> n;
    vl a (n);
    FOR (i, 0, n) cin >> a[i];

    FOR (i, 0, n) {
        FOR (j, 0, 61) {
            if (a[i] & (1LL << j) ) bit[j]++;
        }
    }

    ll ans = 0;
    FOR (i, 0, 61) {
        ll cnt = bit[i] * (n - bit[i]) % MOD;
        ll val = (1LL << i);
        val %= MOD;
        ans = (ans + cnt * val % MOD) % MOD;
    }

    cout << ans << '\n';


    return  0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int calc(int number_of_district, char *index);
int count_district(char *str, char **next);
int comp(const void *a, const void *b);
char line[10010];

int main(void){
	int n,i;
	int number_of_children;
	char *end;
	scanf("%d%*c",&n);
	for(;n>0;n--){
		fgets(line, 10010, stdin);
		number_of_children=count_district(line, &end);
		//printf("number_of_children:%d\n",number_of_children);
		printf("%d\n",calc(number_of_children,line));
	}
	return 0;
}

int comp(const void *a, const void *b){
	return *(int *)a-*(int *)b;
}

int calc(int number_of_district, char *index){
	int minimum[number_of_district];
	int i,number_of_children;
	int sum=0;
	char *end;

	for(i=0;i<number_of_district;i++){
		number_of_children=count_district(index+1, &end);
		if(number_of_children==0){
			sscanf(index+2,"%d",&minimum[i]);
			minimum[i]=minimum[i]/2+1;
			index=end;
		}else{
			minimum[i]=calc(number_of_children,index+1);
			index=end;
		}
	}
	qsort(minimum, number_of_district, sizeof(int), comp);
	for(i=0;i<number_of_district/2+1;i++){
		sum+=minimum[i];
	}
	return sum;
}

int count_district(char *str, char **end){
	int count=0;
	int level=0;
	while(1){
		if(*str=='['){
			if(level==1) count++;
			level++;
		}
		if(*str==']'){
			level--;
			if(level==0){
				*end=str;
				return count;
			}
		}
		str++;
	}
}

Measured memory_bytes: 680
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001;

using namespace std;



int main(void) {
	int n;
	int dp[1001];
	long long int total = 1;
	int p;
	
	FOR(i, 0, 1000) {
		dp[i] = 1;
	}

	cin >> n;
	FOR(i, 2, n) {
		p = i;
		FOR(t, 2, 1000) {
			while (p % t == 0) {
				dp[t]++;
				p = p / t;
				if (p == 1) {
					break;
				}
			}
			if (p == 1) {
				break;
			}
		}
	}
	FOR(i, 1, n) {
		total *= dp[i];
		if (total > MOD) {
			total %= MOD;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;

int n;
void dfs(string s, char mx) {
	if (s.size() == n) {
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= mx+1; c++) {
		string t = s;
		t += c;
		dfs(t, max(mx,c));
	}
}

int main(){
	cin >> n;
	dfs("", 'a'-1);
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 3
#define true 1
#define false 0

int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int limit;
int t[N][N];

void swap(int *x,int *y){
  int tmp=*x;
  *x=*y;
  *y=tmp;
  return ;
}

int getHeuristic(){
  int i,j,sum=0,x;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
    if(t[i][j]==0)continue;
    x=t[i][j]-1;
    sum+=abs(x/N-i)+abs(x%N-j);
    }
  }
  return sum;
}

int dfs(int depth,int prev,int py,int px){
  int h=getHeuristic();
  if(h==0)return true;
  if(depth+h>limit)return false;
  int i;
  for(i=0;i<4;i++){
    if(abs(i-prev)==2)continue;
    int tx=px+dx[i],ty=py+dy[i];
    if(tx<0||ty<0||tx>=N||ty>=N)continue;
    swap(&t[ty][tx],&t[py][px]);
    if(dfs(depth+1,i,ty,tx))return true;
    swap(&t[ty][tx],&t[py][px]);
  }
  return false;
}

void isSolved(int py,int px){
  for(limit=0;;limit++){
    if(dfs(0,99,py,px)){
      printf("%d\n",limit);
      return ;
    }
  }
}

int main(){
  int i,j,px,py;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&t[i][j]);
      if(t[i][j]==0){
        py=i;
        px=j;
      }
    }
  }
  isSolved(py,px);
  return 0;
}



Measured memory_bytes: 2760
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>

using namespace std;

const int INF = (1<<30) - 1;
const int dh[] = {0, 0, 1, -1};
const int dw[] = {1, -1, 0, 0};

int compress(vector<int>& x1, vector<int>& x2, int W){
    vector<int> xs;
    for(int i=0; i<x1.size(); i++){
        for(int d=-1; d<=1; d++){
            int tx1 = x1[i] + d;
            int tx2 = x2[i] + d;
            if(0<=tx1 && tx1<W) xs.push_back(tx1);
            if(0<=tx2 && tx2<W) xs.push_back(tx2);
        }
    }
    
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    
    for(int i=0; i<x1.size(); i++){
        x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    
    return xs.size();
}

void dfs(int h, int w, vector<vector<bool>>& field){
    const int H = field.size();
    const int W = field[0].size();
    
    field[h][w] = true;
    for(int i=0; i<4; i++){
        int nh = h + dh[i];
        int nw = w + dw[i];
        if(0<=nh && nh<H && 0<=nw && nw<W && !field[nh][nw])
            dfs(nh, nw, field);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, H;
    while(cin >> W >> H, W|H){
        int N;
        cin >> N;
        vector<int> x1(N);
        vector<int> y1(N);
        vector<int> x2(N);
        vector<int> y2(N);
        for(int i=0; i<N; i++)
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        
        W = compress(x1, x2, W);
        H = compress(y1, y2, H);
        
        vector<vector<bool>> field(H, vector<bool>(W));
        for(int i=0; i<N; i++){
            for(int x=x1[i]; x<x2[i]; x++){
                for(int y=y1[i]; y<y2[i]; y++){
                    field[y][x] = true;
                }
            }
        }
        int ans = 0;
        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                if(field[h][w]) continue;
                ans++;
                queue<pair<int, int>> q;
                q.push(make_pair(h, w));
                
                while(!q.empty()){
                    auto p = q.front(); q.pop();
                    int th = p.first;
                    int tw = p.second;
                    for(int i=0; i<4; i++){
                        int nh = th + dh[i];
                        int nw = tw + dw[i];
                        if(0<=nh && nh<H && 0<=nw && nw<W && !field[nh][nw]){
                            q.push(make_pair(nh, nw));
                            field[nh][nw] = true;
                        }
                    }
                }

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

Measured memory_bytes: 1408
N,K=map(int,input().split())
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if N==2 and K>=1:
    print(-1)
    exit()
if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<vector<int> > dp(H+1, vector<int>(W, 0)); dp[0][0] = 1;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      for(int k = 0; k < 1 << (W-1); ++k) {
        bool ok = true;
        for(int l = 0; l < W-2; ++l) {
          if(((k>>l)&1) && ((k>>(l+1))&1)) {
            ok = false;
          }
        }
        if(ok) {
          if(j >= 1 && ((k >> (j-1)) & 1)) {
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= mod;
          } else if (j <= W-2 && ((k>>j)&1)) {
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= mod;
          } else {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K-1] << endl;


  return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

template<typename T> void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

string pad(const int& num) {
  string t = to_string(num);
  string pad = "";
  if (t.size() < 6) {
    int diff = 6 - (int) t.size();
    for (int i = 0; i < diff; ++i) {
      pad += '0';
    }
  }
  return pad + t;
}

struct task{
  int year, id;
};

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

  int n, m; fastin(n); fastin(m);
  vector<task> v[101010];
  for (int i = 0; i < m; ++i) {
    int p, y; fastin(p); fastin(y);
    v[p].push_back({y, i + 1});
  }

  vector<string> ans(m + 1);

  for (int i = 1; i <= n; ++i) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end(), [](const task &x, const task &y){
      return x.year < y.year;
    });
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (int)v[i].size(); ++j) {
      ans[v[i][j].id] = pad(i) + pad(j + 1);
    }
  }

  for (int i = 1; i <= m; ++i) {
    printf("%s\n", ans[i].c_str());
  }

  return 0;
}

Measured memory_bytes: 12416
n = int(raw_input())
data = map(int, raw_input().split(" "))

#data = [10, 1, 5, 4, 17]

minimum = data[0]
maximum = data[0]
goukei = 0

for i in data:
	if i < minimum:
		minimum = i

	if i > maximum:
		maximum = i

	goukei += i

print("{:} {:} {:}".format(minimum, maximum, goukei))

Measured memory_bytes: 7096
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MAXN = 1001;

struct cake{
    LL c[3];
};

vector<cake> cakes;

int main(){
    int N, M; cin >> N >> M;
    cakes.resize(N);
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < 3; ++j){
            cin >> cakes[i].c[j];
        }
    }
    LL ans[3], answer = 0;
    for (int i = 0; i < 8; ++i){
        memset(ans, 0, sizeof ans);

        sort(cakes.begin(), cakes.end(), [i](const cake& l, const cake& r){
            LL lval = 0, rval = 0;
            for (int p = 0; p < 3; ++p){
                lval += l.c[p] * ((i & (1 << p)) ? 1 : -1);
                rval += r.c[p] * ((i & (1 << p)) ? 1 : -1);
            }
            return lval > rval;
        });

        for (int i = 0; i < M; ++i){
            for (int j = 0; j < 3; ++j){
                ans[j] += cakes[i].c[j];
            }
        }
        LL temp = 0;
        for (int i = 0; i < 3; ++i) temp += abs(ans[i]);
        answer = max(answer, temp);
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll x, y, z;
    cin >> x >> y >> z;
    cout << (x * y / 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    array<string, 3> s;
    rep(i, 0, 3) cin >> s[i];
    for (const string& i : s)
    {
        cout << static_cast<char>(i[0] - 'a' + 'A');
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        arr[0] = sc.nextInt();
        int max = 0;
        for (int i = 1; i < n; i++) {
            arr[i] = sc.nextInt();
            max = Math.max(max, arr[i] - arr[i - 1]);
        }
        max = Math.max(max, arr[0] - arr[n - 1] + k);
        System.out.println(k - max);
    }
}


Measured memory_bytes: 65628
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int a[7368792];
int main(){
	int i,c,m,n,b;
	while (~fscanf(stdin, "%d%d", &m, &n), m || n) {
		memset(a, 0, sizeof(a));
		for (c = 0, b = m; c != n;) {
			if (!a[b]) {
				for (i = 1; i*b < 7368792; i++)
					a[i*b] = 1;
				c++;
			}
			b++;
		}
		while (a[b++]);
		P(d, b-1);
	}
	return 0;
}

Measured memory_bytes: 29396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int M = in.Int();
            int X = in.Int();
            int[] C = new int[N];
            int[][] A = new int[N][];
            for (int i = 0; i < N; i++) {
                C[i] = in.Int();
                A[i] = in.Int(M);
            }
            long lm = 1 << N;
            int cost = Integer.MAX_VALUE;
            for (int i = 0; i < lm; i++) {
                int[] v = new int[M];
                int temp = 0;
                for (int j = 0; j < N; j++) {
                    if (((i >> j) & 1) == 1) {
                        temp += C[j];
                        for (int k = 0; k < M; k++) {
                            v[k] += A[j][k];
                        }
                    }
                }
                boolean chk = IntStream.of(v).allMatch(n -> n >= X);
                if (chk) {
                    cost = Math.min(cost, temp);
                }
            }
            out.println(cost == Integer.MAX_VALUE ? -1 : cost);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 37680
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const long long INF=2E17;
typedef pair<LL,LL> Pair;
int cnt=0;
const int MAX=100010;

LL haita(LL n){
    cnt++;
    if(n>3){
        LL keta=65;
        for(LL i=63;i>=0;i--){
            if(n >> i == 1){
                keta=i;
                break;
            }
        }
        if(keta==65) return 0ll;
        return (((n-(1ll << keta)+1ll)%2) << keta) ^ haita(n-(1ll << keta));
    }
    if(n==2) return 3ll;
    if(n==1) return 1ll;
    if(n==0) return 0ll;
    if(n==3) return 0ll;
}

int main(){
    LL A,B;
    cin >> A >>B;
    cout << (haita(A-1) ^ haita(B)) << endl;
    return 0;
}

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

int calc(int x){
  
  int sum = 0, max = 0;
  for(int i=2;i<=x;++i){
    if(x%i==0){
      sum += i;
      max = i;

      while(x%i==0){
        x /= i;
      }
    }
  }

  return max - (sum - max);
}

int main(){
  int n,m;

  while(cin>>n>>m&&n!=0){
    calc(n) > calc(m) ? cout<<"a"<<endl : cout<<"b"<<endl; 
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main()
{
  int m1,d1,m2,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  if(m1!=m2)
  {
    cout<<"1"<<endl;
  }else{
    cout<<"0"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  char m[3];
  while (scanf("%s\n",m)!=EOF) {

  }
  int count =0;
  for (size_t i = 0; i < 3; i++) {
    if(m[i]=='1'){
      count++;
    }
  }
  printf("%d\n",count );
  return 0;
}


Measured memory_bytes: 256
def bubblesort(A,N):
    flag = 1 
    count = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
           if A[j] < A[j-1]:
                ho = A[j]
                A[j] = A[j-1]
                A[j-1] = ho
                flag = 1
                count += 1
    return A,count

n = int(input())
a = [ int(i) for i in input().split()]
b , count = bubblesort(a,n)
for i in range(len(b)):
    if i == len(b)-1:
        print(b[i])
    else:
        print(b[i],end=' ')
print(count)


Measured memory_bytes: 5612
for i in range(100):
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    #print(h*w)
    #print(h)
    #print(w)
    else:
        for j in range(1,2):
            for k in range(1,w):
                print('#',end='')
            print('#')
        for l in range(2,h):
            print('#',end='')
            for n in range(2,w):
                print('.',end='')
            print('#')
        for m in range(h,h+1):
            for n in range(1,w):
                print('#',end='')
            print('#')
    print('')


Measured memory_bytes: 7000
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi v(5);
  rep(i, 5) {
    cin >> v[i];
    v[i] = max(40LL, v[i]);
  }
  cout << accumulate(all(v), 0) / 5 << endl;
}

Measured memory_bytes: 3068
def cal_combi(num)
  (num * (num-1)) / 2
end

n = gets.chomp.to_i
nums = gets.chomp.split(' ').map(&:to_i)

# 累積和
a = [0]
1.upto(n) do |i|
  a << nums[i-1] + a[i-1]
end

h = Hash.new(0)
a.each do |num|
  h[num] += 1
end

count = 0
h.each do |k, v|
  count += cal_combi(v)
end

puts count

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

int main() {
    int n, k;
    cin>>n>>k;
    vector<int> stones(n);
    for(int i=0; i<n; i++) cin>>stones[i];

    vector<bool> dp(k+1, false);
    for(int i=1; i<=k; i++)
        for(int j=0; j<n && dp[i] == false; j++)
            dp[i] = stones[j] <= i && dp[i - stones[j]] == false;
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}

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

int main(){
  int n;
  long long int cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    char s;
    long long int a;
    cin>>s>>a;
    if(s=='('){
      cnt+=a;
    }else{
      cnt-=a;
    }
    if(cnt<0){
      break;
    }
  }
  if(cnt==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
using namespace std;
long long n,ans,a,b,sum,mi;
#define inf 1000000005
int main()
{
	scanf("%lld",&n);
	mi=inf;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		sum+=a;
		if(a>b)
			mi=min(mi,b);
	}
	printf("%lld\n",mi==inf?0:sum-mi);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, w; cin >> n >> w;
  int l = n * 1001;
  vector<long long> f(l + 1, 1ll<<62);
  f[0] = 0;
  for(int i = 0; i < n; i++){
    int wi, vi; cin >> wi >> vi;
    for(int j = l - vi; j >= 0; j--)
      f[j+vi] = min(f[j+vi], f[j]+wi);
  }
  int p = l;
  while(f[p] > w) p--;
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[2000];
vector <long long> divided_A[2000];
int main(){
  int N;
  int K;
  int Q;
  cin >> N >> K >> Q;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  long long ans = LLONG_MAX;
  for(int i = 0; i < N; i++){
    long long cur_min = A[i];
    for(int j = 0; j < N; j++){
      divided_A[j].clear();
    }
    int div_no = 0;
    bool in_div = false;
    for(int j = 0; j < N; j++){
      if(A[j] >= cur_min){
        if(in_div){
          divided_A[div_no - 1].push_back(A[j]);
        } else {
          in_div = true;
          div_no ++;
          divided_A[div_no - 1].push_back(A[j]);
        }
      } else {
        if(in_div){
          in_div = false;
        }
      }
    }

    vector <long long> candidates;
    for(int j = 0; j < div_no; j++){
      if(divided_A[j].size() >= K){
        sort(divided_A[j].begin(), divided_A[j].end());
        for(int k = 0; k < divided_A[j].size() - (K - 1); k++){
          candidates.push_back(divided_A[j][k]);
        }
      }
    }
    //for(int j = 0; j < candidates.size(); j++){
    //  cout << candidates[j] << " ";
    //}
    //cout << endl;
    if(candidates.size() >= Q){
      sort(candidates.begin(), candidates.end());
      ans = min(ans, candidates[Q - 1] - candidates[0]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n];
	rep(i,n){
		cin>>a[i];
	}
	ll dp[n+1][2];
	dp[0][0]=0;dp[0][1]=-inf;

	rep(i,n){
		dp[i+1][0]=max(dp[i][0]+a[i],dp[i][1]-a[i]);
		dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i]);
	}
/*
	rep(i,n+1) cout<<dp[i][0]<<" ";
	cout<<"\n";
	rep(i,n+1) cout<<dp[i][1]<<" ";
	cout<<"\n";
*/	

	cout<<dp[n][0]<<"\n";

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n,m;cin >> n >> m;
  vector<vector<int>> acwa_pena(n,vector<int>(2,0));
  rep(i,m){
    int no;
    string acwa;
    cin>>no>>acwa;
    if(acwa=="AC") acwa_pena[no-1][0]=1;
    else if(acwa_pena[no-1][0]==0) acwa_pena[no-1][1]+=1;
  }
  int ac=0;
  int pena=0;
  rep(i,n) {
    ac+=acwa_pena[i][0];
    if (acwa_pena[i][0]) pena+=acwa_pena[i][1];
  }
  cout << ac << " " << pena << endl;
}

Measured memory_bytes: 8744
///
// File:  alds1_5_d.cpp
// Author: ymiyamoto
//
// Created on Wed Oct 11 00:04:59 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint64_t> array;

static uint64_t merge(uint32_t left, uint32_t mid, uint32_t right)
{
  vector<uint64_t> lefts, rights;
  for (uint32_t i = left; i <= right; i++) {
    if (i <= mid) {
      lefts.push_back(array[i]);
    } else {
      rights.push_back(array[i]);
    }
  }

  lefts.push_back(UINT64_MAX);
  rights.push_back(UINT64_MAX);
  uint64_t count = 0;

  uint32_t left_index = 0;
  uint32_t right_index = 0;
  for (uint32_t i = left; i <= right; i++) {
    if (lefts[left_index] <= rights[right_index]) {
      array[i] = lefts[left_index];
      left_index++;
    } else {
      array[i] = rights[right_index];
      count += lefts.size() - 1 - left_index;
      right_index++;
    }
  }

  return count;
}

static uint64_t merge_sort(uint32_t left, uint32_t right)
{
  uint64_t count = 0;
  if (left < right) {
    uint32_t mid = (left + right) / 2;
    count += merge_sort(left, mid);
    count += merge_sort(mid + 1, right);
    count += merge(left, mid, right);
  }

  return count;
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint64_t val;
    cin >> val;
    array.push_back(val);
  }

  uint64_t count = merge_sort(0, array.size() - 1);
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 7016
# フレームの描画

while True:
    H, W = map(int, input().split())
    if H==0 and W==0: # stop condition
        break

    for h in range(H):
        for w in range(W):
            if h==0 or h==(H-1) or w==0 or w==(W-1):
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()
    



Measured memory_bytes: 7000
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n;i>0;i--)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;


//int arr[N]
////sort(arr,arr +N)
//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

void print(int n);
void next(int locate);

int main() {
	int n, cost = 1000000, tmp;
	string s;
	cin >> n >> s;
	int blk=0, right;
	int w_all=0;
	rep(i,n){
		if(s[i]=='.')
			w_all++;
	}
	if(w_all==0 ||w_all==n){
		cout<<0;
		return 0;
	}
	if(w_all==1&& s[0]!='.'){
		cout<<1;
		return 0;
	}
	right=w_all;
	rep(i, n) {
		if(s[i]=='.')
			right-=1;
		else
			blk++;
		tmp=right+blk;

		if(tmp==n){
			cout<<min(w_all,n-w_all);
			return 0;
		}
		if (cost > tmp)
			cost = tmp;
		//cout<<cost;

	}
	cout << cost;
	return 0;
}


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

const int N = 2e5 + 5;

int n;
char s[N];
int f[N][2];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    memset(f, -0x3f, sizeof(f));
    f[1][0] = 1;
    f[2][1] = 1;
    if (s[1] != s[2]) f[2][0] = 2;
    for (int i = 3; i <= n; i++) {
        f[i][0] = std::max(f[i][0], f[i - 1][1] + 1);
        f[i][1] = std::max(f[i][1], f[i - 2][0] + 1);
        if (s[i] != s[i - 1]) f[i][0] = std::max(f[i][0], f[i - 1][0] + 1);
        if (!(s[i] == s[i - 2] && s[i - 1] == s[i - 3]))
            f[i][1] = std::max(f[i][1], f[i - 2][1] + 1);
    }
    int ans = -1;
    for (int i = 1; i <= n; i++) { ans = std::max(ans, f[i][0]); ans = std::max(ans, f[i][1]); }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
  int x, ans=1, s=1;
  cin >> x;
  for(int i=2; i<x; i++){
    while(s<=x) s*=i;
    s /=i;
    if(ans < s && i!=s) ans = s;
    s=1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r, d, x;
    cin >> r >> d >> x;
    F0R(i, 10)
    {
        x = r * x - d;
        cout << x << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1<<20)
#define NIL -1

struct RUQ {
	int N;
	int a[N_SIZE];
	int seg[N_SIZE * 2];
	int lazy[N_SIZE * 2];
	int gt;
	void init(int n) {
		N = n;
		gt = 1;
		while (N > gt)gt *= 2;
		REP(i, n)a[i] = (1LL << 31) - 1;
		REP(i, N_SIZE) {
			seg[i] = (1LL << 31) - 1;
			lazy[i] = NIL;
		}
		REP(i, n)seg[i + gt - 1] = a[i];
	}

	void lazy_evaluate(int k) {
		seg[k] = lazy[k];
		if (k < gt) {
			lazy[2 * k + 1] = lazy[k];
			lazy[2 * k + 2] = lazy[k];
		}
		lazy[k] = NIL;
	}

	//[a,b)
	void update(int a, int b, int x) { update(a, b, 0, 0, gt, x); }
	void update(int a, int b, int k, int l, int r, int x) {
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b)lazy[k] = x;
		else {
			if (lazy[k] != NIL)lazy_evaluate(k);
			update(a, b, 2 * k + 1, l, (l + r) / 2, x);
			update(a, b, 2 * k + 2, (l + r) / 2, r, x);
		}
	}

	//[a,b)
	ll query(int a, int b) { return query(a, b, 0, 0, gt); }
	ll query(int a, int b, int k, int l, int r) {
		ll res = NIL;
		if (r <= a || b <= l)return res;
		if (a <= l&&r <= b) {
			if (lazy[k] != NIL)lazy_evaluate(k);
			return seg[k];
		}
		else {
			if (lazy[k] != NIL)lazy_evaluate(k);
			ll num[2] = { query(a, b, 2 * k + 1, l, (l + r) / 2),
				query(a, b, 2 * k + 2, (l + r) / 2, r) };
			REP(i, 2)if (num[i] != NIL)res = num[i];
		}
		return res;
	}

	void print() {
		REP(i, gt * 2)cout << "!" << i << " " << seg[i] << " " << lazy[i] << endl;
	}
};

RUQ ruq;

int n, q;

int main() {
	cin >> n >> q;
	ruq.init(n);
	REP(i, q) {
		int s, t, x;
		bool f;
		cin >> f;
		if (!f) {
			cin >> s >> t >> x;
			ruq.update(s, t + 1, x);
		}
		else {
			cin >> x;
			cout << ruq.query(x, x + 1) << endl;
		}
		//ruq.print();
	}
}

Measured memory_bytes: 11700
# -*- coding: utf-8 -*-
# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
result = 1
if 0 in A:
    result = 0
else:
    sorted_A = list(reversed(sorted(A)))
    for A_n in sorted_A:
        result *= A_n
        if result > pow(10, 18):
            result = -1
            break

# 結果出力
print(result)


Measured memory_bytes: 21692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var b = new int[100001];
			for (int i = 0; i < n; i++) {
				b[a[i]]++;
			}

			int count = b.Where(x => x > 1).Select(x => x - 1).Sum();
			int ans = n - count - (count % 2);

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 18528
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    int j = 0;
    for(int i = 0 ; i < s.length() ; ++i){
        if(s[i] == t[j]){
            ++j;
        }
    }
    cout << s.length() + t.length() - j << '\n';
    return 0;
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
pos, neg, zero = [], [], []

for Ai in A:
    if Ai>0:
        pos.append(Ai)
    elif Ai<0:
        neg.append(Ai)
    else:
        zero.append(0)

if len(neg)==0:
    neg += zero
else:
    pos += zero
    
ope = []

if len(pos)>0 and len(neg)>0:
    now1 = pos[0]
    
    for i in range(1, len(neg)):
        ope.append((now1, neg[i]))
        now1 -= neg[i]
    
    now2 = neg[0]
    
    for i in range(1, len(pos)):
        ope.append((now2, pos[i]))
        now2 -= pos[i]
    
    ope.append((now1, now2))
    M = now1-now2
elif len(pos)==0:
    neg.sort(reverse=True)
    now = neg[0]
    
    for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
    M = now
else:
    pos.sort()
    now = pos[0]
    
    for i in range(1, len(pos)-1):
        ope.append((now, pos[i]))
        now -= pos[i]
    
    ope.append((pos[-1], now))
    M = pos[-1]-now

print(M)

for x, y in ope:
    print(x, y)

Measured memory_bytes: 89824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		
		int ans = 0;
		if(A > B)
			ans += B;
		else
			ans += A;
		if(C > D)
			ans += D;
		else
			ans += C;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = float("inf")
for x, y, c in xyc:
    x -= 1
    y -= 1
    cost = a[x] + b[y] - c
    ans = min(ans, cost)

cost = min(a) + min(b)
ans = min(ans, cost)
print(ans)


Measured memory_bytes: 38560
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using i64 = long long;
using pii = pair<int, int>;

static i64 fix(i64 x) {
	return x < 0 ? i64(1e10) : x; }

vector<pii> v;

int main() {
#ifdef HOME
	freopen("agc8a.in", "r", stdin);
	freopen("agc8a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant, x, y;

	cin >> x >> y;
	ant = 1e10;
	for (auto i: {-x - 1, x})
	for (auto j: {-y + 1, y})
		ant = min(ant, fix(j - i));

	cout << ant << endl;

	return 0; }


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

int main() {
  string S;
  cin >> S;
  string s1 = S.substr(0, 2);
  string s2 = S.substr(2);
  int x = stoi(s1);
  int y = stoi(s2);
  if (1 <= x && x <= 12) {
    if (1 <= y && y <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if (1 <= y && y <= 12) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() { 
	cin >> N;
	COMinit(N + 2);
	vl A(N + 1);
	vl P(N,-1);
	ll F = -1, S = -1;
	for (i = 0; i < N+1; i++) {
		cin >> A[i];
		if (P[A[i] - 1] == -1) P[A[i] - 1] = i;
		else {
			F = P[A[i] - 1];
			S = i;
		}
	}
	vl Ans(N + 2);
	//Fより左側とSより右側で合計i個選ぶ
	vl FS(F+N-S+1);
	FS[0] = 1;
	for (i = 1; i <= F+N-S; i++) {
		FS[i] = COM(F+N-S, i);
	}
	for (i = 1; i < N+2; i++) {
		Ans[i] = COM(N + 1, i);
		if (i - 1 < F + N - S + 1) {
			//debug(Ans[i], FS[i - 1]);
			Ans[i] = ((Ans[i] - FS[i - 1]) % MOD + MOD) % MOD;
		}
		cout << Ans[i] << endl;
	}
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a + b > c + d){
    cout << "Left" << endl;
  }
  else if(a + b < c + d){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

int solve(){
    
    return 0;
}

signed main(){
    IOS
// 	#ifndef ONLINE_JUDGE
//     	freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
	ll a;
    cin>>a;
    MI m;
    ll s=0;
    rep(i,0,a){
      ll v;
      cin>>v;
      if(m.find(v)==m.end()) m.insert({v,1});
         else m[v]++;
         s+=v;
         }
         ll q;
         cin>>q;
         rep(i,0,q){
           ll b,c;
           cin>>b>>c;
           if(m.find(b)!=m.end()){
             auto it =m.find(b);
             ll va = it->S;
             if(m.find(c)==m.end()){
             	m.erase(it);
             	m.insert({c,va});
             }
             else{
             	m.erase(it);
               m[c]+=va;
             }
             s+=c*(va);
             s-=b*(va);
           }
           cout<<s<<"\n";
         }
  
    return 0;
}


Measured memory_bytes: 7612
/*
* @author:  codancer
* @createTime:  time
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
long long cal(long long x){
	long long l=1;
	long long r=3e9;
	long long mid;
	for(int i=1;i<=200;i++){
		mid=(l+r)/2;
		if(mid*mid<=x){
			l=mid;
		}
		else {
			r=mid;
		}
	}
	return l;
}
int main(){
	long long  a,b,c;
	cin>>a>>b>>c;
	if(a+b+cal(4*a*b)<c){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define INF 1000000007
#define fori for(int i=0;i<3;i++)

int main(){
	int x,n,tmp,minn=INF;
	cin>>x>>n;
	map<int,int>p;
	for(int i=0;i<n;i++){
		cin>>tmp;
		p[tmp]=1;
	}
	for(int i=-1000;i<1002;i++){
		if(!p[i])minn=min(minn,abs(i-x));
	}
	for(int i=-1000;i<1002;i++){
		if(!p[i]&&abs(i-x)==minn){
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3728