akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef struct node_{
    int id;
    int left;
    int right;
    int degree;
    int sib;
    int depth;
    int height;
    int parent;
}* node;

void printTree(vector<node> tree, int n){
    for(int i = 0; i < n; i++){
        node nd = tree[i];
        char* kind = new char[15];
        if(nd -> parent == -1){
            strcpy(kind, "root");
        }else if(nd -> degree == 0){
            strcpy(kind, "leaf");
        }else{
            strcpy(kind, "internal node");
        }
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", nd -> id, nd -> parent, nd -> sib, nd -> degree, nd -> depth, nd -> height, kind);
    }
}

int culHeight(vector<node> tree, node nd){
    if(nd -> degree == 0){
        nd -> height = 0;
        return 0;
    }else if(nd -> degree == 2){
        node l = tree[nd -> left];
        node r = tree[nd -> right];
        int lheight = culHeight(tree, l);
        int rheight = culHeight(tree, r);
        int h = max(lheight, rheight);
        nd -> height = h + 1;
        return h + 1;
    }else if(nd -> degree == 1){
        int p = max(nd -> left, nd -> right);
        int h = culHeight(tree, tree[p]);
        nd -> height = h + 1;
        return h + 1;
    }
    return -500;
}

int main(){
    int n;
    scanf("%d", &n);
    vector<node> tree(n);
    vector<int> find_root(n);
    for(int i = 0; i < n; i++){
        node nd = new node_;
        tree[i] = nd;
        find_root[i] = 1;
        nd -> parent = -1;
        nd -> depth = -1;
        nd -> height = -1;
        nd -> degree = -1;
        nd -> left = -1;
        nd -> right = -1;
        nd -> sib = -1;
    }
    for(int i = 0; i < n; i++){
        int id, l, r;
        scanf("%d %d %d", &id, &l, &r);
        node nd = tree[id];
        nd -> id = id;
        nd -> left = l;
        nd -> right = r;
        if(l == -1 && r == -1){
            nd -> degree = 0;
        }else if(l == -1 || r == -1){
            int p = max(l, r);
            nd -> degree = 1;
            tree[p] -> parent = id;
            find_root[p] = 0;
        }else{
            nd -> degree = 2;
            tree[l] -> parent = id;
            tree[r] -> parent = id;
            tree[l] -> sib = r;
            tree[r] -> sib = l;
            find_root[l] = 0;
            find_root[r] = 0;
        }
    }//tree自体はできた
    
    int rootid = 0;
    while(find_root[rootid] == 0){
        rootid++;
    }
    node rootnd = tree[rootid];
    rootnd -> depth = 0;

    queue<node> Q;
    Q.push(rootnd);
    while(Q.empty() == 0){
        node nd = Q.front();
        Q.pop();
        if(nd -> degree == 2){
            Q.push(tree[nd -> left]);
            tree[nd -> left] -> depth = nd -> depth + 1;
            Q.push(tree[nd -> right]);
            tree[nd -> right] -> depth = nd -> depth + 1;
        }else if(nd -> degree == 1){
            int p = max(nd -> left, nd -> right);
            Q.push(tree[p]);
            tree[p] -> depth = nd -> depth + 1;
        }
    }
    
    int a = culHeight(tree, rootnd);
    printTree(tree, n);
    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  vi A(3);
  cin>>A[0]>>A[1]>>A[2];
  int N;
  cin>>N;
  sort(ALL(A));
  rep(i,0,N)
    A[2]*=2;
  cout<<A[0]+A[1]+A[2];
  }


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

int main(){
    long long n,l;
    cin>>n>>l;
    long long a[n],sum=0,t;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i){
            if(sum<a[i]+a[i-1]){
                sum=a[i]+a[i-1];
                t=i;
            }
        } 
    }
    if(sum<l){
            cout<<"Impossible"<<endl;
            return 0;
    }

    cout<<"Possible"<<endl;

    for(int i=1;i<t;i++){
         cout<<i<<endl;
    }
    for(int i=n-1;i>t;i--){
        cout<<i<<endl;
    }
    cout<<t;
}

Measured memory_bytes: 1536
n = int(input())
a = list(map(int, input().split()))

c = 0
i = 0
while i < n:
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            buf = a[j]
            a[j] = a[j - 1]
            a[j - 1] = buf
            c += 1
    i += 1

print(" ".join([str(x) for x in a]))
print(c)



Measured memory_bytes: 5608
<?php 
fscanf(STDIN, '%d', $a);
$initNum = 400;
$initMax = 600;
$range = 200;
for($i = 8; $i > 0; $i--) {
  if($initNum <= $a && $a < $initMax) {
   echo $i.PHP_EOL; 
  }  
  $initNum += $range;
  $initMax += $range;
}
?>

Measured memory_bytes: 15956
#include <bits/stdc++.h>
using namespace std;
int a[101],cr[101],b[26];
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	n=100;
	for(int i=51;i<=100;i++)if(a[i]<0)a[i]=0;
	for(int i=1;i<=25;i++)for(int j=i+i;j<=25;j+=i)b[i]|=1<<j-1;
	long long ans=0;
	for(int tt=0;tt<1<<25;tt++){
		bool bad=false;
		long long a2=0;
		for(int i=1;i<=25;i++)if((tt&1<<i-1)&&(tt&b[i])){
			bad=true;break;
		}
		if(bad)continue;
		for(int i=1;i<=n;i++)cr[i]=a[i];
		for(int i=1;i<=25;i++)if(tt&1<<i-1)for(int j=i;j<=n;j+=i)cr[j]=0;
		for(int i=26;i<=50;i++){
			if(i%2==0 && 3*i/2 <= 50){
				long long t[4]={
					0LL+cr[i]+cr[3*i/2]+cr[i+i]+cr[i+i+i],
					cr[i]+cr[i+i],
					cr[3*i/2],
					0
				};
				int x=max_element(t,t+4)-t;
				if(x&1)cr[3*i/2]=cr[i+i+i]=0;
				if(x>=2)cr[i]=cr[i+i]=cr[i+i+i]=0;
			}
			else if(3*i <= 100){
				if(0LL+cr[i]+cr[i+i]+cr[i+i+i]<0)cr[i]=cr[i+i]=cr[i+i+i]=0;
			}
			else{
				if(cr[i]+cr[i+i]<0)cr[i]=cr[i+i]=0;
			}
		}
		for(int i=1;i<=100;i++)a2+=cr[i];
		ans=max(ans,a2);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<ll,ll>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline ll read()
{
    ll x=0,f=1;
    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;
}
ll a[11];
ll q[51][5];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	ll n=read(),m=read(),qq=read();
	for(ll i=1;i<=qq;++i){
        q[i][1]=read();
        q[i][2]=read();
        q[i][3]=read();
        q[i][4]=read();
	}
	ll ans=0;
	for(ll x1=1;x1<=m;x1++){
            a[1]=x1;
    for(ll x2=a[1];x2<=m;x2++){
        a[2]=x2;
        for(ll x3=a[2];x3<=m;x3++){
            a[3]=x3;
            for(ll x4=a[3];x4<=m;x4++){
                a[4]=x4;
                for(ll x5=a[4];x5<=m;x5++){
                    a[5]=x5;
                    for(ll x6=a[5];x6<=m;x6++){
                        a[6]=x6;
                        for(ll x7=a[6];x7<=m;x7++){
                            a[7]=x7;
                            for(ll x8=a[7];x8<=m;x8++){
                                a[8]=x8;
                                for(ll x9=a[8];x9<=m;x9++){
                                    a[9]=x9;
                                    for(ll x10=a[9];x10<=m;x10++){
                                        a[10]=x10;
                                        ll sum=0;
                                        for(ll i=1;i<=qq;i++){
                                            ll bi=q[i][2],ai=q[i][1];
                                            if(a[bi]-a[ai]==q[i][3]) sum+=(ll)q[i][4];
                                            ans=max(sum,ans);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<ll> as(n);
    bool containsZero = false;
    rep(i, n)
    {
        cin >> as[i];
        if (as[i] == 0)
        {
            containsZero = true;
        }
    }
    if (containsZero)
    {
        cout << 0 << endl;
    }
    else
    {
        ll result = 1;
        rep(i, n)
        {
            if (result >= LLONG_MAX / as[i])
            {
                result = -1;
                break;
            }
            result *= as[i];

            ll m = 1e18;
            if (result > m || result < 0)
            {
                result = -1;
                break;
            }
        }
        cout << result << endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,d,x;cin >>n>>d>>x;
    ll ans=x;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        ans++;
        ll c=d;
        c--;
        ans+=c/a;
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if ((n | k) == 0)
				break;
			int[] s = new int[k];
			for (int i = 0; i < k; i++)
				s[i] = sc.nextInt();
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < k; j++) {
					s[j] -= sc.nextInt();
				}
			}
			boolean flag = true;
			for (int i = 0; i < k; i++) {
				if (s[i] < 0) {
					flag = false;
					break;
				}
			}
			System.out.println(flag ? "Yes" : "No");
		}
	}
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  map<int,int>m;
  for(int i=0;i<N;i++){
    m[A[i]]++;
  }
  for(int i=1;i<=N;i++){
    cout<<m[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 13516
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string A, B; cin >> A >> B;
    bool ok = true;
    rep(i, 3){
        ok &= (A[i] == B[2-i]);
    }

    cout << (ok ? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
  int h,w,i,j;
  while(scanf("%d %d",&h,&w)!=EOF){;
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++) printf("%c",(i+j)%2==0 ? '#' : '.');
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<cstdio>
#include<iostream>
#define ll long long
#define maxn 100010
using namespace std;
ll n,i,a[maxn],l,r,mid,ans,t,ans2;
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	l=1;r=1e18;
	while(l<=r)
	{
		t=mid=(l+r)/2;
		for(i=1;i<=n;i++)
			t=t/a[i]*a[i];
		if(t>=2)
		{
			if(t==2)ans=mid;
			r=mid-1;
		}else l=mid+1;
	}
	l=1;r=1e18;
	while(l<=r)
	{
		t=mid=(l+r)/2;
		for(i=1;i<=n;i++)
			t=t/a[i]*a[i];
		if(t<=2)
		{
			if(t==2)ans2=mid;
			l=mid+1;
		}else r=mid-1;
	}
	if(ans)printf("%lld %lld\n",ans,ans2);else printf("-1\n");
}

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		int pre[n];
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
		}		
		pre[0] = arr[0];
		int sum  =0;
		for(int i=1;i<n;++i)
		{
			pre[i] = max(pre[i-1],arr[i]);
			sum+=(pre[i]-arr[i]);
		}
		cout<<sum;
		
    }
    return 0;
}


Measured memory_bytes: 6744
#include<iostream>
using namespace std;
int main(){
  string a, b;
  cin >> a >> b;
  char tmp;
  for(int i=0; i<a.length(); i++){
    for(int j=i+1; j<a.length(); j++){
      if(a[i]>a[j]){
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  for(int i=0; i<b.length(); i++){
    for(int j=i+1; j<b.length(); j++){
      if(b[i]<b[j]){
        tmp = b[i];
        b[i] = b[j];
        b[j] = tmp;
      }
    }
  }
  if(a<b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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


int main(){
    int n;
    cin >> n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin >> d[i];
    sort(d.begin(),d.end());
    if(d[n/2] == d[n/2-1]){
        cout << 0 << endl;
        return 0;
    }
    else {
        cout << d[n/2] - d[n/2-1] << endl;
    }
}


Measured memory_bytes: 768
#include <iostream>
#define M 100000
using namespace std;
typedef long long llong;
llong T[M];
int n, k;

int check(llong p) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong x = 0;
		for (i; x + T[i] <= p; x += T[i++]) if (i == n)return n;
	}
	return i;
}

llong solve() {
	llong left = 0, right = M * M;
	while (right - left > 1) {
		llong mid = (right + left) / 2;
		int x = check(mid);
		if (x >= n)right = mid;
		else left = mid;
	}
	return right;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
	llong x = solve();
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3792
function Main(input) {
  lines = input.split("\n")
  N = lines[0] * 1
  s = lines[1].split(" ").map(function(i) { return i * 1})
  cnt = 0
  for (var i = 0; i < s.length - 2; i++) {
    t = s.slice(i, i + 3)
    t = t.sort(function(a, b) { return a - b })
    if (t[1] == s[i+1]) {
      cnt++
    }
  }
  console.log(cnt)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] s;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        s = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        Array.Sort(s);
        int sum = s.Sum();

        if(sum % 10 != 0)
        {
            WriteLine(sum);
            return;
        }

        if(s.Count(x => x % 10 != 0) == 0)
        {
            WriteLine(0);
            return;
        }

        for(int i = 0; i < N; i++)
        {
            if(s[i] % 10 != 0)
            {
                WriteLine(sum - s[i]);
                return;
            }
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13268
from heapq import heappush, heappop
INF = 10**20
def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(que, (dist[t], t))
    return dist

N = int(input())
edge = [[] for _ in range(N)]

for _ in range(N-1):
    a,b,c = map(int,input().split())
    edge[a-1].append((b-1,c))
    edge[b-1].append((a-1,c))

Q,K = map(int,input().split())

dist = dijkstra(N,edge,K-1)

for _ in range(Q):
    x,y = map(int,input().split())
    print(dist[x-1]+dist[y-1])

Measured memory_bytes: 46236
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val maze = (0 until h).map { readLine()!! }

    val dy = listOf(1, 0, -1, 0)
    val dx = listOf(0, 1, 0, -1)

    var ans = 0

    fun bfs(y: Int, x: Int): Int {
        var d = 0

        val queue = ArrayDeque<Triple<Int, Int, Int>>()
        val visited = Array(h) { BooleanArray(w) { false } }

        queue.addLast(Triple(y, x, 0))
        visited[y][x] = true

        while (queue.isNotEmpty()) {
            val p = queue.removeFirst()
            d = Math.max(d, p.third)

            for (i in 0 until 4) {
                val yi = p.first + dy[i]
                val xi = p.second + dx[i]

                if (yi !in 0 until h) continue
                if (xi !in 0 until w) continue
                if (maze[yi][xi] == '#') continue
                if (visited[yi][xi]) continue

                queue.addLast(Triple(yi, xi, p.third + 1))
                visited[yi][xi] = true
            }
        }

        return d
    }

    for (i in 0 until h)
        for (j in 0 until w) {
            if (maze[i][j] == '#') continue
            ans = Math.max(ans, bfs(i, j))
        }

    println(ans)
}


Measured memory_bytes: 40488
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <set>
#include <string>
#include <vector>


using namespace std;

typedef long long ll;
typedef long double ld;

ld a[1000];
ld b[1000];
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    ld ma=0.0;
    for(int j=1;j<i;j++){
      ld r=a[i];
      ld x=b[j]+a[j];//center
      ld y=a[j];
      ld dy=abs(y-r);
      ld dd=r+a[j];
      ld dx=sqrt(dd*dd-dy*dy);
      ma=max(ma,x+dx-r);
    }
    b[i]=ma;
  }
  {
    ld ma=0.0;
    for(int i=1;i<=n;i++){
      ma=max(b[i]+2*a[i],ma);
      //cout<<b[i]<<endl;
    }
    cout<<setprecision(15)<<ma<<endl;
  }
}


Measured memory_bytes: 3300
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var p = cin.ReadInt;
            var q = cin.ReadInt;
            var r = cin.ReadInt;

            var ans = 0;

            ans = Math.Min(p + q, Math.Min(q + r, r + p));

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11220
// https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int pos1 = 0, pos2 = s.length() - 1, cnt = 0;
    while (pos1 < pos2) {
        int t1 = 0, t2 = 0;
        while (s[pos1] == 'x') {
            pos1++;
            t1++;
        }
        while (s[pos2] == 'x') {
            pos2--;
            t2++;
        }
        cnt += abs(t1 - t2);
        if (s[pos1] != s[pos2]) {
            cout << "-1\n";
            return 0;
        } else {
            pos1++;
            pos2--;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    int N;
    cin >> N;
    constexpr int n = 32;
    map<ll, bitset<n>> s1, s2;
    for (int i = 0; i < 1 << (n / 2); i++) {
        ll base = 1, sum = 0;
        bitset<n> b;
        for (int j = 0; j < n / 2; j++) {
            if (i >> j & 1) {
                sum += base;
                b |= 1UL << (j * 2);
            }
            base *= 4;
        }
        s1[sum] = b;
    }
    for (int i = 0; i < 1 << (n / 2); i++) {
        ll base = 2, sum = 0;
        bitset<n> b;
        for (int j = 0; j < n / 2; j++) {
            if (i >> j & 1) {
                sum += base;
                b |= 1UL << (j * 2 + 1);
            }
            base *= 4;
        }
        s2[sum] = b;
    }

    bitset<n> ret;
    for(auto e: s1) {
        if (s2.find(e.first - N) != s2.end()) {
            ret = e.second | s2[e.first - N];
            break;
        }
    }
    stringstream ss;
    ss << ret;
    string s = ss.str();
    for (int i = 0; i + 1 < s.size(); i++) {
        if (s[i] == '1') {
            s = s.substr(i);
            break;
        }
    }
    if (s == "00000000000000000000000000000000") {
        cout << 0 << endl;
    } else {
        cout << s << endl;
    }
}

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

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> D(N,0);
  for(int i=0;i<N;i++){
    cin >> D[i];
  }
  int sum=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum += D[i]*D[j];
    }
  }
  cout << sum << endl;
}

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

#define FOR(i,n) for(int i=0;i<(n);i++)
#define FOR1(i,n) for(int i=1;i<=(n);i++)
typedef long long LL;

using namespace std;

int main(){
  LL X,Y;
  cin >> X >> Y;
  int cnt = 0;
  while(X <= Y) {
    cnt ++;
    X *= 2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int n,m,d[N],a[N],b[N], c[N];

int p[N], sz[N], col[N];

ll dl[N];

vector <int> edges, g[N], rb[N];

bool cmp(int i,int j){
	return max(d[a[i]],d[b[i]]) < max(d[a[j]],d[b[j]]);
}

int get(int v){
	if(p[v] == v) return v;
	return p[v] = get(p[v]);
}

void Merge(int u,int v,int i){
	u = get(u);
	v = get(v);
	if(u == v) return;
	rb[a[i]].pb(b[i]);
	rb[b[i]].pb(a[i]);

	c[i] = max(d[a[i]],d[b[i]]);
	sz[u] += sz[v];
	p[v] = u;
}

void dfs(int v,int cv = 1){
	col[v] = cv;
	for(int to : rb[v]){
		if(!col[to]){
			dfs(to, 3 - cv);
		}
	}
}

int main () {
	scanf("%d%d", &n, &m);

	int mn = mod;

	for(int i = 1; i <= n; i++){
		scanf("%d", &d[i]);
		mn = min(mn, d[i]);
		p[i] = i, sz[i] = 1;
	}

	int e = -1;

	for(int i = 1; i <= m; i++){
		scanf("%d%d", &a[i], &b[i]);
		edges.pb(i);
		g[a[i]].pb(i);
		g[b[i]].pb(i);
		if(d[a[i]] == mn && d[b[i]] == mn) e = i;
	}
	if(e == -1){
		printf("-1");
		return 0;
	}
	
	sort(edges.begin(), edges.end(), cmp);

	for(int i : edges){
		Merge(a[i],b[i],i);
	}

	dfs(1);

	for(int i = 1; i <= m; i++){
		if(c[i] == 0) c[i] = int(1e9);
	}

	set <pair<ll,int> > st;

	for(int i = 1; i <= n; i++){
		dl[i] = (ll)(1e18);
	}

	for(int i = 1; i <= n; i++){
		if(col[i] == 1){
			dl[i] = 0;
			st.insert(mp(dl[i], i));
		}
	}

	while(!st.empty()){
		int v = (*st.begin()).s;
		st.erase(st.begin());
		for(int i : g[v]){
			int to = (a[i] ^ b[i] ^ v);
			if(dl[to] > dl[v] + c[i]){
				st.erase(mp(dl[to],to));
				dl[to] = dl[v] + c[i];
				st.insert(mp(dl[to], to));
			}
		}
	}

	for(int i = 1; i <= n; i++){
		if(col[i] == 2){
			if(dl[i] != d[i]){
				printf("-1");
				return 0;
			}
		}
	}


	for(int i = 1; i <= n; i++){
		dl[i] = (ll)(1e18);
	}

	for(int i = 1; i <= n; i++){
		if(col[i] == 2){
			dl[i] = 0;
			st.insert(mp(dl[i], i));
		}
	}

	while(!st.empty()){
		int v = (*st.begin()).s;
		st.erase(st.begin());
		for(int i : g[v]){
			int to = (a[i] ^ b[i] ^ v);
			if(dl[to] > dl[v] + c[i]){
				st.erase(mp(dl[to],to));
				dl[to] = dl[v] + c[i];
				st.insert(mp(dl[to], to));
			}
		}
	}

	for(int i = 1; i <= n; i++){
		if(col[i] == 1){
			if(dl[i] != d[i]){
				printf("-1");
				return 0;
			}
		}
	}

	for(int i = 1; i <= n; i++){
		printf("%c", col[i] == 1 ? 'B' : 'W');
	}
	printf("\n");
	for(int i = 1; i <= m; i++){
		printf("%d\n", c[i]);
	}



 
return 0;
}

Measured memory_bytes: 39660
N=int(input())
A=list(map(int,input().split()))

d=dict()
sum=0
for i in A:
  if not i in d:
    d[i]=0
  d[i]+=1
  sum+=i
#counterと同じ
for i in range(int(input())):
  b,c=map(int,input().split())
  if not c in d:
    d[c]=0
  if not b in d:
    d[b]=0
    
  sum=sum-(d[b]*b)
  sum=sum-(d[c]*c)
  d[c]+=d[b]
  d[b]=0
  sum=sum+(d[c]*c)
  #print(d)
  print(sum)

Measured memory_bytes: 23660
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        double b=100;
        for (int i=0;i<n;i++){
        	b=Math.ceil(b*1.05);
        }
        
        System.out.println((int)b*1000);
   
    }
}

Measured memory_bytes: 17180
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	
//	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	
	long N = 0;
	long h = 0;
	long n = 0;
	long w = 0;
	boolean ans = false;
	
	public void input() throws IOException {
		N = in.nextInt();
	}

	public void solve() throws IOException {
		for(h=1;h<=3500;h++)
			for(n=1;n<=3500;n++){
				long w_bunsi=N*h*n;
				long w_bunbo=4*h*n - N*(h+n);
				if(w_bunbo > 0 && w_bunsi%w_bunbo == 0 && w_bunsi/w_bunbo <= 3500){
					w = w_bunsi/w_bunbo;
					return;
				}
			}
	}
	
	public void output() {
		out.println(h + " " + n + " " + w);
		out.flush();
	}
}



class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 23252
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int n;
string a,b,c,d,x;
int a1,b1,c1,d1;
int main(){
	scanf("%d",&n);
	a="AC";b="WA";c="TLE";d="RE";
	while(n--){
		cin>>x;
		if(x==a)a1++;
		if(x==b)b1++;
		if(x==c)c1++;
		if(x==d)d1++;
	}
	cout<<a<<" x "<<a1<<endl;
	cout<<b<<" x "<<b1<<endl;
	cout<<c<<" x "<<c1<<endl;
	cout<<d<<" x "<<d1<<endl;
}

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

int main(){
  string W;  cin >> W;
  int N;  N = W.size();
  char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int alphabet_num[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  for(int A = 0; A < N; A++){
    for(int B = 0; B < 26; B++){
      if(W.at(A) == alphabet[B]) alphabet_num[B]++;
    }
  }
  
  string answer = "Yes";
  for(int C = 0; C < 26; C++){
    if(alphabet_num[C] % 2 != 0) answer = "No"; 
  }
  cout << answer << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

int main()
{
    long N;
    std::cin >> N;
    long x[8];
    long y[8];
    double map[8][8];
    for(long i=0; i<N; i++){
        std::cin >> x[i] >> y[i];
    }
    long ave=0;
    for(long i=0; i<N; i++){
        for(long j=0; j<N; j++){
            map[i][j]=std::sqrt(std::pow((x[i]-x[j]),2)+std::pow((y[i]-y[j]),2));
        }
    }
    double result=0;
    for(long i=0; i<N; i++){
        for(long j=0; j<N;j++){
            result+=map[i][j];
        }
    }
    result=result/(double)N;
    std::cout << std::fixed;
    std::cout << std::setprecision(10) << result << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>

using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;

int main() {
  int N, T;
  i8t until=0;
  i8t loss=0;
  std::cin >> N >> T;
  for(int i =0;i<N;i++){
    int time;
    std::cin >>time;
    if(time<until)loss+=until-time;
    until=time+T;
  }
  std::cout<<(i8t)N*T-loss<<std::endl;
  return 0;
}


Measured memory_bytes: 764
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    W, H, x, y = LI()
    ans = W*H/2
    if x*2==W and y*2==H:
        print(ans, 1)
    else:
        print(ans, 0)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    N = I()
    R = [inf, -inf]
    L = [inf, -inf]
    U = [inf, -inf]
    D = [inf, -inf]
    X = [inf, -inf]
    Y = [inf, -inf]
    for _ in range(N):
        x, y, s = LSI()
        x, y = int(x), int(y)
        if s == "R":
            if x < R[0]: R[0] = x
            if x > R[1]: R[1] = x
            if y < Y[0]: Y[0] = y
            if y > Y[1]: Y[1] = y
        elif s == "L":
            if x < L[0]: L[0] = x
            if x > L[1]: L[1] = x
            if y < Y[0]: Y[0] = y
            if y > Y[1]: Y[1] = y
        elif s == "U":
            if y < U[0]: U[0] = y
            if y > U[1]: U[1] = y
            if x < X[0]: X[0] = x
            if x > X[1]: X[1] = x
        elif s == "D":
            if y < D[0]: D[0] = y
            if y > D[1]: D[1] = y
            if x < X[0]: X[0] = x
            if x > X[1]: X[1] = x

    def calc_area(t):
        x = max(R[1] + t, L[1] - t, X[1]) - min(R[0] + t, L[0] - t, X[0])
        y = max(U[1] + t, D[1] - t, Y[1]) - min(U[0] + t, D[0] - t, Y[0])
        if x <= 0 or y <= 0:
            return 0
        return x * y

    ans = calc_area(0)
    for i in [0, 1]:
        for j in [0, 1]:
            if R[i] <= X[j]:
                T = (X[j] - R[i])
                ans = min(ans, calc_area(T))
            if L[i] >= X[j]:
                T = (L[i] - X[j])
                ans = min(ans, calc_area(T))
            if R[i] <= L[j]:
                T = dec((L[j] - R[i]) / 2)
                ans = min(ans, calc_area(T))

            if U[i] <= Y[j]:
                T = (Y[j] - U[i])
                ans = min(ans, calc_area(T))
            if D[i] >= Y[j]:
                T = (D[i] - Y[j])
                ans = min(ans, calc_area(T))
            if U[i] <= D[j]:
                T = dec((D[j] - U[i]) / 2)
                ans = min(ans, calc_area(T))

    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N, X, Y;
    std::cin >> N >> X >> Y;

    vector<ll> ans(N - 1);
    iota(ALL(ans), 1);
    reverse(ALL(ans));
    for(int i = 1; i <= N - 1; i++) {
        for(int j = i + 1; j <= N; j++) {
            if((i < X && j < X) || (Y < i && Y < j)) continue;
            auto unuse = j - i;
            auto use = abs(i - X) + abs(j - Y) + 1;
            if(use < unuse) {
                ans[unuse - 1]--;
                ans[use - 1]++;
            }
        }
    }

    for(const auto& v : ans) {
        std::cout << v << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
R=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N=int(input())
A=list(input())
for i in range(len(A)):
  A[i]=R[(R.index(A[i])+N)%26]
print("".join(A))


Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Stack<Integer> S = new Stack<>();

        String input = sc.nextLine();
        String[] input_ = input.split(" ");
        sc.close();

        for(int i = 0; i < input_.length; i++){
            if(input_[i].equals("+")){
                int x = S.pop();
                int y = S.pop();
                S.push(y + x);
            }else if(input_[i].equals("-")){
                int x = S.pop();
                int y = S.pop();
                S.push(y - x);
            }else if(input_[i].equals("*")){
                int x = S.pop();
                int y = S.pop();
                S.push(y * x);
            }else{
                S.push(Integer.parseInt(input_[i]));
            }
        }
        System.out.println(S.firstElement());
    }
}



Measured memory_bytes: 26188
#include<stdio.h>
int main()
{
    int x,a,b;
    int X,A,B,P,Q;
    scanf("%d %d %d",&x,&a,&b);
    if(x>=1 && x<=1000)
    {
        X=x;
    }
    if(a>=1 && a<=1000)
    {
        A=a;
    }
    if(b>=1 && b<=1000)
    {
        B=b;
    }

    if(A!=B)
    {
    if(X>A)
    {
        P=X-A;
    }
    else
    {
        P=A-X;
    }

    if(X>B)
    {
        Q=X-B;
    }
    else
    {
        Q=B-X;
    }

    if(P>Q)
    {
        printf("B");
    }
    else
    {
        printf("A");
    }
    }

    else
        {
            printf("Error");
        }
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int val[n],cost[n],sub[n];
    for(int i=0;i<n;i++){
        cin >> val[i];
    }
    for(int i=0;i<n;i++){
        cin >> cost[i];
    }
    for(int i=0;i<n;i++){
        if(val[i] - cost[i] > 0){
            ans += val[i] - cost[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> order(n * n);
    for (int i = 0; i < (n * n); ++i) {
        cin >> order[i];
        --order[i];
    }
    vector<vector<int>> dist(n, vector<int>(n, 1));
    vector<vector<int>> occ(n, vector<int>(n, 1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = 1 + min(i, min(j, min(n - i - 1, n - j - 1)));
        }
    }
    long long sum = 0;

    const int dx[4] = {-1, 1, 0, 0};
    const int dy[4] = {0, 0, -1, 1};
    for (int p: order) {
        int x = p / n;
        int y = p % n;
        assert(dist[x][y] >= 1);
        sum += (dist[x][y] - 1);
        --dist[x][y];
        --occ[x][y];
        queue<pair<int, int>> q;
        q.emplace(x, y);
        while (!q.empty()) {
            tie(x, y) = q.front(); q.pop();
            for (int i = 0; i < 4; ++i) {
                const int nx = x + dx[i];
                const int ny = y + dy[i];
                if (nx < 0 || nx >= n || ny < 0 || ny >= n)
                    continue;
                if (dist[nx][ny] > dist[x][y] + occ[nx][ny]) {
                    dist[nx][ny] = dist[x][y] + occ[nx][ny];
                    q.emplace(nx, ny);
                }
            }
        }
    }
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 6160
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	AB := map[int][]int{}

	for i := 0; i < N; i++ {
		a := nextInt()
		b := nextInt()

		AB[a] = append(AB[a], b)
	}
	pq := make(pqueue, 0)

	c := 0
	for i := 0; i < M; i++ {
		// (i+1)日後に報酬を受け取れるアルバイトを追加する
		for j := 0; j < len(AB[i+1]); j++ {
			b := AB[i+1][j]
			heap.Push(&pq, &item{value: b, priority: b})
		}
		if len(pq) != 0 {
			v := heap.Pop(&pq)
			c += (*v.(*item)).value
		}
	}

	fmt.Println(c)
}

type item struct {
	value    int
	priority int
	index    int
}

type pqueue []*item

// キューの長さ
func (pq pqueue) Len() int { return len(pq) }

// キューの大小比較
// 基本は大きい方を優先する
func (pq pqueue) Less(i, j int) bool { return pq[i].priority > pq[j].priority }

// キューの内容交換
func (pq pqueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// キューへの追加
func (pq *pqueue) Push(x interface{}) {
	n := len(*pq)
	(x.(*item)).index = n
	*pq = append(*pq, x.(*item))
}

// キューからの取り出し
func (pq *pqueue) Pop() interface{} {
	old := *pq
	n := len(old)
	x := old[n-1]
	x.index = -1
	*pq = old[0 : n-1]
	return x
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 14976
//abc111_b.cpp
//Sat Sep 29 20:23:33 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	if (n%111==0){
		ans = n;
	}else {
		ans = n/111;
		ans = 111*(ans+1);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import math
n = int(input())
root_n = int(math.sqrt(n)) + 10
ans = 1<<60
def f(a, b):
    len_a = len(str(a))
    len_b = len(str(b))
    return max(len_a, len_b)
for i in range(1, root_n):
    if n % i == 0:
         ans = min(ans, f(i, n // i))
print(ans)

Measured memory_bytes: 9012