akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	string s;
	cin >> s;
	rep(i,0,sz(s))cout << s[i++];
	cout << endl;

	return  0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(cin >> H >> W){
        if(H==0 and W==0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

#define N 8

int main(void){
  int i, j, k, n, max, min;
  char tmp, num[N+1];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", num);
    for(j = N-1; j > 0; j--){
      for(k = 0; k < j; k++){
	if(num[k] > num[k+1]){
	  tmp = num[k];
	  num[k] = num[k+1];
	  num[k+1] = tmp;
	}
      }
    }
    min = atoi(num);
    for(j = 0; j < N/2; j++){
      tmp = num[j];
      num[j] = num[N-1-j];
      num[N-1-j] = tmp;
    }
    max = atoi(num);
    printf("%d\n", max-min);
  }
  return 0;
}

Measured memory_bytes: 596
//
// Created by tac on 2016/10/16.
//

#include <cstdlib>
#include <string>
#include <iostream>

namespace {

std::string shuffle(const std::string& str, std::string::size_type pos) {
    std::string ret;
    ret = str.substr(pos, str.length() - pos) + str.substr(0, pos);
    return ret;
}

}

int main() {
    std::string str;
    int n;
    int pos;
    while (true) {
        std::cin >> str;
        if (str == "-") {
            break;
        }
        std::cin >> n;
        for (int i = 0; i < n; ++i) {
            std::cin >> pos;
            str = shuffle(str, pos);
        }
        std::cout << str << std::endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) 
	string s; cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
	
    return 0 ;  
}

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

using namespace std;

const int MX = 4001, md = 1000000007;

int C[MX][MX], S[MX][MX], f[MX][MX];

int main() {
	S[0][0] = C[0][0] = 1;
	for (int i = 1; i < MX; i++) {
		S[i][0] = C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % md;
			S[i][j] = (S[i][j - 1] + C[i][j]) % md;
		}
	}

	for (int a = 0; a < MX; a++)
		for (int b = 0; b < MX; b++) {
			if (a == 0 || b == 0) {
				f[a][b] = 1;
				continue;
			}
			
			f[a][b] = (f[a - 1][b] + S[b - 1][min(b - 1, a)]) % md;
		}
	
	int a, b, ans = 0;
	ignore = scanf("%d %d", &a, &b);
	if (a == 0 || b == 0) {
		printf("1\n");
		return 0;
	}
	
	for (int k = 0; k <= a; k++) {
		int left = a - k;
		for (int x = 0; x < b && x <= left; x++)
			ans = (ans + C[b - 1][x] * 1ll * f[left - x][x]) % md;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 187776
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

void m1(){
  int n; cin >> n;
  int a[n+5];
  REP(i,n) cin >> a[i];
  int sum = 0;
  REP(i,n-1){
  	if(a[i] > a[i+1]){
    	sum += a[i] - a[i+1];
      	a[i+1] = a[i];
    }
  }
  cout << sum;
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}


Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, count;
	cin >> n;
	vector<int> num(n);
	for (int i = 0; i < n; ++i)
		cin >> num.at(i);
	sort(num.begin(), num.end());
	count = num.at(n / 2) - num.at((n / 2) - 1);
	cout << count;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  string s=to_string(n);
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
return 0;
}


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

int main () {
  int N, K;
  int sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (x <= K-x){
      sum += x*2;
    }
    
    if (x > K-x){
      sum += (K-x)*2;
    }
  }
  
  cout << sum << endl;
}

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

int m1,d1,m2,d2;

int main(){
	scanf("%d%d%d%d",&m1,&d1,&m2,&d2);
	if(d2 == 1) printf("1\n");
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    char s[10];
    while (scanf("%s",&s)!=EOF) {
        bool flaga = false;
        bool flagb = false;
        for (int i = 0; i < 3;i++) {\
            if (s[i]=='A')
                flaga=true;
            if (s[i]=='B')
                flagb=true;
        }
        printf("%s\n",(flaga&&flagb)?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 256
def gen_d_prim(n):
    D = [n+1 if i%2 else 2 for i in range(n+1)]
    D[0] = D[1] = 0
    for i in range(3, n+1, 2):
        if D[i] != n+1: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int g,r;cin>>r>>g;
  cout<<2*g-r<<endl;

  return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int n;
    cin >> n;
    VI av(n);
    REP(i, n) cin >> av[i];
    VI bv(n);
    REP(i, n) cin >> bv[i];
    VI cv(n);
    REP(i, n) cin >> cv[i];
    sort(ALL(av));
    sort(ALL(bv));
    sort(ALL(cv));
    VI ab;
    VI bc;
    REP(i, n) {
        auto it1 = upper_bound(ALL(bv), av[i]);
        ab.push_back(bv.end() - it1);
        auto it2 = upper_bound(ALL(cv), bv[i]);
        bc.push_back(cv.end() - it2);
    }
    VL bc_ac;
    ll c = 0;
    REP(i, n) {
        bc_ac.push_back(c);
        c += bc[n-i-1];
    }
    bc_ac.push_back(c);
    ll ans = 0;
    REP(i, n) {
        ans += bc_ac[ab[i]];
    }
    cout << ans << endl;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



Measured memory_bytes: 6244
#include<stdio.h>
#define N 100
int main(){
  int i,j,count,A[N],key;
    scanf("%d",&count);
  for(i=0;i<count;i++){
    scanf("%d",&A[i]);
  }

  for(j=0;j<count-1;j++){
    printf("%d ",A[j]);
  }

  printf("%d\n",A[count-1]);

  for(i=1;i<count;i++){
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
  for(j=0;j<count-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[count-1]);
  }

  return 0;
  }



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int a[5],rem[5],sum1=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        int val = a[i]%10;
        if(val==0)
            rem[i]=0;
        else
            rem[i] = 10-val;
        sum1+=a[i];
    }
    sort(rem,rem+5);
    reverse(rem,rem+5);
    int sum=0;
    for(int i=1;i<5;i++)
        sum+=rem[i];
    cout<<sum1+sum<<"\n";
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  int N;cin >> N;
bool frag = 0;
  for(ll i = 1;i <= 3500;i++){
    for(ll j = 1;j <= 3500;j++){
      ll w = 1;
      //cout << N*i*j << ' ' << 4*i*j-N*i-N*j << endl;
      if(4*i*j-N*i-N*j != 0){
        w = (N*i*j) / (4*i*j-N*i-N*j);
      }else{
        continue;
      }
      if(4 * i * j * w == N * (i*j+j*w+w*i) && w > 0){
        cout << i << ' ' << j << ' ' << w << endl;
        frag = 1;
        break;
      }
      //cout << w << endl;
    }
    if(frag){
      break;
    }
  }
}

Measured memory_bytes: 384
require 'prime'

n = gets.to_i
m = 10 ** 9 + 7

h = Hash.new(0)

2.upto(n) do |i|
    i.prime_division.each {|pr, c| h[pr] += c}
end

puts h.values.inject(1) {|r, v| r * (v + 1) % m}

Measured memory_bytes: 2300
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
ll ar[40];
bool use[40];
bool table[40][40];
int n;
ll rec(int v) {

	if (v >= n) return 1LL;
	ll res = 0;
	bool ok = true;
	for (int i = 0; i < v; i++)
	{
		if (use[i]) {
			if (table[i][v]) {
				ok = false;
				break;
			}
		}
	}
	if (ok) {
		use[v] = true;
		res += rec(v + 1);
	}

	use[v] = false;
	res += rec(v + 1);
	return res;
}
ll rec(ll f,ll p, ll s, ll d,ll b,ll v) {

	if (d == b) return v;
	ll res = 0;
	for (ll i = 1; i <= p; i++)
	{
		
		res += rec(i, p, s, d + 1, b,v + (abs(f - i) == s));
	}
	return res;
}
pair<ll, ll> f(ll a, ll b, ll c) {
	ll pa = pow(a, b);
	ll pat = ((c == 0) ? a : (a - c) * 2);
	return pair<ll, ll>(pat, pa);
}
void solv() {
	
	ll n,m,d;
	cin >> n >> m >> d;
	auto r = f(n, 2, d);
	double mo = n * n;
	double deno = r.first * (m - 1);

	cout << setprecision(10) << (deno / mo)<< endl;
}




int main() {
	solv();

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long r,d,x,ans[15];
int main()
{
	cin>>r>>d>>x;
	ans[0]=x;
	for(int i=1;i<=10;i++)
	ans[i]=ans[i-1]*r-d;
	for(int i=1;i<=10;i++)
	cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  vi A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(rng(A));
  reverse(rng(A));
  cout <<A[0]*10+A[1]+A[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 205
#define MV 100005
int n, sx;
int s[MN];
ll dp[MN][MV];

ll fac[MV];
void getFacs(){
    fac[0] = 1;
    FOR(i, 1, MN-1){
        fac[i] = (fac[i-1]*i)%MOD;
    }
}


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

    getFacs();

    cin >> n >> sx;
    F0R(i, n){
        cin >> s[i];
    }
    sort(s, s+n, greater<int>());

    dp[0][sx] = 1;
    F0R(i, n){
        F0R(j, sx+1){
            /*dp[i+1][j%s[i]] += dp[i][j];
            dp[i+1][j%s[i]] %= MOD;*/
            if(s[i] > j){
                dp[i+1][j] += (dp[i][j] * (n-i));
            } else{
                dp[i+1][j%s[i]] += dp[i][j];
                dp[i+1][j] = (dp[i+1][j] + (dp[i][j] * (n-i-1))%MOD) % MOD;
            }
            dp[i+1][j%s[i]] %= MOD;
        }
    }

    ll sm = 0;
    F0R(i, sx){
        sm = (sm+(i*dp[n][i])%MOD) % MOD;
    }

    cout << sm << "\n";

    return 0;
}


Measured memory_bytes: 158464
/**
*    author:  yuya1234
*    created: 25.06.2020 14:56:58
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n,m;
    cin>>n;

    map<string,int> card;
    string s;

    REP(i,n)
    {
        cin>>s;
        if(card.count(s)==0)
            card.insert(make_pair(s,1));
        else
            card[s]++;
    }

    cin>>m;
    REP(i,m)
    {
        cin>>s;
        if(card.count(s)==0)
            card.insert(make_pair(s,-1));
        else
            card[s]--;
    }

    int ans=-100;
    for(auto it=card.begin(); it!=card.end(); ++it)
    {
        ans=max(ans,it->second);
    }

    if(ans>0)cout<<ans<<endl;
    else cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

char grid[500][500];
pair<ll, ll> dsu[500][500];
ll cnt[500][500][2];

pair<ll, ll> find(pair<ll, ll> v) {
    if (dsu[v.first][v.second] == v) return v;
    else return dsu[v.first][v.second] = find(dsu[v.first][v.second]);
}

void uni(pair<ll, ll> v, pair<ll, ll> u) {
    v = find(v);
    u = find(u);
    if (v != u) {
        dsu[u.first][u.second] = v;
        cnt[v.first][v.second][0] += cnt[u.first][u.second][0];
        cnt[v.first][v.second][1] += cnt[u.first][u.second][1];
    }
}

ll nw[500][500];
vector<pair<ll, ll>> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main()
{
    fastInp;

    ll h, w;
    cin >> h >> w;

    ll ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int k = 0; k < h; k++) {
            for (int j = 0; j < w; j++) {
                dsu[k][j] = {k, j};
               
                ll vl = !(grid[k][j] == '.');
                cnt[k][j][vl] = 1;
                cnt[k][j][!vl] = 0;
                if ((k + j) % 2 == i) {
                    vl = !vl;
                }
                nw[k][j] = vl;
 
            }
        }

        for (int k = 0; k < h; k++) {
            for (int j = 0; j < w; j++) {
                for (auto cur : dir) {
                    if (k + cur.first >= 0 && k + cur.first < h && j + cur.second >= 0 && j + cur.second < w && (nw[k][j]) && (nw[k + cur.first][j + cur.second])) {
                        uni({k, j}, {k + cur.first, j + cur.second});
                    }
                }
            }
        }

        set<pair<ll, ll>> s;
        for (int k = 0; k < h; k++) {
            for (int j = 0; j < w; j++) {
                if (nw[k][j]) s.insert(find({k, j}));
            }
        }

        for (auto cur : s) {
            ans += (cnt[cur.first][cur.second][0] * cnt[cur.first][cur.second][1]);
        }
    }

    cout << ans;

    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  for(int i=1;i<1251;i++){
    if(int(i*0.08)==a && int(i*0.1)==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
} 

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

class RollingHash {
  int bases[2] = {1007, 1009}, mods[2] = {1000000009, 1000000007};
  vector<int> mul[2], hash[2];

public:
  using hash_type = pair<int, int>;

  RollingHash(const string &s) {
    int n = s.size();
    rep(i, 2) {
      hash[i] = vector<int>(n + 1, 0);
      mul[i] = vector<int>(n + 1, 1);
      rep(j, n) {
        hash[i][j + 1] = (hash[i][j] * bases[i] + s[j]) % mods[i];
        mul[i][j + 1] = (mul[i][j] * bases[i]) % mods[i];
      }
    }
  }

  hash_type get(int l, int r) { // [l, r)
    int &&h0 = ((hash[0][r] - hash[0][l] * mul[0][r - l]) % mods[0] + mods[0]) % mods[0];
    int &&h1 = ((hash[1][r] - hash[1][l] * mul[1][r - l]) % mods[1] + mods[1]) % mods[1];
    return {h0, h1};
  }
};

main {
  int n = in();
  int m = in();
  RollingHash rh(in<string>());
  set<RollingHash::hash_type> hashes;
  int l = 0, r = 1;
  rep(i, m) {
    auto q = in<string>();
    if (q == "L++") l++;
    if (q == "L--") l--;
    if (q == "R++") r++;
    if (q == "R--") r--;
    hashes.emplace(rh.get(l, r));
  }
  cout << hashes.size() << endl;
}



Measured memory_bytes: 30944
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 2010
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,Q;
char g[MAX][MAX];
int s[MAX][MAX],sl[MAX][MAX],su[MAX][MAX];
int Calc(int s[][MAX],int x1,int y1,int x2,int y2)
{
	if(x1>x2||y1>y2)return 0;
	return s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1];
}
int main()
{
	n=read();m=read();Q=read();
	for(int i=1;i<=n;++i)scanf("%s",g[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			s[i][j]=(g[i][j]=='1');
			sl[i][j]=(g[i][j]=='1'&&g[i][j-1]=='1');
			su[i][j]=(g[i][j]=='1'&&g[i-1][j]=='1');
		}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
			sl[i][j]+=sl[i-1][j]+sl[i][j-1]-sl[i-1][j-1];
			su[i][j]+=su[i-1][j]+su[i][j-1]-su[i-1][j-1];
		}
	while(Q--)
	{
		int x1=read(),y1=read(),x2=read(),y2=read();
		printf("%d\n",Calc(s,x1,y1,x2,y2)-Calc(sl,x1,y1+1,x2,y2)-Calc(su,x1+1,y1,x2,y2));
	}
	return 0;
}


Measured memory_bytes: 53120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int q;
	cin>>q;
	while(q--){
		int n,X,Y;
		cin>>n>>X>>Y;
		vvi G(n);
		int x,y;cin>>x>>y;
		vi a(n),b(n);
		rep(i,n)cin>>a[i]>>b[i];
		rep(i,n)rep(j,n)if(i!=j&&hypot(a[i]-a[j],b[i]-b[j])<EPS+50){
			G[i].pb(j);
			G[j].pb(i);
		}
		vi in(n,-2000);
		int out=0;
		rep(i,n)if(hypot(x-a[i],y-b[i])<EPS+10)in[i]=X,out=X;
		while(1){
			vi ne=in;
			int t=out;
			rep(i,n)if(in[i]==t){
				rep(j,G[i].size())if(in[i]-Y>in[G[i][j]]){
					out=ne[G[i][j]]=t+X;
				}
			}
			if(in==ne){
				cout<<out<<endl;
				goto end;
			}
			if(out>1e5)break;
			in=ne;
		}
		cout<<"You're always welcome!"<<endl;
		end:;
	}
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 2000007;
const int MOD = 998244353;

int n, k;
LL frac[MAXN], rf[MAXN];

void init ();
void input ();
void work ();

int add ( int x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
	return x;
}

void addv ( int &x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
}

int dec ( int x, int y )
{
	x -= y;
	if ( x < 0 ) x += MOD;
	return x;
}

void decv ( int &x, int y )
{
	x -= y;
	if ( x < 0 ) x += MOD;
}

int qpow ( int a, int b )
{
	LL base = a, ans = 1;
	while ( b ){
		if ( b & 1 ) ( ans *= base ) %= MOD;
		( base *= base ) %= MOD;
		b >>= 1;
	}
	return SC ( int, ans );
}

int C ( int n, int m )
{
	if ( m > n || m < 0 ) return 0;
	return SC ( int, frac[n] * rf[m] % MOD * rf[n-m] % MOD );
}

int getans ( int n, int m, int x )
{
	if ( x < 0 ) return 0;
	++x;
	return dec ( C ( n + m, n ), C ( n + m, m - x ) );
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
	
	frac[0] = 1;
	lp ( i, 1, MAXN ) frac[i] = frac[i-1] * i % MOD;
	rf[MAXN-1] = qpow ( frac[MAXN-1], MOD-2 );
	lpdi ( i, MAXN-2, 0 ) rf[i] = rf[i+1] * ( i + 1 ) % MOD;
}

void input ()
{
	// input method
	
	cin >> k >> n;
}

void work ()
{
	// main work
	
	int b;
	int ans = 0;
	lpi ( r, 0, n ){
		b = n - r;
		
		if ( r == b ){
			addv ( ans, getans ( r, b - 1, r - k ) );
		}else if ( r > b ){
			addv ( ans, getans ( r, b, r - k ) );
		}
	}
	
	cout << ans << endl;
}

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

int main()  {
    string s;
    cin>>s;
    unordered_map<char,int> m;
    for(auto i:s)
        m[i]++;
    for(auto i:m)
    {
        if((i.second)%2)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3596
n,C = map(int,input().split())

d = [0 for i in range(C)]
for i in range(C):
    d_xy =  list(map(int,input().split()))
    d[i] = d_xy

c = [0 for i in range(n)]
for i in range(n):
    c_xy =  list(map(int,input().split()))
    c[i] = c_xy

li0 = [0 for i in range(C)]
li1 = [0 for i in range(C)]
li2 = [0 for i in range(C)]

for i in range(n):
    for j in range(n):
        a=i+1
        b=j+1
        if (a+b)%3==0:
            li0[c[i][j]-1] += 1
        elif (a+b)%3==1:
            li1[c[i][j]-1] += 1
        elif (a+b)%3==2:
            li2[c[i][j]-1] += 1

ans = (10**3)*500*500


for c0 in range(C):
    for c1 in range(C):
        for c2 in range(C):
            cst = 0
            if (c0==c1) or (c1==c2) or (c2==c0):
                continue

            for i in range(C):
                cst += d[i][c0]*li0[i]
                cst += d[i][c1]*li1[i]
                cst += d[i][c2]*li2[i]
            ans = min(ans,cst)

print(ans)




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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define inf (int)(1e9)
#define MAXX 1.1529215e+18
#define INF 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/
//DP(配るDP)
const int MAX_N=1000001;
int main(){
    int n;cin>>n;
    V dp(MAX_N,INF);
    dp[0]=0;
    rep(i,n){
        for(int j=1;i+j<=n;j*=6)dp[i+j]=min(dp[i+j],dp[i]+1);//dp[i]には最短経路が格納済み
        for(int k=1;i+k<=n;k*=9)dp[i+k]=min(dp[i+k],dp[i]+1);
        //printf("dp=%d\n",dp[i]);
    }
    cout<<dp[n]<<endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0

int main(){
	lli n;
	cin>>n;
	vector<lli> a;
	a.resize(n);
	lli sum=0;
	REP(i,n){
		cin>>a[i];
		sum += a[i];
	}
	sort(a.begin(),a.end());

	lli now=0;
	while(sum%10==0){
		if(now>=n)break;
		if(a[now]%10==0){
			now++;
		}
		else{
			sum -= a[now];
		}
	}
	if(sum%10==0)cout<<0<<endl;
	else cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    map<char, int> mp;
    for (int i = 0; i < 4; i++)
    {
        mp[s[i]]++;
    }
    int cnt = 0;
    int tmp = 0;
    for (auto p : mp)
    {
        cnt++;
        if (p.second == 2)
        {
            tmp++;
        }
    }
    if (cnt == 2 && tmp == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

map<long long, long long> way[100005];


bool dfs(long long start, long long cur){
	if(way[cur].size() == 0){
		return false;
	}

	long long next = way[cur].begin()->first;
	way[cur][next]--;
	if(way[cur][next]<=0){
		way[cur].erase(next);
	}

	way[next][cur]--;
	if(way[next][cur]<=0){
		way[next].erase(cur);
	}
	if(next == start){
		return true;
	}
	return dfs(start, next);
}


bool loop(long long idx){
	long long next = way[idx].begin()->first;
	way[idx][next]--;
	if(way[idx][next]<=0){
		way[idx].erase(next);
	}

	way[next][idx]--;
	if(way[next][idx]<=0){
		way[next].erase(idx);
	}

	return dfs(idx, next);
}


int main(){
	long long N, M;
	cin >> N >> M;

	for(long long i = 0; i < M; i++){
		long long a, b;
		cin >> a >> b;
		a--;b--;
		way[a][b]++;
		way[b][a]++;
	}

	for(long long i = 0; i < N; i++){
		while(way[i].size() != 0){
			//cout << "way[" << i << "].size() == " << way[i].size() << endl;
			if(loop(i) == false){
				cout << "NO" << endl;
				return 0;
			}
			/*
			for(int j = 0; j < N; j++){
				cout << "j = " << j << endl;
				for(int k = 0; k < way[j].size(); k++){
					cout << way[j][k] << endl;
				}
			}
			*/
		}
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 23168
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;

int main(void){
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        if(i%2==0 && S[i]=='R' || S[i]=='U' || S[i]=='D'){

        }
        else if(i%2==1 && S[i]=='L' || S[i]=='U' || S[i]=='D'){}
        else{
            cout <<"No" << endl;
            return 0;
        }

    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b, k;
  cin >> a >> b >> k;
  sl ans;
  rep(i, k) {ans.insert(min(a+i, b)); ans.insert(max(b-i, a));}
  for(ll i: ans) cout << i << newl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n;
	cin >> n; 

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

	map<ll,ll> mp;

	rep(i,n) mp[a[i]] = 0;

	ll ans = 0;
	rep(i,n){
		if(mp[a[i]] == a[i]) ans++;
		else mp[a[i]]++;
	}
	
	rep(i,n){
		if(mp[a[i]] > 0 && mp[a[i]] < a[i]){
			ans += mp[a[i]];
			mp[a[i]] = 0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 7040
N = int(input())
l = []
for _ in range(N):
    A, B = map(int, input().split())
    l.append((A, B))

t = N//2
tl = sorted(l)
tr = sorted(l, key=lambda x:-x[1])

if N%2:
    print(tr[t][1]-tl[t][0]+1)
else:
    a1, a2 = tl[t-1][0], tr[t][1]
    a3, a4 = tl[t][0], tr[t-1][1]
    print(a4-a3+a2-a1+1)


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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define repe(a, b) for (auto&(a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define mp(a, b) make_pair((a), (b))
#define Push_back(a, b) push_back( mp( (a), (b) ) )

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<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int inf = 0x3fffffff;
const int64_t INF = 0x3fffffffffffffff;
const int64_t MOD = 1e9+7;

int main() {
    int64_t n;
    cin >> n;
    std::vector<int64_t> x(n), y(n);
    std::vector<int64_t> z(n), w(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        z[i] = x[i]+y[i];
        w[i] = x[i]-y[i];
    }
    Sort(z);Sort(w);
    cout << max(z[n-1]-z[0], w[n-1]-w[0]) << endl;
    return 0;
}


Measured memory_bytes: 9592
class Pool:
    def __init__(self, pos, area):
        self.pos = pos
        self.area = area


data = input()

s1 = []
s2 = []
area_sum = 0
for i, v in enumerate(data):

    if v == '\\':
        s1.append(i)
    elif v == '/' and len(s1) > 0:
        j = s1.pop()
        area = i - j
        area_sum += area
        while len(s2) > 0 and s2[-1].pos > j:
            area += s2.pop().area
        s2.append(Pool(j, area))

print(area_sum)
print(len(s2), end='')
if len(s2):
    print(' ' + ' '.join([str(v.area) for v in s2]))
else:
    print()


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

inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
} 

string s;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout); 
	
	cin >> s;
	
	if(s[2]!=s[3]||s[4]!=s[5]){
		cout << "No";
		return 0;
	}
	
	cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 2005
int n,x,y;
int cnt[MAXN];
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    int circle=y-x+1;
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
           int dis=min(j-i,abs(i-x)+abs(j-y)+1);
           cnt[dis]++;
        }
    }
    for(int i=1;i<n;i++)
    printf("%d\n",cnt[i]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  priority_queue<int> pq;
  rep(i,n) {
    int a;
    cin >> a;
    pq.push(a);
  }

  while (m > 0) {
    int x = pq.top(); pq.pop();
    pq.push(x/2);
    m--;
  }

  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top(); pq.pop();
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
int ucm(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int x[n+1],y[m+1];
  scanf("%d%d",&x[0],&y[0]);
  for(i=1;i<n+1;i++)scanf("%d",&x[i]);
  for(i=1;i<m+1;i++)scanf("%d",&y[i]);
  qsort(x,n+1,sizeof(int),ucm);
  qsort(y,m+1,sizeof(int),ucm);
  if(x[n]<y[0])printf("No War");
  else printf("War");
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
//        long startTime = System.currentTimeMillis();
 
        Scanner scanner = new Scanner(System.in);
 
        int N = scanner.nextInt();
 
        ArrayList<Long> X = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            X.add(scanner.nextLong());
        }
        scanner.close();

        @SuppressWarnings("unchecked")
        ArrayList<Long> C = (ArrayList<Long>) X.clone();
        Collections.sort(C);
//        System.out.println(C);
        int l = C.size();
        int d = l / 2;
//        System.out.println(l);
//        System.out.println(d);
        Long medi = C.get(d-1);
        
        for (int i = 0; i < N; i++) {
            Long x = X.get(i);
            if (medi >= x) {
                System.out.println(C.get(d));                
            }
            if (medi < x) {
                System.out.println(C.get(d-1));
            }
        }
//        System.out.println(System.currentTimeMillis() - startTime);
    }
}

Measured memory_bytes: 102048
n, m = map(int, input().split())
li = []
for _ in range(n):
    a, b = map(int, input().split())
    li.append((a, b))
li.sort()
money = 0
for a, b in li:
    if m <= 0: break
    if b > m:
        money += a * m
    else:
        money += a * b
    m -= b
print(money)

Measured memory_bytes: 16892
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

inline void add(int& a, int b){a = (a+b); if(a>=mod)a-=mod;}
inline void sub(int& a, int b){a = a-b; if(a<0)a+=mod;}
inline void mul(int& a, int b){a = (a*b)%mod;}

const int N = 3e4;
int n;
vi dp(N+1,0);

vector<pair<int,pair<int,int>>> arr;
bool cmp(pair<int,pair<int,int>> a , pair<int,pair<int,int>> b){
    return a.F+a.S.F < b.F+b.S.F;
}

void mymain(){
    cin >> n;
    arr.resize(n);
    int mw=INT_MAX,jj=-1;
    for(int i=0;i<n;i++){
        cin >> arr[i].S.F >> arr[i].F >> arr[i].S.S;
    }
    sort(all(arr),cmp);
    /*for(int i=0;i<n;i++){
        if(arr[i].S.F < mw){
            mw = arr[i].S.F;
            jj=i;
        }
    }*/


    //dp[arr[0].S.F] = arr[0].S.S;
    //for(int i : dp)
     //   cout << i <<" ";
    //cout << endl;
    for(int i=0;i<n;i++){
        //if(i==jj)
         //   continue;
        int w = arr[i].S.F,s=arr[i].F,v=arr[i].S.S;
        //vi ndp(dp);
        //for(int i=0;i<N;i++)
        //    ndp[i]=dp[i];

        for(int j=s;j>=0;j--){
                if(w+j <= N)
                dp[w+j] = max(dp[w+j],dp[j]+v);
        }
        //ndp[w] = max(ndp[w],v);
       // deb(i)
       // debarr(ndp)
        //dp = ndp;
    }

    int ans = 0;
    for(int i : dp)
        ans = max(ans,i);//,cout << i <<" ";
        //cout << endl;
    cout << ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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

int main() {
  int l, r, d;
  int ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if (i%d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){\
        int n; cin>>n;
        vector<ll> a(n);
        FOR(i,0,n) cin>>a[i];
        ll mx = *max_element(all(a));
        int mark[mx+1];
        memset(mark,0,sizeof(mark));
        FOR(i,0,n){
            for(ll x=a[i];x<=mx;x+=a[i]) mark[x]++;
        }
        ll ans = 0;
        FOR(i,0,n)
            if(mark[a[i]]==1) ans++;
        cout<<ans;
    }   
}



Measured memory_bytes: 8740