akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,p;
  int l=0;
  cin >> n >> m;
  p=m;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    l+=a.at(i);
  }
  for(int i=0;i<n;i++){
    if(a.at(i)>=(l+(m*4)-1)/(m*4)){
    p--;
    }
    if(p==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
N,T = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
max_ra = [0 for i in range(len(A)+1)]
ans = 0
k = 0
for i in range(len(A)-1,-1,-1):
    if max_ra[i+1] < A[i]:
        max_ra[i] = A[i]
    else:
        max_ra[i] = max_ra[i+1]
for i in range(len(A)):
    if max_ra[i] - A[i] > k:
        ans = 1
        k = max_ra[i] - A[i]
    elif max_ra[i] - A[i] == k:
        ans += 1
print(ans)


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

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

vector<ll> makePrimeList(const ll &n){

    if(n <= 1){
        vector<ll> null;
        return null;
    }

    vector<ll> prime_list(1,2);
    for(ll i = 2; i <= n; i++){
        bool is_prime = true;
        for(ll j = 0; j < prime_list.size(); j++){
            ll now_prime = prime_list[j];
            if(i%now_prime==0){
                is_prime = false;
                break;
            }else if(now_prime*now_prime > n){
                break;
            }
        }
        if(is_prime){
            prime_list.push_back(i);
        }
    }
    return prime_list;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> list = makePrimeList(100010);
  ll ans;
  ll i = 0;
  while(1){
    if(n<=list[i]){
      ans = list[i];
      break;
    }
    i++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main()
{
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    int dirX = x2 - x1;
    int dirY = y2 - y1;

    std::cout << x1 + dirX - dirY << ' ' << y1 + dirX + dirY << '\n';
    std::cout << x2 - dirX - dirY << ' ' << y2 + dirX - dirY << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[10000007]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<10000007;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(10000007);i++){
//      if(prime[i]==i){
//          for(j=i*i;j<10000007;j+=i){
//             if(!prime[j])
//                 prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}
ll dp[53];
void solve()
{   
    int n;
    cin>>n;
    string s[2];
    cin>>s[0]>>s[1];
    int prev;
    if(s[0][0]==s[1][0])
        dp[0]=3,prev=1;
    else
        dp[0]=6,prev=2,dp[1]=dp[0];
    for(int i=prev;i<n;){
        if(prev==1){
            if(s[0][i]==s[1][i])
                dp[i]=dp[i-1]*2%mod,++i;
            else
                dp[i]=dp[i-1]*2%mod,prev=2,dp[i+1]=dp[i],i+=2;
        }
        else
        {
            if(s[0][i]==s[1][i])
                dp[i]=dp[i-1],prev=1,++i;
            else
                dp[i]=dp[i-1]*3%mod,dp[i+1]=dp[i],i+=2;
        }
    }
    cout<<dp[n-1];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}   


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <queue>
const int N = 1e5+10;

vector<int>v[N];

int n,m,a,b;
int main()
{


    for(int i = 0;i < N;i++)
    {
        v[i].push_back(0);
    }
        
    cin >> n >> m;
    for(int i = 0;i < n;i++)
    {
        cin >> a>> b;
        if(a<=m){
            v[m-a+1].push_back(b);
        }
    }
    
    priority_queue<int>q;
    
    int res = 0;
    for(int k = m;k>0;k--)
    {
        if(v[k].size())
        for(auto &x :v[k])q.push(x);
        res+=q.top();
        q.pop();
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 6976
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int field[52][52];
int memo[52][52];

void dfs(int j, int i){
	if( memo[i][j] || !field[i][j] ) return;
	memo[i][j] = 1;
	dfs(j-1, i-1);
	dfs(j, i-1);
	dfs(j+1, i-1);
	dfs(j-1, i);
	dfs(j+1, i);
	dfs(j-1, i+1);
	dfs(j, i+1);
	dfs(j+1, i+1);
}

int main(void){
	int w, h;
	while( cin>>w>>h, w||h ) {
		for( int i=0; i<h; ++i ) {
			for( int j=0; j<w; ++j ) {
				cin>>field[i][j];
				memo[i][j] = 0;
			}
		}
		int ans = 0;
		for( int i=0; i<h; ++i ) {
			for( int j=0; j<w; ++j ) {
				if( field[i][j] && !memo[i][j] ){
					dfs( j, i );
					++ans;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1324
import sys
def 解():
    iH, iW = [int(x) for x in input().split()]
    iCount = 0
    iSum = 0
    aHW = [[int(x) % 2 for x in sLine.split() ] for sLine in  sys.stdin.readlines()]
    aRoute = []
    aTe = []
    aMove = []


    for i in range(iH):
        if i % 2 == 0:
            for j in range(iW):
                aRoute.append((i,j))
        else:
            for j in range(iW-1,-1,-1):
                aRoute.append((i,j))
    iF = 0
    for y,x in aRoute:
        iV = aHW[y][x]
        if iV and iF == 0:
            aMove.append((y+1,x+1))
            iF = 1
        elif iV == 0 and iF :
            aMove.append((y+1,x+1))
        elif iV and iF :
            aMove.append((y+1,x+1))
            for i in range(len(aMove)-1):
                aM = (aMove[i],aMove[i+1])
                aTe.append(aM)
            aMove = []
            iF = 0

    print(len(aTe))
    for aE in aTe:
        print(aE[0][0],aE[0][1],aE[1][0],aE[1][1])
解()


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


int main() {
  int A, B; cin >> A >> B;
  int cnt = 0;

  for(int i=A; i<=B; i++){
    int d1, d2, d4, d5;
    d1 = i%10;
    d2 = i/10%10;
    d4 = i/1000%10;
    d5 = i/10000%10;
    if(d1==d5&&d2==d4) cnt++;
  }

  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
ll dp[2002][2002];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	cin>>n;
	vii b(n);
	for(int i=0;i<n;i++){
		cin>>b[i].F;
		b[i].S = i;
	}
	sort(all(b),greater<ii>());
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(i!=j){
				dp[i][j] = max(dp[i][j], dp[i-1][j] + abs(n-i+j - b[i-1].S)*b[i-1].F);
			}   
			if(j){
				dp[i][j] = max(dp[i][j], dp[i-1][j-1]+ abs(j-1 - b[i-1].S)*b[i-1].F);
			}
		}
	}
	ll ans = -1;
	for(int j=0;j<=n;j++){
		ans = max(ans, dp[n][j]);
	}
	cout<<ans;




	return 0;
}







Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt[40];

signed main()
{
    int N,K; cin>>N>>K;
    vint a(N); REP(i,N) cin>>a[i];

    REP(i,N) REP(j,40){
        if((a[i]>>j)&1) cnt[j]++;
    }

    K++;

    int ans=0,cur=0;
    for(int i=39;i>=0;i--){
        if(!((K>>i)&1)){
            cur+=(1LL<<i)*cnt[i];
        }
        else{
            int sum=cur+(1LL<<i)*cnt[i];
            for(int j=i-1;j>=0;j--) 
                sum+=(1LL<<j)*max(cnt[j],N-cnt[j]);
            ans=max(ans,sum);
            cur+=(1LL<<i)*(N-cnt[i]);
        }
    }
    cout<<ans<<endl;

}   

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

int main(void){
 char b;
 char array[128];
 array['A'] = 'T';
 array['C'] = 'G';
 array['T'] = 'A';
 array['G'] = 'C';
 cin >> b;
 cout << array[(int)b] << endl;
  
 return 0; 
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a), green(b), musyoku(c);
    vector<int> gokei(x+y+c);
    int idx = 0;
    REP(i, a) {
        cin >> red[i];
        //gokei[idx].first = red[i];
        //gokei[idx].second = 0;
        //idx++;
    }
    REP(i, b){
        cin >> green[i];
        //gokei[idx].first = green[i];
        //gokei[idx].second = 1;
        //idx++;
    }
    REP(i, c) {
        cin >> musyoku[i];
        gokei[idx] = musyoku[i];
        idx++;
    }        
    sort(red.begin(), red.end());
    reverse(red.begin(), red.end());
    sort(green.begin(), green.end());
    reverse(green.begin(), green.end());

    REP(i, x) {
        gokei[idx] = red[i];
        idx++;
    }

    REP(i, y) {
        gokei[idx] = green[i];
        idx++;
    }
    sort(gokei.begin(), gokei.end());
    reverse(gokei.begin(), gokei.end());

    ll ans = 0;
    REP(i, x + y) {
        ans += gokei[i];
    }
    cout << ans << endl;

    

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int> > S(N, vector<int>(2));
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            S[p-1][0] = 1;
        }
        if (S[p-1][0] == 0 && s == "WA") {
            S[p-1][1]++;
        }
    }
    int ac = 0;
    int wa = 0;
    rep(i, N) {
        if(S[i][0] == 1) {
            ac += 1;
            wa += S[i][1];
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef vector<ll> v;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)

bool isodd(ll a, int N){
  ll mask = 1;
  int cnt = 0;
  rep(i, N){
    if(a & mask) cnt++;
    mask = mask << 1;
  }
  return cnt % 2;
}

int diff_idx(ll a, ll b, int N){
  ll mask = 1;
  ll axorb  = a ^ b;
  rep(i, N){
    if(axorb & mask) return i;
    mask = mask << 1;
  }
  return -1;
}

v differ_by_1bit(ll a, ll b, int N){
  v ans;
  if(N == 1){
    ans.push_back(a);
    ans.push_back(b);
  }else{
    int atail = a % 2;
    int btail = b % 2;
    ll a_ = a / 2;
    ll b_ = b / 2;

    if(atail == btail){
      v ch = differ_by_1bit(a_, b_, N-1);
      int tail = atail;
      rep(i, 1 << (N-1)){
        ans.push_back(ch[i] * 2 + tail);
        ans.push_back(ch[i] * 2 + 1 - tail);
        tail = 1 - tail;
      }
    }else{
      v ch1 = differ_by_1bit(a_, a_^1, N-1);
      v ch2 = differ_by_1bit(a_^1, b_, N-1);
      rep(i, 1 << (N-1)) ans.push_back(ch1[i] * 2 + atail);
      rep(i, 1 << (N-1)) ans.push_back(ch2[i] * 2 + btail);
    }
  }
  return ans;
}

int main(){
  int N;
  ll A, B;
  scanf("%d %lld %lld", &N, &A, &B);
  if(isodd(A, N) == isodd(B, N)){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
    v ans = differ_by_1bit(A, B, N);
    rep(i, 1 << N)
      cout << ans[i] << (i == ((1<<N)-1) ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 2432
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a, b = MAP()
print((a - 1) * (b - 1))

Measured memory_bytes: 5324
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v(n),w;
  set<int> st;
  map<int,int> mp;
  rep(i,n){
    cin>>v[i];
    st.insert(v[i]);
    mp[v[i]]++;
  }
  for(auto c:mp){
    w.push_back(c.second);
  }
  sort(w.begin(),w.end());
  int ans=0;
  if(st.size()<=k){
    cout<<0<<endl;
    return 0;
  }else{
    rep(i,st.size()-k) ans+=w[i];
  }
  
  cout<<ans<<endl;
  
  
  
  
}



Measured memory_bytes: 20988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i
int main(){
	int n,a,b;
	ll sum=0;
	cin>>n>>a>>b;
	rep(i,n+1){
		int j=i;
		int suma=0,c[4];
		rep(k,4){
			c[i]=j%10;
          	suma+=c[i];
          j/=10;
		}
		suma+=j;
		if(suma>=a&&suma<=b){
			sum+=i;
		}
	}
	puts(sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INFI = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 102, MAXK = 1e5+2;
int N, K, a[MAXN];
bool dp[MAXK], vis[MAXK];
bool solve(int stones){
	if(vis[stones])return dp[stones];
	vis[stones] = true;
	if(stones==0) return dp[stones]=false;
	for(int i = 1;i<=N;i++){
		if(a[i]==stones)return dp[stones]=true;
		if(a[i]<stones){
			if(!solve(stones-a[i]))return dp[stones]=true;
		}
	}
	return dp[stones]=false;
}
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> K;
	for(int i = 1;i<=N;i++)cin >> a[i];
	if(solve(K)){
		cout << "First" << nl;
	}else{
		cout << "Second" << nl;
	}
	return 0;
}

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

int main(){
	int n;
	int a[1000];
	cin >> n;
	
	for ( int i = 1; i <= n; i++ ){
		cin >> a[i];
	}
	
	for ( int j = n; j >= 1; j-- ){
		if ( j != n ){
			cout << " ";
		}
		cout << a[j];
	}
	cout << endl;
	
return 0;
}


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

#define ll long long
ll k,n,h,height=0;
vector<ll> v;
set<ll> s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>k;
	for(ll i=0;i<n;i++){
		cin>>h;
		v.push_back(h);
	}
	sort(v.begin(), v.end());
	for(ll i=0;i<=v.size()-k;i++){
		s.insert(v[k+i-1]-v[i]);
	}
	cout<<*s.begin();
	return 0;
}

Measured memory_bytes: 4852
fn main() {
    let l1 = read_line().unwrap();
    let mut l1 = l1.split_whitespace().map(|s| { s.parse::<i32>().unwrap() });
    let a = l1.next().unwrap();
    let b = l1.next().unwrap();
    let c = l1.next().unwrap();

    println!("{}", if (a == b && a != c) || (a != b && a == c) || (a != b && b == c) {"Yes"} else {"No"});
}

fn read_line() -> Option<String> {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    match stdin.read_line(&mut buf) {
        Ok(_) => Some(String::from(buf.trim())),
        Err(_) => None
    }
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N, T = map(int, input().split())
t = list(map(int, input().split()))

count = T
for i in range(1, N):
    count += T
    if t[i-1]+T > t[i]:
        count -= (t[i-1]+T)-t[i]

print(count)


Measured memory_bytes: 25744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a&1 && b&1 && c&1) {
        vint x = {a,b,c};
        sort(all(x));
        cout << (ll)x[0]*x[1] << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3608
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1
dp_sum = [[0]*(k+1) for i in range(n+1)]
for i in range(k+1):
    dp_sum[0][i] = 1
for i in range(n):
    for j in range(k+1):
        dp[i+1][j] += dp_sum[i][j]
        if j - a[i] > 0:
            dp[i+1][j] -= dp_sum[i][j-a[i]-1]
        if j -1 >= 0:
            dp_sum[i+1][j] = dp_sum[i+1][j-1]+dp[i+1][j]
        else:
            dp_sum[i+1][j] = dp[i+1][j]
        dp[i+1][j] %= mod
        dp_sum[i+1][j] %= mod
print(dp[-1][-1]%mod)

Measured memory_bytes: 192792
#include <bits/stdc++.h>
#define FOR(i, n) for (long long i = 0; i < (n); ++i)
#define pb push_back
#define int long long
#define debug(x) std::cout << #x << ": " << x << '\n';
typedef long long ll;
const int N = 2e5 + 10;
int a[N];

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    std::cin >> n;
    FOR(i, n) {
    	std::cin >> a[i];
    }
    bool fl = false;
    FOR(i, n) {
    	if (i == 0) continue;
    	if (a[i] > a[i - 1]) {
    		continue;
    	}
    	else {
    		fl = true;
    	}
    }
    if (!fl) {
    	std::cout << 1;
    	return 0;
    }
    int l = 1, r = n;
    while (r - l > 1) {
    	int tm = (l + r) / 2;
    	std::map<int, int> cnt;
    	bool check = true;
    	for (int i = 1; i < n; ++i) {
    		if (a[i] > a[i - 1]) {
    			continue;
    		}
    		else {
    			int nowLen = a[i];
    			while (!cnt.empty()) {
    				auto it = cnt.end();
    				--it;
    				if (it->first > nowLen) {
    					cnt.erase(it);
    				}
    				else {
    					break;
    				}
    			}
    			cnt[nowLen]++;
    			while (cnt[nowLen] >= tm && nowLen >= 1) {
    				cnt.erase(cnt.find(nowLen));
    				--nowLen;
    				cnt[nowLen]++;
    			}
    			if (nowLen <= 0) {
    				check = false;
    				break;
    			}
    		}
    	}
    	if (check) {
    		r = tm;
    	}
    	else {
    		l = tm;
    	}
    }
    std::cout << r;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define REPE(i,a,b) for (int i = a; i <= b; i++)

int main() {
	int n = 0, k = 0;
	scanf("%d %d", &n, &k);
	vector<int> arr(n + 1, 0), dp(n + 1, 1e9);
	int i = 0, j = 0;
	for (i = 0; i < n; i++)
		cin >> arr[i];
	dp[0] = 0;
	for (i = 1; i < n ; i++) {
		for (j = i - 1; j >= 0 && j > i - k - 1; j--)
			dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import math

a,b,x = map(int,input().split())
V = a*a*b/2

if V < x:
    c = 2*(a*a*b - x)/(a*a)
    print(math.degrees(math.atan(c/a)))
else:
    c = (x*2)/(a*b)  
    print(math.degrees(math.atan(b/c))) 
    

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int i = 1; 
	    int firstfour = 0; 
	    if(n == 1 || n == 2) {
	    	System.out.println(4);
	    	return; 
	    }
	    while(n != 1) {
	    	if(n == 4) firstfour = i;
	    	if(n%2 == 0) {
	    		n /= 2; 
	    	}
	    	else {
	    		n = 3*n + 1;
	    	}
	      i++;
	    }
	    System.out.println(firstfour+3);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, res=0;
    vi vodd, veven;
    rep(i,0,3){
        cin >> t;
        (t&1)?vodd.push_back(t):veven.push_back(t);      
    }
    if (sz(vodd)==3){
        sort(all(vodd));
        res = (2*vodd[2]-vodd[1]-vodd[0])>>1;
    }
    else if (sz(vodd)==2){
        if (veven[0]>= max(vodd[0],vodd[1])){
            res = ((2*veven[0]-(vodd[0]+vodd[1]+2))>>1) + 1;
        }
        else{
            res = (abs(vodd[0]-vodd[1])>>1) + ((max(vodd[0],vodd[1])+1-veven[0])>>1) + 1;
        }
    }
    else if (sz(vodd)==1){
        if (vodd[0] >= max(veven[0], veven[1])){
            res = ((2*vodd[0]- (veven[0]+veven[1]+2))>>1) +1;
        }
        else{
            res = (abs(veven[0]-veven[1])>>1) + ((max(veven[0],veven[1])+1 - vodd[0])>>1) + 1;
        }
    }
    else{
        sort(all(veven));
        res = (2*veven[2]-veven[1]-veven[0])>>1;
    }
    // check odd, even situation
    cout << res <<endl;
    return 0;
}

Measured memory_bytes: 3544
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct edge {
  int to, d, e;
};

struct state {
  int cur, cost, remain;
  bool operator<(const state& o) const {
    return cost > o.cost;
  }
};

vector<edge> es[102];
int L, N, M, d[102][102];

int solve() {
  rep(i,102) rep(j,102) d[i][j] = 1 << 30;
  
  priority_queue<state> Q;
  Q.push((state){0, 0, L});
  
  while (!Q.empty()) {
    state s = Q.top(); Q.pop();
    int cur = s.cur, cost = s.cost, remain = s.remain;
    if (s.cost > d[s.cur][s.remain]) continue;
    if (cur == N-1) {
      return cost;
    }
    rep(i,es[s.cur].size()) {
      edge e = es[cur][i];
      // やとわない
      if (d[e.to][remain] > e.e + cost) {
        d[e.to][remain] = e.e + cost;
        Q.push((state){e.to, e.e + cost, remain});
      }
      // やとってみる
      if (remain >= e.d && d[e.to][remain - e.d] > cost) {
        d[e.to][remain - e.d] = cost;
        Q.push((state){e.to, cost, remain - e.d});
      }
    }
  }
  return -1;
}

int main() {
  while (scanf("%d%d%d", &N, &M, &L), N) {
    rep(i,102) es[i].clear();
    int a, b, d, e;
    rep(i,M) {
      scanf("%d%d%d%d", &a, &b, &d, &e);
      --a; --b;
      es[a].push_back((edge){b, d, e});
      es[b].push_back((edge){a, d, e});
    }
    // memset(visited, 0, sizeof visited);
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 1472
#include<stdio.h>
#include<string.h>
int main()
{
    char a[20],i=0,len=0;
    scanf("%s",a);

    while(a[i]!='\0')
    {
        i++;
        len++;
    }
    for(i=0; i<len; i++)
    {
        if(a[i]==','){
            printf(" ");}
        else{
            printf("%c",a[i]);}
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

bool check(const vector<double>& v1, const vector<double>& v2)
{
    double res = 0.0;
    for(int i = 0; i < v1.size(); i++)
    {
        res += (v1[i] - v2[i]) * (v1[i] - v2[i]);
    }
    return ((int)sqrt(res) * (int)sqrt(res)) == res;
}

void solve()
{
    int n, d; cin >> n >> d;
    vector<double> v[n];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < d; j++)
        {
            int x; cin >> x;
            v[i].push_back(x);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(check(v[i], v[j])) ans++;
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n;
    string s;
    cin >> n >> s;
    set<char> all;
    rep(i,n) {
        all.insert(s[i]);
    }
    int i = 1;
    int cnt = 0;
    while(i<n) {
        set<char> f;
        set<char> b;
        int _cnt = 0;
        rep(j,i) {
            f.insert(s[j]);
        }
        for(int k=i; k<n; ++k) {
            b.insert(s[k]);
        }
        for(auto a: all) {
            if (f.find(a) != f.end() && b.find(a) != b.end()) {
                _cnt++;
            }
        }
        cnt = max(_cnt, cnt);
        i++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
AB = [LI() for _ in range(N)]
AB_a = sorted(AB,key=lambda x: x[0])
AB_b = sorted(AB,key=lambda x: x[1])

#"""
if N%2 == 0:
    p = N//2 -1
    q = p+1
    #print(p,q)
    ans = abs(AB_a[p][0]+AB_a[q][0] - AB_b[p][1]-AB_b[q][1])+1    
else:
    p = (N+1)//2 -1
    #print(p)
    ans = abs(AB_a[p][0] - AB_b[p][1])+1
print(ans)
#"""

Measured memory_bytes: 69500
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a<b){
            if(b<=c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else if(a>=c){
                System.out.printf("%d %d %d\n",c,a,b);
            }else if(a<c && c<b){
                System.out.printf("%d %d %d\n",a,c,b);
            }
        }else{
            if (a <=c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b >=c) {
                System.out.printf("%d %d %d\n", c, b, a);
            }else if(b<c && c<a){
                System.out.printf("%d %d %d\n",b,c,a);
            }
        }
    }
}


Measured memory_bytes: 26352
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>

using namespace std;

int main(){
    long int n;
    cin>>n;
    map<long int,long int> mp;
    long int i,j;
    for(i=0;i<n;i++){
        cin>>j;
        if(mp.count(j)==0){
            mp[j]=1;
        }else{
            mp[j]++;
        }
    }
    long int m;
    cin>>m;
    for(i=0;i<m;i++){
        cin>>j;
        if(mp.count(j)==0){
             cout<<"NO"<<endl;
            return 0;
        }else{
            mp[j]--;
            if(mp[j]==0){
                mp.erase(j);
            }
        }    
    }
    cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 12800
def gcd(x,y):
    if x<y:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return(y)

a,b,c,d = map(int,input().split())
cd = gcd(c,d)
cd = c*d//cd

c_num  = (b//c)-(a//c)
d_num  = (b//d)-(a//d)
cd_num = (b//(cd))-(a//(cd))

if a%c == 0:
    c_num = c_num+1

if a%d == 0:
    d_num = d_num+1

if a%(cd) == 0:
    cd_num = cd_num+1

if c%d == 0:
    print(b-a+1-d_num)
elif d%c ==0:
    print(b-a+1-c_num)
else:
    print(b-a+1-c_num-d_num+cd_num)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	long long int a,b,k;
	cin>>a>>b>>k;
	if(a>=k)
	{
		cout<<a-k<<" "<<b<<endl;
	}
	else
	{
		cout<<0<<" ";
		if(b-(k-a)>0)
		{
			cout<<b-(k-a)<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
	return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl

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

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    vector<bool> water_ok(F + 1, false);
    for (int a = 0; a <= F; a += 100 * A) {
        for (int water = a; water <= F; water += 100 * B) {
            water_ok[water] = true;
        }
    }
    vector<bool> suger_ok(F + 1, false);
    for (int c = 0; c <= F; c += C) {
        for (int suger = c; suger <= F; suger += D) {
            suger_ok[suger] = true;
        }
    }
    vector<int> water;
    for (int i = 1; i <= F; i++) {
        if (water_ok[i]) {
            water.push_back(i);
        }
    }
    vector<int> suger;
    for (int i = 1; i <= F; i++) {
        if (suger_ok[i]) {
            suger.push_back(i);
        }
    }
    long double maxc = -1;
    int maxs = 0;
    int maxw = 0;
    for (const int w : water) {
        for (const int s : suger) {
            if (s + w <= F and s <= w * E / 100) {
                if (maxc < (long double)100.0 * s / (s + w)) {
                    maxc = (long double)100.0 * s / (s + w);
                    maxw = w;
                    maxs = s;
                }
            }
        }
    }
    if (maxc == -1) {
        cout << 100 * A << " " << 0 << endl;
    } else {
        cout << maxw + maxs << " " << maxs << endl;
    }

    return 0;
}


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

using namespace std;

const int N = 100005;

int n, a[N], b[N], c[N], dp[N][3];

int fun(int i, int f) {
  if (i >= n) return 0;
  int &ret = dp[i][f];
  if (ret != -1) return ret;
  ret = 0;
  if (i == 0) {
    ret = max(ret, a[i] + fun(i + 1, 0));
    ret = max(ret, b[i] + fun(i + 1, 1));
    ret = max(ret, c[i] + fun(i + 1, 2));
  } else {
    if (f == 0) {
      ret = max(ret, b[i] + fun(i + 1, 1));
      ret = max(ret, c[i] + fun(i + 1, 2));
    } else if (f == 1) {
      ret = max(ret, a[i] + fun(i + 1, 0));
      ret = max(ret, c[i] + fun(i + 1, 2));
    } else {
      ret = max(ret, a[i] + fun(i + 1, 0));
      ret = max(ret, b[i] + fun(i + 1, 1));
    }
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", fun(0, 0));
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define Mod  1000000007
ll fast(ll n,ll a,ll M)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,M);
        if(n%2==0)
        {
            return ((res%M)*(res%M))%M;
        }
        else
        {
            return (((((res%M)*a)%M)*res)%M);
        }
    }
}
int main()
{
    ll K;
    cin>>K;
    ll ans=0;
    ll i,j,k;
    for(i=1;i<=K;i++)
    {
       for(j=1;j<=K;j++)
       {
           for(k=1;k<=K;k++)
           {
               ll p=__gcd(i,j);
               p=__gcd(p,k);
               ans+=p;
           }
       }
    }
    cout<<ans;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y;
  cin >> x >> y;
  // 鶴
  for (int i = 0; i <= 100; i++) {
    // 亀
    for (int j = 0; j <= 100; j++) {
      if ((i + j) != x) {
        continue;
      }
      if ((i * 2 + j * 4) == y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define all(x) (x).begin() ,(x).end()

const int p = 1e9 + 7;

ll binpow(ll a, ll b , ll mod) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

const int dx[] = {1 , -1 , 0 , 0};
const int dy[] = {0 , 0 , -1 , 1};
const ll inf = 1e18 - 5LL;
const int N = 1e5 + 9;



void solve() {

	int n;
	cin >> n;

	vector<ll> x(n) , y(n);

	for (int i = 0 ; i < n ; i++)
		cin >> x[i] >> y[i];

	ll mx1 = LLONG_MIN , mx2 = LLONG_MIN , mn1 = LLONG_MAX , mn2 = LLONG_MAX;

	for (int i = 0 ; i < n ; i++)
	{
		mx1 = max(mx1 , x[i] + y[i]);
		mn1 = min(mn1 , x[i] + y[i]);
		mx2 = max(mx2 , x[i] - y[i]);
		mn2 = min(mn2 , x[i] - y[i]);
	}

	cout << max(mx1 - mn1 , mx2 - mn2) << "\n";
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();

	return 0;
}

Measured memory_bytes: 6360
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


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


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 1000003
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(){
	
	fastio;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<sz(s);i++){
		ans = (ans%9 + (s[i]-'0')%9)%9;
	}
	if(ans)cout<<"No";
	else cout<<"Yes";
	
	}


	
	
	
	



Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int main(int argc, char const *argv[]) {
    int a,b;
    cin >> a >> b;
    int sub = b - a;
    int sum = 0;
    for (int i = 1; i < sub; i++){
        sum += i;
    }
    cout << sum - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
    long long dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++)
            dp[i][j]=0;
    }

    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i-1])
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
    /*
   for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    */
    /*
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    cout<<endl;
    */
    cout<<dp[n][W]<<endl;
    
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
bool sortbysec(const pair<lli,lli> &a,
              const pair<lli,lli> &b)
{
    return (a.second < b.second);
}
lli modulo(string num, lli a)
{
    lli res = 0;
    for (lli i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}

int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli q=0,m=0,z,k=0,i=0,n,sum=0,x,l,ans=0,p,j;
        cin>>n;
        vector<lli> v;
        lli a[n+1];
        v.pb(0);
        for(i=0;i<n;i++)
        {
            cin>>z;
            v.pb(z);
            sum+=z;
        }
        m=v[n];
        for(i=1;i<n;i++)
        {
            //what_is(m);
            if(i%2==0)
            m+=v[i];
            else
            m-=v[i];
        }
        a[n]=m;
        a[1]=2*v[n]-a[n];
        for(i=1;i<n;i++)
        {
            a[i+1]=2*v[i]-a[i];
        }
        for(i=1;i<n+1;i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}
/*
5
1 2 3 4 5
*/


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

#define INF 1e9+1

int main(){
  int N, L; cin >> N >> L;
  int t = (2*L+N-1)*N/2;
  int a, eat=1e3;
  for(int i=0; i<N; ++i){
    a = L+i;
    if(abs(a)<abs(eat)){
      eat=a;
    }
  }
  t -= eat;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#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 sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.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;

const int MAX_SIZE = 52;

int LCS(const string& a, const string& b){
    int n = (int)a.size(), m = (int)b.size();
    vector<int> x(n), y(m);
    rep(i,n){
        x[i] = a[i]-'a';
        if(x[i] < 0){
            x[i] = a[i]-'A'+26;
        }
    }
    rep(i,m){
        y[i] = b[i]-'a';
        if(y[i] < 0){
            y[i] = b[i]-'A'+26;
        }
    }
    vector<vector<int> > vec(MAX_SIZE);
    for(int j = m-1; j >= 0; --j){
        vec[y[j]].push_back(j);
    }
    vector<int> xs(n, INF);
    rep(i,n){
        rep(j,(int)vec[x[i]].size()){
            *lower_bound(xs.begin(),xs.end(),vec[x[i]][j]) = vec[x[i]][j];
        }
    }
    return lower_bound(xs.begin(),xs.end(),INF) - xs.begin();
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    rep(i,q){
        string a,b;
        cin >> a >> b;
        cout << LCS(a,b) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) cout << "Balanced" << endl;
  else if (A + B > C + D) cout << "Left" << endl;
  else cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>

using namespace std;

int main()
{
    int h=1,w=1;

    while(1){
        cin >> h >> w;
        if(h==0&&w==0){
            return 0;
        };
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i==0 || i==(h-1) || j==0 || j==(w-1)){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3064