akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
struct edge{int x,y,c,next;}a[12*MAXN];int len=1,last[2*MAXN];
void ins(int x,int y,int c)
{
	len++;a[len].x=x;a[len].y=y;a[len].c=c;a[len].next=last[x];last[x]=len;
	len++;a[len].x=y;a[len].y=x;a[len].c=0;a[len].next=last[y];last[y]=len;
}
int h[2*MAXN],S,T;
queue<int> li;
bool bt_h()
{
	memset(h,0,sizeof(h));h[S]=1;
	li.push(S);
	while(!li.empty())
	{
		int x=li.front();li.pop();
		for(int k=last[x];k;k=a[k].next)
		{
			int y=a[k].y;
			if(a[k].c&&!h[y])h[y]=h[x]+1,li.push(y);
		}
	}return h[T];
}
int cur[2*MAXN];
int findflow(int x,int f)
{
	if(x==T)return f;
	int s=0,t;
	for(int &k=cur[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(h[y]==h[x]+1&&a[k].c&&s<f)
		{
			s+=(t=findflow(y,min(a[k].c,f-s)));
			a[k].c-=t;a[k^1].c+=t;
		}
		if(s==f)break;
	}if(!s)h[x]=0;
	return s;
}
int n,P[MAXN],Q[MAXN],bl1[MAXN],bl2[MAXN],vis[MAXN],siz1,siz2;
void dfs1(int x){if(vis[x])return ;vis[x]=1;bl1[x]=siz1;dfs1(P[x]);}
void dfs2(int x){if(vis[x])return ;vis[x]=1;bl2[x]=siz2;dfs2(Q[x]);}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)P[i]=read()+1;
	for(int i=1;i<=n;i++)Q[i]=read()+1;
	for(int i=1;i<=n;i++)if(!vis[i])++siz1,dfs1(i);memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)if(!vis[i])++siz2,dfs2(i);
	int cnt=0;S=siz1+siz2+1;T=S+1;
	for(int i=1;i<=n;i++)
	{
		if(P[i]==i&&Q[i]==i)++cnt;
		else if(P[i]==i)ins(siz1+bl2[i],T,1);
		else if(Q[i]==i)ins(S,bl1[i],1);
		else
		{
			ins(siz1+bl2[i],bl1[i],1);
			if(P[i]==Q[i])ins(bl1[i],siz1+bl2[i],1);
		}
	}
	while(bt_h())
	{
		memcpy(cur,last,sizeof(cur));
		cnt+=findflow(S,999999999);
	}
	pr2(n-cnt);
	return 0;
}


Measured memory_bytes: 12544
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll a;
    cin >> a;
    long double b;
    cin >> b;
    b = 1/b;
    long double c = a/b;
    dunk((ll)c);
    return 0;
}

Measured memory_bytes: 3732
/*
https://atcoder.jp/contests/dp/tasks/dp_m
*/

#include <bits/stdc++.h>
using namespace std;
const int N = 100, K = 1e5+1,mod=1e9+7;
int pre[K+1][N];
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,k;
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> a[i];
  // dp[0][0] = 1;
  for(int c=0;c<n;c++) {
    for(int r=0;r<=k;r++) {
      if (c==0) {
        if (r <= a[c]) pre[r+1][c] = 1;
        pre[r+1][c] += (pre[r][c])%mod;
        continue;
      }
      // dp[r][c] = (pre[r+1][c-1] - pre[max(0,r-a[c])][c-1] + mod)%mod;
      auto val = (pre[r+1][c-1] - pre[max(0,r-a[c])][c-1] + mod)%mod;

      // for(int i=r;i>=max(0,r-a[c]);i--) {
      //   dp[r][c] += dp[i][c-1];
      //   dp[r][c] %= mod;
      // }
      pre[r+1][c] = (pre[r][c] + val)%mod;
      // assert((pre[r+1][c] - pre[r][c] + mod)%mod == dp[r][c]);
    }
  }
  cout << (pre[k+1][n-1] - pre[k][n-1] + mod)%mod << '\n';
  return 0;
}

Measured memory_bytes: 39424
#include <iostream>
#include <string.h>

using namespace std;
void serch(const string &st,int c[26])
{
  char cmp = 'a';
  char cmp2 ='A';
  for(int i = 0;i < 26;i++)
  {
    for(int j = 0; j < st.size(); j++)
    {
      if(cmp + i == st[j])c[i]++;
      if(cmp2 + i == st[j])c[i]++;
    }
  }
}
int main()
{
  string a;
  char b = 'a';
  int c[26] = {0};
  while(getline(cin,a))
  {
    serch(a,c);
  }
  for(int i = 0; i< 26 ; i++)
  {
    cout<< (char)(b + i) << " : "<<c[i]<<endl;
  }

  return 0;
}



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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, len[max_n];

void write(const set<pair<int, int>> &q) {
    for (auto p : q) {
        cout << "(" << p.first << " " << p.second << ") ";
    }
    cout << endl;
}

bool check(int cnt) {
    set<pair<int, int>> q;
    int last_len = 0;
    for (int i = 0; i < n; ++i) {
        //cout << i << ": ";
        //write(q);
        if (last_len < len[i]) {
            last_len = len[i];
            continue;
        }
        while (!q.empty()) {
            pair<int, int> p = *q.rbegin();
            if (p.first > len[i]) {
                q.erase(p);
            } else {
                break;
            }
        }
        if (cnt == 1) {
            return false;
        }
        last_len = len[i];
        int pos = len[i], ok = 0;
        while (!q.empty()) {
            pair<int, int> p = *q.rbegin();
            if (p.first < pos) {
                q.insert({pos, 2});
                ok = 1;
                break;
            }
            q.erase(p);
            if (p.second < cnt) {
                ++p.second;
                q.insert(p);
                ok = 1;
                break;
            }
            --pos;
        }
        if (ok) {
            continue;
        }
        if (pos == 0) {
            return false;
        }
        q.insert({pos, 2});
    }
    //write(q);
    return true;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &len[i]);
    }
    //cout << check(2) << endl;
    //return 0;
    int l = 0, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    printf("%d\n", r);
    return 0;
}


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

using namespace std;
int main()
{
    int n;
    cin >> n;
//    map<int,int> m;
    long long v[100001] = {0};
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        v[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        v[c] += v[b];
        sum += v[b] * (c - b);
        v[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 4356
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = x/100;
      int z = x%100;
      for(int i=5;i>=1;i--){
        int k = z/i;
        z-=k*i;
        y-=k;
      }
      if(y>=0)System.out.println(1);
      else System.out.println(0);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N; long long K;
    cin >> N >> K;
    vector<pair<long long, long long> > v(N);
    for (int i = 0; i < N; ++i) cin >> v[i].first >> v[i].second;

    // ソート
    sort(v.begin(), v.end());
    
    // a_i が小さい順に b_i を合計して K 以上になる瞬間をとらえる
    long long res = 0;
    long long sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += v[i].second;
        if (sum >= K) {
            res = v[i].first; // sum >= K になった瞬間の a_i
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int vis[1000005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=7;
	int m;
	cin>>m;vis[t%m]=1;
	if(t%m==0){
		cout<<1;RE 0;
	}
	FOR(i,2,m){
		t=t*10+7;
		t%=m;
		if(vis[t]){
			cout<<-1;RE 0;
		}else{
			if(!t){
				cout<<i;RE 0;
			}else{
				vis[t]=1;
			}
		}
	}
	RE 0;
}




Measured memory_bytes: 7512
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))
    K = int(readline())

    A.sort()
    for _ in range(K):
        A[-1] *= 2

    print(sum(A))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8984
import numpy as np
from sys import stdin

'''
Reference: https://codeforces.com/blog/entry/75046#comment-591494 (1-based index)

(0-based index)

For a sequence A[l]..A[k]..A[r] with sum S contributes l * (N - r) to answer.
    0, 1, 2, ..., l....k....r, ..., N - 2, N - 1
    x  x  x   x   x         v   v     v      v
There are l `x` and (N - r) `v`.

Enumerate all possible sequence is impossible. 
Let's consider all sequeuces with sum S and **ends** at r:
    A[l1]...A[r] -> l1 * (N - r)
    A[l2]...A[r] -> l2 * (N - r)
    A[l3]...A[r] -> l3 * (N - r)
    .
    .
    .
which contributes (l1 + l2 + ... + lm) * (N - r) in total.

We can find *sum of left index for all valid sequence* for each r using DP.

    dp[i][s] = the sum of left index for all sequence that
                    1. ends at i
                    2. has sum s
    
    dp[i][:A[i]] = 0  since any sequence ends at i has sum >= A[i]

    dp[i][A[i]] = i + 1
    dp[i][s] = sum(dp[j][s - A[i]] for j in range(i))

    Take A = [2, 3, 4] for example, sequences that end at A[2] are:
    
             [      4] -> dp[2][4] = 3
             [2,    4] ↘
             [   3, 4] -> dp[2][s] = dp[2][s - 4] for all s
             [2, 3, 4] ↗
    
    The answer is dp[r][S] * (N - r) for r in range(N)

So the naive implementation is:

    dp = np.zeros((N, max(S, A.max()) + 1), dtype=np.int64)
    for i, a in enumerate(A):
        dp[i, a] = i + 1
        for s in range(a + 1, S + 1):
            dp[i, s] = dp[:i, s - a].sum() % M  # can be optimized
    
    ans = 0
    for i in range(N):
        ans += (N - i) * dp[i, S]
        ans = ans % M

has time O(N * S * N) which results in TLE.

Using another array to store the cumsum (prefix sum) of dp solves the problem:
'''

N, S = map(int, input().split())
A = np.int32(input().split())
M = 998244353
V = max(A.max(), S)

ans = 0
dp = np.zeros((N, V + 1), dtype=np.int64)
cs = np.zeros(V + 1, dtype=np.int64)
for i, a in enumerate(A):
    dp[i, a] = i + 1
    dp[i, a + 1 : S + 1] = cs[np.arange(a + 1, S + 1) - a]
    cs = (cs + dp[i]) % M
    ans = (ans + (N - i) * dp[i, S]) % M
print(ans)


Measured memory_bytes: 82764
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    int N, K; cin >> N >> K;
    vector<bool> cnt(N, false);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            --a;
            cnt[a] = true;
        }
    }
    int ans = 0;
    rep(i, N) {
        if(!cnt[i])++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

li = [[0, a], [1, b], [2, c], [3, d], [4, e]]
idx = sorted(list(map(lambda x: [x[0], (x[1] % 10) + 10] if (x[1] % 10) == 0 else [x[0], (x[1] % 10)], li)), key=lambda x: x[1])[0][0]
print(sum(map(lambda x: li[x][1] if x == idx else math.ceil(li[x][1] * 0.1) * 10, [0, 1, 2, 3, 4])))


Measured memory_bytes: 38768
#include <stdio.h>
#include <map>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;

const int N=100100;
int n,a[N];
map<int,int>f;
int main(void){
  scanf("%d",&n);
  REP(i,0,n)scanf("%d",a+i);
  REP(i,0,n){
    f[a[i]]++;
  }
  int ans=0;
  for(auto e:f){
    ans+=e.second-(e.second>=e.first?e.first:0);
  }
  printf("%d\n",ans);
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    int a;
    for (int i = 0; i < 5; ++i) {
        cin >> a;
        if (a == 0) {
            cout << (i+1) << endl;
        }
    }
    return 0;
}



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

typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int MID = 1e5 + 3;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main(){
	speed;
	int n;
	cin >> n;
	int mx = 0;
	ll ans = 0;
	forn(i, n){
		int x;
		cin >> x;
		if(x > mx){
			mx = x;
		}
		else{
			ans += mx - x;
		}
	}
	cout << ans;
}

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

int main()
{
  int n;
  cin >> n;
  if (n % 2 == 0)
  {
    double odd = n / 2;
    cout << fixed << setprecision(10) << odd / n << endl;
    return 0;
  }
  else
  {
    double odd = n / 2 + 1;
    cout << fixed << setprecision(10) << odd / n << endl;
    return 0;
  }
}

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

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif

template<typename T>
T& ckmin(T& a, T b){ return a = a > b ? b : a; }

template<typename T>
T& ckmax(T& a, T b){ return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

namespace ioUtils {

    char vector_delimiter = ' ';

    template<typename T>
    istream& operator >>(istream&, vector<T>&);

    template<typename... Ts>
    istream& operator >>(istream& is, pair<Ts...>& p){
        is >> p.first >> p.second;
        return is;
    }

    template<typename T> 
    istream& operator >>(istream& is, vector<T>& v){
        for(auto& e : v) is >> e;
	       return is;
    }

    template<typename T>
    ostream& operator <<(ostream&, vector<T>&);

    template<typename... Ts>
    ostream& operator <<(ostream& os, pair<Ts...>& p){
        os << p.first << " " << p.second;
        return os;
    }

    template<typename T>
    ostream& operator <<(ostream& os, vector<T>& v){
        for(auto&& e : v) os << e << vector_delimiter;
        return os;   
    }   
}

using namespace ioUtils;


signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif

    int N;
    cin >> N;
   	vector<vi> v(N, vi(3));
   	cin >> v;
   	vector<vi> dp(N + 1, vi(3));
   	rep3(i, N - 1, 0, -1)
   		rep(j, 3) rep(k, 3)
   			if(j != k) ckmax(dp[i][j], v[i][j] + dp[i + 1][k]);
   	
   	cout << max({dp[0][0], dp[0][1], dp[0][2]}) << '\n';

    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}


Measured memory_bytes: 14228
#include<stdio.h>

int main()

{
    int H,K,B,N,P;

    scanf("%d%d%d",&H,&K,&N);

    if(H>K)
        B=H;
    else
        B=K;

    if (N%B==0)

        P=N/B;
    else
        P=(N/B)+1;

    printf("%d",P);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (int)(1e9+7)
#define int long int

using namespace std;

void solve(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    for(char &c:s){
        int v=c-'A';
        v+=k;
        v%=26;
        c='A'+v;
    }
    cout<<s;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

int main()
{
    int a[6], c, n, m;
    char command;
    for (int i = 0; i < 6; i++)
    {
        cin >> a[i];
    }
    cin.get(command);
    while (1)
    {
        cin.get(command);
        if (command == '\n')
        {
            break;
        }
        else if (command == 'N')
        {
            n = 1;
        }
        else if (command == 'W')
        {
            n = 2;
        }
        else if (command == 'E')
        {
            n = 3;
        }
        else
        {
            n = 4;
        }

        c = a[0];
        a[0] = a[n];
        a[n] = a[5];
        a[5] = a[5 - n];
        a[5-n] = c;     
    }
    cout << a[0] << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
typedef long long ll;

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; }

int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  
  cout << setprecision(13);
  int flag=0;

  if(x*2==W&&y*2==H)
    flag=1;
  cout << (double)W*H/2.0 << " "  << flag << endl;
  
  
  
  
  
  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	a := io.ScanInts(n)
	b := io.ScanInts(n)
	c := io.ScanInts(n)

	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)

	var count int
	for i := 0; i < n; i++ {
		aCount := sort.SearchInts(a, b[i])
		ci := sort.Search(len(c), func(j int) bool { return c[j] > b[i] })
		count += aCount * (n - ci)
	}

	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int N;
	cin >> N;
	vector <ll> inputs( N ), vec( N );
	ll temp = 0;
	rep( i, 0, N ){
		cin >> inputs[ i ];
		temp += inputs[ i ];
	}
	rep( i, 0, N ){
		temp -= inputs[ i ];
		vec[ i ] = temp % k_mod;
	}
	ll sum = 0;
	rep( i, 0, N ){
		sum += ( inputs[ i ] * vec[ i ] ) % k_mod;
		sum %= k_mod;
	}
	cout << sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 6384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 3005;
const int mo = 1e+9+7;

int n,m;
int a[N],R[N];
int pre[N],ps[N];
int f[N][N];

int add(int x,int y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	n=get();m=get();
	fo(i,1,n){
		char ch;
		while(ch=getchar(),ch<'0'||ch>'1');
		a[i]=ch-'0';
	}
	fo(i,1,m){
		int l=get(),r=get();
		R[l]=max(R[l],r);
	}
	fo(i,1,n){
		if (R[i]>pre[i-1])pre[i]=R[i];
		else R[i]=0,pre[i]=pre[i-1];
	}
	fo(i,1,n)ps[i]=ps[i-1]+a[i];
	f[0][0]=1;
	fo(i,0,n-1){
		if (!R[i+1]&&pre[i+1]<i+1)f[i+1][0]=f[i][0];
		if (!R[i+1]&&pre[i+1]>=i+1){
			int cnt=pre[i]-i;
			fo(j,0,n){
				if (j)f[i+1][j-1]=add(f[i+1][j-1],f[i][j]);
				if (cnt-j)f[i+1][j]=add(f[i+1][j],f[i][j]);
			}
		}
		if (R[i+1]){
			int cnt=R[i+1]-i,ad=ps[R[i+1]]-ps[max(i,pre[i])];
			fo(j,0,n){
				if (j+ad)f[i+1][j+ad-1]=add(f[i+1][j+ad-1],f[i][j]);
				if (cnt-(j+ad))f[i+1][j+ad]=add(f[i+1][j+ad],f[i][j]);
			}
		}
	}
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 35456
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n+1];
	int b[n+1];
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[i] = i;
	}
	int cnt = 0;
	for (int i = 1;i<=n;i++)
	{
		if(a[i]!=b[i])
		cnt++;
	}
	if(cnt >= 3)
	{
		cout << "NO";
	} 
	else
	cout << "YES";
	
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int n;
    cin >> n;

    if (400 <= n && n <= 599) {
        cout << 8 << endl;
    } else if (600 <= n && n <= 799) {
        cout << 7 << endl;
    } else if (800 <= n && n <= 999) {
        cout << 6 << endl;
    } else if (1000 <= n && n <= 1199) {
        cout << 5 << endl;
    } else if (1200 <= n && n <= 1399) {
        cout << 4 << endl;
    } else if (1400 <= n && n <= 1599) {
        cout << 3 << endl;
    } else if (1600 <= n && n <= 1799) {
        cout << 2 << endl;
    } else if (1800 <= n && n <= 1999) {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;

    for(int i = 1 ; i < n ; i++){
        if(s[i] != s[i - 1]){
            ans++;
        }
    }

    cout << ans;
}

Measured memory_bytes: 512
s = list(str(input()))
w_1 = 0  # 1
b_1 = 0  # 0と違う個数

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            w_1 += 1
        else:
            b_1 += 1
    else:
        if s[i] == "1":
            w_1 += 1
        else:
            b_1 += 1


print(min(b_1, w_1))

Measured memory_bytes: 3956
use proconio::input;

fn main() {
    input! {
        n: usize,
        h: [(i32, i32, i32); n]
    };
    let mut dp = vec![[0; 3]; n];
    dp[0][0] = h[0].0;
    dp[0][1] = h[0].1;
    dp[0][2] = h[0].2;
    for i in 1..n {
        dp[i][0] = dp[i-1][1].max(dp[i-1][2]) + h[i].0;
        dp[i][1] = dp[i-1][2].max(dp[i-1][0]) + h[i].1;
        dp[i][2] = dp[i-1][0].max(dp[i-1][1]) + h[i].2;
    }
    println!("{}", dp[n-1].iter().max().unwrap());
}


Measured memory_bytes: 6020
#include<stdio.h>
int A;
int B;
int AA;
int main(void){
  scanf("%d",&A);
  scanf("%d",&B);
  if(A==1){
    if(B==2){
      AA = 3;}
    else{
      AA = 2;}
  }
  else if(A==2){
    if(B==1){
      AA =3;}
    else{
      AA =1;}
  }
  else if(A==3){
    if(B==1){
      AA=2;}
    else{
      AA=1;}
  }
    printf("%d",AA);
  }
    

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

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

constexpr int MOD =1'000'000'007;
ModInt<MOD> dp[10000+1000][2][200];


signed main(){
	string S; int D; cin>>S>>D;
	dp[0][0][0]=1;
	int N=S.size();
	for(int i=0;i<N;i++){
		for(int smaller=0;smaller<2;smaller++){
			for(int j=0;j<=D;j++){
				for(int x=0;x<=(smaller ? 9 : S[i]-'0');x++){
					dp[i+1][smaller or x<(S[i]-'0')][(j+x)%D]+=dp[i][smaller][j];
				}
			}
		}
	}
	cout<< dp[N][0][0]+dp[N][1][0]-1 <<endl;
}


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

int main(){
    int a,b,c,temp;
    cin >> a>>b>>c;
    if(a>b){
        temp = a;
        a = b;
        b = temp;
    }if(b>c){
        temp = b;
        b = c;
        c = temp;
    }if(a>b){
        temp = a;
        a = b;
        b = temp;   
    }
    cout << a <<" " << b << " "<< c << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a%3==0 || b%3==0 ||(a+b)%3==0)
        cout<<"Possible";
        else
        cout<<"Impossible";
        
    }
    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int M,D;
	cin >> M >> D;
	int ans = 0;
	FORq(m,1,M){
		FORq(d,1,D){
			int d1 = d % 10;
			int d10 = d / 10;
			if (d1 <= 1) continue;
			if (d10 <= 1) continue;
			if (d1 * d10 == m) ans++;

		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second)
    {
        return a.second < b.second;
    }
    else
    {
        return a.first < b.first;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<pair<int, int>> bc(m);

    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> bc[i].first >> bc[i].second;

    sort(a.begin(), a.end());
    sort(bc.rbegin(), bc.rend(), compare_by_b);

    int n_bc = 0, used_bc = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] < bc[n_bc].second)
        {
            a[i] = bc[n_bc].second;
            used_bc++;
            if (used_bc >= bc[n_bc].first)
            {
                n_bc++;
                used_bc = 0;
            }
        }
        else
            break;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a[i];
    }


    cout << ans << endl;

    return 0;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　


Measured memory_bytes: 1408
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()
a = RI()

s = 0
for i in a:
    s ^= i
# print(s)

l = []
for i in a:
    b = i^s
    l.append(b)
myoutput(l,True)

Measured memory_bytes: 121720
n, x, m = map(int, input().split())
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
    if X[x] > -1:
        cyc_len = len(P) - X[x]
        nxt_len = (n - X[x]) % cyc_len
        pre = P[X[x]][1]
        cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
        nxt = P[X[x]+nxt_len][1] - P[X[x]][1]
        print(pre + cyc + nxt)
        exit()
    P.append([x, sum_p])
    sum_p += x
    X[x] = i
    x = x*x % m
print(sum_p)


Measured memory_bytes: 19184
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[200020], sum[200020];
    cin >> n;
    for (int i = 0; i < n; i++) {
        sum[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i != 0) sum[i] += a[i] + sum[i - 1];
        else sum[0] = a[0];
    }
    sort(sum, sum + n);
    
    
    ll ans = 0, cons = 1;
    for (int i = 0; i < n; i++) {
        if (i == n - 1) {
            if (cons > 1) ans += cons * (cons - 1) / 2;
            if (sum[i] == 0) ans += cons;
        }
        else if (sum[i] == sum[i + 1]) cons++;
        else {
            if (cons > 1) ans += cons * (cons - 1) / 2;
            if (sum[i] == 0) ans += cons;
            cons = 1;
        }
    }
    
    cout << ans << endl;
    //for (int i = 0; i < n; i++) cout << sum[i] << " ";
}


Measured memory_bytes: 3328
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

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

int X, Y;
int TX, TY, KX, KY;
int field[64][64];
int done[52][52][52][52];

int main(void) {
    while (1) {
        cin >> X >> Y;
        if (X == 0 && Y == 0) break;
        cin >> TX >> TY;
        cin >> KX >> KY;
        for (int i = 0; i <= X; i++) {
            for (int j = 0; j <= Y; j++) {
                for (int k = 0; k <= X; k++) {
                    for (int l = 0; l <= Y; l++) {
                        done[i][j][k][l] = -1;
                    }
                }
            }
        }
        for (int i = 1; i <= Y; i++) {
            for (int j = 1; j <= X; j++) {
                cin >> field[i][j];
            }
        }
        queue<int> tX;
        queue<int> tY;
        queue<int> kX;
        queue<int> kY;
        tX.push(TX);
        tY.push(TY);
        kX.push(KX);
        kY.push(KY);
        done[TX][TY][KX][KY] = 0;
        bool flag = false;
        while (!tX.empty()) {
            int tx = tX.front(); tX.pop();
            int ty = tY.front(); tY.pop();
            int kx = kX.front(); kX.pop();
            int ky = kY.front(); kY.pop();
            for (int i = 0; i < 4; i++) {
                int ntx = tx + dx[i];
                int nty = ty + dy[i];
                int nkx = kx - dx[i];
                int nky = ky - dy[i];
                if (ntx < 1 || ntx > X || nty < 1 || nty > Y) {
                    ntx = tx; nty = ty;
                } else if (field[nty][ntx] == 1) {
                    ntx = tx; nty = ty;
                }
                if (nkx < 1 || nkx > X || nky < 1 || nky > Y) {
                    nkx = kx; nky = ky;
                } else if (field[nky][nkx] == 1) {
                    nkx = kx; nky = ky;
                }
                if (nkx == ntx && nty == nky) {
                    cout << done[tx][ty][kx][ky] + 1 << endl;
                    flag = true;
                    break;
                }
                if (done[ntx][nty][nkx][nky] < 0) {
                    done[ntx][nty][nkx][nky] = done[tx][ty][kx][ky] + 1;
                    tX.push(ntx);
                    tY.push(nty);
                    kX.push(nkx);
                    kY.push(nky);
                }
            }
            if (flag) break;
        }
        if (!flag) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 29376
/*
g++ -std=c++11 -o2 -Wall ABC098A.cpp -o ./out/ABC098A.out
./out/ABC098A.out
*/

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;


int main() {
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = - 1000 * 1000;
  ans = max(ans, a + b);
  ans = max(ans, a - b);
  ans = max(ans, a * b);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
num = [0]
N, X = map(int, input().split())
[num.append(i) for i in list(map(int, input().split()))]

cost = 0
for i in range(1, N+1):
    if num[i-1] + num[i] > X:
        newcost = num[i-1] + num[i] - X
        num[i] -= newcost
        cost += newcost

print(cost)


Measured memory_bytes: 19992
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int k = cin.nextInt();

        if (b - a < k * 2) {
            for (int i = a; i <= b; i++) {
                System.out.println(i);
            }
        } else {
            for (int i = a; i < a + k; i++) {
                System.out.println(i);
            }
            for (int i = b - k + 1; i <= b; i++) {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 21972
n = gets.chomp.to_i
aa = gets.split.map(&:to_i)

len  = Array.new(n,0) #1～Nまでの要素数
len2 = Array.new(n,0)
#1~nまで順番にその要素数を数え上げて
#各要素を格納する
aa.each{ |l|
    len[l-1] += 1
}
len2 = len.dup

total = 0
len.each{ |l|
    if l > 1 then
        total += l*(l-1)/2
    end
}
aa.each{ |l|
    if len[l-1] > 1 then
        p total - len[l-1]*(len[l-1]-1)/2 + (len[l-1]-1)*(len[l-1]-2)/2 
    else
        p total
    end
}

Measured memory_bytes: 32112
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200010;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// for prime mod
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vi c(n, 0);
	rep(i, n) cin >> c[i];
	vi d;
	int last = c[0];
	d.push_back(last);
	for(int i = 1; i < n; i++) {
		if(last == c[i]) continue;
		last = c[i];
		d.push_back(last);
	}
	mint dp[N];
	vi idx(N, -1);
	dp[0] = 1;
	idx[d[0]] = 0;
	for(int i = 1; i < d.size(); i++) {
		int j = idx[d[i]];
		dp[i] = dp[i-1] + (j >= 0 ? dp[j] : 0);
		idx[d[i]] = i;
	}
	cout << dp[d.size()-1].x << endl;
}


Measured memory_bytes: 4340
#include <cstdio>
#include <algorithm>
using namespace std;

struct C {
  int s;
  int i;
  
  static bool greater(const C &l, const C &r) {
    return l.s > r.s;
  }
};

int main() {
  char country[10][21];
  C obj[10];
  int n, a, b, c;
  bool flg = false;
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
    for (int i=0; i<n; i++) {
      scanf("%s %d %d %d\n", country[i], &a, &b, &c);
      obj[i].s = 3*a+c;
      obj[i].i = i;
    }
    stable_sort(obj, obj+n, C::greater);
    if (!flg) {
      flg = true;
    } else {
      printf("\n");
    }
    for (int i=0; i<n; i++) {
      printf("%s,%d\n", country[obj[i].i], obj[i].s);
    }
  }
  return 0;
}

Measured memory_bytes: 1064