akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; double v[50];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> v[i];
	sort(v, v + N);

	double ans = v[0];
	rep(i, 1, N) ans = (ans + v[i]) / 2;
	printf("%.10f\n", ans);
}







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

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Int();
			}

			int[] ans = new int[n];
			for (int i = n - 1; i >= 0; --i) {
				int d = n / (i + 1);
				if (d < 2) {
					ans[i] = a[i];
				} else {
					int temp = 0;
					for (int j = 2; j <= d; j++) {
						temp += ans[(i + 1) * j - 1];
					}

					if (a[i] == 1) {
						if (temp % 2 == 1) {
							ans[i] = 0;
						} else {
							ans[i] = 1;
						}
					} else {
						if (temp % 2 == 1) {
							ans[i] = 1;
						} else {
							ans[i] = 0;
						}
					}
				}
			}

			int m = ans.Where(x => x == 1).Count();
			Console.WriteLine(m);
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				if (ans[i] == 1) {
					sb.Append($"{i + 1} ");
				}
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			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] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			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] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

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


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

void greatFirst(ll& a, ll& b)
{
  if(a < b)
  {
    ll tmp = a;
    a = b;
    b = tmp;
  }
}

ll gcd(ll a, ll b)
{
  greatFirst(a, b);
  
  while(a % b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  
  return b;
}

int myfind(vector<int>& a, int v)
{
  int mini = 0;
  int maxi = a.size() - 1;
  
  while(maxi - mini >= 0)
  {
    int mid = (maxi + mini) / 2;
    int x = a[mid];
//cout << "2:" << mid << "," << x << "," << v << endl;
    if(a[mid] == v)
    {
//cout << "out" << endl;
      return mid;
    }
    else if(a[mid] < v)
    {
      mini = mid + 1;
    }
    else
    {
      maxi = mid - 1;
    }
  }
  
  return -1;
}

int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  vector<int> r, g, b;
  rep(i, n)
  {
    if(s[i] == 'R')
    {
      r.push_back(i);
    }
    else if(s[i] == 'G')
    {
      g.push_back(i);
    }
    else
    {
      b.push_back(i);
    }
  }
  
  if(r.size() == 0 || g.size() == 0 || b.size() == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  
  ll out = 0;
  for(auto ri : r)
  {
    for(auto gi : g)
    {
       int ma  = max(ri, gi);
       int mi = min(ri, gi);
//cout << "1:" << ma << "," << mi << endl;
//cout << ( ma + (ma - mi)) << endl;
       if(myfind(b, ma + (ma - mi)) >= 0)
       {
         out++;
       }
//cout << (ma - (ma - mi)/2) << endl;
       if((ma - mi) % 2 == 0 && myfind(b, ma - (ma - mi)/2) >= 0)
       {
         out++;
       }
//cout << (mi - (ma - mi)) << endl;
       if(myfind(b, mi - (ma - mi)) >= 0)
       {
         out++;
       }
    }
  }
  
  ll ans = r.size() * g.size() * b.size() - out;
  cout << fixed << ans << endl; 
  
  return 0;
}


Measured memory_bytes: 3632
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	string S;
	cin >> S;
	i64 min_diff = 1000;
	REP(i, SIZE(S) - 2)
	{
		i64 diff = abs(753 - atoi(S.substr(i, 3).c_str()));
		if (diff < min_diff)
			min_diff = diff;
	}
	cout << min_diff << endl;
	return 0;
}


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

using namespace std;

int main()
{
     int a,b,c,d;
     scanf("%d%d%d%d",&a,&b,&c,&d);
     if(a+b>c+d)printf("Left");
     else if(a+b<c+d)printf("Right");
     else printf("Balanced");
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
even = Counter(v[::2]).most_common()
odd = Counter(v[1::2]).most_common()

if even[0][0] != odd[0][0]:
    print(n - even[0][1] - odd[0][1])
else:
    if even[0][1] == odd[0][1] == n // 2:
        print(even[0][1])
    else:
        print(min(n - even[1][1] - odd[0][1], n - even[0][1] - odd[1][1]))



Measured memory_bytes: 20700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n,k;
	cin >> n >> k;
	int i;
	double a[330000];
	a[0] = 0;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	double K_sum[330000];
	for (i = 1; i <= n; i++) {
		double A = a[i] + 1;
		double souwa = A * a[i] / 2;
		double K = souwa / a[i];
		K_sum[i] = K + K_sum[i - 1];
	}
	double MAX = 0;
	for (i = k; i <= n; i++) {
		MAX = max(MAX, K_sum[i] - K_sum[i - k]);
	}
	cout << fixed << setprecision(8) << MAX;
	return(0);
}

Measured memory_bytes: 5248
import java.util.*;

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

     int sum = 0;
     sum = a / 2;
      if(a % 2 == 0) {
         System.out.print(a / 2); 
} else {
           sum = a / 2;
System.out.print(sum + 1); 
}

      

}

}

Measured memory_bytes: 23380
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	ll n, W; cin >> n >> W;
	ll wt[n], val[n];
	FOR(i, n) cin >> wt[i] >> val[i];
	// Linear dp - by errichto
	ll dp[W + 1] = {};
	for (ll item = 0; item < n; ++item) {
		// dp[0] -> dp[3] -> dp[6]
		ll weight = wt[item];
		ll value = val[item];
		for (ll weight_already = W - weight; weight_already >= 0; --weight_already) {
			dp[weight_already + weight] = max(dp[weight_already + weight], dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for (ll i = 0; i <= W; ++i) {
		answer = max(answer, dp[i]);
	}
	cout << answer;
	return 0;
}

Measured memory_bytes: 4356
import math

n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

if n == s:
    print(n+1)
    exit()

for b in range(2, int(math.sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        exit()

for p in list(range(1, min(int(math.sqrt(n))+1, s+1)))[::-1]:
    q = s - p
    b = (n - q) // p
    if b >= 2 and f(b, n) == s:
        print(b)
        exit()

print(-1)

Measured memory_bytes: 18036
#include <iostream>
#include <vector> 

using namespace std;

int main()
{
    const int INF = 1e9+7;
    int n,k;
    cin>>n>>k;
    
    vector<int> inp(n),dp(n,0);
    
    
    for(int i=0;i<n;++i){
        cin>>inp[i];
    }
    
    for(int i=1;i<n;++i){
        
        int count = 0,mini = INF;
        for(int j=i-1;j>=0&&((count++)<k);j--)
        {
            mini = min(mini , abs(inp[i]-inp[j])+dp[j]); 
        }
        dp[i] = mini;
    }
    
    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int H, W;
    while (cin >> H >> W, H) {
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int INF = 10000000;

int N;
ll a[100];
int li = -1, ui = -1;

bool check1(int idx) {
    for (int j = 0; j < idx; ++j) {
        if (a[j] > a[idx]) return false;
    }
    return true;
}

bool check2(int idx) {
    for (int j = idx+1; j < N; ++j) {
        if (a[j] < a[idx]) return false;
    }
    return true;
}


int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) cin >> a[j];

    for (int j = 0; j < N; ++j) {
        if (li == -1 || a[j] < a[li]) {
            li = j;
        }
        if (ui == -1 || a[j] > a[ui]) {
            ui = j;
        }
    }

    vector<pair<int, int>> opers;

    if (abs(a[ui]) >= abs(a[li])) {
        for (int j = 0; j < N; ++j) {
            while (!check1(j)) {
                opers.emplace_back(ui, j);
                a[j] += a[ui];
                if (a[j] > a[ui]) {
                    ui = j;
                }
            }
        }
    } else {
        for (int j = N-1; j >= 0; --j) {
            while (!check2(j)) {
                opers.emplace_back(li, j);
                a[j] += a[li];
                if (a[j] < a[li]) {
                    li = j;
                }
            }
        }
    }

    cout << opers.size() << endl;
    for (auto& p : opers) {
        cout << (p.first+1) << " " << (p.second+1) << endl;
    }

    // cout << "## ";
    // for (int j = 0; j < N; ++j) cout << a[j] << " ";
    // cout << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace kpc2020
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_kpc2020A();
        }

        public static void solve_kpc2020B()
        {

        }

        public static void solve_kpc2020A()
        {
            int h = Convert.ToInt32(Console.ReadLine());
            int w = Convert.ToInt32(Console.ReadLine());            
            int n = Convert.ToInt32(Console.ReadLine());
            int max = Math.Max(h, w);
            Console.WriteLine((n + max - 1) / max);
        }
    }
}


Measured memory_bytes: 13268
//#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int n;
ll a,t;
ll a_,t_;
ll mina=1,mint=1;
ll mx,mn;
int main(){
    cin>>n;
    REP(i,n){
        cin>>t>>a;

        ll n1,n2;
        //find minimum n such as mint<=t*n mina<=a*n

        //mint/t<=n
        n1=mint/t;
        if(mint%t)n1++;

        n2=mina/a;
        if(mina%a)n2++;
        
        mina=a*max(n1,n2);
        mint=t*max(n1,n2);


        /*
        for(int j=1;;j++){
            if((a_=a*j)>=mina && (t_=t*j)>=mint)break;
        }
        mina=a_;
        mint=t_;*/




    }
    cout<<mina+mint<<endl;
    

    return 0;
}

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

using namespace std;
typedef long long ll;

ll cubic(ll n) {
    return 1ll * n * n * n;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if (k & 1) {
        ll ans = n / k;
        cout << cubic(ans) << endl;
    } else {
        ll ans1 = n / k;
        ll ans2 = 0;
        ll k2 = k >> 1;
        for (ll i = 1; i <= n; ++i) {
            if (i % k == k2) {
                ++ans2;
            }
        }
        cout << cubic(ans1) + cubic(ans2) << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

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

int main(void) {
  ll N;
  cin >> N;

  double ans = 0;
  REP(i, 0, N) {
    double x;
    string s;
    cin >> x >> s;
    if (s == "JPY") {
      ans += x;
    }
    if (s == "BTC") {
      ans += x * 380000;
    }
  }
  printf("%.8lf\n", ans);
}

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

int main() {
	int n;
	cin >> n;
	string s[n];
	string t[n]={};
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	sort(s,s+n);
	int c[n]={0};
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]){
					c[i+1]=c[i+1]+1+c[i];
		}
		
	}
	int max = -1000;
	for(int i=0;i<n;i++){
		if(c[i]>max){
			max = c[i];
		}
	}
	
	for(int i=0;i<n;i++){
			if(c[i]==max){
				cout << s[i] << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N,W;
	cin>>N>>W;
	vector <pair<ll,ll>> v;
	ll a,b;
	ll sum=0;
	for(ll i=0;i<N;i++)
	{
		cin>>a>>b;
		sum+=b;
		v.pb(mp(a,b));
	}
	ll ar[sum+1];
	for(ll i=0;i<sum+1;i++)
	{
		ar[i]=1000000000000;
	}
	ar[0]=0;
	for(ll j=0;j<N;j++)
	{
		for(ll i=sum;i>=0;i--)
		{
			if(i>=v[j].ss)
				ar[i]=min(ar[i],v[j].ff+ar[max((i-v[j].ss),0ll)]);
		}
	}
	ll ans=0;
	for(int i=0;i<sum+1;i++)
		if(ar[i]<=W)
			ans=i;
	cout<<ans<<endl;
}	


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, s, n) for(int i = s; i < n; i++)
void max_self(int &a, int b) { a=a>b?a:b; }
void min_self(int &a, int b) { a=a<b?a:b; }

using namespace std;

int n;
int temp=INT_MAX;
int temp2;

int curr_min=INT_MAX;

int main() {
    cin >> n;

    rep(i, n) {
        min_self(curr_min, temp);
        cin >> temp;

        if(temp<=curr_min)
            temp2++;
    }

    cout << temp2 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int oddCount;

int main()
{
	scanf("%d", &n);
	
	oddCount = n / 2 + n % 2;
	
	double prob = (double)oddCount / (double)n;
	printf("%.9lf\n", prob);
	
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int a[500010],l,r,bit[500010],n,cnt[555],sp;
set<int> S[30];
char s[500010];
LL ans;
int lowbit(int x){
	return x&-x;
}
void add(int x,int y){
	for (;x<=n;x+=lowbit(x)) bit[x]+=y;
}
int sum(int x){
	int s=0;
	for (;x;x-=lowbit(x)) s+=bit[x];
	return s;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	FOR(i,1,n) a[i]=s[i]-'a'+1,S[a[i]].insert(i);
	FOR(i,1,n) cnt[a[i]]++;
	int t=0;
	FOR(i,1,26) if (cnt[i]&1) ++t,sp=i;
	if (n%2==0 && t>0 || n%2==1 && t!=1) return puts("-1"),0;
	FOR(i,1,n) add(i,1);
	l=1;
	r=n;
	FOR(i,1,n/2){
		while (S[a[l]].find(l)==S[a[l]].end()) ++l;
		while (S[a[r]].find(r)==S[a[r]].end()) --r;
		if (a[l]==a[r]){
			add(l,-1),add(r,-1);
			S[a[l]].erase(S[a[l]].find(l));
			S[a[l]].erase(S[a[l]].find(r));
			continue;
		}
		if (a[l]!=sp){
			set<int>::iterator it=S[a[l]].end();
			it--;
			int t=*it;
			ans+=sum(n)-sum(t);
			add(t,-1),add(l,-1);
			S[a[l]].erase(S[a[l]].find(l));
			S[a[l]].erase(S[a[l]].find(t));
		}
		else{
			set<int>::iterator it=S[a[r]].begin();
			int t=*it;
			ans+=sum(t)-1;
			add(t,-1),add(r,-1);
			S[a[r]].erase(S[a[r]].find(r));
			S[a[r]].erase(S[a[r]].find(t));
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12672
package main

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

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func solve(n, k int, a []int) int {
	dp := make([]uint, k+1)

	for i := 0; i <= k; i++ {
		x := 0
		for j := 0; j < n; j++ {
			if i-a[j] >= 0 {
				x |= (1 << dp[i-a[j]])
			}
		}

		if x == 0 || x == 1 {
			dp[i] = 1
		} else {
			dp[i] = 0
		}
	}

	return int(dp[k])
}

func main() {
	s := bufio.NewScanner(bufio.NewReader(os.Stdin))
	s.Split(bufio.ScanWords)

	n := nextInt(s)
	k := nextInt(s)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(s)
	}

	if solve(n, k, a) == 0 {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi h(n);
    rep(i,n) cin>>h[i];
    int cnt=0,ans=0;
    rep(i,n-1){
        if (h[i]>=h[i+1]) cnt++;
        else cnt=0;
        chmax(ans,cnt);
    }
    cout<<ans<<"\n";
    return 0;
}


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

long long N, A, B;

int main() {
  scanf("%lld%lld%lld", &N, &A, &B);
  if(A > B || (N == 1 && A < B)) printf("0\n");
  else printf("%lld\n", (B - A) * (N - 2) + 1);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

string s;
int a, b, c, x, m[5];

int main() {
	cin >> s;
	for (int i = 0; i < 3; i++) m[s[i] - 'a']++;
	if(m[0] && m[1] && m[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#ifndef mx
#define mx 1000003
#endif
int ar[mx];
vector<ll> prime = {2};
map<ll,ll> mp;

void sieve(){
	for(ll i = 3; i*i<mx; i+=2)	if(ar[i]==false)	for(ll j = i*i; j<mx; j+=2*i)
		ar[j] = 1;
	for(ll i = 3; i<mx; i+=2)
		if(ar[i]==false)	prime.push_back(i);
}

void fn(ll n){

	for(ll i = 1; i*i<=n; i++){
		ll a = i,b = n/i;
		if(n%i==0){
			mp[a]++;
			if(a!=b)	mp[b]++;
		}
	}

}
vector<ll> v,u;
bool check(ll n){
	for(ll i:prime){
		if(i*i>n)	return true;
		if(n%i==0)	return false;
	}
return true;
}

int main(){
int t,tc = 0;

// read;	
// write;
sieve();

ll a,b;
cin>>a>>b;
fn(a);	fn(b);

for(auto i:mp){
	if(i.second==2)	{
		if(check(i.first))	v.push_back(i.first);
		else u.push_back(i.first);
	}
}

for(ll i:u){
	bool fl = true;
	for(ll j:v){
		if(__gcd(i,j)>1){
			fl = false;
			break;
		}
	}
	if(fl)	v.push_back(i);
}
cout<<v.size()<<endl;

return 0;
}

Measured memory_bytes: 5364
import java.io.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args)throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);		
		
		while(true){
		String str =  br.readLine();
		if(str == null)break;
		int n = Integer.parseInt(str);
		
		int[] sosu = new int[100000];
		int cs=0;
		
		int count = 0;
		if(n > 1) {
			count++;
			sosu[cs++] = 2;
		}
		if(n > 2){
			sosu[cs++] = 3;
			count++;
		}
		for(int i = 5; i < n+1; i+=2){
			boolean f = true;
			for(int j = 1; sosu[j]*sosu[j]  <= i; j++){
				if(i%sosu[j] == 0) {
					f = false;
					break;
				}
			}
			if(f){
				count++;
				sosu[cs++] = i;
			}
		}
		System.out.println(count);
	}

}
}

Measured memory_bytes: 10000
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int d1[4] = { -1,0,1,0 };
int d2[4] = { 0,1,0,-1 };
int main() {
	int n, m; cin >> n >> m;
	char jagan[10000][100];
	string s;
	rep(i, m) {
		cin >> s;
		rep(j, n) {
			jagan[j][i] = s[j];
		}
	}
	int wcnt[10000] = {};
	int sum = 0;
    int out = 0;
	rep(i, n) {
		rep(j, m) {
			if (jagan[i][j] == 'W') {
				wcnt[i]++; sum++;
			}
		}
	}
	int mi = sum;
	rep(i, n) {
		sum += m - 2*wcnt[i];
		if (sum < mi) {
			mi = sum; out = i + 1;
		}
	}
	cout << out << " " << out + 1 << endl;
	return 0;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int cnt[13];
bool hoge[13];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi vec;
    cnt[0]++;
    rep(i,n){
        int a;
        cin >> a;
        cnt[a]++;
    }
    if(cnt[0] >= 2 || cnt[12] >= 2){
        cout << "0\n";
        return 0;
    }
    rep(i,13){
        if(cnt[i] >= 3){
            cout << "0\n";
            return 0;
        }else if(cnt[i] == 2){
            vec.pb(i);
            hoge[i] = true;
        }else if(cnt[i] == 1){
            vec.pb(i);
        }
    }
    n = len(vec);
    int ans = 0;
    rep(i,(1<<n)){
        int mn = INF;
        vi val;
        rep(j,n){
            if(hoge[vec[j]]){
                val.pb(vec[j]),val.pb((24-vec[j])%24);
            }else{
                if(i & (1 << j)){
                    val.pb((24-vec[j])%24);
                }else{
                    val.pb(vec[j]);
                }
            }
        }
        sort(all(val));
        val.pb(24);
        rep(j,len(val)-1){
            cmn(mn,val[j+1]-val[j]);
        }
        cmx(ans,mn);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    int A, B, C, D;
    readf("%d %d %d %d", &A, &B, &C, &D);
    writeln(A+B > C+D ? "Left" : A+B < C+D ? "Right" : "Balanced");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    double pi = 3.1415;
    double r;cin >> r;
    cout << fixed << setprecision(12) << r*pi*2 << endl;
}


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

int main(){
  int n,k,ans=0;
  cin >> n >> k;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  
  sort(a,a+n);
  
  rep(i,k){
    ans += a[i];
  }
  
  cout << ans << endl;
  
  return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int a[110000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    sort(a, a + N);
    if (a[0] == a[N - 1]) {
        if (a[0] + 1 == N || a[0] * 2 <= N)cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    if (a[0] + 1 != a[N - 1]) {
        cout << "No" << endl;
        return 0;
    }

    int n = 0;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] == a[0]) {a[N - 1]--; n++;}
    }

    if (a[0] >= n && a[N - 1] != 0 && a[N - 1] * 2 <= N - n)cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long A, long long B, long long C){
    lli cnt = 0;
    vector<lli> a(3);
    a[0]=A,a[1]=B,a[2]=C;
    sort(a.begin(),a.end());

    if((a[2]-a[1])%2 != 0){
        cnt++;
        a[1]++;
        a[0]++;
    }
    cnt += (a[2]-a[1])/2;
    if((a[2]-a[0])%2 != 0){
        cnt++;
        a[2]++;
        a[1]++;
    }
    cnt+=(a[2]-a[0])/2;

    cout<<cnt<<endl;
    
}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    func(A, B, C);
    return 0;
}


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

typedef long long LL;
const int MAX_N = 56;

LL a[MAX_N];

int main () {
	LL n=50;
	LL k;
	scanf("%lld",&k);
	for (int i=1;n>=i;i++) {
		a[i] = (n-1) + (k/n);
	}
	k%=n;
	for (int i=1;k>=i;i++) {
		a[i] += (k + -(k-1));
	}
	for (int i=k+1;n>=i;i++) {
		a[i] += (-k);
	}
	puts("50");
	for (int i=1;n>=i;i++) {
		if (i!=1) printf(" ");
		printf("%lld",a[i]);
	}
	puts("");
}


Measured memory_bytes: 256
grade=[]
while True:
    m,f,r=list(map(int,input().split()))
    if [m,f,r] == [-1,-1,-1]:
        break
    if m==-1 or f==-1:
        grade.append('F')
    elif m+f>=80:
        grade.append('A')
    elif m+f>=65:
        grade.append('B')
    elif m+f>=50:
        grade.append('C')
    elif m+f>=30:
        if r>=50:
            grade.append('C')
        else:
            grade.append('D')
    else:grade.append('F')
print(*grade,sep='\n')


Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		Array.Sort(a,(u,v)=>v-u);
		var h=new int[2];
		for(int i = 0;i<n;i++) {h[i&1]+=a[i];}
		Console.WriteLine("{0}",h[0]-h[1]);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N+1);
    for(int i=1; i<=N; i++) cin >> H[i];

    static int64_t dp[301][301][302];
    for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) for(int k=0; k<=K; k++) dp[i][j][k] = 1e18;
    dp[0][0][0] = 0;
    for(int i=0; i<N; i++) for(int j=0; j<=N; j++) for(int k=0; k<=K; k++){
        chmin(dp[i+1][i+1][k], dp[i][j][k] + max(0, H[i+1] - H[j]));
        chmin(dp[i+1][j][k+1], dp[i][j][k]);
    }
    int64_t ans = 1e18;
    for(int j=0; j<=N; j++) for(int k=0; k<=K; k++) chmin(ans, dp[N][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 214016
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod=1e9+7;
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        long long n;cin>>n;
        vector <long long> diff,sum;
        for(int i=0;i<n;i++){
            long long x,y;cin>>x>>y;
            diff.push_back(x-y);
            sum.push_back(x+y);
        }
        sort(diff.begin(),diff.end());
        sort(sum.begin(),sum.end());
        long long ans=max(sum.back()-sum[0],diff.back()-diff[0]);
        cout<<ans<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 6672
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    int main() {
    	// your code goes here
    	ll n;
    	cin>>n;
    	for(ll i=1;i<10;i++)
    	{
    		if(n%i==0 && (n/i)<10)
    		{
    			cout<<"Yes";
    			exit(0);
    		}
    	}
     
    		cout<<"No";
    	
    	return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
    }
    int ans = INF32;
    for(int c= -100; c <= 100; ++c){
    int tmp = 0; 
    for(int i = 0; i < n; ++i){
		tmp += (c - a[i])*(c - a[i]);
    }
    ans = min (ans, tmp);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
 
#define FILE_NAME "a"
 
struct point
{
    int x, y;

    point () : x(0), y(0) {}

    point (int x_, int y_) : x(x_), y(y_) {}

    point operator + (const point &o) const
    {
        return point (x + o.x, y + o.y);
    }

    point operator - (const point &o) const
    {
        return point (x - o.x, y - o.y);
    }

    ll operator * (const point &o) const
    {
        return (ll)x * o.x + (ll)y * o.y;
    }

    ll operator % (const point &o) const
    {
        return (ll)x * o.y - (ll)y * o.x;
    }

    bool operator < (const point &o) const
    {
        if (*this % o)
            return *this % o > 0;
        return *this * *this < o * o;
    }

    bool operator == (const point &o) const
    {
        return x == o.x && y == o.y;
    }

    void read () 
    {
        cin >> x >> y;
    }
};

bool is_less (const point &l, const point &r)
{
    if (l.x != r.x)
        return l.x < r.x;
    return l.y < r.y;
}

vector<point> v;
int n;

bool read() {
    if (!(cin >> n)) {
        return 0;
    }

    v.resize(n);
    forn (i, n)
        v[i].read();

    return 1;
}

using T = long double;
const T pi = acos(-1.0);

T angle (const point &p, const point &q)
{
    return fabs(atan2(p % q, p * q));
}
 
void solve() {
    int where = 0;
    forn (i, n) if (is_less(v[i], v[where]))
        where = i;

    auto orig_v = v;
    auto start = v[where];

    forn (i, n)
        orig_v[i] = orig_v[i] - start;

    swap(v[where], v[0]);
    ford (i, n)
        v[i] = v[i] - v[0];

    sort(v.begin() + 1, v.end());
    
    vector<point> res;
    res.pb(v[0]);

    forn (i, n) if (i)
    {
        point cur = v[i];
        while (sz(res) >= 2)
        {
            point last = res.back(), prev = res[sz(res) - 2];
            if ((last - prev) % (cur - last) <= 0)
                res.pop_back();
            else
                break;
        }

        res.pb(cur);
    }

    vector<T> ans(sz(res));

    assert(sz(res) >= 2);
    forn (i, sz(res))
    {
        point two = (res[(i + 1) % sz(res)] - res[i]);
        point one = (res[i] - res[(i + sz(res) - 1) % sz(res)]);
        ans[i] = angle(one, two) / (2 * pi);
    }

    forn (i, n)
    {
        int pos = find(all(res), orig_v[i]) - res.begin();
        if (pos != sz(res))
           printf("%.10f\n", (double)ans[pos]);
        else
           printf("0\n");
    }
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
//    freopen(FILE_NAME ".out", "w", stdout);
#endif
 
    while (read()) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long int i,n,m,a, b, h[100001], g[100001]={0}, c=0;
  scanf("%ld%ld", &n, &m);
  for(i=1;i<=n;i++){
    scanf("%ld", &h[i]);
  }
  for(i=1;i<=m;i++){
    scanf("%d%d", &a, &b);
    if(h[a]<h[b]){
      g[a]=1;
    }
    else if(h[b]<h[a]){
      g[b]=1;
    }
    else{
      g[a]=1;
      g[b]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(g[i]==0){
      c++;
    }
  }
  printf("%d", c);
  return 0;
}


Measured memory_bytes: 3292
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self, x):
        if self.par[x] == x:
          return x
        else:
          self.par[x] = self.find(self.par[x])
          return self.find(self.par[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
n, m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
  x, y = map(int, input().split())
  uf.union(x-1, y-1)
ans = 0
for i in range(n):
  if uf.is_same(i, p[i] - 1):
    ans += 1
print(ans)

Measured memory_bytes: 102508
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

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

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	setIO();
	cin >> n >> k;
	vector < int > pos, neg;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		if(x>0) pos.pb(x);
		else {
			neg.pb(x);
		}
		a[i] = x;
	}
	sort(every(neg));
	sort(every(pos));

	if(pos.empty()) {
		int ans = 1;
		for (int i = 0; i < k; ++i) {
			ll cur = 0;
			if(k&1) {
				cur = neg[sz(neg)-i-1];
			} else {
				cur = neg[i];
			}

			cur %= mod;
			cur += mod;

			ans = (ans * cur) % mod;
		}

		cout << ans << '\n';
		exit(0);
	}

	int pA = n-2;
	int pB = 0;
	sort(a, a + n);

	ll ans = 1;
	if(k&1) {
		--k;
		ans *= a[n-1];
		--pA;
	}
	k /= 2;

	while(k) {
		--k;
		ans %= mod;
		ll A = (a[pB] * (ll)a[pB+1]);
		ll B = (a[pA] * (ll)a[pA+1]);
		if (A > B) {
			A %= mod;
			ans = (ans * A) % mod;
			pB += 2;
		} else {
			B %= mod;
			ans = (ans * B) % mod;
			pA -= 2;
		}
		ans %= mod;
	}
	ans += mod;
	ans %= mod;
	cout << ans << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 19352
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a<c) cout<<b/a;
    else cout<<c;
}

Measured memory_bytes: 256