akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	string S;
	cin >> S;
	S = '#' + S;
	S += '#';
	if (C > D) {
		while (B < D) {

			if (S[B - 1] == '.' && S[B + 1] == '.') {
				break;
			}

			if (S[B + 1] == '.') {
				B++;
			}
			else if (S[B + 2] == '.') {
				B += 2;
			}
			else {
				break;
			}
		}
		S[B] = '#';
		while (A < B) {
			if (S[A + 1] == '.') {
				A++;
			}
			else if (S[A + 2] == '.') {
				A += 2;
			}
			else {
				break;
			}
		}
		S[B] = '.';
		if (A != B + 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	while (B < D) {
		if (S[B + 1] == '.') {
			B++;
		}
		else if (S[B + 2] == '.') {
			B += 2;
		}
		else {
			break;
		}
	}
	while (A < C) {
		if (S[A + 1] == '.') {
			A++;
		}
		else if (S[A + 2] == '.') {
			A += 2;
		}
		else {
			break;
		}
	}
	if (A == C && B == D) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}

Measured memory_bytes: 720
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 234567;
char s[MAXN];
int par[MAXN];

int main() {
    while (~scanf("%s", s + 1)) {
          int n = strlen(s + 1);
          memset(par, 0, sizeof(par));
          bool OK = true;
          for (int i = 1; i <= n / 2; i++) {
              if (s[i] != s[n - i]) OK = false;
          }
          if (s[n] == '1' || s[1] != '1') OK = false;
          if (!OK) {
             puts("-1");
             continue;
          }
          int root = 1, cur = 2;
          vector<pii> ans;
          for (int i = 2; i <= n / 2 + 1; i++) {
              if (s[i - 1] == '1') {
                 ans.push_back(make_pair(i, root));
                 while (cur != i) {
                     ans.push_back(make_pair(cur, root));
                     cur++;
                 }
                 cur++;
                 root = i;
              }
          }
          for (int i = cur; i <= n; i++) {
              ans.push_back(make_pair(i, root));
          }
          for (auto i : ans) printf("%d %d\n", i.first, i.second);
    }
    return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

int main(void)
{
	string S;
	lli k;
	cin >> S >> k;

	vector<pair<lli, lli>> A;
	for(auto it: S)
	{
		if(!A.empty() && A.back().first == lli(it-'a'))
		{
			A[lli(A.size())-1].second++;
		}
		else A.push_back({lli(it-'a'), 1});
	}

	lli res = 0;
	if(int(A.size()) == 1)
	{
		printf("%lld\n", (A.back().second*k)/2);
		return 0;
	}
	for(auto it: A) res += it.second/2;
	res *= k;
	//cout << res << "\n";
	if(A[0].first == A.back().first)
	{
		res -= (k-1)*((A[0].second/2)+(A.back().second/2)-(A[0].second+A.back().second)/2);
	}
	
	printf("%lld\n", res);
}

Measured memory_bytes: 256
N, K = map(int,input().split( ))
H = [int(i) for i in input().split( )]

H = sorted(H)
def binary_search(arr, x):
    start = 0
    end = len(arr)-1
    while(end >= start):
        mid = int(start + (end-start)/2)
        if x > arr[mid]:
            start = mid+1
        elif x < arr[mid]:
            end = mid -1
        else:
            for i in range(mid-start):
                if arr[mid-i-1] < x:
                    start = mid - i
                    break
            break
    print(N-start)
binary_search(H, K)

Measured memory_bytes: 11896
h, w = (int(x) for x in input().split())
n = int(input())
A = list(int(x) for x in input().split())
B = []
for i, a in enumerate(A, start=1):
    B += [i] * a
for i in range(h):
    start, end = i * w, i * w + w
    if i % 2 == 0:
        print(*B[start:end])
    else:
        print(*B[start:end][::-1])

Measured memory_bytes: 68624
implicit none
integer :: n
integer,allocatable :: a(:),idx(:)
integer :: i,jcomb,rswp
logical :: flg_swp

read *,n
allocate(a(n))
allocate(idx(n))
do i = 1,n
   read *,a(i)
   idx(i) = i
enddo

   i = n
   flg_swp = .false.
   do while (i > 1 .or. flg_swp)
      i = (i * 10) / 13
      if (i < 1) then
         i = 1
      else if (i == 9 .or. i == 10) then 
         i = 11
      endif
      flg_swp = .false.
      do jcomb = 1, n-i
         if (a(jcomb) > a(jcomb+i)) then
            rswp = a(jcomb) 
            a(jcomb) = a(jcomb+i)
            a(jcomb+i) = rswp
            rswp = idx(jcomb)
            idx(jcomb) = idx(jcomb+i)
            idx(jcomb+i) = rswp
            flg_swp = .true.
         endif
      enddo
   enddo

do i = 1, n
   print '(i0)',a(merge(n-1,n,i==idx(n)))
enddo

stop
end

Measured memory_bytes: 3200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
typedef long long int ll;
typedef double ld;
using namespace std;

class AServalVsMonster {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,b;
	    in>>a>>b;
	    double d = (double)a/b;
	    out<<ceil(d)<<endl;

	}
};


int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    AServalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define ok puts("OK");
#define int long long

using namespace std;

const int N = 1005, inf = 1e9 + 7;

int dp[N][2], n, x, ar[N], Dp[5005], old[5005];

vector <vector <int> > g;

void Do(int type, int v, int p)
{
    for (int j = 0; j <= ar[v]; j++)
        old[j] = Dp[j] = inf;

    old[0] = 0;

    for (auto to : g[v])
    {
        if (to == p) continue;

        for (int j = 0; j <= ar[v]; j++)
        {
            if(j) Dp[j] = Dp[j - 1];

            if ( j >= ar[to] && Dp[j] > old[j - ar[to]] + dp[to][type] )
                Dp[j] = old[j - ar[to]] + dp[to][type];

            else if (j >= dp[to][type ^ 1] && Dp[j] > old[j - dp[to][type ^ 1]] + ar[to] )
                Dp[j] = old[j - dp[to][type ^ 1]] + ar[to];
        }
        for (int j = 0; j <= ar[v]; j++)
            old[j] = Dp[j], Dp[j] = inf;
    }
    for (int j = 0; j <= ar[v]; j++)
        dp[v][type] = min(dp[v][type], old[j]);
}

void dfs (int v, int p = 0)
{
    if (g[v].size() == 1 && p)
    {
        dp[v][0] = 0;
        dp[v][1] = 0;
        return ;
    }
    for (auto to : g[v])
    {
        if (to != p)
            dfs(to, v);
    }
    Do(0, v, p);
    Do(1, v, p);
}

main ()
{
    cin >> n;

    g.resize(n + 1);

    for (int i = 2; i <= n; i++)
    {
        scanf("%lld", &x);
        g[i].pb(x);
        g[x].pb(i);
    }
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &ar[i]);
        dp[i][0] = dp[i][1] = inf;
    }
    dfs(1);
    if (dp[1][0] != inf || dp[1][1] != inf)
        puts("POSSIBLE");
    else
        puts("IMPOSSIBLE");
}


Measured memory_bytes: 384
#include<cstdio>
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
int n,f[3][139],a;
int main(){
	register int i,j;
	scanf("%d",&n);
	for(i=1;i<=2;i++){
		for(j=1;j<=n;j++) scanf("%d",&a),f[i][j]=max(f[i][j-1],f[i-1][j])+a;
	}
	printf("%d\n",f[2][n]);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(){
	int q,a,b;
	int s,t;
	cin>>q;
	multiset<int>m;
	for(;q--;){
		cin>>a;
		if(a==0)cin>>s,m.insert(s),cout<<m.size()<<endl;
		if(a==1)cin>>s,cout<<m.count(s)<<endl;
		if(a==2)cin>>s,m.erase(s);
		if(a==3){cin>>s>>t;auto it1=m.lower_bound(s),it2=m.upper_bound(t);for(;it1!=it2;++it1)cout<<*it1<<endl;}
	}
}



Measured memory_bytes: 12352
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    bool f = true;
    rep(i, 2)
    {
        int x = c[i][0] - c[i + 1][0], y = c[i][1] - c[i + 1][1], z = c[i][2] - c[i + 1][2];
        f &= (x == y && y == z);
    }
    rep(i, 2)
    {
        int x = c[0][i] - c[0][i + 1], y = c[1][i] - c[1][i + 1], z = c[2][i] - c[2][i + 1];
        f &= (x == y && y == z);
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int S[1000] = { 0 };


int main() {
	ll N,Q;
	cin >>N>>Q;
	stack<ll>Y[N];
	rep(i, Q) {
		int a;
		cin >> a;
		if (a == 0) {
			int b,c;
			cin >> b>>c;
			Y[b].push(c);
		}
		else if (a == 1) {
			int b;
			cin >> b;
			if (0 < Y[b].size()) cout << Y[b].top() << endl;
		}
		else {
			int b;
			cin >> b;
			if (0 < Y[b].size()) Y[b].pop();
		}
	}
	return 0;
}





Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,n,a,b,flag=0;
  cin >> n >> a >> b;
  for(int i=a;i<=b;i++){
  if(i%n==0){
    cout << "OK" << endl;
    flag=1;
    break;
  }
  }
  if(flag!=1)
    cout << "NG" << endl;
  
return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

signed main()
{
int a[3][3];
bool b[3][3];
map<int,pair<int,pair<int,int>>>m;
memset(b,true,sizeof(b));
for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    {cin>>a[i][j];
    m[a[i][j]].first++;
    m[a[i][j]].second={i,j};
    }
int n;
cin>>n;
int c[n];
for(int i=0;i<n;i++)
{cin>>c[i];
if(m[c[i]].first>0)
{
    b[m[c[i]].second.first][m[c[i]].second.second]=false;
}
}
for(int i=0;i<3;i++)
{
  if(b[i][0]==false&&b[i][1]==false&&b[i][2]==false)
  {
      cout<<"Yes"<<endl;
      return 0;
  }
  if(b[0][i]==false&&b[1][i]==false&&b[2][i]==false)
  {
       cout<<"Yes"<<endl;
      return 0;
  }
}
if(b[0][0]==false&&b[1][1]==false&&b[2][2]==false)
{
     cout<<"Yes"<<endl;
      return 0;
}
if(b[2][0]==false&&b[1][1]==false&&b[0][2]==false)
{
     cout<<"Yes"<<endl;
      return 0;
}
    cout<<"No"<<endl;
}





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

using namespace std;

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> v(n, 0);
	for(int i = 1; i <= n; i ++) {
		for(int j = i+1; j <= n; j++) {
			v[min(j-i, abs(x-i) + abs(j-y) + 1)]++;
		}
	} 
	for(int i = 1; i < n; i++) { 
		cout << v[i] << "\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
 long long n,t[1000],a[1000],j;
 cin>>n>>t[0]>>a[0];
 for(int i=1;i<n;i++){
  cin>>t[i]>>a[i];
   j=max((a[i-1]-1)/a[i],(t[i-1]-1)/t[i])+1;
   a[i]*=j;t[i]*=j;
 }
 cout<<a[n-1]+t[n-1]<<endl;
}

Measured memory_bytes: 256
I,O,T,J,L,S,Z=map(int,input().split())
i=I%2
j=J%2
l=L%2
if i+j+l>=2:
  if i+j+l==3:
    print(I+O+J+L)
  elif I*J*L!=0:
    print((I-1)//2*2+O+(J-1)//2*2+(L-1)//2*2+3)
  else:
    print(I//2*2+O+J//2*2+L//2*2)
else:
  print(I//2*2+O+J//2*2+L//2*2)

Measured memory_bytes: 3064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {h: usize, w: usize, a: [String; h]};

    let mut t = 0;
    while w + 1 > t {
        print!("#");
        t += 1;
    }
    println!("#");
    for a_iter in a.iter() {
        println!("#{}#", a_iter);
    }
    let mut u = 0;
    while w + 1 > u {
        print!("#");
        u += 1;
    }
    println!("#");
}


Measured memory_bytes: 2144
n, m = map(int, input().split())
aas = list(map(int, input().split()))
import heapq
hq = []
for i in aas:
    heapq.heappush(hq,-i)
for i in range(m):
    tmp = heapq.heappop(hq)
    heapq.heappush(hq,-((-tmp)//2))
print(-sum(hq))

Measured memory_bytes: 20024
N = int(input())
A = [int(i) for i in input().split()]
A[N:N] = [0]
A[0:0] = [0]

yosan = 0
for i in range(N+1):
  yosan += abs(A[i+1]-A[i])
  
for i in range(N):
  print(yosan -abs(A[i+1]-A[i]) -abs(A[i+2]-A[i+1]) +abs(A[i+2]-A[i]))

Measured memory_bytes: 14176
#include <iostream>
#include <vector>
#include <map>
#define llint long long

using namespace std;

llint n, p;
bool prime[1000005];
vector<llint> vec;
map<llint, llint> mp;

int main(void)
{
	cin >> n >> p;
	for(int i = 2; i < 1000005; i++){
		if(prime[i]) continue;
		vec.push_back(i);
		for(int j = 2*i; j < 100005; j+=i) prime[j] = true;
	}
	
	for(int i = 0; i < vec.size(); i++){
		while(p % vec[i] == 0){
			mp[vec[i]]++;
			p /= vec[i];
		}
	}
	if(p > 1) mp[p]++;
	
	llint ans = 1;
	for(auto it = mp.begin(); it != mp.end(); it++){
		llint x = it->second / n;
		for(int j = 0; j < x; j++) ans *= it->first;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin >> s;
    bool ok = false;
    for(int i=0;i<s.length();i++) {
        if(s[i]=='7') ok = true;
    }
    cout << ((ok) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[200010];
int main(){
    ll n, k, h;
    while(cin>>h){
        ll ans=0, tmp=1;
            while(h>1){
                ans+=tmp;
                tmp*=2;
                h/=2;
            }
            ans+=tmp;
        cout<<ans<<endl;

    }
    return 0;
}




Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ll rem = n%26;
        ans+=('a'+rem);
        n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3580
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (false)                                                                   \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long x, long long y) {
  if (x == y) {
    cout << 0 << endl;
    return;
  }

  ll ans = abs(abs(x) - abs(y));
  ll ma = max(x, y);
  ll mi = min(x, y);

  if (ma > 0 && mi < 0)
    ans++;
  else if (y < x && ma != 0 && mi != 0)
    ans += 2;
  else if (x == 0 && y < 0)
    ans++;
  else if (x > 0 && y == 0)
    ans++;

  cout << (ans) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long x;
  long long y;
  cin >> x;
  cin >> y;
  solve(x, y);
  return 0;
}


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

namespace ABC167C
{
    class Program
    {
        static int ans = -1;
        static void Main(string[] args)
        {
            string[] nmx = Console.ReadLine().Split(' ');
            int N = int.Parse(nmx[0]);
            int M = int.Parse(nmx[1]);
            int X = int.Parse(nmx[2]);
            int[,] array = new int[N, M + 1];
            for (int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                for (int j = 0; j < M + 1; j++)
                {
                    array[i, j] = int.Parse(input[j]);
                }
            }
            string[] yn = new string[N];
            
            int num = 0;
            tansaku(N, M, yn, num, array, X);
            Console.WriteLine(ans);
        }
        static void tansaku(int N, int M, string[] yn, int num, int[,] array, int X)
        {
            if (num == N)
            {
                int temp = 0;
                int[] rikai = new int[M];
                for (int i = 0; i < N; i++)
                {
                    if (yn[i] == "y")
                    {
                        for(int j = 0; j < M; j++)
                        {
                            rikai[j] += array[i, j + 1];
                        }
                        temp += array[i, 0];
                    }
                }
                //Console.WriteLine(temp);
                bool hantei = true;
                for (int i = 0; i < M; i++)
                {
                    if (rikai[i] < X)
                    {
                        hantei = false;
                    }
                }
                //Console.WriteLine(rikai[0]);
                if (hantei == true)
                {
                    if (ans == -1)
                    {
                        ans = temp;
                    }
                    else if (temp < ans)
                    {
                        ans = temp;
                    }
                }
                //Console.WriteLine(string.Join("", yn));
                return;
            }
            else
            {
                yn[num] = "y";
                tansaku(N, M, yn, num + 1, array, X);
                yn[num] = "n";
                tansaku(N, M, yn, num + 1, array, X);
            }
        }
    }
}


Measured memory_bytes: 27744
import sys
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
if len(S) == 1:
    print(0)
    sys.exit()

for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1

if len(S_dict.values()) == 1:
    print(0)
    sys.exit()
print(min(S_dict.values()) * 2)

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

int main() {
  int n;
  cin>>n;
  set<string> s;
  for (int i=0; i<n; i++) {
    string si;
    cin>>si;
    s.insert(si);
  }
  cout<<s.size()<<endl;

}

Measured memory_bytes: 19228
/************************** B ******************************/
#include <iostream>
using namespace std;

int main()
{
	int K = 0, N = 0;
	cin >> N >> K;
	long long count[N];
	count[0] = K;
	for(int i = 1; i < N; i++){
		count[i] = count[i - 1] * (K - 1);
	}
	cout << count[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
import math
from operator import itemgetter

N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

C = [(A[i], B[i], A[i] + B[i]) for i in range(N)]
C = sorted(C, key=itemgetter(2), reverse=True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += C[i][0]
    else:
        ans -= C[i][1]

print(ans)


Measured memory_bytes: 24548
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ans=0;
    rep(i,4){
        if(s[i]=='+'){
            ans+=1;
        }
        else{
            ans-=1;
        }
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int wall[100],wide,q,i,j,k,needwide,id,c,flag,m;
  char sorw[2];
  while(1){
    scanf("%d%d",&wide,&q);
    if(wide==0&&q==0) break;
    for(i=0;i<wide;i++){
      wall[i]=-1;
    }
    for(i=0;i<q;i++){
      scanf("%s",sorw);
      if(sorw[0]=='s'){
	scanf("%d%d",&id,&needwide);
	c=0;
	flag=0;
        for(j=0,m=0;j<wide;j++){
          if(wall[j]==-1){
	    c++;
            if(c==needwide){
              flag=1;
	      break;
	    }
	  }
          else if(wall[j]!=-1){
	    c=0;
            m=j+1;
	  }
	}
	if(flag==1){
	  for(k=m;k<m+needwide;k++){
            wall[k]=id;
	  }
	  printf("%d\n",m);
	}
        else if(flag==0){
          printf("impossible\n");
	}
      }
      else if(sorw[0]=='w'){
        scanf("%d",&id);
        for(j=0;j<wide;j++){
          if(wall[j]==id) wall[j]=-1;
	}
      }

    }
    printf("END\n");
  } 
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://beta.atcoder.jp/contests/abc100/tasks/abc100_b 

int main() {
    int D, N;
    cin >> D >> N;

    if (N==100) N = 101;

    if (D == 0) {
        cout << N << "\n";
    }
    else if (D == 1) {
        cout << N * 100 << "\n";
    }
    else {
        cout << N * 10000 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
m, f, r = 0, 0, 0 
dataset = []
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:break
    dataset.append([m, f, r])
for data in dataset:
    m, f, r = data[0], data[1], data[2]
    if m == -1 or f == -1 or m + f < 30:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m +f >= 65:
        print('B')
    elif m +f >= 50 \
          or (m + f >= 30 and r >= 50):
        print('C')
    else:
        print('D')


Measured memory_bytes: 5600
import sys
sys.setrecursionlimit(10**7)

def modinv(a,m=10**9+7):
    if a==0: return 1
    else:
        b=m
        (x, lastx) = (0, 1)
        (y, lasty) = (1, 0)
        while b != 0:
            q = a // b
            (a, b) = (b, a % b)
            (x, lastx) = (lastx - q * x, x)
            (y, lasty) = (lasty - q * y, y)
        return lastx % m

def cur(p):
    if neighbor[p]==[]: return
    for x in neighbor[p]:
        par[x]=p
        neighbor[x].remove(p)
        cur(x)
    descend[par[p]]+=descend[p]

def cur2(p):
    for x in neighbor[p]:
        ans[x]=ans[p]*descend[x]*modinv(n-descend[x])
        ans[x]%=mod
        cur2(x)

mod=10**9+7
n=int(input())
neighbor=[set()  for _ in range(n+2)]
descend=[1 for i in range(n+1)]
par=[0]+[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].add(b)
    neighbor[b].add(a)

cur(1)


ans=[1]*(n+1)
ans1=1
for i in range(1,n+1):
    ans1=ans1*i*modinv(descend[i])
    ans1%=mod
ans[1]=ans1

cur2(1)

for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 176476
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <math.h>
#include <string.h>
#define eps 1e-9
typedef long long int ll;
#define p1 3.1415926535898
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&c!=a)
    {
        cout<<"Yes"<<endl;
    }
    else if(c==b&&c!=a)
    {
        cout<<"Yes"<<endl;
    }
    else if(a==c&&b!=a)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);

int main()
{
   	int n, k;
   	cin >> n >> k;
   	int d[110];
   	int s[110][110];
   	map<int,int>q;
   	for(int i = 1; i <= k; i++){
   		cin >> d[i];
   		int x;
   		for(int j = 1; j <= d[i]; j++){
   			cin >> x;
   			q[x] = 1;
   		}
   	}
   	int cnt = 0;
   	for(int i = 1; i <= n; i++){
   		if(q[i]==0) cnt++;
   	}
   	cout << cnt << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);

  double near_diff = 100000;
  int near_point = -1;

  for (int i = 0; i < n; i++) {
    double mean = t - h.at(i) * 0.006;
    double diff = abs(a - mean);
    if (near_diff > diff) {
      near_diff = diff;
      near_point = i + 1;
    }
  }

  cout << near_point << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

string X;
int main(){
    cin>>X;
    int ans=X.size();
    int tmp = 0;
    REP(i,0,X.size()){
        if(X[i]=='S'){
            tmp++;
        }else{
            if(tmp>0){
                ans-=2;
                tmp--;
            }
        }
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 640
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<B:
    if A+V*T>=B+W*T:
        print("YES")
    else:
        print("NO")
if A==B:
    print("YES")
if A>B:
    if A-V*T<=B-W*T:
        print("YES")
    else:
        print("NO")

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

const int mod = 1e9 + 7;
const int MN = 333;

int po[MN * MN];

int N, R;
int C[MN][MN];

void gauss() {
    for(int i = 0; i < N; i++) {
        int p = -1;
        for(int j = R; j < N; j++) {
            if(C[j][i]) {
                p = j;
                break;
            }
        }
        if(p == -1) continue;
        for(int j = 0; j < N; j++) swap(C[R][j], C[p][j]);

        for(int j = R + 1; j < N; j++) if(C[j][i]) {
            for(int k = i; k < N; k++) {
                C[j][k] ^= C[R][k];
            }
        }
        R++;
    }
}

int cc[MN][MN][MN];
int dp(int x, int rnk, int rem) {
    if(x == N) return rem == 0? po[ N * (N - rnk) ] : 0;
    int &ret = cc[x][rnk][rem];
    if(ret != -1) return ret;

    int used = R - rem;
    int tot = po[N];

    ret = 0;
    if(rem) {
        ret += 1LL * po[rnk] * (po[R - used] + mod - 1) % mod * dp(x + 1, rnk + 1, rem - 1) % mod;
        ret %= mod;

        tot += mod - 1LL * po[rnk] * (po[R - used] + mod - 1) % mod;
        tot %= mod;
    }
    ret += 1LL * po[rnk] * dp(x + 1, rnk, rem) % mod;
    ret %= mod;

    tot += mod - po[rnk];
    tot %= mod;

    ret += 1LL * tot * dp(x + 1, rnk + 1, rem) % mod;
    ret %= mod;

    return ret;
}

int main() {
    po[0] = 1;
    for(int i = 1; i < MN * MN; i++) {
        po[i] = po[i - 1] * 2 % mod;
    }

    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            scanf("%d", &C[i][j]);
        }
    }

    gauss();

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, 0, R));
}


Measured memory_bytes: 145408
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, d, x; cin >> n >> d >> x;

    vi a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0;
    rep(i, n){
        ll t = 0;
        while(a[i]*t+1 <= d) sum++, t++;
    }
    cout << sum + x << endl;
}

Measured memory_bytes: 256
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = 'a' + input() + 'a'
n = len(s)
count = 0
ans = [0]*n
for i in range(1,n-1):
        if s[i] == 'R':
                count += 1
        elif s[i-1] + s[i] == "RL":
                ans[i-1] += (count+1)//2
                ans[i] += count//2
                count = 0
count = 0
for i in range(n-2,0,-1):
        if s[i] == 'L':
                count += 1
        elif s[i] + s[i+1] == "RL":
                ans[i+1] += (count+1)//2
                ans[i] += count//2
                count = 0
print(*ans[1:n-1])

Measured memory_bytes: 12232
import java.util.*

fun solve(n:Int, w:Int, wv:Array<Pair<Long, Long>>){
    val w0 = wv[0].first
    //val dp = Array(n+1,n+1,4 *(n+1)){0}
    val dp = Array(n + 1) {
        Array(n + 1) {
            Array(4 * (n + 1)) { -1L }
        }
    }
    dp[0][0][0] = 0
    dp[0][1][0] = wv[0].second
    for (i in 1 until n) {
        for (c in 0..n) {
            for (d in 0 until 4 * (n + 1)) {
                if (c - 1 >= 0 && d - (wv[i].first - w0) >= 0) {
                    dp[i][c][d] = Math.max(dp[i - 1][c][d], dp[i - 1][c - 1][d - (wv[i].first - w0).toInt()] + wv[i].second)
                } else {
                    dp[i][c][d] = dp[i - 1][c][d]
                }


            }
        }
    }

    for (i in 0 until n) {
        for (c in 0..n) {
            for (d in 0 until 4 * (n + 1)) {
                print(dp[i][c][d].toString() + " ")
            }
            println()
        }
        println()
    }

    // Wいか
    val result = (0 .. n).map{c ->
        (0 until 4 *(n+1)).map{d->
            Pair(c * w0 + d, dp[n-1][c][d])
        }
    }.flatten().filter{
        it.first <= w
    }.map{it.second}.max()
    println(result)
}

fun solve2(n:Int, w:Int, wv:Array<Pair<Long, Long>>){
    val w0 = wv[0].first
    //val dp = Array(n+1,n+1,4 *(n+1)){0}
    val dp = Array(n + 1) {
        //    Array(4 * (n + 1)) { Int.MIN_VALUE.toLong() }
        Array(4 * (n + 1)) { -1L }

    }

    val nextDP = Array(n + 1) {
        //    Array(4 * (n + 1)) { Int.MIN_VALUE.toLong() }
        Array(4 * (n + 1)) { -1L }

    }

    dp[0][0] = 0
    dp[1][0] = wv[0].second
    for (i in 1 until n) {
        for (c in 0..n) {
            for (d in 0 until 4 * (n + 1)) {
                if (c - 1 >= 0 && d - (wv[i].first - w0) >= 0) {
                    nextDP[c][d] = Math.max(dp[c][d], dp[c - 1][d - (wv[i].first - w0).toInt()] + wv[i].second)
                } else {
                    nextDP[c][d] = dp[c][d]
                }
            }
        }
        for (c in 0..n) {
            for (d in 0 until 4 * (n + 1)) {
                dp[c][d] = nextDP[c][d]
            }
        }


    }

    /*
    for (i in 0 until n) {
        for (c in 0..n) {
            for (d in 0 until 4 * (n + 1)) {
                print(dp[i][c][d].toString() + " ")
            }
            println()
        }
        println()
    }

     */
    // Wいか
    val result = (0 .. n).map{c ->
        (0 until 4 *(n+1)).map{d->
            Pair(c * w0 + d, dp[c][d])
        }
    }.flatten().filter{
        it.first <= w
    }.map{it.second}.max()
    println(result)
}


fun main(args: Array<String>) {
    val (n, w) = readLine()!!.split(' ').map(String::toInt)
    val wv = Array(n) {
        val (w0, v0) = readLine()!!.split(' ').map(String::toLong)
        Pair(w0, v0)
    }
    solve2(n,w,wv)
}

Measured memory_bytes: 79124
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	long long int r;
	cin>>r;
	cout<<3*r*r<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,d;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	if( a*b > c*d ){
		printf("%d\n",a*b);
	}else{
		printf("%d\n",c*d);
	}

	return 0;
}

Measured memory_bytes: 128
n = gets.chomp.to_i
resutaurants = []
n.times do |time|
  resutaurants << gets.chomp.split(' ')
  resutaurants[time][1] = resutaurants[time][1].to_i
  resutaurants[time] << time+1
end
resutaurants.sort! { |a, b| a[0] == b[0] ? b[1] <=> a[1] : a[0] <=> b[0] }
resutaurants.each { |resutaurant| puts resutaurant[2] }


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, p;
    cin >> n >> p;

    string s;
    cin >> s;

    vector<int64_t> v;
    for (auto c : s) {
        v.push_back(c - '0');
    }

    if (p == 2 || p == 5) {
        int64_t ans = 0;
        for (auto i : irange(0L, n)) {
            if (v[i] % p == 0) {
                ans += i + 1;
            }
        }

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

    int64_t ans = 0;
    int64_t m = 0, d = 1;
    unordered_map<int64_t, int64_t> u;
    u[0] = 1;
    for (auto i : irange(0L, n) | reversed) {
        m += v[i] * d;
        m %= p;
        d *= 10;
        d %= p;
        ans += u[m];
        ++u[m];
    }

    cout << ans << endl;
}

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

void print(int A[], int N, int cnt) {
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return;
}

void selectionSort(int A[], int N) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int min_id = i;
        for (int j = i; j < N; j++) {
            if (A[min_id] > A[j]) {
                min_id = j;
            }
        }
        if (i != min_id) {
            swap(A[i], A[min_id]);
            cnt++;
        }
    }
    print(A, N, cnt);
    return;
}

int main() {
    int N, A[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    selectionSort(A, N);
    return 0;
}


Measured memory_bytes: 3096
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll n;
	cin>>n;
	ll a[n+1],i;
	for(i=1; i<=n; i++)
		cin>>a[i];
	
	ll dp[n+1];
	dp[0]=0; dp[1]=0; dp[2]=abs(a[1]-a[2]);
	for(i=3; i<=n; i++)
	{
		dp[i]=min( dp[i-2]+abs(a[i-2]-a[i]) , dp[i-1]+abs(a[i-1]-a[i]));
		// cout<<dp[i]<<" ";
	}

	cout<<dp[n]<<endl;
}

int main()
{
    fastio;
    
    solve();

    return 0;
}


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

int N, K, Q;
int A[2010];

bool judge(int mid)
{
    //printf("mid : %d\n", mid);

    int mem[2010] = {0};
    for(int i = 0; i < N; i++)
    {
        memset(mem, 0, sizeof(mem));
        //printf(" bottom : %d\n",A[i]);
        for(int j = 0; j < N; j++)
        {
            if(A[j] < A[i])mem[j] = 2;
            else if(A[j] <= A[i] + mid)mem[j] = 1;
            else mem[j] = 0;
        }

        /*
        printf("  mem : ");
        for(int j = 0; j < N; j++)printf("%d ",mem[j]);printf("\n");
        */

        int q = 0;
        int cnt = 0, len = 0;
        for(int j = 0; j <= N; j++)
        {
            if(j == N || mem[j] == 2)
            {
                q += max(min(len - K + 1, cnt), 0);
                cnt = len = 0;
            }
            else
            {
                if(mem[j] == 1)cnt++;
                len++;
            }
        }

        //printf("  q : %d\n",q);

        if(q >= Q)return true;
    }

    return false;
}

int main()
{
    cin >> N >> K >> Q;
    for(int i = 0; i < N; i++)cin >> A[i];

    int l = 0, r = 1000000001;
    for(int i = 0; i < 50; i++)
    {
        int mid = (l + r) / 2;
        if(judge(mid))r = mid;
        else l = mid;
    }

    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min, Reverse};
#[allow(unused)]
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [i64; n],
    }
    p.sort();
    let mut ans = 0;
    for i in 0..k {
        ans += p[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 2212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n, k;

	std::cin >> n >> k;

	long long ans = 0;
	long long num = 1;

	while (num <= n) {
		ans++;
		num *= k;
	}

	std::cout << ans << std::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;
using ll = long long;

int main() {
  
  int a;
  cin >> a;
  
  if(a % 2 == 0) cout << a << endl;
  else cout << a*2 << endl;
  
}


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

void solve() {
  int n, k; string s; cin >> n >> s >> k; --k;
  for(auto &c : s) {
    if(c != s[k]) {
      c = '*';
    }
  }
  cout << s << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a[10001],n,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=2*n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2){
        ans+=a[i];
    } 
   cout<<ans;
    return 0;
} 


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

using namespace std;
#define mod 10000000+7

#define ll long long
int main() {
 ll h,n;
  cin>>h>>n;
  ll arr[n];
  ll sum=0;
  for(ll i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum>=h)
    cout<<"Yes";
  else
    cout<<"No";
  
    
 }
   



 
  




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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=false;
	if(ch=='-')
	{
		flag=true;
		ch=getchar();
	}
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	return flag?-ans:ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=false;
	if(ch=='-')
	{
		flag=true;
		ch=getchar();
	}
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	return flag?-ans:ans;
}

void write(int a)
{
	if(!a)
	{
		putchar('0');
		return;
	}
	static char ans[233];
	int n=0;
	for(;a;a/=10)ans[n++]=a%10+'0';
	for(;n;)putchar(ans[--n]);
}

void write(long long a)
{
	if(!a)
	{
		putchar('0');
		return;
	}
	static char ans[233];
	int n=0;
	for(;a;a/=10)ans[n++]=a%10+'0';
	for(;n;)putchar(ans[--n]);
}

int main()
{
	long long n,m;
	cin>>n>>m;
	if(n>m)swap(n,m);
	if(n==1 && m==1)puts("1");
	else if(n==1)printf("%lld\n",m-2ll);
	else printf("%lld\n",(n-2ll)*(m-2ll));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

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

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

#define MAX 200000

signed main(){
    int n;
    cin >> n;
    vector<int> c;
    int pre = 0;
    REP(i,n){
        int t;
        cin >> t;
        if(t != pre) c.emplace_back(t);
        pre = t;
    }
    n = c.size();
    Mint<> dp[n + 1];
    Mint<> pdp[MAX + 1];
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        dp[i + 1] = dp[i] + pdp[c[i]];
        pdp[c[i]] = dp[i + 1];
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4340
X=int(input())
a=[1,2,3,4,5,6,7,8,9]
if 1<=X<=10**5:
    while len(a)<X:
        i=0
        for i in range(X-10):
            if i<len(a):
                c=int(a[i])
                d=10*c
                b=c%10
                b_1=b-1
                b_2=b
                b_3=b+1
                if (b_1>=0)and(b_3<10):
                    a_1=d+b_1
                    a_2=d+b_2
                    a_3=d+b_3
                    a.append(a_1)
                    a.append(a_2)
                    a.append(a_3)
                elif b_1<0:
                    a_2=d+b_2
                    a_3=d+b_3
                    a.append(a_2)
                    a.append(a_3)
                else:
                    a_1=d+b_1
                    a_2=d+b_2
                    a.append(a_1)
                    a.append(a_2)
            i+=1
    a=sorted(a)
    print(a[X-1])

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    ll ans1 = 0;
    ll ans2 = 0;
    ll now = 0;
    vector<ll> used(n);
    vector<ll> unused(n);
    vector<ll> delta(n);
    ll used_max = 0;
    ll unused_min = INF;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        used[i] = min(a[i], b[i]);
        unused[i] = max(a[i], b[i]);
        used_max = max(used_max, used[i]);
        unused_min = min(unused_min, unused[i]);
        delta[i] = unused[i] - used[i];
        ans1 += a[i];
        ans2 += b[i];
        now += min(a[i], b[i]);
    }
    sort(used.begin(), used.end(), greater<ll>());
    sort(unused.begin(), unused.end());
    used_max = used[0];
    unused_min = unused[0];
    //cout << used_max << " " << unused_min << endl;
    ll ans = min(ans1, ans2);
    if(used_max >= unused_min){
        //cout << "a" << endl;
        vector<ll> total;
        for(int i = 0; i < n; i++){
            total.push_back(used[i]);
            total.push_back(unused[i]);
        }
        sort(total.begin(), total.end());
        ans = 0;
        for(int i = 0; i < n; i++){
            ans += total[i];
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        ll maxi = max(a[i], b[i]);
        ll mini = min(a[i], b[i]);
        ll New = now + maxi;
        if(used[0] != mini){
            New -= used[0];
        } else {
            New -= used[1];
        }
        ans = min(ans, New);
    }
    /*for(int i = 0; i < n; i++){
        now += unused[i];
        now -= used[i];
        ans = min(ans, now);
    }*/
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6388
n = int(input())
fx_list = []
fy_list = []

for i in range(n):
    x,y = (int(x) for x in input().split())
    fx_list.append(x-y)
    fy_list.append(x+y)

a = max(fx_list) - min(fx_list)
b = max(fy_list) - min(fy_list)

print(max([a,b]))


Measured memory_bytes: 24948