akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ans = int.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                int sum = 0;
                for (int j = 0; j < N; j++)
                {
                    sum += Get_cost(s[j], i);
                }
                if (sum < ans)
                {
                    ans = sum;
                }
                else
                {
                    break;
                }
            }
            WriteLine(ans);
        }

        static int Get_cost(int x,int y)
        {
            return Abs(
                (x - y) * (x - y)
                );

        }
    }
}


Measured memory_bytes: 13268
s = input()
n = len(s) - 1
for i in range(2**n):
    tmp = []
    for j in range(n):
        tmp.append(s[j])
        if i >> j & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    tmp.append(s[-1])
    if eval("".join(tmp)) == 7:
        print("".join(tmp) + "=7")
        exit()

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


int main() {
    int a, b;
    cin >> a >> b;
    if (a + b > 23)cout << a + b - 24 << endl;
    else cout << a + b << endl;
    
    return 0;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/10
// Problem:ABC 070 MultipleClocks c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

ll lcm(ll x, ll y)
{
  ll r0, r1, a0, a1, b0, b1, q0, q1, tmp;
  r0 = x; r1 = y;
  a0 = 1; a1 = 0;
  b0 = 0; b1 = 1;

  while(r1 > 0) {
    q1 = r0 / r1;

    // a2 = a0 - q1 * a1
    tmp = a1;
    // a1 := a2
    a1 = a0 - q1 * a1;
    a0 = tmp;

    // b2 = b0 - q1 * b1
    tmp = b1;
    // b1 := b2
    b1 = b0 - q1 * b1;
    b0 = tmp;

    // r2 = r0 - q1 * r1
    tmp = r1;
    // r1 := r2
    r1 = r0 - q1 * r1;
    r0 = tmp;
  }
  return (x / r0) * y;
}

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

  int N;
  cin >> N;

  // 1 <= T[i] <= 10e18
  vector< ll > T(N);
  REP(i, N) {
    cin >> T[i];
  }

  ll ans = T[0];
  FOR(i, 1, N) {
    ans = lcm(ans, T[i]);
  }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<n*n*n;
}

Measured memory_bytes: 384
/*input
apple
apple
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
void solve()
{
	string s,t;
	cin >> s >> t;
	lld res=0; 
	rep(i,0,sz(s)){
		if(s[i]!=t[i]){
			res++;
		}
	}
	cout << res << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


int main(){
    ll N,odd=0;
    cin >> N;
    vector<ll>A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    for(ll i = 0;i < N;i++){
        if(A.at(i) % 2 != 0)
            odd++;
    }

    if(odd % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;     

}

Measured memory_bytes: 3984
#include <cstdio>

int main() {
    int n,a,b;
    scanf("%d%d%d", &n, &a, &b);
    int pp = n*a;
    if (pp < b) {
        printf("%d\n", pp);
    } else {
        printf("%d\n", b);
    }
    return  0;
}

Measured memory_bytes: 128
n = int(input())
h_input = list(map(int,input().split()))

ans=0

for i in range(max(h_input)):
    x = h_input[:]
    for j in range(n):
        if j==0 and x[0]!=0:#左端
            ans+=1
            h_input[j]-=1
        if j!=0:
            if x[j-1]==0 and x[j]!=0:#探索の左が0でかつ自身が0になっていない解き
                ans+=1
            if x[j]!=0:
                h_input[j]-=1
print(ans)

Measured memory_bytes: 9212
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt;
ll ans,x[100010];
int main()
{
	ll i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",&x[i]);
	if(x[n]!=2){printf("-1");return 0;}
	a=2;b=3;
	for(i=n-1;i;i--)
	{
		j=(a-1)/x[i]+1;k=b/x[i];
		//cout<<" "<<x[i]<<" "<<j<<" "<<k<<endl;
		if(j>k){printf("-1");return 0;}
		a=j*x[i];b=(k+1)*x[i]-1;
	}
	printf("%lld %lld",a,b);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;


int main(){

  ll ii,jj,kk,nn,oo,dimension,minDimension,inNum;

  ll n,k,x1,y1,x2,y2;

  vector<long> x,y;
  cin >> n >> k;
  x.resize(n);
  y.resize(n);
  minDimension = LONG_LONG_MAX;

  for(ii=0;ii<n;ii++){
    cin >> x[ii] >> y[ii];
  }

  for(ii=0;ii<n-1;ii++){
    for(jj=ii+1;jj<n;jj++){

      for(nn=0;nn<n-1;nn++){
	for(oo=nn;oo<n;oo++){

	  x1 = min(x[ii],x[jj]);
	  x2 = max(x[ii],x[jj]);
	  y1 = min(y[nn],y[oo]);
	  y2 = max(y[nn],y[oo]);
	  //cout << "ii" << ii << "jj" << jj << "nn" << nn << "oo" << oo << endl;
	  //1.面積の計算
	  dimension = (x2-x1) * (y2-y1);
	  //cout << "x1:" << x1 << "x2:" << x2 << "y1:" << y1 << "y2:" << y2 << "面積" << dimension << endl;;
	  //2.四角内の点の計算
	  inNum = 0;

	  for(kk=0;kk<n;kk++){
	    if(x1<= x[kk] && x[kk] <= x2 &&
	       y1<= y[kk] && y[kk] <= y2){
	      inNum ++;
	    }
	    if(inNum >= k && dimension < minDimension){
	      minDimension = dimension;
	    }
	  }
	}
      }
    }
  }
  cout << minDimension << endl;
  return 0;
}


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

int main() {
    string S; cin >> S;
    rep(bit, (1 << 3)) {
        int sum = S[0] - '0';
        string ans = S.substr(0, 1);
        rep(i, 3) {
            int n = S[i + 1] - '0';
            if(bit & (1 << i)) sum += n, ans += "+";
            else sum -= n, ans = ans += "-";
            ans += S[i + 1];
        }
        if(sum == 7) {
            ans = ans + "=7";
            cout << ans << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        if (N % 10 == 3)
            Console.WriteLine("bon");
        else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
            Console.WriteLine("pon");
        else
            Console.WriteLine("hon");
    }
}



Measured memory_bytes: 27472
n = [int(i) for i in input()]
sukimanokazu = len(n) - 1
for i in range(2 ** sukimanokazu):
    op = ["-"] * sukimanokazu #予め作っておくリスト
    for j in range(sukimanokazu):
        if (i >> j) & 1:
            op[sukimanokazu - 1 - j] = "+"  #フラグの場所を＋で上書き

    m = [str(k) for k in n]
    siki = m[0] + op[0] + m[1] + op[1] + m[2] + op[2] + m[3]
    if eval(siki) == 7:
        print(siki+"=7")
        exit()


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[10];
int main()
{
    for(int i=1;i<=4;i++)
    {
        a[read()]++;
    }
    if(a[1]==1&&a[4]==1&&a[9]==1&&a[7]==1)  puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,ans,j,k,q,c;
    ans=0;
    cin>>a>>c;
    fr(i,a){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=c*c) ++ans;
    }
    cout<<ans;
}

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

int main() {
	string S,T;
	cin >> S >> T;
	int count = 0;
	for(int i=0;i<S.size();i++){
		if(S.at(i) != T.at(i)){
			count ++;

		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3912
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int count=0,i=0;
  int H[10000],W[10000];
  while(true){
    cin >> H[i] >> W[i];
    if(H[i]==0 && W[i]==0)
      break;
    count++;
    i++;
    }
  for(int l=0;l<count;l++){
    for(int k=0;k<H[l];k++){
      for(int j=0;j<W[l];j++){
        if(k==0 || k==H[l]-1 || j==0|| j==W[l]-1)
          printf("#");
        else
          printf(".");
      }
      printf("\n");
     }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3044
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)
	for i := x; i >= 1; i-- {
		if isPow(i) {
			fmt.Println(i)
			break
		}
	}
}

func isPow(n float64) bool {
	if n == 1 {
		return true
	}
	for i := float64(2); i <= n/2; i++ {
		for j := float64(2); math.Pow(i, j) <= n; j++ {
			if math.Pow(i, j) == n {
				return true
			}
		}
	}
	return false
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n;
  cin >> n;
  vll a(n), b(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  
  ll x = 0;
  if (n % 2 == 0) {
    for (ll i = 0; i < n; i++) {
      if (i%2 == 1 && b[i] == 2) continue;
      if (i%2 == 0 && b[i] == 0) continue;
      x++;
      break;
    }
  }
  else {
    for (ll i = 0; i < n; i++) {
      if (i%2 == 0 && i > 0 && b[i] == 2) continue;
      if (i%2 == 1 && b[i] == 0) continue;
      if (i == 0 && b[i] == 1) continue;
      x++;
      break;
    }
  }
  
  if (x>0) {
    cout << 0 << endl;
  }
  else {
    ll ans=1;
    for (ll i = 1; i <= n/2; i++) {
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
#define sf(n) scanf("%d",&n);
#define sfl(n) scanf("%lld",&n);
#define pf(n) printf("%d",n);
#define pfl(n) printf("%lld",n);
#define pr printf("\n");
#define LL long long
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    cout<<"ABC"<<n<<endl;
    return 0;
}
/*
10
7 7
CEOKERE
ACMICPC
PKPIZKC
*/


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<complex>
#define eps 1e-12
#define RE real()
#define IM imag()
using namespace std;
typedef complex<double> Point;
Point I,A,B,C;

int main()
{
    double x1,y1,x2,y2,x3,y3;
    while(~scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3))
    {
        if(fabs(x1)<eps && fabs(y1)<eps && fabs(x2)<eps && fabs(y2)<eps && fabs(x3)<eps && fabs(y3)<eps) break;
        A = Point(x1,y1), B = Point(x2,y2), C = Point(x3,y3);
        double a,b,c;
        c = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
        a = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
        b = sqrt((x1-x3)*(x1-x3) + (y3-y1)*(y3-y1));
        double p = (c+a+b)/2.0;
        double r = sqrt(p*(p-a)*(p-b)*(p-c))/p;
        I = Point( ((a*A.RE+b*B.RE+c*C.RE)/(a+b+c)),((a*A.IM+b*B.IM+c*C.IM)/(a+b+c)));
        double Ia,Ib,Ic;
        Ia = sqrt((x1-I.RE)*(x1-I.RE) + (y1-I.IM)*(y1-I.IM));
        Ib = sqrt((x2-I.RE)*(x2-I.RE) + (y2-I.IM)*(y2-I.IM));
        Ic = sqrt((x3-I.RE)*(x3-I.RE) + (y3-I.IM)*(y3-I.IM));
        double  r1=(r/(2*(p-a)))*(p-r+Ia-Ib-Ic);
        double  r2=(r/(2*(p-b)))*(p-r+Ib-Ia-Ic);
        double  r3=(r/(2*(p-c)))*(p-r+Ic-Ib-Ia);
        printf("%.6f %.6f %.6f\n",r1,r2,r3);
    }
    return 0;
}

Measured memory_bytes: 1088
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 {
		new Main().exec();
	}
	
	int[] rc;
	int[] min;
	int n;

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		rc = in.nextInt(new int[n*2]);
		min = new int[n*n];
		Arrays.fill(min, -1);
		out.println(minCount(0,n-1));
		out.flush();
	}
	
	private int minCount(int from, int to) {
		if(min[from*n+to] != -1)
			return min[from*n+to];
		int ans=Integer.MAX_VALUE;
		if(from==to) 
			ans = 0;
		else if(from+1==to) 
			ans = rc[from*2]*rc[to*2]*rc[to*2+1];
		else {
			for(int mid=from+1; mid<=to; mid++){
				ans = Math.min(ans, minCount(from,mid-1) + minCount(mid,to) + rc[from*2]*rc[mid*2]*rc[to*2+1]);
			}
		}
		return min[from*n+to] = ans;
	}
}

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: 25004
//
// Created by matteo on 29/03/19.
//
#include <bits/stdc++.h>

using namespace std;

int main() {
   vector<vector<long>> DP(2, vector<long>(3, 0));
   //input parsing
   unsigned long days = 0;
   scanf("%ld", &days);
   int currIdx = 0;
   for (int i = 0; i < days; ++i) {
      currIdx = i % 2;
      scanf("%ld%ld%ld", &DP[currIdx][0], &DP[currIdx][1], &DP[currIdx][2]);
      for (int j = 0; j < 3; ++j) {
         DP[currIdx][j] += max(DP[1 - currIdx][(j + 1) % 3], DP[1 - currIdx][(j + 2) % 3]);
      }
   }
   //result
   printf("%ld", max(DP[currIdx][0], max(DP[currIdx][1], DP[currIdx][2])));
}


Measured memory_bytes: 256
N=int(input())
i=0
s=[]
n=N
while 1:
    k=pow(2,i+1)
    d=n%k
    if d!=0:
        s.append(1)
        n=n-pow(-2,i)
    elif n//k!=0:
        s.append(0)
    else:
        break
    i=i+1
while s:
    print(s.pop(),end="")
if N==0:
    print(0,end="")
print("")
    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a != c){
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include<cmath>
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  // x[y]
  map<ll,vector<ll>> mp;
  for(int i=0; i<N; i++){
    int x,y;
    cin >> x >> y;
    mp[x].emplace_back(y);
  }
  ll mx_x=-1,mn_x,mx_y,mn_y;
  ll ans = 0;
  for(auto m: mp){
    for(int i=0; i<m.second.size(); i++){
      if(mx_x == -1){
        mx_x = m.first;
        mn_x = m.first;
        mx_y = m.second[i];
        mn_y = m.second[i];
      }
      if((m.first - mx_x) < m.second[i]-mx_y){
        mx_x = m.first;
        mx_y = m.second[i];
      }
      if((m.first - mn_x) < mn_y - m.second[i]){
        mn_x = m.first;
        mn_y = m.second[i];
      }
      chmax(ans,abs(mx_x-m.first)+abs(mx_y-m.second[i]));
      chmax(ans,abs(mn_x-m.first)+abs(mn_y-m.second[i]));
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 25452
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){

        int N = nextInt();
        int D = nextInt();

        int[][] a = new int[N][D];
        for(int i=0; i<N; i++){
            for(int j=0; j<D; j++){
                a[i][j] = nextInt();
            }
        }

        boolean[][] reached = new boolean[N][N];
        for(int i=0; i<N; i++){
            Arrays.fill(reached[i], false);
        }

        int count = 0;
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if (i == j || reached[i][j] || reached[j][i]) continue;
                int sum = 0;
                for (int k = 0; k < D; k++) {
                    sum += Math.pow(a[i][k] - a[j][k], 2);
                }
                reached[i][j] = true;

                int num = (int)Math.sqrt(sum);
                if(num == Math.sqrt(sum)){
                    count++;
                }
            }
        }
        println(count);
    }

    static int nextInt(){
        return Integer.parseInt(sc.next());
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	LL M, K;
	cin >> M >> K;
	LL ter = (1 << M ) - 1;
	if (ter < K) {
		cout << -1 << endl;
		return;
	}
	if (M == 1) {
		if (K == 1) {
			cout << -1 << endl;
		}
		else {
			cout << "0 1 1 0" << endl;
		}
		return;
	}
	cout << K << " ";
	for (int i = 0; i <= ter; ++i) {
		if (i != K) {
			cout << i << " ";
		}
	}
	cout << K << " ";
	int cnt = 0;
	for (int i = ter; i >= 0; --i) {
		if (i != K) {
			cout << i;
			++ter;
			if (cnt < ter-1) {
				cout << " ";
			}
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[100010][100][2];

int main(){
	string K; cin >> K;
	int D; cin >> D;
	memset(dp,0,sizeof(dp));
	dp[0][0][0] = 1;
	int N = K.size();
	rep(i,N)rep(j,D)rep(k,2){
		int c = K[i] - '0';
		rep(l,10){
			if(l < c){
				dp[i+1][(j+l)%D][1] += dp[i][j][k];
				dp[i+1][(j+l)%D][1] %= MOD;
			}
			else if(l == c){
				dp[i+1][(j+l)%D][k] += dp[i][j][k];
				dp[i+1][(j+l)%D][k] %= MOD;
			}
			else{
				if(k) dp[i+1][(j+l)%D][1] += dp[i][j][1];
				dp[i+1][(j+l)%D][1] %= MOD;
			}
		}
	}
	int ans = dp[N][0][0] + dp[N][0][1] - 1;
	if(ans < 0) ans += MOD;
	cout << ans << endl;

    
}
   


Measured memory_bytes: 156544
import itertools
import math

N = int(input())
town = [list(map(int,input().split())) for _ in range(N)]

S = 0
for P in itertools.permutations(range(N)):
    for i in range(N-1):
        s, t = P[i+1], P[i]
        S += math.sqrt((town[s][0]-town[t][0]) ** 2 + (town[s][1]-town[t][1]) ** 2)

for i in range(1,N+1):
    S /= i

print(S)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,H,x,y,r;
  int min,mid,max;
  vector<int> li;
  int i = 1;
  
  cin >> x;
  while(x != 0){
    cout << "Case " << i << ": " << x << endl;
      cin >> x;
    i++;
  }
  
}


Measured memory_bytes: 3096
const inf = Number.MAX_SAFE_INTEGER;
function Main(input){
	var mem = input.split(" ").map(Number);
	var n = Math.abs(mem[0]-mem[1])+1;
	var a=0,b=0;
	if(mem[0]>0) a = 1;
	else if(mem[0]<0) a= -1;
	if(mem[1]>0) b = 1;
	else if(mem[1]<0) b= -1;
	if(a==0||b==0||a!=b) console.log("Zero");
	else{
		if(a==-1&&b==-1&&n%2==1) console.log("Negative");
		else console.log("Positive");
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll n,l;
    cin>>n>>l;
    ll sum = (1+n)*n/2 + n*(l-1);
    ll ans;
    if(l*(l+n-1) <=0) ans = sum;
    else if(l>0) ans = sum-l;
    else ans = sum-(l+n-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def dice_r(u,f):
	if u == 1:
		if f == 2:
			r = 3
		if f == 3:
			r = 5
		if f == 5:
			r = 4
		if f == 4:
			r = 2
	if u == 2:
		if f == 1:
			r = 4
		if f == 4:
			r = 6
		if f == 6:
			r = 3
		if f == 3:
			r = 1
	if u == 3:
		if f == 1:
			r = 2
		if f == 2:
			r = 6
		if f == 6:
			r = 5
		if f == 5:
			r = 1
	if u == 4:
		if f == 1:
			r = 5
		if f == 5:
			r = 6
		if f == 6:
			r = 2
		if f == 2:
			r = 1
	if u == 5:
		if f == 1:
			r = 3
		if f == 3:
			r = 6
		if f == 6:
			r = 4
		if f == 4:
			r = 1
	if u == 6:
		if f == 2:
			r = 4
		if f == 4:
			r = 5
		if f == 5:
			r = 3
		if f == 3:
			r = 2
	return r
		
n = list(map(int,input().split()))
q = int(input())
for i in range(q):
	a,b = map(int,input().split())
	u = n.index(a) +1
	f = n.index(b) +1
	c = dice_r(u,f)
	ans = n[c-1]
	print(ans)
	
	


Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
#define pii pair<int,int>
typedef long long ll;
using namespace std;
vector<int> g[1000001];
bool was[1000001];
int f[100001];
int dfs(int v)
{
	if(was[v])
	{
		return f[v];
	}
	was[v]=1;
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		f[v]=max(f[v],dfs(to)+1);
	}
	return f[v];
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

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

struct edge{
    int to, cap, rev;
};

#define MAX_V 300
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

// v...target vertex, t...end vertex, f...maximum flow 
int dfs(int v, int t, int f){
    if(v == t)  return f;

    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

const int INF = 1<<29;

// maxflow from s to t
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0)  return flow;
        flow += f;
    }
}

int main(){
    int SOURCE = 298, SINK = 299;
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n), d(n);
    for(int i = 0; i < n; i++)  cin >> a[i] >> b[i];
    for(int i = 0; i < n; i++)  cin >> c[i] >> d[i];
    for(int i = 0; i < n; i++){
        add_edge(SOURCE, i, 1);
        add_edge(n+i, SINK, 1);
        for(int j = 0; j < n; j++){
            if(c[j]-a[i] > 0 && d[j]-b[i] > 0)  add_edge(i, n+j, 1);
        }
    }
    cout << max_flow(SOURCE, SINK) << endl;
    return 0;
}

Measured memory_bytes: 384
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
nl=[]
for i in range(n):
  nl.append([l[i][0]+l[i][1],l[i][0]-l[i][1]])
nl.sort()
if n==1:
  print(1)
else:
  ans=1
  k=nl[0][0]
  for i in range(1,n):
    if k<=nl[i][1]:
      ans+=1
      k=nl[i][0]
  print(ans)


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

int main()
{
	int a,b,c,d[15]={};
	cin>>a>>b>>c;
	d[a]++;
	d[b]++;
	d[c]++;
	if(d[5]==2&&d[7]==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

n, k = map(int, input().split())

def cmb(n, r):
    return math.factorial(n)// (math.factorial(n-r) * math.factorial(r))

for i in range(k):
    if i <= n-k:
        print(cmb(n-k+1, i+1) * cmb(k-1, i) % 1000000007)
    else:
        print(0)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
  int a, b, c;
  int num = 0;
  scanf("%d", &a);
  c = a % 10;
  a /= 10;
  b = a % 10;
  a /= 10;
  if(a == 1) num++;
  if(b == 1) num++;
  if(c == 1) num++;
  printf("%d\n", num);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);


    int status = 1; 
    int tot = 0;
    for(int i=N-1;i>-1;i--){
        if(A.at(i)>i){
            cout<<-1<<endl;
            return 0;
        }

        if(status==1){
            tot += A.at(i);
            if(i>0){
                if(A.at(i-1)<A.at(i)){
                    status=0;
                    if(A.at(i)-A.at(i-1)>1){
            cout<<-1<<endl;
            return 0;

                    }
                }
            }
        }else{
            if(i>0){
                if(A.at(i-1)>=A.at(i))status=1;
            }
        }
    }
    cout<<tot<<endl;


    return 0;
}

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

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

	vector<int> a(n);
	for(auto &x: a) cin>>x;

		int res=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			res+=(a[i]*a[j]);
		}
	}
	cout<<res;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n; cin >> n; vector<double>v(n); rep(i, 0, n)cin >> v[i];
	sort(all(v));
	double ab, cd;
	double ans(-INF);
	rep(i, 1, n) {
		cd = v[i] - v[i - 1];
		if (i == n - 2)ab = v[n - 1] + v[n - 4];
		else if (i == n - 1)ab = v[n - 3] + v[n - 4];
		else ab = v[n - 1] + v[n - 2];
		ans = max(ans, ab / cd);
	}
	cout << fixed << setprecision(6) << ans << endl;
	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
string ans;

void saiki(int sum,int kai,string str){
  if(sum==n)ans=str;
  if(ans!=""||kai>1500000)return;

  saiki(sum+kai,kai*3,str+'+');
  saiki(sum-kai,kai*3,str+'-'); 
  saiki(sum,kai*3,str+'0'); 
}

int main(){
  cin>>n;
  ans="";
  saiki(0,1,"");
  reverse(ans.begin(),ans.end());
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define BR cout<<endl;
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

double expect(int x){
    double kitai,tem=0;
    for(int i=1;i<=x;i++){
        tem += i;
    }
    kitai = tem/x;
    cout << kitai << endl;
    return kitai;
    
}

int main(){
    int x;cin >> x;
    
    if(x>=30)cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 3596
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

s = input()[:-1]
a,b = -1,-1

for i in range(1,len(s)):
    if i >= 2:
        if s[i] == s[i-1]:
            a = i
            b = i+1
            break
        if s[i] == s[i-2]:
            a = i-1
            b = i+1
            break

    else:
        if s[i] == s[i-1]:
            a = i
            b = i+1
            break
print(a,b)


Measured memory_bytes: 39536
import java.util.*;

public class Main {
	
	class C{
		String from, to;
		boolean ispermit;
		public C(String from, String to, boolean ispermit) {
			this.from = from;
			this.to = to;
			this.ispermit = ispermit;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			C [] data = new C[n];
			for(int i = 0; i < n; i++){
				boolean ispermit = sc.next().charAt(0) == 'p';
				String from = sc.next();
				String to = sc.next();
				data[i] = new C(from, to, ispermit);
			}
			StringBuilder ans = new StringBuilder();
			int anssize = 0;
			while(m-- > 0){
				String from = sc.next();
				String to = sc.next();
				String msg = sc.next();
				if(check(from, to, data)){
					anssize++;
					ans.append(from + " " + to + " " + msg + "\n");
				}
			}
			System.out.println(anssize);
			System.out.print(ans.toString());
		}
	}

	private boolean check(String from, String to, C[] data) {
		for(int i = data.length - 1; i >= 0; i--){
			boolean flg = true;
			for(int j = 0; j < 8; j++){
				if(data[i].from.charAt(j) != '?'){
					if(data[i].from.charAt(j) != from.charAt(j)){
						flg = false;
						break;
					}
				}
				if(data[i].to.charAt(j) != '?'){
					if(data[i].to.charAt(j) != to.charAt(j)){
						flg = false;
						break;
					}
				}
			}
			if(flg){
				return data[i].ispermit;
			}
		}
		return false;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 44104
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
vector<vector<ll>> f(MAX_N,vector<ll>());
vector<vector<ll>> bl(MAX_N,vector<ll>());
bool bll[MAX_N];
void matching(ll a,ll n){
    bll[a]=true;
    for (ll i=0;i<n;i++){
        if (bll[i])continue;
        bool flag=true;
        for (ll j=0;j<f[a].size();i++){
            if(f[a][j]==i){
                flag=false;
                break;
            }
        }
        if (flag)matching(i,n);
    }
}

int main(){
    ll h,w;
    while(1){
        cin>>h>>w;
        if(h == 0 || w == 0){
            break;
        }
        
        for(ll i = 0; i<h; i++){
            if(h == 0)return 0;
            for(ll j  = 0; j<w; j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout << endl;
    }
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  double tmp1, tmp2;
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  while(v.size() > 1){
    tmp1 = v[0];
    tmp2 = v[1];
    v.erase(v.begin());
    v.erase(v.begin());
    v.insert(v.begin(), (tmp1 + tmp2) / 2);
  }
  cout << v[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int ans = min(a, k);

  int t = max(k - a - b, 0ll);

  ans -= t;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c, d, e, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c >> d >> e >> k;

  cout << ((e - a) > k ? ":(" : "Yay!") << endl;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
dp = [0]
if N == 1:
    print(0)
else:
    dp.append(dp[0] + abs(H[1]-H[0])) # step-1
    for i in range(2, N):
        c_one_step = dp[i-1] + abs(H[i] - H[i-1])
        c_two_step = dp[i-2] + abs(H[i] - H[i-2])
        dp.append(min(c_one_step, c_two_step))

    print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int H,W,K;
    cin >> H >> W >> K;
    K--;
    long long P=1000000007;
    long long dp[101][8];
    int F[]={1,1,2,3,5,8,13,21,34,55,89,144,233};
    for (int i=0;i<W;i++){
        dp[0][i]=0;
    }
    dp[0][0]=1;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            dp[i+1][j]=dp[i][j]*F[j]*F[W-j-1];
            dp[i+1][j]%=P;
            if (j!=0){
                dp[i+1][j]+=dp[i][j-1]*F[j-1]*F[W-j-1];
                dp[i+1][j]%=P;
            }
            if (j!=W-1){
                dp[i+1][j]+=dp[i][j+1]*F[j]*F[W-j-2];
                dp[i+1][j]%=P;
            }
        }
    }
    cout << dp[H][K] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();

    if (A % 2 == 1 && B % 2 == 1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i, j, k ,n,m,l,f;
	int x, y;
	cin >> n >> k >> x;

	cout << (n+k) * x/2 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    import math
    A, B, C, D = map(int, input().split())
    answer = ""
    atack_no_takahashi = math.ceil(C/B)
    atack_no_aoki = math.ceil(A/D)
    if atack_no_takahashi <= atack_no_aoki:
        answer = "Yes"
    else:
        answer = "No"
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 9180
import collections

N,P = map(int,input().split())

def factorization(n):
    res = []
    x = n
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res
    
F = factorization(P)
F = collections.Counter(F)

ans = 1

for k,v in F.items():
    ans *= k**(v//N)

print(ans)

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

using namespace std;
using ll = long long;

const int N = 303;
ll dp[N][N][N];
vector<int> v;
const ll M = 998244353LL;

int main() {
    string s; cin >> s;
    v.push_back(0);
    int c = 0; cin >> c;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            v.back() += 1;
        } else {
            v.push_back(0);
        }
    }
    c = min(c, accumulate(begin(v), end(v), 0));
    reverse(begin(v), end(v));
    dp[0][0][0] = 1;
    for (int i = 0; i < v.size()-1; i++) {
        for (int j = 0; j <= c; j++) {
            for (int k = 0; k <= c; k++) {
                for (int l = 0; l <= k; l++) {
                    dp[i+1][j][k-l] += dp[i][j][k];
                    dp[i+1][j][k-l] %= M;
                }
                for (int l = 1; l <= min(v[i], min(c-j, c-k)); l++) {
                    dp[i+1][j+l][k+l] += dp[i][j][k];
                    dp[i+1][j+l][k+l] %= M;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= c; i++) {
        for (int j = 0; j <= c; j++) {
            ans += dp[v.size()-1][i][j];
            ans %= M;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 57236
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int H, W, K;
	cin >> H >> W >> K;

	vector<string> S(H, "");

	for (int i = 0; i < H; i++)
	{
		cin >> S[i];
	}

	int result = 0;
	for (int comb_H = 0; comb_H < (1 << H); comb_H++)
	{
		for (int comb_W = 0; comb_W < (1 << W); comb_W++)
		{
			int value = 0;
			for (int i = 0; i < H; i++)
			{
				for (int j = 0; j < W; j++)
				{
					if (S[i][j] == '#' && (comb_H >> i & 1) == 0 && (comb_W >> j & 1) == 0) value++;
				}
			}

			if (value == K) result++;
		}
	}

	cout << result;
	
	return 0;
}


Measured memory_bytes: 3656
x, k, d = map(int,input().split())

x = abs(x)
# mを得るために必要な最小の移動回数
n = x // d

if k <= n:
    print(x - k * d)
    exit()

k -= n

x = x % d

if x > abs(x - d):
    x = x - d
    k -= 1

if k % 2 == 0:
    print(abs(x))
else:
    print(min(abs(x - d), abs(x + d)))

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
int L[100000];
int R[100000];

int main()
{
	int N;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N) {
		if (i == 0) L[i] = abs(A[i]);
		else {
			L[i] = L[i - 1] + abs(A[i] - A[i - 1]);
		}
	}

	rrep(i, N) {
		if (i == N - 1) R[i] = abs(A[i]);
		else {
			R[i] = R[i + 1] + abs(A[i] - A[i + 1]);
		}
	}

	rep(i, N) {
		if (i == 0) cout << abs(A[i + 1]) + R[i + 1] << endl;
		else if (i == N - 1) cout << L[i - 1] + abs(A[i - 1]) << endl;
		else cout << L[i - 1] + abs(A[i - 1] - A[i + 1]) + R[i + 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
memo = {}


def f(n):
    if n == 0:
        return 1
    if n == 1:
        return 1

    a1 = memo.get(n - 1)
    if not a1:
        a1 = f(n - 1)
        memo[n - 1] = a1

    a2 = memo.get(n - 2)
    if not a2:
        a2 = f(n - 2)
        memo[n - 2] = a2

    return a1 + a2


n = int(input())
print(f(n))



Measured memory_bytes: 5600