akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=200001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

ll PERMU(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M;
}

ll ans,N,K;
vl G[100000];

void dfs(ll v,ll p){
    if(p!=-1){
        ans*=PERMU(K-2,G[v].size()-1,MOD);
    }
    if(p==-1){
        ans*=PERMU(K-1,G[v].size(),MOD);
    }
  	ans%=MOD;
    rep(i,G[v].size()){
        if(p!=G[v][i]){
            dfs(G[v][i],v);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    COMinit(MOD);
    ans=K;
    rep(i,N-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(0,-1);
    cout << ans << endl;
}

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

const int N = 105;

int a[3][N], sum[3][N];

int main(){
	int n, ans;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[1][i]);
	for (int i = 1; i <= n; i++) scanf("%d",&a[2][i]);
	sum[1][0] = sum[2][0] = 0;
	for (int i = 1; i <= n; i++){
		sum[1][i] = sum[1][i - 1] + a[1][i];
		sum[2][i] = sum[2][i - 1] + a[2][i];
	}
	ans = 0;
	for (int i = 1; i <= n; i++) ans = max(ans, sum[1][i] + sum[2][n] - sum[2][i - 1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import collections

N, X = map(int, input().split())
x = [int(i) for i in input().split()]

y = [abs(X-i) for i in x]
y.append(0)
y.sort()
D = min(collections.Counter(list(set([(y[i+1] - y[i]) for i in range(0, N) if (y[i+1] - y[i]) != 0]))).keys())
f = True
for i in range(D, 0, -1):
    f = True
    for j in range(0, N):
        if y[j]%D != 0:
            f = False
            break
    if f:
        break
    D = i
print(D)

Measured memory_bytes: 15252
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i = (a);i < (b); i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int n, d, sum;
vector<vector<int> > c;
vector<int> f;

void input()
{
  sum = 0;
  c.assign(n, vector<int>());
  f.assign(n, 0);
  rep(i, n) {
    int m; cin >> m;
    sum += m;
    c[i].resize(m);
    rep(j, m)
      cin >> c[i][j];
    f[i] = accumulate(c[i].begin(), c[i].end(), 0);
  }
}

bool solve()
{
  if (n <= 1)
    return true;

  bool loop = true;
  while (loop) {
    loop = false;
    int fst = f[0];
    int snd = f[1];
    if (snd > fst)
      swap(fst, snd);
    repi(i, 2, n) {
      if (f[i] > snd) {
	snd = f[i];
	if (snd > fst)
	  swap(fst, snd);
      }
    }

    int update = -1;
    rep(i, n) {
      if (c[i].empty())
	continue;

      int after = f[i] - c[i].back();
      if (f[i] < fst) {
	if (after >= fst - d) {
	  update = i;
	  break;
	}
      } else {
	if (after >= snd - d) {
	  update = i;
	  break;
	}
      }
    }

    if (update >= 0) {
      loop = true;
      f[update] -= c[update].back();
      c[update].pop_back();
      --sum;
    }
  }

  return !sum;
}

int main()
{
  while (cin >> n >> d && n) {
    input();
    cout << (solve() ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 1272
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	cin >> s;

	int zero_num = count(s.begin(), s.end(), '0');

	cout << min(zero_num, (int)s.length() - zero_num) * 2 << endl;
	return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

string S, T;

i32 dp[3001][3001];

int main() {
  cin >> S >> T;

  rep(s, S.length()) {
    rep(t, T.length()) {
      if (S[s] == T[t]) {
        dp[s + 1][t + 1] = max(dp[s + 1][t + 1], dp[s][t] + 1);
      }
      dp[s + 1][t + 1] = max(dp[s + 1][t + 1], dp[s + 1][t]);
      dp[s + 1][t + 1] = max(dp[s + 1][t + 1], dp[s][t + 1]);
    }
  }

  string ans = "";

  auto i = S.length();
  auto j = T.length();

  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      ans = S[i - 1] + ans;
      i--;
      j--;
    }
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 38768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const ll MOD = 1e9 + 7;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<vector<ll>> ab(N, vector<ll>(2));
	rep(i, N) {
		cin >> ab[i][0];
		cin >> ab[i][1];
	}
	sort(ab);
	ll sum = 0;
	ll ans;
	rep(i, N) {
		sum += ab[i][1];
		if (sum >= K) {
			ans = ab[i][0];
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using pb = pair<double,double>;

signed main(){
	ll n; cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	rep(i,1,n+1){
		if(i*i>n){
			cout<<(i-1)*(i-1)<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define S8 long

#define TRUE					(1)
#define FALSE					(0)

#define RATE_OF_INTEREST        (105)    /* 借金の利率(%) */
#define PERCENT                 (100)    /* 割合をパーセントに変換する定数 */
#define ROUNDUP_THRESHOLD       (1000)   /* 切り上げの閾値 */
#define AMOUNT_OF_DEBT          (100000) /* 借金の金額 */

S4 main(void)
{
	S4 s4_t_balance;	/* 借金残高 */
	S4 s4_t_week;		/* 借金をしてから経過した週間 */
	S4 s4_t_cnt;		/* 残高計算用のカウンタ */
	S4 s4_t_mod;		/* 切り上げ計算用余り */
	U1 u1_t_delimiter;	/* scanfの改行を捨てるための変数 */

	/* 経過した週間を入力 */
	(void)scanf("%d%c", &s4_t_week, &u1_t_delimiter);

	/* 借金の初期値 */
	s4_t_balance = (S4)AMOUNT_OF_DEBT;

	/* 残高を計算 */
	for (s4_t_cnt = (S4)0; s4_t_cnt < s4_t_week; s4_t_cnt++)
	{
		/* 利子を加算 */
		s4_t_balance = s4_t_balance * (S4)RATE_OF_INTEREST / (S4)PERCENT;

		/* 1000円未満は切り上げ */
		s4_t_mod = s4_t_balance % (S4)ROUNDUP_THRESHOLD;
		if (s4_t_mod > (S4)0)
		{
			s4_t_balance = ((s4_t_balance / (S4)ROUNDUP_THRESHOLD) + (S4)1) * (S4)ROUNDUP_THRESHOLD;
		}
	}

	/* 残高を出力する */
	printf("%d\n", s4_t_balance);

	return((S4)0);
}



Measured memory_bytes: 1996
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int x = scanInt(), y = scanInt(), z = scanInt();
        out.print(z + " " + x + " " + y);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 22612
#include <stdio.h>
int main(void){
  int x,y,m,n,k;

  scanf("%d%d",&x,&y);

  if(x>=y){
    m=x;
    n=y;
  }
  else{
    m=y;
    n=x;
  }
  while(n!=0){
    k=n;
    n=m%n;
    m=k;
  }
  printf("%d\n",m);
  return 0;
}













 



Measured memory_bytes: 2136
import sys

n, k, *x = map(int, sys.stdin.read().split())

def main():
    l = 0; r = k - 1
    ans = float('inf')
    while r < n:
        if x[r] <= 0:
            res = abs(x[l])
        elif x[l] < 0:
            res = min(abs(x[l]), x[r]) * 2 + max(abs(x[l]), x[r])
        else:
            res = x[r]
        ans = min(ans, res)
        l += 1; r += 1
    
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14052
a,*b=map(int,open(0).read().split())
c=[i for i in b if i%10==0]
d=sorted([i for i in b if i%10!=0])
if len(d)==0:
    print(0)
    exit()
for i in range(len(d)):
    if sum(d)%10==0:
        d[i]=0
    else:
        break
print(sum(d)+sum(c))

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

const ll INF = 1e18;
struct edge { int from, to; ll cost; };

vector<vector <ll>> worshallFloyd(vector<vector <ll>> d) {
  int V = d.size();
  for(int k = 0; k < V; k++) {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        if(d[i][k] != INF && d[k][j] != INF)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  return d;
}

const int M_MAX = 2000;

int main () {
  int N, M, a, b;
  ll c;

  cin >> N >> M;
  vector<vector <ll>> d(N, vector<ll>(N, INF));
  REP(i,N) d[i][i] = 0;
  REP(i,M) {
    cin >> a >> b >> c;
    d[a-1][b-1] = -c;
  }

  d = worshallFloyd(d);
  REP(i,N) {
    if(d[i][i] < 0 && (i == 0 || (d[0][i] != INF && d[i][N-1] != INF))) {
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -d[0][N-1] << endl;
  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    for(int i = 0; i<a; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No";
            return 0;
        }
    }
    if(s[a] != '-'){
        cout << "No";
        return 0;
    }
    for(int i = a+1; i<a+b; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>v, w;


int main() {

	int N, W;
	cin >> N >> W;

	
	v.resize(N); w.resize(N);
	//入力
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];

	}

	//それぞれの重さの時の最大の価値
	int MaxValue[10001] = { 0 };

	//与えられたものを一個ずつ入れる場合の最大の価値を算出
	//重さiのものを入れる時の価値を計算していく。
	//重さ9のものを入れた場合の最大の価値を計算する。
	//Wから計算していくのは20-9==11としたときに11の重さの時の最大の価値を重さ9を使って計算してしまっていて、同じ重りを使うことになってしまうため。
	for (int i = 0; i < N; i++) {
		for (int j = W; j>0; j--) {
			if (j - w[i] >= 0) {
				MaxValue[j] = max(MaxValue[j], MaxValue[j - w[i]] + v[i]);
			}
		}

	}

	cout << MaxValue[W] << "\n";

	return 0;
}


Measured memory_bytes: 3152
#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>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
int main() {
	ll h;
	cin >> h;
	ll count = 0;
	if (h > 1) {
		for (int i = 0; i < 100; i++) {
			h = h / 2;
			count++;
			if (h == 1) {
				break;
			}
		}
		ll ans = pow(2, count);
		cout << ans * 2 - 1 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

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

int main() {
  string a, b; cin >> a >> b;
  for (int i=0; i<b.size();i++) {
    cout << a.at(i);
    cout << b.at(i);
  }
  if(a.size()!=b.size()){
    int e=a.size();
    cout << a.at(e-1);
  }
cout << endl;
}


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

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i,_n) for(ll _i = 0; _i < _n; ++_i)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; ++_i)
#define elif else if
#define push(_a) push_back(_a)
#define append(_x) push_back(_x)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecUL(_name, _n) vec<ul> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecULL(_name, _n) vec<ull> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define findMaxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";

int main()
{
    long N;
    cin >> N;
    inputVecLL(A, N);
    map <ll, long> WA;
    map <ll, long> SA;
    rep(i, N){
      WA[(i + 1) + A[i]] += 1;
      SA[(i + 1) - A[i]] += 1;
    }
    long ans = 0;
    for(auto i : WA){
      ans += SA[i.first] * i.second;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 39092
#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

using namespace std;

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

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

ll lcm_n(vector<ll> &num){
  int l=num[0];
  for(int i=0;i<num.size();i++)l=lcm(l,num[i]);
  return l;
}

ll func(ll a, ll m){
  ll cnt=1,x=a%m;
  while(x!=1)x=(a*x)%m,cnt++;
  return cnt;
}

int main(void){

  ll m[4],a[4];

  while(true){

    int b=0;
    for(int i=1;i<4;i++){
      cin >> a[i] >> m[i];
      b=a[i]+m[i];
    }
    if(b==0)break;
    
    ll cnt=0,x=1,y=1,z=1;
    vector<ll>num;

    for(int i=1;i<4;i++)
    num.push_back(func(a[i],m[i]));

    cout << lcm(lcm(num[0],num[1]),num[2])<< endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs           v.size()
#define sot(v)       sort(v.begin(),v.end())
#define rev(v)       reverse(v.begin(),v.end())
#define yes          cout<<"Yes"<<endl
#define no           cout<<"No"<<endl
#define ii           pair<int, int>
#define int          long long
#define ull          unsigned long long
#define pb           push_back
#define mpp          make_pair
#define Okay         0
#define pi           3.14159

const int inf = 1e6;
const int cont = 1e18;
const int mod = 1e9+7;
using namespace std;

void solve(){
   char a, b;
   cin>>a>>b;
   if(a == 'H'){
        cout<<b<<endl;
   }
   else{
     if(b == 'H')cout<<'D'<<endl;
     else cout<<"H"<<endl;
   }
}

int32_t main() {
    Fast;
    solve();
    return Okay;
}


Measured memory_bytes: 3552
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
    vector<vector<long long int>> v;
    int n;
    long long int k;
    cin >> n >> k;
    rep(i,n){
        long long int a,b;
        cin >> a >> b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    vector<long long int> total_v;
    
    long long int total = 0;
    for(auto w:v){
        total+=(long long int)w[1];
        total_v.push_back(total);
    }
    auto itr = lower_bound(total_v.begin(),total_v.end(),k);
    int p = distance(total_v.begin(),itr);
    cout << v[p][0] << endl;
}

Measured memory_bytes: 8240
# ABC100D - Patisserie ABC
def calc(func: "func") -> int:
    cakes = [func(x, y, z) for x, y, z in zip(*[iter(XYZ)] * 3)]
    cakes.sort(reverse=1)
    return sum(cakes[:M])


def main():
    global M, XYZ
    N, M, *XYZ = map(int, open(0).read().split())
    ans = max(
        calc(lambda x, y, z: x + y + z),
        calc(lambda x, y, z: x + y - z),
        calc(lambda x, y, z: x - y + z),
        calc(lambda x, y, z: x - y - z),
        calc(lambda x, y, z: -x + y + z),
        calc(lambda x, y, z: -x + y - z),
        calc(lambda x, y, z: -x - y + z),
        calc(lambda x, y, z: -x - y - z),
    )
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define mod 1000000007
#define pb push_back
#define mk make_pair
#define ff first
#define ss second



int main(){

    long long a,b,c;
    cin>>a>>b>>c;
    long long ans=LLONG_MAX;
    ans = min(ans,abs(a*b*(c-c/2)-a*b*(c/2)));
    ans = min(ans,abs(c*b*(a-a/2)-c*b*(a/2)));
    ans = min(ans,abs(a*c*(b-b/2)-a*c*(b/2)));
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int Maxn=110000;
int n,h[Maxn],f[Maxn],k;
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	memset(f,0x3f,sizeof(f)),f[1]=0;
	for(int i=2;i<=n;i++) for(int j=1;j<i&&j<=k;j++) f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
	printf("%d",f[n]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 


int main() {
    string s; cin >> s;
    vector<int> cnt(3,0); 
    for(char c : s) cnt[c-'a']++;
    sort(all(cnt));
    if ((cnt[0] == cnt[1] && cnt[1]== cnt[2]) ||
        (cnt[0]== cnt[1] && cnt[1]+1 == cnt[2]) ||
        (cnt[0]+1 == cnt[1] && cnt[1] == cnt[2])) {
            cout << "YES" << endl;
    } else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define pb push_back
#define mp make_pair
#define f first
#define s second
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
	{
		cout<<s<<"es"<<endl;
	}
	else
	{
		cout<<s<<"s"<<endl;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
double EPS=1e-10;
int INF=1e9;
string C(string s){
      string res=s;
      for(int i=1;i<s.size();i++){
            res[i-1]=s[i];
      }
      res[s.size()-1]=s[0];
      return res;
}
string J(string s){
      string res=s;
      res[0]=s[s.size()-1];
      for(int i=0;i<s.size()-1;i++){
            res[i+1]=s[i];
      }
      return res;
}
string E(string s){
      int sl=s.size();
      char t;
      string tmp1="",tmp2="",res="";
      REP(i,sl){
            if(i<sl/2)tmp1+=s[i];
            else if(sl%2==1&&i==sl/2){
                  t=s[i];
            }else{
                  tmp2+=s[i];
            }
      }
      if(sl%2==1){
            return tmp2+t+tmp1;
      }
      return tmp2+tmp1;
}
string A(string s){
      reverse(ALL(s));
      return s;
}
string M(string s){
      REP(i,s.size()){
            if('0'<=s[i]&&s[i]<='9'){
                  s[i]=(s[i]-'0'+1)%10+'0';
            }
      }
      return s;
}
string P(string s){
      REP(i,s.size()){
            if('0'<=s[i]&&s[i]<='9'){
                  s[i]=(s[i]-'0'+9)%10+'0';
            }
      }
      return s;
}
int main(){
      string s,t;
      int n;
      cin>>n;
      while(n--){
            cin>>t>>s;
            for(int i=t.size()-1;i>=0;i--){
                  if(t[i]=='J')s=J(s);
                  else if(t[i]=='C')s=C(s);
                  else if(t[i]=='E')s=E(s);
                  else if(t[i]=='A')s=A(s);
                  else if(t[i]=='P')s=P(s);
                  else s=M(s);
            }
            cout<<s<<endl;
      }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b;++i)
#define fdto(i,a,b) for(int i=a; i>=b;--i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define maxn 1000009
#define gb(i,j) ((i>>j)&1)
#define name "a"
#define endl '\n'

using namespace std;

ll f[maxn],s[maxn];
int mod=1e9+7,n;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    f[0]=1;
    s[0]=1;
    if(n==1){cout << 1; return 0;}
    for(int i=1; i<=n; ++i){
        f[i]=f[i-1];
        if(i>2)f[i]=(f[i]+s[i-3])%mod;
        s[i]=(f[i]+s[i-1])%mod;
    }
    ll res=(f[n]+f[n-1]*(n-1))%mod;
    fto(i,0,n-2){
        res=(res+f[i]*(i+1)%mod*n)%mod;
        res=(res+f[i]*(n-i-2)%mod*(n-1))%mod;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
char ans[100004];
char conv(char c){
	return c == 'W' ? 'S' : 'W';
}
char next(char prev, char now){
	if(now == 'S')	return prev;
	else	return conv(prev);
}

void restore(char first,char second){
	ans[0]=first;
	ans[1] = second;
	char tmp;
	for(int i = 1;i<n;i++){
		if(s[i] == 'o')
			tmp=next(ans[i-1],ans[i]);
		else
			tmp = conv(next(conv(ans[i-1]),conv(ans[i])));
		ans[i+1] = tmp;
	}
}

int main() {
	cin>>n>>s;
	char it[2] = {'W','S'};
	bool ok = true;
	for(int i = 0 ; i < 2;i++)
		for(int j = 0;j<2;j++){
			ok = true;
			restore(it[i],it[j]);
			if(ans[n] != ans[0])	ok = false;
			char c;
			if(s[0] == 'o')
				c = next(ans[n-1],ans[0]);
			else
				c = conv(next(conv(ans[n-1]),conv(ans[0])));
			if ( c != ans[1])	ok = false;
			if(!ok)	continue;
			for(int k = 0 ; k<n;k++){	
				cout<<ans[k];
			}
			return 0;
		}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int v[N];
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    int n;
    cin >> n;
    int x;
    set<int> s;
    fore(i,0,n){
        cin >> x;
        s.insert(x);
    }
    int ans = sz(s);
    if((n - sz(s)) % 2 == 1)
        ans--;
    cout << ans << '\n';

    return 0;   
}

Measured memory_bytes: 4992
import itertools

n = int(input())

T = 'MARCH'
ct = [0 for _ in range(5)]
for _ in range(n):
    s = input()
    if s[0] not in T:
        continue
    ct[T.find(s[0])] += 1

ans = 0
for x,y,z in itertools.combinations(ct,3):
    ans += x*y*z
print(ans)


Measured memory_bytes: 3060
//When it comes Head ,then we need atleast (X-1) Heads from rest (N-1) coins.
//When it comes Tail,then we need atleast X Heads from rest (N-1) coins.
//We need atleast (N+1)/2 coins to get number of Heads greater than number of Tails.
//For atleast zero Heads,Probability is always 1.
// 3
// 0.30 0.60 0.80
#include<bits/stdc++.h>
#define ll long long
#define inf 1e12 
#define mo 1000000007
double dp[3000][1501];
using namespace std;
int main()
{
	ll n;
	cin>>n;
	double a[n];
	for(ll p=1;p<=n;p++)
	{
		cin>>a[p];
	}
	for(ll p=0;p<=(n+1)/2;p++)
	{
		dp[0][p]=0;
	}
	dp[0][0]=1;
	for(ll e=1;e<=n;e++)
	{
		dp[e][0]=1;
	}
	for(ll w=1;w<=n;w++)
	{
		for(ll q=1;q<=(n+1)/2;q++)
		{
			dp[w][q]=(a[w]*dp[w-1][q-1])+((1-a[w])*dp[w-1][q]);
		}
	}
	cout<<fixed<<setprecision(10)<<dp[n][(n+1)/2];
}

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


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


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


long long A, B;

void read() {
    cin >> A >> B;
}


void work() {
    cout << lcm(A, B) << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

using namespace std;

const int NMAX = 100000 + 5;

int N;
int v[NMAX];

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

    cin >> N;
    for (int i = 1; i <= N; ++ i)
        cin >> v[i];
    sort(v + 1, v + N + 1);

    //Erase first line and last column while possible
    int lin = 1, col = N;
    while (col - 1 >= 1 && v[col - 1] >= lin + 1) {
        ++ lin;
        -- col;
    }

    //Game was reduced to 2 piles linked together
    int len1 = v[col] - lin;
    int len2 = 0;

    while (col - 1 >= 1 && v[col - 1] == lin) {
        ++ len2;
        -- col;
    }

    //Solve each of the 2 games separately
    bool win1 = (len1 & 1) ^ 1;
    bool win2 = (len2 & 1) ^ 1;

    //Link piles together and print result
    bool win = (!win1 || !win2);
    if (win)
        cout << "First\n";
    else
        cout << "Second\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	LL n;cin>>n;
	vector<vector<LL>>A(n+1,vector<LL>(26));
	string s;cin>>s;
	LL ans=0;
	
	for(LL i=1;i<=n;i++)
	{
		char ch=s[i-1];
		LL f=1;
		
		for(LL j=0;j<26;j++)
		{
			if(j+'a'!=ch)
			{
				f*=(A[i-1][j]+1);
				f%=MOD;
			}
			else
			{
				A[i][j]+=1;
			}
			A[i][j]+=A[i-1][j];
		}
		//cout<<i<<" "<<f<<endl;
		ans+=f;
		ans%=MOD;
	}
	cout<<ans<<endl;
}
	
	
				
	
	
	
			

		
		
		
	
		
			

	
				
	
		
	

			
	
    
	
	


Measured memory_bytes: 24704
#!/usr/bin/env python3 

n, T = map(int, input().split())
t = list(map(int, input().split()))
dt = [0 for _ in range(n-1)]

for i in range(n-1):
    dt[i] = t[i+1]-t[i]

ans = 0 
for i in range(n-1):
    if dt[i] <= T:
        ans += dt[i]
    else:
        ans += T

print(ans+T)


Measured memory_bytes: 30824
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;


int main(void){
	ll a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int x,y;
  cin>>x>>y;
  if(x==2 ||y==2){
    cout<<"No"<<endl;
    return 0;
  }
  int a[7]={1,3,5,7,8,10,12};
  int ans=0;
  rep(i,7)if(x==a[i])ans++;
  rep(i,7)if(y==a[i])ans++;
  if(ans%2)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"

	// Reader
	"bufio"
	"os"
	"strings"
)

func main() {




	l := nextLine()

	nc, _ := strconv.Atoi(l[0])
	mc, _ := strconv.Atoi(l[1])
	dx, _ := strconv.Atoi(l[2])
	
	books := make([][]int, nc)
	for n := 0; n < nc; n++ {
		books[n] = make([]int, mc + 1)

		bl := nextLine()
		c, _ := strconv.Atoi(bl[0])
		books[n][0] = c
		for m := 1; m <= mc; m++ {
			x, _ := strconv.Atoi(bl[m])
			books[n][m] = x
		}
	}

	fmt.Printf("%d\n", exec(books, nc, mc, dx))
}

func exec(books [][]int, nc int, mc int, dx int) int {
	var patterns [][]int
	patterns = append(patterns, make([]int, nc))
	patterns = append(patterns, make([]int, nc))
	patterns[len(patterns) - 1][0] = 1

	for n := 1; n < len(books); n++ {
		tmp := patterns
		for _, p := range(tmp) {
			tp := append([]int{}, p...)
			tp[n] = 1
			patterns = append(patterns, tp)
		}
	}

	minCost := -1
	for _, pattern := range(patterns) {
		ret := checkBooks(pattern, books, mc, dx)
		if ret == -1 {
			continue
		}
		if minCost == -1 || ret < minCost {
			minCost = ret
		}
	}
	return minCost
}


func checkBooks(pattern []int, books [][]int, mc int, dx int) int {
	totals := make([]int, mc + 1)
	for key, book := range(books) {
		if pattern[key] == 0 {
			continue
		}

		for k, v := range(book) {
			totals[k] += v
		}
	}

	for m := 1; m <= mc; m++ {
		if totals[m] < dx {
			return -1
		}
	}

	return totals[0]
}

func remove(books [][]int, search int) [][]int {
    result := [][]int{}
    for k, v := range books {
        if k != search {
            result = append(result, v)
        }
    }
    return result
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

// Reader
var limit int = 100000
var rdr = bufio.NewReaderSize(os.Stdin, limit)

func nextLine() []string {
	return parseLine(readLine())
}

func readLine() string {
	buf := make([]byte, 0, limit)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func parseLine(s string) []string {
	slice := strings.Split(s, " ")
	return slice
}


Measured memory_bytes: 3128
import scala.io.StdIn.readLine

object Types {
  type Roll = ((Int,Int,Int,Int,Int,Int))=>(Int,Int,Int,Int,Int,Int)
}
import Types._

class Dice(var d:(Int,Int,Int,Int,Int,Int)) {
  val fs = (x:(Int,Int,Int,Int,Int,Int)) => x match {case (x1,x2,x3,x4,x5,x6) => (x5,x1,x3,x4,x6,x2) }
  val fw = (x:(Int,Int,Int,Int,Int,Int)) => x match {case (x1,x2,x3,x4,x5,x6) => (x3,x2,x6,x1,x5,x4) }

  def roll(dir:Char)  =
    dir match {
      case 'S' => fs
      case 'N' => fs compose fs  compose fs
      case 'W' => fw
      case 'E' => fw compose fw compose fw
    }

  def apply(f:Roll) = this.d = f(this.d)
  def getTopFace() = d._1.toString
}

object Main extends App {

  val faces = readLine.split(" ").map(_.toInt) match { case Array(x1,x2,x3,x4,x5,x6) => (x1,x2,x3,x4,x5,x6) }
  val dice = new Dice(faces)
  var rolls:Roll = x=>x

  dice.apply(readLine.foldLeft(rolls) { (x:Roll,y) => dice.roll(y) compose x })
  println(dice.getTopFace)
}

Measured memory_bytes: 44128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B; cin >> A >> B;
  
  if(A != 1 && B != 1) cout << 1 << endl;
  if(A != 2 && B != 2) cout << 2 << endl;
  if(A != 3 && B != 3) cout << 3 << endl;
}

Measured memory_bytes: 256
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, W = list(map(int, sys.stdin.readline().split()))
    h, w = list(map(int, sys.stdin.readline().split()))
    print(H*W-(h*W)-(w*H)+h*w)



if __name__ == '__main__':
    main()


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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int get_int(){int x;scanf("%d",&x);return x;}
LL get_long(){LL x;scanf("%lld",&x);return x;}

LL W;
int N;
vector<int> V[4];


int main()
{
    N = get_int();
    W = get_long();
    int w1;
    int v;
    scanf("%d %d",&w1,&v);
    V[0].push_back(v);

    _for(i,1,N){
        int w;scanf("%d %d",&w,&v);
        V[w-w1].push_back(v);
    }
    _for(i,0,4){
        sort(ALL(V[i]),greater<int>());
    }

    int a = V[0].size()+1;
    int b = V[1].size()+1;
    int c = V[2].size()+1;
    int d = V[3].size()+1;

    int can[a][b][c][d];
    int weigh[a][b][c][d];
    LL value[a][b][c][d];

    //cout << a << b << c << d;
    memset(can,0,sizeof(can));
    memset(weigh,0,sizeof(weigh));
    memset(value,0,sizeof(value));

    can[0][0][0][0] = 1;

    while(true){
        int ok = 0;
        _for(i,0,a){
            _for(j,0,b){
                _for(k,0,c){
                    _for(l,0,d){
                        if(can[i][j][k][l] == 1){
                            ok = 1;
                            int ww = weigh[i][j][k][l];
                            LL vv = value[i][j][k][l];

                            if(i+1 < a){
                                if(W >= ww + w1 && !can[i+1][j][k][l]){
                                    can[i+1][j][k][l] = 1;
                                    weigh[i+1][j][k][l] = ww + w1;
                                    value[i+1][j][k][l] = vv + V[0][i];
                                }
                            }
                            if(j+1 < b){
                                if(W >= ww + w1 + 1 && !can[i][j+1][k][l]){
                                    can[i][j+1][k][l] = 1;
                                    weigh[i][j+1][k][l] = ww + w1 + 1;
                                    value[i][j+1][k][l] = vv + V[1][j];
                                }
                            }
                            if(k+1 < c){
                                if(W >= ww + w1 + 2 && !can[i][j][k+1][l]){
                                    can[i][j][k+1][l] = 1;
                                    weigh[i][j][k+1][l] = ww + w1 + 2;
                                    value[i][j][k+1][l] = vv + V[2][k];
                                }
                            }
                            if(l+1 < d){
                                if(W >= ww + w1 + 3 && !can[i][j][k][l+1]){
                                    can[i][j][k][l+1] = 1;
                                    weigh[i][j][k][l+1] = ww + w1 + 3;
                                    value[i][j][k][l+1] = vv + V[3][l];
                                }
                            }

                            can[i][j][k][l] = -1;
                        }
                    }
                }
            }
        }
        if(!ok) break;
    }

    LL maxv = 0;
    _for(i,0,a) _for(j,0,b) _for(k,0,c) _for(l,0,d) maxv = max(maxv,value[i][j][k][l]);
    printf("%lld\n",maxv);

    return 0;
}


Measured memory_bytes: 7424
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nq=arr[0].split(" ").map(Number);
var s = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<s.length;i++){
   if(s[i]=="C" && s[i-1]=="A")cnt++;
   a.push(cnt);
}
var ans=[];
while(ans.length < nq[1]) {
   var lr=arr[ans.length+2].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
}
console.log(ans.join("\n"));

Measured memory_bytes: 34640
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=1e6+5;
int n;
int a[N];
int cnt(int n){
	if (n==0)
		return 0;
	int res=0;
	while (n%2==0)
		res++,n/=2;
	return res;
}
int main(){
	n=read();
	For(i,1,n)
		scanf("%1d",&a[i]),a[i]--;
//	outarr(a,1,n);
	int flag=0;
	For(i,1,n)
		if (a[i]==1)
			flag=1;
	if (flag)
		For(i,1,n)
			a[i]%=2;
	else
		For(i,1,n)
			a[i]/=2;
	int ans=0;
	int c=0;
	For(i,1,n){
		if (a[i])
			ans^=c==0;
		c+=cnt(n-i)-cnt(i);
	}
	if (!flag)
		ans*=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

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

    r = (n >= 10) ? r : r + 100 * (10 - n);
    cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;
  int dp1[3001] = {0}; 
  int dp2[3001] = {0};
  dp1[0] = 1;
  dp2[0] = 1;
  REP(x,3001){
    if(dp1[x]){
      if(x+A<3001){ dp1[x+A] = 1;}
      if(x+B<3001){ dp1[x+B] = 1;}
    }
    if(dp2[x]){
      if(x+C<3001){ dp2[x+C] = 1;}
      if(x+D<3001){ dp2[x+D] = 1;}
    }
  }
  
  int p = 0;
  int q = A;
  for(int x=1; x<=F/100; x++){
    if(!dp1[x]){continue;}
    for(int y = 0; x*100+y<=F; y++){
      if( y>x*E){break;}
      if(!dp2[y]){continue;}
      if(y*q>x*p){
        p = y;
        q = x;
      }
    }
  }
  printf("%d %d\n",p+q*100,p);
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		
		List<Integer> arr = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			arr.add(d);
            }
			
			if(!arr.contains(X))
			{System.out.println(X);}
		else{
		for(int i = 0; i < 101; i++){
			if(!arr.contains(X-i))
			{System.out.println(X-i);break;}
		else if(!arr.contains(X+i))
			{System.out.println(X+i);break;}
		}
		
	
	}
}
}

Measured memory_bytes: 35896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define lSOne(x)(x&-x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 100 + 9;

ll x; vector<ld> vec;
int main(){
    FASTIO //ONLINE__JUDGE();

    cin >> x; vec.resize(x);
    for ( ld& i : vec ) cin >> i;
    sort( all(vec) );

    ld sum = vec.front();
        for ( int i = 1; i < SZ(vec); ++i ){
            sum += vec[i]; sum /= 2;
        }
    cout << fixed << setprecision(10) << sum; return 0;


    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;

  if (a<b){
    cout << "a < b" <<endl;
  }
  if (a==b){
    cout << "a == b" <<endl;
  }
  if (a>b){
    cout << "a > b" <<endl;
  }
}



Measured memory_bytes: 3080
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = 0;
        char A = 'A';
        char B = 'B';
        char C = 'C';
        int N = sc.nextInt();
        String S = sc.next();

        char[] s = S.toCharArray();

        for(int i = 0; i < N-2; i++) {
            if (s[i] == A) {
                if (s[i+1] == B) {
                    if (s[i+2] == C) {
                        X++;
                    }
                }
            }
        }
        System.out.println(X);
    }
}

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

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

    int n, m;
    cin >> n >> m;

    vector<bool> a(n + 1, true);
    REP(i, m) {
        int tmp;
        cin >> tmp;
        a[tmp] = false;
    }

    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    for (int now = 0; now < n; now++) {
        for (int next = now + 1; next <= min(n, now + 2); next++) {
            if (a[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }

    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input);
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input.chars().collect::<Vec<char>>();

    if list[0] == list[1] && list[0] == list[2] || list[3] == list[2] && list[3] == list[1] {
        "Yes"
    } else {
        "No"
    }.to_string()
}

#[test]
fn test() {
    let tests = vec![("1118", "Yes"), ("7777", "Yes"), ("1234", "No")];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  
    if(N<10){
      cout<<N<<endl;
    }
    else if(N<100){
      cout<<9<<endl;
    }
    else if(N<1000){
      cout<<9+N-100+1<<endl;
    }
    else if(N<10000){
      cout<<909<<endl;
    }
    else if(N<100000){
      cout<<909+N-10000+1<<endl;
    }
    else{
      cout<<90909<<endl;
    }
}

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

bool fun(pair<ll,ll>& a,pair<ll,ll>& b)
{
    if(a.first<b.first) return true;
    if(a.first==b.first && a.second > b.second) return true;
    return false;
}

ll max_value(ll w,ll position,vector<vector<ll>>& knapsack,vector<pair<ll, ll>>& arr)
{
    if(position<=0) return 0;
    
    if(knapsack[position][w]!=-1) return knapsack[position][w];
    
    if(arr[position].first > w)
        return knapsack[position][w]=max_value(w, position-1, knapsack, arr);
    else
        return knapsack[position][w]=max(arr[position].second+max_value(w-arr[position].first, position-1, knapsack, arr),max_value(w, position-1, knapsack, arr));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll items,weight,value,target;
    cin>>items>>target;
    vector<pair<ll,ll>> arr;
    arr.push_back(make_pair(0, 0));
    for(auto i=1;i<=items;i++)
    {
        cin>>weight>>value;
        arr.push_back(make_pair(weight,value));
    }
    
    sort(arr.begin(),arr.end(),fun);
    vector<vector<ll>> knapsack(items+1,vector<ll>(target+1,-1));
    
    cout<<max_value(target, items, knapsack, arr);
    
    
    return 0;
}

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

int main(){
    
    int K,A,B;
    cin >> K;
    cin >> A >> B;
if (K>B){
    cout << "NG" << endl;
}
else if (A%K==0 || B%K==0 || (B-(B%K)>=A)){
    cout << "OK" << endl;
}else{
    cout << "NG" << endl;
}

}

Measured memory_bytes: 3636