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

using namespace std;

class UnionFind {
  unordered_map<int, int> graph_;
  unordered_map<int, int> sizes_;
public:
  int Root(int key) {
    if (graph_.count(key) == 0 || graph_[key] == key) {
      return key;
    } else {
      return graph_[key] = Root(graph_[key]);
    }
  }

  bool Same(int key1, int key2) {
    return Root(key1) == Root(key2);
  }
  
  void Unite(int key1, int key2) {
    if (Same(key1, key2)) {
      return;
    }
    
    int root1 = Root(key1);
    int root2 = Root(key2);
    int size = Size(root1) + Size(root2);
    graph_[root1] = root2;
    sizes_[root2] = size;
  }

  int Size(int key) {
    int root = Root(key);
    return sizes_.count(root) > 0 ? sizes_[root] : 1;
  }
};


int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; i++) {
    cin >> edges[i].first >> edges[i].second;
    edges[i].first--, edges[i].second--;
  }
  
  int ans = 0;
  for (int i = 0; i < m; i++) {
    UnionFind uf;
    for (int j = 0; j < m; j++) {
      if (j == i) {
        continue;
      }
      
      uf.Unite(edges[j].first, edges[j].second);
    }
    
    int key = i == 0 ? 1 : 0;
    if (uf.Size(key) < n) {
      ans++;
    }
  }
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
#include <math.h>

signed main(){
	acc_io;
	ll x;
	cin>>x;
	ll y=1,tmp=100;
	while(1){
//		tmp/=100;
		tmp*=1.01;
		if(x<=tmp) break;
		y++;
	}
	cout<<y<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k; cin>>n>>k;
    vi v(n);
    for(int i =0;i<n;++i){
        cin>>v[i];
    }
    sort(all(v));
    int ans =0;
    for(int i =0;i<k;++i)ans +=v[i];
    cout << ans;
    
   
    return 0;
}

// Химаншу    

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

#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define int long long
#define all(a) a.begin(),a.end()
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};



int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> A(n);
	for(auto &a:A)
		cin >> a;
	for(int i=1;i<n;i++)
		A[i]+=A[i-1];
	int ans = 1000;
	for(int i=0;i<n;i++){
		ans = min(ans,abs(A[i]-(A[n-1]-A[i])));
	}
	cout << ans <<'\n';
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




















Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	char a[4],b[4];
	while(scanf("%s%s",&a,&b)!=EOF){
		if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
		printf("YES\n");
		else
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
K_X = list(map(int, input().split()))
min_cordinate = K_X[1]-(K_X[0]-1)
max_cordinate = K_X[1]+(K_X[0]-1)
if min_cordinate < -1000000:
    min_cordinate = -1000000
if max_cordinate > 1000000:
    max_cordinate = 1000000

N = (max_cordinate - min_cordinate) + 1
cordinateList = [min_cordinate]
s = ''

for i in range(N-1):
    cordinateList.append(cordinateList[-1] + 1)

for i in range(len(cordinateList)):
    s += ' ' + str(cordinateList[i])
print(s.lstrip(' '))

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

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int i = 0, j = 0;
    int maxv = 0;
    int cnt = 1;
    int nexti = 0;
    while (j < N) {
        cnt--;
        while (cnt < K && j < N) {
            while (j < N && S[j] == '1') j++;
            if (j == N) break;
            while (j < N && S[j] == '0') j++;
            cnt++;
        }
        while (j < N && S[j] == '1') j++;
        maxv = max(maxv, j - i);
        while (i < N && S[i] == '1') i++;
        while (i < N && S[i] == '0') i++;
    }
    cout << maxv << endl;

    return 0;
}


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

int main(){	
	long long n;
	scanf("%lld",&n);
	vector<long long> a(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%lld",&a[i]);
	}
	long long ai = 0, aj = -1000000000;
	for(int i = 0 ; i <= n-1 ; i++){
		ai = max(ai, a[i]);
	}
	for(int i = 0 ; i <= n-1 ; i++){
		if (abs(ai/2-aj)>abs(ai/2-a[i]) && a[i] < ai) aj = a[i];
	}
	cout << ai << " " << aj << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

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



int main(void)
{
float h,w,n;

cin>>h>>w>>n;

float ma=max(h,w);

float ans =ceil(n/ma);

cout<<ans<<endl;
}


Measured memory_bytes: 256
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
h=[0]
h.extend(n1())
AB=n3(m)

d={i:[] for i in range(1,n+1)}
for line in AB:
    a,b=line
    d[a].append(b)
    d[b].append(a)

ans=0
for i in range(1,n+1):
    h_now=h[i]
    h_OK=True
    for j in d[i]:
        if h_now<=h[j]:
            h_OK=False
            break
    if h_OK:
        ans+=1
print(ans)

Measured memory_bytes: 48268
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

ll battle(ll x, ll y){
    while(x != 0 && y != 0){
        y = y % x;
        swap(x, y);
    }
    return max(x,y);
}


int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    std::vector<ll> a(n); REP(i,n) cin >> a[i];

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

    REP(i, n-1){
        ll x = a[i];
        ll y = a[i+1];
        a[i+1] = battle(x, y);
    }

    cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
ll n,a,b;
int main()
{
	cin>>n>>a>>b;
	if(n==1&&a!=b)
	{
		cout<<0<<"\n";
		return 0;
	}
	if(n==1)
	{
		cout<<1<<"\n";
		return 0;
	}
	if(a>b)
	{
		cout<<0<<"\n";
		return 0;
	}
	ll L=a*(n-1)+b,R=a+b*(n-1);
	cout<<max(R-L+1,0LL)<<"\n";
}


Measured memory_bytes: 256
def main():
    N = int(input())
    values = list(map(int,input().split()))
    for i in range(1,N):
        print(" ".join(map(str,values)))
        v = values[i]
        j = i - 1
        while 0 <= j and v < values[j]:
            values[j+1] = values[j]
            j -= 1
        values[j+1] = v
    print(" ".join(map(str, values)))


if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Measured memory_bytes: 7772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       long double p;
       vector<long double> dp(n+1);
       dp[0] = 1.00;
       //dp[i][j] probability of getting j heads in i tosses
       for(int i=1;i<=n;++i)
       {
           cin>>p;
           for(int j=i;j>=0;--j)
           {
               
                dp[j]= (j>0?p*dp[j-1]:0) + (1-p)*dp[j];
           }
       }
       int x = (n+1)/2;
       p = 0;
       for(int i=x;i<=n;++i)
        p+= dp[i];
       cout<<fixed<<setprecision(15)<<p<<el;
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vl A;
void input() {
	cin >> n;
	inputv(A, n);
}
void solve() {
	vl B(100010, 0);
	x = 0;
	if (A[0] != 0)x = 1;
	sort(all(A));
	rep(i, n) {
		B[A[i]]++;
	}



	if (B[0] == 1&&x==0) {
		ans = 1;
		for (ll i = 1; i < n; i++) {
			ans = (ans * B[A[i] - 1]) % MOD;
		}
	}

	cout << ans << endl;
}

int main() {
	input();
	solve();
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n;
	cin >> n;
	int a[n];
	vector<int> pref(n+1,0);
	for(int i = 0;i < n;i++){
		cin >> a[i];
		pref[i+1] += a[i] + pref[i];
	}
	int dp[n][n];
	memset(dp,0,sizeof dp);
	for(int i = n-1;i >= 0;i--){
		for(int j = i+1;j < n;j++){
			if(i==j) dp[i][j] = a[i];
			else{
				dp[i][j] = 1e18;
				for(int k = i;k <= j;k++){
					dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + pref[j+1]-pref[i]);
				}
			}
		}
	}
	cout << dp[0][n-1] << "\n";
}

Measured memory_bytes: 4884
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            int[] MARCH = new int[5];
            for (int i = 0; i < N; i++) {
                int index = index(S[i].substring(0, 1));
                if (index < 0) {
                    continue;
                }
                MARCH[index]++;
            }

            long sum = 0;
            for (int mask = 0; mask < (1 << 5); mask++) {
                if (Integer.bitCount(mask) != 3) {
                    continue;
                }
                long count = 1;
                for (int i = 0; i < 5; i++) {
                    if ((mask & (1 << i)) == 0) {
                        continue;
                    }
                    count *= MARCH[i];
                }
                sum += count;
            }

            System.out.println(sum);
        }
    }

    private static int index(String s) {
        return "MARCH".indexOf(s);
    }
}


Measured memory_bytes: 55932
import java.util.Scanner;

public class Main{    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);        
                
        while(true){
            String x=sc.next();
            int i=0;
            int sum=0;
            
            if(x.equals("0")){
                break;
            }
         
            while(i<x.length()){
                String piv=String.valueOf(x.charAt(i));
                switch (piv) {
                    case "1" :
                        sum+=1;
                        break;
                    case "2" :
                        sum+=2;
                        break;
                    case "3" :
                        sum+=3;
                        break;
                    case "4" :
                        sum+=4;
                        break;
                    case "5" :
                        sum+=5;
                        break;
                    case "6" :
                        sum+=6;
                        break;
                    case "7" :
                        sum+=7;
                        break;
                    case "8" :
                        sum+=8;
                        break;
                    case "9" :
                        sum+=9;
                        break;
                    case "0" :
                        sum+=0;
                        break;
                    default:
                        System.out.println("err");
                }
                i++;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26560
local mmin, mfl, ior = math.min, math.floor, io.read
local n, c = ior("*n", "*n")
local d = {}
for i = 1, c * c do
  d[i] = ior("*n")
end
local diffsum = {}
for i = 1, 3 * c do
  diffsum[i] = 0
end
for pos = 1, n * n do
  local row, col = 1 + mfl((pos - 1) / n), pos % n
  if(col == 0) then col = n end
  local md = (row + col) % 3
  local a = ior("*n")
  for i_c = 1, c do
    local idx = md * c + i_c
    diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]
  end
end
local dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]
for i_1 = 1, c do
  for i_2 = 1, c do
    if(i_1 ~= i_2) then
      for i_3 = 1, c do
        if(i_1 ~= i_3 and i_2 ~= i_3) then
          dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])
        end
      end
    end
  end
end
print(dfmin)


Measured memory_bytes: 496
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

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


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

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




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



int main() {

	
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a*b)) << endl;








	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int ans = 0, cnt = 1;
    REP(i, 1, n) {
        if(a[i] == a[i-1]) {
            ++cnt;
        }
        else {
            ans += cnt/2;
            cnt = 1;
        }
    }
    ans += cnt/2;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n=0,k=0,ans=0;
  cin >> n >> k;
  
  for (int i=0; i < n; i++) {
    int x=0;
    cin >> x;
    
    if (x >= k) {
      ans += (2*(x-k));
    } 
    else if (k-2*x >= 0 ) {
      ans += 2*x;
    }
    else {
      ans += 2*(k-x);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// atcoder/abc122/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, q;
  string s;
  while (cin >> n >> q >> s) {
    vector<int> v;
    for (int i = 0; i + 1 < s.size(); ++i) {
      if (s[i] == 'A' && s[i + 1] == 'C') {
        v.push_back(i);
      }
    }
    sort(begin(v), end(v));
    while (q--) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      cout << lower_bound(begin(v), end(v), b) - lower_bound(begin(v), end(v), a) << endl;
    }
  }

  return 0;
}


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

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    readln;

    int cnt = 1;
    N -= K;
    --K;

    while (N > 0) {
        ++cnt;
        N -= K;
    }

    writeln(cnt);
}

Measured memory_bytes: 3452
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	//cin >> N;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] == 'L') {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == 'R') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int x,y;
     cin>>x>>y;
         int k=0,z=x,flag{0};
         while(k<=x&&z>=0){
             int ans=k*2+z*4;
             if(ans==y){
                 flag=1;
                 break;
             }
             else{
                 z--;
                 k++;
             }
         }
         if(flag==1)
             cout<<"Yes"<<endl;
         else
             cout<<"No"<<endl;
 return 0;    
}


Measured memory_bytes: 3644
// D - XXOR

// 一致しない桁を全探索する解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

// 常に50桁で考える（実際は40ビットで十分）
ll A[100000];
ll B[41]; // S[i][j]: K+1の2^iの桁がjのときのfの各Aの2^iの桁が1の数
ll S[41][2]; // S[i][j]: K+1の2^iの桁がjのときのfの各Aの2^iの桁が表す数の和
ll k[41]; // K+1の2^iの桁のビット

int main() {
	ll N, K;
	cin >> N >> K;

	for (int i=0; i<N; i++) {
		ll A;
		cin >> A;
		for (int i=0; i<=40; i++) {
			B[i] += A % 2;
			A /= 2;
		}
	}

	/*
	// **** debug ****
	for (int i=0; i<=40; i++) {
		cout << "B[" << i << "] = " << B[i] << endl;
	}
	*/

	for (int i=0; i<=40; i++) {
		S[i][0] = B[i] * pow(2, i);
		S[i][1] = (N - B[i]) * pow(2, i);
	}

	/*
	// **** debug ****
	for (int i=0; i<=40; i++) {
		cout << "S[" << i << "][0] = " << S[i][0] << endl;
		cout << "S[" << i << "][1] = " << S[i][1] << endl;
	}
	*/

	K++;
	int max_i = 0;
	for (int i=0; i<=40; i++) {
		k[i] = K % 2;
		K /= 2;
		if (k[i]) max_i = max(max_i, i);
	}

	ll ans = 0;

	// X と K+1 が 2^i の桁で x < k
	for (int i=0; i<=40; i++) {
		if (k[i] == 0) continue;

		ll candidate = 0;

		// iより右
		for (int j=0; j<i; j++) {
			candidate += max(S[j][0], S[j][1]); // どちらでも
		}

		// i
		candidate += S[i][0];// x < k

		// iより左
		for (int j=i+1; j<=40; j++) {
			candidate += S[j][k[j]]; // 一致
		}

		//cout << "i=" << i << " " << candidate << endl; // **** debug ****

		ans = max(ans, candidate);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4100
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
a.sort()
ln = len(bin(max(k,a[-1]))) - 2 #2進数に直した時の桁数
bit = [0 for i in range(ln)]
res = 0
ans = 0
for x in a:
    for i in range(ln):
        if i: 
            (x>>1) % 2
            x = x>>1
        if x%2:
            bit[i] += 1
    # print(bit)
for i,j in enumerate(bit):
    if j < n/2:
        bit[i] = 1
    else:
        bit[i] = 0
# print(bit)
for i in range(ln):
    if bit[ln-i-1]:
        c = pow(2,ln-i-1)
        if k >= c:
            res += c
            k -= c

for i in a:
    ans += i^res
print(ans)

Measured memory_bytes: 89196
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
using namespace std;

using LL = long long;
const int N = 505;

int p[N * N];
int vis[N][N];
int dis[N][N];
bool mk[N][N];

int n, ans;
int dx[]{1, -1, 0, 0};
int dy[]{0, 0, 1, -1};


void dij(int x, int y, int f) {
    ans += dis[x][y];
    queue<pair<int, pair<int, int>>> que;
    que.push({dis[x][y], {x, y}});
    vis[x][y] = f;
    mk[x][y] = true;
    while (!que.empty()) {
        auto [d, p] = que.front();
        auto [x, y] = p;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int xx =  x + dx[i], yy = y + dy[i];
            if (xx <0 || yy < 0 || xx >= n || yy >= n || vis[xx][yy] == f) continue;
            
            int v = d + !mk[x][y];
            if (v < dis[xx][yy]) {
                vis[xx][yy] = f;
                dis[xx][yy] = v;
                que.push({v, {xx, yy}});
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n;
    
    for (int i = 0; i < n * n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = min(min(i, j), min(n - i - 1, n - j - 1));
        }
    }
    for (int i = 0; i < n * n; i++) {
        int t = p[i] - 1;
        dij(t  / n, t % n, i + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6852
#include<stdio.h>
int main(){
    int height[100005],n,m,temp,badobs[100005]={0},a,b,cnt=0;//
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&height[i]);
    }
    for(int i=1;i<=m;i++){
        scanf("%d %d",&a,&b);
        if(height[a]<height[b]){
            badobs[a]=1;

        }
        else if(height[b]<height[a]){
            badobs[b]=1;
        }
        else {
            badobs[a]=1;
            badobs[b]=1;
        }
    }
    for(int i=1;i<=n;i++){
        if(badobs[i]==0) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 2516
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
			String line0;
			line0 = stdReader.readLine();

			String Array[] = line0.split(" ");
			int a = Integer.parseInt(Array[0]);
			int b = Integer.parseInt(Array[1]);
			int c = Integer.parseInt(Array[2]);
			int abc[] = { a, b, c };
			int ans[] = new int[2];
			if (abc[1] < abc[0]) {
				int x=abc[0];
				abc[0] = abc[1];
				abc[1] = x;
			} 
			if (abc[2] < abc[1]) {
				int x=abc[1];
				abc[1] = abc[2];
				abc[2] = x;
			} 
			if (abc[1] < abc[0]) {
				int x=abc[0];
				abc[0] = abc[1];
				abc[1] = x;
			} 
			System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
			stdReader.close();
		} catch (

		Exception e) {
			e.getStackTrace();
			/* ??????´??????0?????? */
			System.exit(0);
		}
	}
}

Measured memory_bytes: 24260
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

pair<int64_t, int64_t>
xgcd(const int64_t x0, const int64_t y0,
     const int64_t x1, const int64_t y1,
     const int64_t r0, const int64_t r1)
{
    const int64_t q  = r0 / r1;
    const int64_t r2 = r0 % r1;
    if(!(r1 % r2)) return {x0 - q * x1, y0 - q * y1};
    return xgcd(x1, y1, x0 - q * x1, y0 - q * y1, r1, r2);
}

inline pair<int64_t, int64_t>
xgcd(const int64_t a, const int64_t b) {
    return (a % b) ? xgcd(1, 0, 0, 1, a, b) : pair<int64_t, int64_t>(0, 1);
}

inline int64_t /* `a` should be prime w.r.t `mod` */
modinv(const int64_t a, const int64_t mod)
{
    static vector<int64_t> cache(1000000);

    if(a < (int64_t) cache.size())
    {
        if(!cache[a]) cache[a] = (mod + xgcd(a, mod).first % mod) % mod;
        return cache[a];
    }

    return (mod + xgcd(a, mod).first % mod) % mod;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int64_t n;
  cin >> n;
  vector<size_t> a(n + 1);
  cin >> a;
  --a;

  const int64_t mod = 1000000007;
  pair<int64_t, int64_t> dup;
  {
    vector<size_t> obs(n, (size_t)-1);
    for(int64_t i = 0; i < n + 1; ++i)
      if(!(obs[a[i]] + 1))
        obs[a[i]] = i;
      else
      {
        dup = {obs[a[i]], i};
        break;
      }
  }

  DEBUG(dup);
  int64_t acc = 1;
  int64_t inc = 1;

  for(int64_t k = 1; k < n + 2; ++k)
  {
    acc = (acc * (n - k + 2)) % mod;
    if(!(acc % k))
      acc /= k;
    else
      acc = acc * modinv(k , mod) % mod;

    int64_t val = acc;
    if(k == 1)
      val = (val + mod - 1) % mod;
    else
    {
      inc = (inc * (n + 1 - (dup.second - dup.first + 1) - k + 2)) % mod;
      if(!(inc % (k - 1)))
        inc /= k - 1;
      else
        inc = inc * modinv(k - 1, mod) % mod;

      val = ((val + mod - inc) % mod + mod) % mod;
    }
#ifdef BUG
    // cerr << acc << ' ' << inc << '\n';
#endif
    cout << val << '\n';
    // cout << ((acc % mod + mod - (inc % mod)) % mod + mod) % mod << '\n';
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 9840
N = int(input())

x = 1
for d in range(1, 15):
  x *= 26
  if N <= x:
    break
  else:
    N -= x
    
#Ans : d digits, N-th number
N -= 1
ans = ''
for i in range(d):
  r = N % 26
  ans = chr(ord('a') + r) + ans
  N //= 26

print(ans)

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//Random r = new Random();
		int N = sc.nextInt();
		int S[] = new int[N];
		long ct1[] = new long[200001];
		long ct2[] = new long[200001];
		int tmp;
		for(int i =0;i!=N;i++) {
			tmp=sc.nextInt();//sc.nextInt();
			S[i]=tmp;
			ct1[tmp]++;
			ct2[tmp]++;
			//System.out.println("tmp"+tmp+"ct"+ct1[tmp]+"ct2"+ct2[tmp]);
		}
		long total=0;
		for(int i= 0;i!=N;i++) {
			total=total+bikkuri(ct1[S[i]]);
			ct1[S[i]]=1;
		}
		for(int i=0;i!=N;i++) {
			if(ct2[S[i]]==1) {
				System.out.println(total);
			}else {
			System.out.println(total-bikkuri(ct2[S[i]])+bikkuri(ct2[S[i]]-1));
		}}
	}
	static long bikkuri(long t){
		return t*(t-1)/2;
	}
}


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

int main()
{
    int n,i,l[1001],r[1001];
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> l[i] >> r[i];
    }
    
    int sum=0;
    for(i=0;i<n;i++)
    {
        sum += r[i]-l[i]+1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < int > a(n);
    int i,ans=0;
    for (i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    for (i=0;i<n-1;i++)
        ans+=a[i];
    ans+=a[n-1]/2;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#ifdef __GNUC__ 
#include <bits/stdc++.h>
#endif
using namespace std;
int main()
{
	string s;
	cin >> s;
	unsigned int counter = 0;
	unsigned int count[2]{};
	int i = 0;
	for (auto c : s) {		
		counter++;
		count[i ^ (c - '0')]++;
		i ^=1;
	}
	cout << counter - max(count[0], count[1])<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;


// mod_tools
ll fact[500000];

ll mpow(ll x, ll y){
    //d(x)
    if(y==0) return 1;
    if(y%2==0){
        return mpow(x*x%mod,y/2)%mod;
    }
    else{
        return x*mpow(x,y-1)%mod;
    }
}

ll minv(ll x){
    // only available for mod=10^9+7
    return mpow(x,mod-2);
}

// Please run this func for preparation
void mfact(){
    //prepare fact-array
    fact[0]=1;
    rep(i,1,500000){
        fact[i]=fact[i-1]*i%mod;
    }
}

//combiの呼び出しが大きいときはこれを使う
ll combi(ll n, ll k){
    return (fact[n]*minv(fact[k])%mod)*minv(fact[n-k])%mod;
}

//combiを一回呼び出すだけなら直接計算

ll dp[1000000];

int main(void){
    string s1,s2;
    cin>>n>>s1>>s2;
    //頭
    //たては最初が３通り
    //横は最初が６通り
    //続き
    //たてを塗る時、塗り方は３通り、次たてなら２通り、横なら２通り
    //よこを塗る時、塗り方は２通り、次たてなら１通り、横なら４通り
    ll i,prv;
    if(s1[0]==s2[0]){
        dp[0]=3;
        i=1;
        prv=1;
    }
    else{
        dp[0]=6;
        dp[1]=6;
        i=2;
        prv=0;
    }
    for(i;i<n;i++){
        if(s1[i]==s2[i]){
            //たて
            if(prv==0){
                //前が横
                dp[i]=(dp[i-1])%mod;
            }
            else{
                dp[i]=(dp[i-1]*2)%mod;
            }
            prv=1;
        }
        else{
            //横
            if(prv==0){
                //前が横
                //a,o o,a, o,g g,a,
                dp[i+1]=(dp[i-1]*3)%mod;
            }
            else{
                dp[i+1]=(dp[i-1]*2)%mod;
            }
            i++;
            prv=0;
        }
    }
    //rep(i,n)d(dp[i]);
    p(dp[n-1]);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	string o, e;
	cin >> o >> e;
	
	int O=0, E=0;

	for(int i=0;i<o.size()+e.size();i++) {
		if(i%2 == 0) {
			cout << o.at(O);
			O++;
		}
		if(i%2 != 0) {
			cout << e.at(E);
			E++;
		}
	}

	cout << endl;

}


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

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    bool a;
    cin >> a;

    a = !a;
    cout << a;
}


Measured memory_bytes: 3648
// AOJ 1067 Cutting a Chocolate
// 2018.3.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()        // get a non-negative integer from stdin
{
	int n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

double dbl()    // get a non-negative real number from stdin  
{
	double x, y;
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	x = n;
	if (c == '.') {
		y = 1, c = getchar_unlocked();
		do y *= 0.1, x += y * (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	}
	return x;
}

#define EQ(a,b)   (fabs(a-b)<1e-7)

typedef struct { double x, y; } P;
P p[30002];

int hl[30002], hr[30002], s[30002], a[30002];

int binary_search(int *tbl, int hi, int k, int key)
{
	int lo = 0, mi, r;

    while (lo < hi) {
        mi = (lo + hi) >> 1;
		r = tbl[mi]*k - key;
		if (!r) return mi;
        if (r < 0) lo = mi + 1; else hi = mi;
    }
	return lo-1;
}

int cmp(P *a, P *b)
{
	if (!EQ(a->y, b->y)) { if (a->y <= b->y) return -1;	return 1; }
	if ( EQ(a->x, b->x)) return 0; if (a->x <= b->x) return -1; return 1;
}

int main()
{
	int n, m, w, h, S, i, j, ans;
	double x, y, y1, y2;

	while (n = in()) {
		m = in(), w = in(), h = in(), S = (w*h-in()) << 1;
		for (i = 0; i < m; i++) {
			hl[i] = in(), hr[i] = in(), a[i] = 0;
			s[i] = hl[i] + hr[i];
		}
		for (i = 0; i < n; i++) p[i].x = dbl(), p[i].y = dbl();
		qsort(p, n, sizeof(P), cmp);

		j = 0; for (i = 0; i < n; i++) {
			x = p[i].x, y = p[i].y;
			while (1) {
				if (j == 0) y1 = 0;
				else y1 = (hr[j-1] - hl[j-1]) * x / w + hl[j-1];
				y2 = (hr[j] - hl[j]) * x / w + hl[j];
				if (y1 < y && y < y2) break;
				if (y2 < y) j++;
				else        j--;
			}
			a[j]++;
		}
		for (i = 1; i < m; i++) a[i] += a[i-1];

		if      (S == 0    ) { printf("%d\n", n); continue; }
		else if (S == 2*w*h) { puts("0");         continue; }

		j = binary_search(s, m, w, S); ans = a[j++];
		for (i = 0; j < m; j++) {
			while ((s[j] - s[i])*w > S) i++;
			if (a[j] - a[i] > ans) ans = a[j] - a[i];
		}
		printf("%d\n", n - ans);
	}
	return 0;
}



Measured memory_bytes: 3244
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define MOD 1000000007
using namespace std;

int main(){
	fast_io;
	string s;
	cin>>s;
	int f[26] = {0};
	for(int i=0;i<4;i++){
        f[s[i]-'A']++;
	}
	for(int i=0;i<4;i++){
        if(f[s[i]-'A']==2){
            continue;
        }
        else{
            cout<<"No";
            return 0;
        }
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  int n;cin>>n;int a[100000], b[100000];pair<int,int> c[100000];
  rep(i,n){
    cin>>a[i]>>b[i];
    c[i] = make_pair(a[i]+b[i], i);
  }
  sort(c,c+n,greater<pair<int,int>>());
  ll ans = 0;
  rep(i,n){
    if(!(i%2)){
      ans += a[c[i].second];
    }else{
      ans -= b[c[i].second];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


vector< int64_t > divisor(int64_t n) {
	vector< int64_t > ret;
	for (int64_t i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}

int dat[1000100] = { 0 };

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

	vector<int> a(n);

	rep(i, n) {
		cin >> a[i];
		dat[a[i]]++;
	}


	int ans = 0;
	bool flag;
	rep(i, n) {
		flag = true;
		//cout << a[i] << ":";
		for (auto x : divisor(a[i])) {
			//cout << x << " ";
			if (x != a[i] && dat[x] != 0)
				flag = false; 
			if (dat[a[i]] != 1)
				flag = false;
		}
		if (flag) ans++;
	}



	cout << ans;


}




Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
int b[1020];
int c[1020][12];
int n, x;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &x);
			b[i] |= x << j;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 10; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	int ans = -1e9;
	for (int u = 1; u < 1024; u++) {
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			int cnt = __builtin_popcount(b[i] & u);
			tmp += c[i][cnt];
		}
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

  int n;

  char buf[1000];
  char outbuf[1000];

  char c;

  int a[1000],b[1000];
  int result[1000];
  
  int sum,carry;
  int idx1,idx2;
  int maxlen;

  int i,j;

  scanf("%d",&n);

  c=getchar();

  for(i=0;i<n;i++) {

    fgets(buf,sizeof(buf),stdin);

    idx1=0;

    while(buf[idx1]!='\n') {

      a[idx1]=buf[idx1]-48;

      idx1++;

    }

    //for(j=0;j<idx1;j++) printf("%d",a[j]);

    fgets(buf,sizeof(buf),stdin);

    idx2=0;

    while(buf[idx2]!='\n') {

      b[idx2]=buf[idx2]-48;

      idx2++;

    }

    if(idx1>idx2) maxlen=idx1;
    
    else maxlen=idx2;

    if(maxlen>80) {

      printf("overflow\n");

      continue;

    }

    carry=0;

    for(j=0;j<maxlen;j++) {

      if(j<idx1 && j<idx2) sum=a[idx1-j-1]+b[idx2-j-1]+carry;

      else if(j>=idx1) sum=b[idx2-j-1]+carry;

      else sum=a[idx1-j-1]+carry;


      if(sum>=10) carry=1;

      else carry=0;

      result[j]=sum%10;

    }
    //printf("%d\n",carry);
    if(carry==1) {

      if(maxlen>=80) printf("overflow\n");

      else {

	outbuf[0]='1';

	for(j=0;j<maxlen;j++) {

	  outbuf[j+1]=result[maxlen-j-1]+48;

	}

	outbuf[maxlen+1]='\0';

	printf("%s",outbuf);

	puts("");

      }

    }

    else {

      for(j=0;j<maxlen;j++) {

	outbuf[j]=result[maxlen-j-1]+48;

      }

      outbuf[maxlen]='\0';

      printf("%s",outbuf);

      puts("");

    }

  }

  return 0;

}
    

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



int main() {
  ll r;
  cin >> r;
  cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}
void YesNo(bool flag){ cout<<(flag? "Possible":"Impossible");}

ll a,b,c,d,n,x;
vector<ll>v[3];
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>a>>b;
}
void src(){
    vector<ll> vv{a,b,a+b};
    YesNo(any_of(vv.begin(),vv.end(),[](auto x){return x%3==0;}));
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    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 rrep(i,n) for(int i = 1; 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 pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n;
  cin >> n;
  double ans=0;
  rep(i,n){
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY"){
      ans+=x;
    }
    else {
      ans += x*380000.0;
    }
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void) {
	int N, Y; cin >> N >> Y;
	for (int x = 0; x <= Y/10000; x++)
		for (int y = 0; y <= Y/5000; y++) {
			int z = N - x - y;
			if (1000*z+10000*x+5000*y == Y && x+y+z == N && z >= 0) {
				cout << x << ' ' << y << ' ' << z<< endl;
				return 0;
			}
		}

	cout << -1 << ' ' << -1 << ' ' << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 *		Atreus
**/
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 1e5 + 10;

vector<ll> q;
ll a[maxn], t[maxn], ans[maxn];

int main () {
	ios_base::sync_with_stdio (false);
	int n, Q;
	cin >> n >> Q;
	a[0] = n;
	for (int i = 1; i <= Q; i++)
		cin >> a[i];
	ll mn = a[Q];
	q.push_back(mn);
	for (int i = Q - 1; i >= 0; i--){
		if (a[i] < mn)
			q.push_back(a[i]);
		mn = min(mn, a[i]);
	}
	q.push_back(0); // chert
	reverse(q.begin(), q.end());
	Q = q.size() - 1;
	t[Q] = 1;
	for (int i = Q; i >= 1; i--){
		ll k = q[i];
		while (true){
			int lo = 0, hi = i;
			while (hi - lo > 1){
				int mid = (lo + hi) >> 1;
				if (q[mid] <= k)
					lo = mid;
				else
					hi = mid;
			}
			if (lo == 0)
				break;
			t[lo] += t[i] * (k / q[lo]);
			k %= q[lo];
		}
		if (k > 0){
			ans[1] += t[i];
			ans[k + 1] -= t[i];
		}
	}
	for (int i = 1; i <= n; i++){
		ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 4980