akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

const int INF = 1e9 + 1;

int main(){
  int in;
  scanf("%d", &in);
  int er_N = 1 << in;
  priority_queue<int> heaven;
  for(int i = 0; i < er_N; i++){
    scanf("%d", &in);
    heaven.push(in);
  }
  
  multiset<int> live;
  live.insert(heaven.top());
  heaven.pop();
  
  bool valid = true;
  while(valid && !heaven.empty()){
    vector<int> unborn;
    vector<int> born;
    for(auto itr = live.rbegin(); itr != live.rend(); itr++){
      int slime = INF;
      while(!heaven.empty()){
        slime = heaven.top();
        heaven.pop();
        if(slime >= *itr){
          unborn.emplace_back(slime);
        }else break;
      }
      if(slime < *itr){
        born.emplace_back(slime);
      }else{
        valid = false;
        break;
      }
    }
    
    if(valid){
      for(int slime : born){
        live.insert(slime);
      }
      for(int slime : unborn){
        heaven.push(slime);
      }
    }
  }
  
  puts(valid ? "Yes" : "No");
  
  return 0;
}

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

typedef long long ll;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

vector<int> grafo[MAXN];
ll dp[MAXN][2];
int N;

ll solve(int v,int c,int p){

	if(dp[v][c] != -1) return dp[v][c];

	ll tot = 1;
	for(int u : grafo[v]){
		if(u == p) continue;
		if(c == 0) tot = (tot * (solve(u,0,v) + solve(u,1,v))) % MOD;
		else tot = (tot * solve(u,0,v)) % MOD;
	}

	return dp[v][c] = tot;

}

int main(){

	memset(dp,-1,sizeof(dp));

	scanf("%d",&N);
	for(int i = 1;i<N;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}

	printf("%lld\n", (solve(1,0,-1) + solve(1,1,-1)) % MOD );

	return 0;

}

Measured memory_bytes: 15616
import math
import statistics
import heapq

X = int(input())
# s, t = [input() for _ in range(2)]
# N = int(input())
# An = [int(e) for e in input().split()]

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)


Measured memory_bytes: 72832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-3;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;



int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int maxx = -1, a[3];
    for(int i=0; i<3; i++){
        scanf("%d",&a[i]);
        maxx = max(maxx,a[i]);
    }
    int b[100];
    mst(b,0);
    int ans = 0;
    for(int i=0; i<3; i++) {
        ans += (maxx-a[i])/2;
        a[i] += (maxx-a[i])/2*2;
        b[a[i]]++;
    }
    if(b[maxx] == 2) ans += 2;
    else if(b[maxx] == 1) ans ++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll x;
   cin>>x;
   if(x>=400&&x<600)
   {
       cout<<8<<"\n";
       return;
   } 
   if(x>=600&&x<800)
   {
       cout<<7<<"\n";
       return;
   }    
   if(x>=800&&x<1000)
   {
       cout<<6<<"\n";
       return;
   }
   if(x>=1000&&x<1200)
   {
       cout<<5<<"\n";
       return;
   }
   if(x>=1200&&x<1400)
   {
       cout<<4<<"\n";
       return;
   }
   if(x>=1400&&x<1600)
   {
       cout<<3<<"\n";
       return;
   }
   if(x>=1600&&x<1800)
   {
       cout<<2<<"\n";
       return;
   }
   if(x>=1800&&x<2000)
   {
       cout<<1<<"\n";
       return;
   }
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int32_t main()
{
	FIO;
	int k; cin >> k;
	vi vis(k, 0);

	int done = 0;

	int cur = 1, mdv = 7 % k;

	while (true)
	{
		if (mdv == 0)
		{
			cout << cur << '\n';
			return 0;
		}

		else if (vis[mdv])
		{
			cout << -1 << '\n';
			return 0;
		}

		else
		{
			vis[mdv] = cur;
			cur++;
			mdv = (10 * mdv + 7) % k;
		}
	}
	return 0;
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long n,ans = 0 ;
   cin>>n;
   pair <long long,long long> p[n];
   for(int i = 0 ;i < n; i ++)
   {
   	cin>>p[i].first>>p[i].second;
   }
   for(int i = n - 1; i >= 0 ;i --)
   {
   	p[i].first+=ans;
   	long double l = p[i].first,r = p[i].second;
   	if(p[i].first % p[i].second != 0)
   	{
   		ans+=(ceil(l / r) * p[i].second) - p[i].first;
	}
   }cout<<ans;
}

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

using namespace std;
using pii = pair<int, int>;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(n);

  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }

  sort(v.begin(), v.end());

  priority_queue<int, vector<int>> q;

  int iv = 0;
  int ret = 0;

  for (int i = 1; i <= m; i++) {
    while (iv < n && v[iv].first <= i) {
      q.push(v[iv].second);
      iv++;
    }

    if (!q.empty()) {
      ret += q.top();
      q.pop();
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string S, T; cin >> S >> T;
    int N = S.size();
    bool can = false;

    for (int i = 0; i < N; ++i) {
        string tmp = "";
        for (int j = 0; j < N; ++j) tmp += S[(i + j) % N];
        can |= T == tmp;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define lli long long int
# define pb push_back
# define pf pop_front()
# define loop(i,a,b) for(int i=a;i<b;i++)
# define loopl(i,a,b) for(lli i=a;i<b;i++)
# define lb lower_bound
# define ub upper_bound
# define INF 1000000000
# define mod 1000000007

using namespace std ;

int gcd(int a, int b)
{
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}
int main()
{
   int d,n;
   cin>>d>>n;
   lli ans=n;
   if(n!=100)
   {
   if(d==0) cout<<ans<<endl;
   else if(d==1) cout<<ans*100<<endl;
   else cout<<ans*10000<<endl;
   }
   else
   {
   	if(d==0) cout<<101<<endl;
   	else if(d==1) cout<<10100<<endl;
   	else cout<<1010000<<endl;
	} 
}


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF (INT_MAX/3)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    int v = 0;

    REP(i, 3)
    {
        string c; cin >> c;
        v *= 10;
        v += atoi(c.c_str());
    }

    cout << ((v % 4 == 0) ? "YES" : "NO");

    return 0;

}

// 00:04:00


Measured memory_bytes: 256
#include <stdio.h>
#define N 25
#define EMPTY -1

typedef struct {
  int parent;
  int left;
  int right;
} Node;

Node node[N];

void preParse(int u){
  if(u == EMPTY) return;
  printf(" %d",u);
  preParse(node[u].left);
  preParse(node[u].right);
}

void inParse(int u){
  if(u == EMPTY) return;
  inParse(node[u].left);
  printf(" %d",u);
  inParse(node[u].right);
}

void postParse(int u){
  if(u == EMPTY) return;
  postParse(node[u].left);
  postParse(node[u].right);
  printf(" %d",u);
}

int main(){
  int i,j,n,l,r,id,root;

  scanf("%d",&n);

  for(i=0; i<n; i++) {
    node[i].left = EMPTY;
    node[i].right = EMPTY;
    node[i].parent = EMPTY;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d",&id,&l,&r);
    node[id].left = l;
    node[id].right = r;
    if(l != EMPTY) node[l].parent = id;
    if(r != EMPTY) node[r].parent = id;
  }

  for(i=0; i<n; i++) if(node[i].parent == EMPTY) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

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

using namespace std;
int main() {
	int n;
	int now = 1;
	int brick = 0;
	cin >> n;
	vector<int> a(n),s(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	
	for (int i = 0; i < n; i++) {
		if (now == a[i]) {
			now++;
		}
		else {
			brick++;
		}
	}
	if (brick == n) {
		brick = -1;
	}
	cout << brick;

	return 0;
}

Measured memory_bytes: 1920
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

in_list = [a,b,c,d,e]
flag = True
for i in in_list:
	for j in in_list:
		if i - j > k:
			flag = False
if flag:
	print('Yay!')
else:
	print(':(')

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

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1
#define PI 3.14159265


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

    int n;
    cin >> n;
    string str;
    cin >> str;

    int earr[n + 1] , warr[n + 1];
    earr[0] = warr[0] = 0;
    for(int i = 0 ; i < n ; i++) {
        if(str[i] == 'W') {
            warr[i + 1] = warr[i] + 1;
            earr[i + 1] = earr[i];
        }
        else {
            earr[i + 1] = earr[i] + 1;
            warr[i + 1] = warr[i];
        }
    }

    int ans = INT_MAX;

    for(int i = 1 ; i <= n ; i++) {
        ans = min(ans , (warr[i - 1] + earr[n] - earr[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n,m;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<(1<<n);i++){
		for(int j=1;j<(1<<m);j++){
			if(lowbit(i)==lowbit(j))
				cout<<1;
			else
				cout<<0;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
    multiset<string> S;
    rep(i,0,3){
        int x;
        cin >> x;
        rep(j,0,x) S.insert(string(1 , i + 'a'));
    }
    while(sz(S) > 1){
        auto it = S.end();
        --it;
        string a = *S.begin() + *it;
        S.erase(it);
        S.erase(S.begin());
        S.insert(a);
    }
    cout << *S.begin() << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int n = scan.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        System.out.println(sum >= h ? "Yes" : "No");
        scan.close();
    }
}

Measured memory_bytes: 50676
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define INF 0x7fffffff

int d;
int n;
int a[200];
int b[200];
int c[200];
int t[200];
int dp[200][200]; // dp[day][used]
int ans;

int main() {
    scanf("%d %d", &d, &n);

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

    for (int i=0; i<n; i++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }

    for (int i=0; i<n; i++) {
        if (t[0] < a[i] || b[i] < t[0]) dp[0][i] = -INF;
    }

    for (int i=1; i<d; i++) {
        for (int j=0; j<n; j++) {
            if (t[i] < a[j] || b[j] < t[i]) continue;
            for (int k=0; k<n; k++) {
                int val;

                if (dp[i-1][k] < 0) continue;
                val = dp[i-1][k] + abs(c[j] - c[k]);
                dp[i][j] = max(dp[i][j], val);
            }
        }
    }

    for (int i=0; i<n; i++) {
        ans = max(ans, dp[d-1][i]);
    }

    printf("%d\n", ans);
}

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

int main()
{
    char s1,s2,s3;
    int count=0;
    cin>>s1>>s2>>s3;
    if(s1=='1')
    {
        count++;
    }
    if(s2=='1')
    {
        count++;
    }
    if(s3=='1')
    {
        count++;
    }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL)

int main(){
  FastIO;
  string S , T;
  cin >> S;
  cin >> T;
  int count = 0;
  for(int i = 0;i < S.size();i++){
    if(S[i] != T[i])
      count++;
  }
  cout << count << "\n";
  return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100 + 5;
ll mp[maxn][maxn];

int main()
{
    
    int v,e;
    scanf("%d%d",&v,&e);
    memset(mp, 0x3f,sizeof(mp));
    for(int i = 1;i <= v;i ++) mp[i][i] = 0;
    int a,b,c;
    for (int i= 0; i < e; i ++) {
        scanf("%d%d%d",&a,&b,&c);
        a ++,b ++;
        mp[a][b] = c;
    }
    for (int k = 1; k <= v; k ++) {
        for (int i = 1; i <= v; i ++) {
            for (int j = 1; j <= v; j ++) {
                if(mp[i][k] != INF && mp[k][j] != INF){
                    mp[i][j] = min(mp[i][j],mp[i][k] + mp[k][j]);
                }
            }
        }
    }
    bool fg = 0;
    for (int i = 1; i <= v; i ++) {
            if(mp[i][i] < 0) {fg = 1;break;}
        
    }
    if(fg) printf("NEGATIVE CYCLE\n");
    else{
        for (int i = 1; i <= v; i ++) {
            for (int j = 1; j <= v; j ++) {
                if(mp[i][j] == INF) printf("INF");
                else printf("%lld",mp[i][j]);
                if(j == v) printf("\n");
                else printf(" ");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
char s[maxn],cnt=0;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	while(n>0)
	{
		n--;
		s[cnt++]=n%26LL+'a';
		n/=26LL;
	}
	for(long long i=cnt-1;i>=0;i--)
		cout<<s[i];
	cout<<endl;
	return 0;
}




Measured memory_bytes: 3672
def main():
    N = int(input())
    A = []
    for i in range(N):
        a = int(input())
        XY = []
        for _ in range(a):
            x,y = map(int,input().split())
            XY.append((x-1,y))

        A.append(XY)
    # print(A)

    MAX = 0
    for i in range(2**N):
        # print(i)
        flg = 1
        for j in range(N):
            if (i >>j) & 1:
                # print('b')
                for ch in A[j]:
                    # print(i,ch[0],bin(i >> ch[0]),ch[1],(i >> ch[0])^ ch[1])
                    if ((i >> ch[0])^ ch[1])%2 == 1:
                        # print('a',ch[0])
                        flg = 0

        if flg == 1:
            t = bin(i).count('1')
            MAX = max(t,MAX)
        
    print(MAX)



main()

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter

def main():
    v = list(map(int, input().strip().split()))
    if len(Counter(v)) == 2:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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

int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	vector<int> a(4);
	for (int i = 0; i < 4; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cout << abs(a[0]+a[3]-(a[1]+a[2]))<<endl;
	



	
	
	return 0;
}




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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    ll sum_a = 0, sum_b = 0;
    ll a[n], b[n];

    rep(i, n){
        cin >> a[i];
        sum_a += a[i];

    }
    rep(i, n){
        cin >> b[i];
        sum_b += b[i];
    }

    if(sum_a > sum_b){
        No();
        return 0;
    }


    ll ope = sum_b - sum_a;
    ll least = 0;
    rep(i, n){
        if(a[i] < b[i]){
            least += (b[i]-a[i]+1)/2;
        }
    }
    Judge(least <= ope);

    return 0;




}


Measured memory_bytes: 384
#include <iostream>

int main()
{
    long long X;
    std::cin >> X;
    constexpr int RANGE_MAX = 178;
    long long pow5[RANGE_MAX];
    for (int i = 0; i < RANGE_MAX; i++)
    {
        long x = i;
        pow5[i] = x * x * x * x * x;
    }

    for (int A = 0; pow5[A] <= 1000000000; A++)
    {
        for (int B_ = 0; pow5[B_] <= 1000000000; B_++)
        {
            if (pow5[A] + pow5[B_] == X)
            {
                std::cout << A << " " << -B_ << std::endl;
                return 0;
            }
        }
    }
    for (int A = 0; A < RANGE_MAX; A++)
    {
        for (long long B = 0; B < A; B++)
        {
            if (pow5[A] - pow5[B] == X)
            {
                std::cout << A << " " << B << std::endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3572
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

const int NUMBER = 200000;

int n,k;
int p[NUMBER];

int sum(int p[],int q,int r)
{
    int c = 0;
    for (int i = q;i <= r;i++){
        c += p[i];
    }
    return c;
}
int main()
{
    cin >> n >> k;
    for (int i = 0;i < n;i++){
        cin >> p[i];
    }
    
    int ans = sum(p,0,k-1);
    int dep = ans;
    for (int i = k;i < n;i++){
        dep = dep + p[i] - p[i-k];
        if (ans < dep){
            ans = dep;
        }
    }
    
    double x = (double)(ans+k)/2;
    printf("%.8lf\n",x);
}




Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int h,w;
	cin>>h>>w;
	string s[1002];
	for(int i=0;i<h;i++)
	cin>>s[i];
	int dp[1002][1002];
	// dp[i][j] is the number of ways to reach cell ,j from 0,0
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i) {
				if(s[i-1][j]!='#')
				dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			}
			if(j){
					if(s[i][j-1]!='#')
				dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1]%mod;
	
}

Measured memory_bytes: 8616
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		//処理
		String ans = "ABC";
		if(x >= 1200) ans = "ARC";

		//出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/
ll pown(ll x,ll n){
    if( x == 0) return 1;
    else return pown(x - 1,n) * n;
}
bool rp(int n){
    char S[5];
    for(int i = 0;i < 5;i++){
        S[i] = n / pown(4 - i,10);
        n %= pown(4-i,10);
    }
    bool ans = true;
    for(int i = 0;i < 2;i++){if(S[i] != S[4-i]){ans = false;}};
    return ans;
}
/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int A,B; cin >> A >> B;
    int cnt = 0;
    for(int i = A;i <= B;i++) if(rp(i)) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[1005],b[1005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[a[i]]++;
	sort(a+1,a+n+1);
	bool f=1;
	if(a[1]!=(a[n]+1)/2)f=0;
	for(int i=a[1]+1;i<a[n];i++)if(b[i]<2)f=0;
	if(a[n]&1&&b[a[1]]!=2)f=0;
	if(!(a[n]&1)&&b[a[1]]!=1)f=0;
	if(f)puts("Possible");else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

template<typename T>
T kiriage(T a, T b)
{
	return (a + b - 1) / b;
}

void Main()
{
	int N, K; cin >> N >> K;
	string S; cin >> S;
	int res = 0;
	int boundary = 0;
	rep(i, S.length() - 1) {
		if (S[i] == S[i + 1]) {
			res++;
		} else {
			boundary += 1;
		}
	}
	int cnt = kiriage(boundary, 2);
	if (cnt <= K) {
		if (boundary % 2 != 0) {
			res += cnt * 2 - 1;
		} else {
			res += cnt * 2;
		}
	} else {
		res += K * 2;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
#define endl "\n";
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
    int n;
    cin >> n;
    vi a; in(a,n);
    ll res = 0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            res += (a[i-1]-a[i]);
            a[i] = a[i-1];
        }
    }
    cout << res << endl;

}

Measured memory_bytes: 4260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;

    s = '-' + s;
    for(int i = a; i <= c; i++) {
        if(s[i]=='#' && s[i-1]=='#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = b; i <= d; i++) {
        if(s[i]=='#' && s[i-1]=='#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if(c<d) cout << "Yes" << endl;
    else {
        for(int i = b; i <= d; i++) {
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,Q;
    cin >> N >> Q;
    queue<P> que;
    for(int i = 0;i < N;i++) {
        string S;
        int A;
        cin >> S >> A;
        que.push(P(S,A));
    }
    int cnt = 0;
    while(!que.empty()) {
        P p;
        p = que.front();
        que.pop();
        if(p.second <= Q) {
            cout << p.first << " " << cnt + p.second << endl;
            cnt += p.second;
        }
        else {
            que.push(P(p.first,p.second - Q));
            cnt += Q;
        }
    }
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0; i<n; i++) cin >> h[i];

	bool ans(true);
	int hmin(1e+9);
	for(int i=n-1; i>0; i--){
		if(h[i] < hmin) hmin = h[i];
		if(h[i-1]-h[i] > 1) ans = false;
		if(h[i]-hmin > 1) ans = false;
	}

	// int hlast = h[n-1];
	// sort(h.begin(), h.end());
	// if(h[n-1] >= hlast + 2) ans = false;

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int Q;
    cin>>Q;
    vector <int>l(Q);
    vector <int>r(Q);
    for(int i=0 ; i<Q ; i++){
        cin>>l[i] ;
        cin>>r[i] ;
    }
    const int OFF=100000;
    vector <bool> t(OFF+1,false);
    vector <int> n(OFF+2,0);
    for(int i=2 ; i<=OFF ;i++){
        if(t[i]==false){
            for(int k=i+i ; k<=OFF ; k+=i){
                t[k]=true;
            }
        }
    }
    for(int i=3 ; i<=OFF ;i+=2){
        if(t[i]==false && t[(i+1)/2]==false)n[i]+=1;
    }
    for(int i=3 ; i<=OFF ;i++){
        n[i]+=n[i-1];
    }
    for(int i=0 ; i<Q ;i++){
        cout<<n[r[i]]-n[l[i]-1]<<endl;
    }
    return 0;

}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;





int main(int argc, char *args[]) {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int N = 5;

	vector<int> Time = { a,b,c,d,e };

	vector<int> NextTime(N);
	for (int i = 0; i < N; i++) {
		if (Time[i] % 10 == 0)NextTime[i] = Time[i];
		else NextTime[i] = Time[i] - Time[i] % 10 + 10;
	}

	int BestTime = 9999999;
	
	for (int i = 0; i < N; i++) {
		int Sum = 0;
		for (int j = 0; j < N; j++) {
			if (i == j)Sum += Time[j];
			else Sum += NextTime[j];
		}
		BestTime = min(BestTime, Sum);
	}
	cout << BestTime << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005

ll he[N],yi[N];

int main()
{
    ll n,i,x,l,r,ans;

    while (scanf("%lld",&n)!=EOF)
    {
        for (i=1;i<=n;i++)
        {
            scanf("%lld",&x);
            he[i]=he[i-1]+x;
            yi[i]=yi[i-1]^x;
        }

        l=1;
        ans=0;

        for (r=1;r<=n;r++)
        {
            for (;he[r]-he[l-1]!=(yi[r]^yi[l-1]);l++); 
            	ans+=r-l+1;
        }
        
        printf("%lld\n",ans);
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int X;
int Y;
char C[102];
int main(){
  int Lj4PdHRW;
  rd(X);
  rd(Y);
  for(Lj4PdHRW=0;Lj4PdHRW<(X);Lj4PdHRW++){
    rd(C);
    wt_L(C);
    wt_L('\n');
    wt_L(C);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int X, Y;
// char C[102];
// {
//   rd(X,Y);
//   rep(X) rd(C), wtLn(C, C);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
int main()
{
    int x,y ;
    cin>>x>>y ;

    
     for(int i=0;i<=x;++i){
        if( ((i*4)+(x-i)*2) == y){
        cout<<"Yes";
          return 0;
        }
          
     }
  cout<<"No";  

    return 0;
}

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

int main(){
  int i;
  string s,t;
  cin>>s>>t;
  for(i=0;i<s.size();i++){
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
    s=s.substr(1)+s[0];
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int count = 0;
  
  for(int i=0;i<n;i++)
  {
    if((i+1)&1 and a[i]&1)
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		long a[][][] = new long[N][N*3+1][N];
		long w[] = new long[N];
		long v[] = new long[N];
		for (int i = 0; i < N; i++) {
			w[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		if (w[0] >= W) {
			System.out.println(0);
			return;
		}
		a[0][0][0] = v[0];
		for (int i = 1; i < N; i++) {
			if (w[i] <= W) {
				a[0][(int) (w[i] - w[0])][i] = Math.max(v[i], a[0][(int) (w[i] - w[0])][i-1]);
			}
//			if (w[0]==2) {
//				if (w[i]>=4) {
//					a[1][(int) (w[i] - w[0])-2][i] = Math.max(a[0][(int) (w[i] - w[0])][i], a[1][(int) (w[i] - w[0])-2][i-1]);
//					a[0][(int) (w[i] - w[0])][i] = Math.max(a[0][(int) (w[i] - w[0])][i], a[1][(int) (w[i] - w[0])-2][i-1]);
//				}
//			} else if (w[0]==1) {
//
//			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N*3+1; k++) {
					if (a[j][k][i - 1] > 0) {
						long nowW = (j + 1) * w[0] + k;
						if (nowW + w[i] <= W) {
							a[j + 1][k + (int) (w[i] - w[0])][i] = Math.max(a[j][k][i - 1] + v[i],
									a[j + 1][k + (int) (w[i] - w[0])][i]);
						}
						a[j][k][i] = Math.max(a[j][k][i - 1], a[j][k][i]);
					}
				}
			}
		}
		long max = 0;
		for (int i=0;i<N;i++) {
			for (int k = 0; k < N*3+1; k++) {
				if (a[i][k][N-1]>max) {
					max = a[i][k][N-1];
				}
			}
		}
		System.out.println(max);

	}
}

Measured memory_bytes: 53968
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,x;
    1<=a<=100;
    1<=b<=100;
    1<=x<=200;
    scanf("%d %d %d",&a,&b,&x);
    if(x<=(a+b)&&x>=a)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        int c = Integer.parseInt(scanner.next());
        scanner.close();

        Integer[] array = {a, b, c};

        Arrays.sort(array, Comparator.reverseOrder());

        boolean canShare = array[0] == (array[1] + array[2]);

        System.out.println(canShare ? "Yes" : "No");
    }
}


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

int main() {
    int N,res=0;

    cin >> N;

    vector<int> V(N);
    vector<int> C(N);
    vector<int> A(N);

    
    for(int i = 0; i < N; i++)
    {
        cin >> V.at(i);
    }
    for(int i = 0; i < N; i++)
    {
        cin >> C.at(i);
    }

    for(int i = 0; i < N; i++)
    {
        A.at(i) = V.at(i) - C.at(i);
    } 

    for(int i = 0; i < N; i++)
    {
        if(A.at(i)>0){
            res += A.at(i);
        }
    } 
    
    cout << res <<endl;



    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	int n,i,j;
	int taro=0,hana=0;
	char t[101],h[101];

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",&t,&h);
		j=strcmp(t,h);
		if (j>0) taro+=3;
		else if (j<0) hana+=3;
		else {taro++;hana++;}
	}
	printf("%d %d\n",taro,hana);
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;

int main()
{
	vector<int> x;
	int N;
	cin >> N;
	x.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}

	sort(x.begin(), x.end());

	cout << x[x.size() - 1] - x[0];
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
data = []
for i in range(m):
    data.append(list(map(int, input().split())))
data.reverse()
class UnionFind:
    def __init__(self, n):
        #親ノードの番号を格納
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)
    def find(self, x):
        #根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        #同じかどうかの確認
        return self.find(x) == self.find(y)
    def union(self, x, y):
        #統合する
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
        else:
            self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
    def getsize(self, x):
        p = self.find(x)
        return self.size[p]
    def printsize(self):
        print(self.size)
    def printparents(self):
        print(self.par)
ans = []
ans.append(n*(n-1)//2)
graph = UnionFind(n)
for i in range(1, len(data)):
    a, b = data[i - 1]
    #print("{} {}".format(a, b))
    if graph.same_check(a,b):
        ans.append(ans[i-1])
    else:
        ans.append(ans[i-1] - (graph.getsize(a) * graph.getsize(b)))
        graph.union(a,b)
ans.reverse()
for i in ans:
    print(i)




Measured memory_bytes: 34980
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    int N;
    cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;
}

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

#define N 100005

int n, a[N][3], f[N][3];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 3; ++j)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= n; ++i) {
        f[i][0] = max(f[i - 1][1], f[i - 1][2]) + a[i][0];
        f[i][1] = max(f[i - 1][0], f[i - 1][2]) + a[i][1];
        f[i][2] = max(f[i - 1][0], f[i - 1][1]) + a[i][2];
    }
    cout << max(f[n][0], max(f[n][1], f[n][2]));
    return 0;
}


Measured memory_bytes: 2560
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)
        

Measured memory_bytes: 47496
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		uint32_t a, b;
		cin >> a >> b;

		bitset<32> bt( a ), bt2( b );
		cout << (bt & bt2) << '\n'
			<< (bt | bt2) << '\n'
			<< (bt ^ bt2) << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

struct Coordinate {
	int h, w;
	std::vector<Coordinate> neighbors() const {
		return { {h + 1, w}, {h - 1, w}, {h, w + 1}, {h, w - 1} };
	}
};
int main() {
	int height, width; std::cin >> height >> width;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	std::queue<Coordinate> queue;
	std::vector<std::vector<bool>> is_searching(height, std::vector<bool>(width, false));
	int max_distance = 0;
	for (auto h = 0; h < height; ++h) for (auto w = 0; w < width; ++w) if (state[h][w] == '.') {
		for (auto& l : is_searching) std::fill(l.begin(), l.end(), false);
		queue.push(Coordinate{ h, w });
		is_searching[h][w] = true;
		int count = -1;
		while (!queue.empty()) {
			++count;
			for (auto _c = queue.size(); _c > 0; --_c) {
				const auto top = queue.front(); queue.pop();
				for (const auto next : top.neighbors()) if (0 <= next.h && next.h < height && 0 <= next.w && next.w < width && state[next.h][next.w] == '.' && !is_searching[next.h][next.w]) {
					is_searching[next.h][next.w] = true;
					queue.push(next);
				}
			}
		}
		max_distance = std::max(max_distance, count);
	}
	std::cout << max_distance << std::endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int r,g;
  cin  >> r >> g;
  cout << r+2*(g-r) << endl;
  return 0;
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e5 + 5;

const int inf = (signed) (~0u >> 2);

typedef class Segment {
public:
    int l, r;

    Segment() { }
    Segment(int l, int r) : l(l), r(r) {    }

    Segment operator & (Segment b) const {
        return Segment(max(l, b.l), min(r, b.r));
    }
    int length() {
        return max(r - l + 1, 0);
    }
    boolean operator < (Segment b) const {
        return r < b.r;
    }
} Segment;

int n;
Segment s[N], sl[N], sr[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &s[i].l, &s[i].r);
    }
    sort(s + 1, s + n + 1);
    int ans = 0;
    sl[0] = Segment(0, inf);
    for (int i = 1; i <= n; i++)
        sl[i] = sl[i - 1] & s[i];
    sr[n + 1] = Segment(0, inf);
    for (int i = n; i; i--)
        sr[i] = sr[i + 1] & s[i];
    for (int i = 1; i < n; i++)
        ans = max(ans, sl[i].length() + sr[i + 1].length());
    for (int i = 1; i <= n; i++)
        ans = max(ans, s[i].length() + (sl[i - 1] & sr[i + 1]).length());
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
A = list(map(int, input().split()))
q = int(input())
Q = list()
for i in range(q):
    tmp = list(map(int, input().split()))
    Q.append(tmp)
for query in Q:
    if query[0] == 0:
        print(min(A[query[1]:query[2]]))
    else:
        print(max(A[query[1]:query[2]]))


Measured memory_bytes: 5820
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
    int N;
    vector<int> A;
    
    cin >> N;
    A.push_back(0);
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    int totalCost = 0;
    for(int i=0; i<=N; i++) {
        int j = (i+1) % (N+1);
        totalCost += abs(A[j] - A[i]);
    }

    for(int i=1; i<=N; i++) {
        int j = (i+1) % (N+1);
        int k = (i-1) % (N+1);
        int ans = totalCost - abs(A[j] - A[i]) - abs(A[i] - A[k]) + abs(A[j] - A[k]);
        cout << ans << endl;
    }

}

Measured memory_bytes: 1784