akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template< typename T >
class segment_tree {
	public:
	const vector<long long> coord;
	const map<long long, long long> mp;
	const long long sz;
	const long long Sz;
	vector<T> seg;
	const function<T(T, T)> o;
	const T id;

		segment_tree (
				const vector<long long> coord,
				const function<T(T, T)> o,
				const T id
			) :
			coord([&](){
					vector<long long> v = coord;
					long long p = 1;
					for (; p < (long long)v.size(); p <<= 1) {}
					v.resize(p, (long long)((1LL << 31) - 1));
					return v;
				}()),
			mp([&](){
					map<long long, long long> m;
					long long i = 0;
					for (auto const& e : coord) {
						m[e] = i++;
					}
					return m;
				}()),
			sz([&](){
					int ret = 1;
					for (; ret < (int)coord.size(); ret <<= 1) {}
					return ret;
				}()),
			Sz(sz << 1),
			seg(Sz, id),
			o(o),
			id(id)
			{
			}

		void update (long long k, const T& x) {
			auto it = mp.find(k);
			assert(it != mp.end());
			k = it->second;
			k += sz;
			seg[k] = x;
			while(k >>= 1) {
				seg[k] = o(seg[2 * k], seg[2 * k + 1]);
			}
		}
		void add (long long k, const T& x) {
			update(k, x + at(k));
		}
		T query (long long l, long long r) {
			l = lower_bound(coord.begin(), coord.end(), l) - coord.begin();
			r = lower_bound(coord.begin(), coord.end(), r) - coord.begin();
			T L = id, R = id;
			for(l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
				if(l & 1) L = o(L, seg[l++]);
				if(r & 1) R = o(seg[--r], R);
			}
			return o(L, R);
		}
		T at (long long k) const {
			auto it = mp.find(k);
			assert(it != mp.end());
			return seg[it->second + sz];
		}
};
int main() {
	const long long inf = 1e17;
	cin.tie(0); cin.sync_with_stdio(false);
	long long q;
	cin >> q;
	vector<tuple<long long, long long, long long>> query;
	vector<long long> a;
	while (q--) {
		long long c;
		cin >> c;
		if (c == 1) {
			long long x, y;
			cin >> x >> y;
			query.emplace_back(1, x, y);
			a.push_back(x);
		} else {
			query.emplace_back(2, 0, 0);
		}
	}
	sort(a.begin(), a.end());
	a = decltype(a)(a.begin(), unique(a.begin(), a.end()));
	segment_tree<long long> sgt(
		a,
		[](long long x, long long y) {return x + y;},
		0
	);
	segment_tree<long long> tgt(
		a,
		[](long long x, long long y) {return x + y;},
		0
	);
	long long base = 0;
	for (auto const& p : query) {
		long long c, x, y; tie(c, x, y) = p;
		if (c == 1) {
			sgt.add(x, 1);
			tgt.add(x, x);
			base += y;
		}
		else {
			long long n = sgt.query(-inf, inf);
			long long m = (n + 1) >> 1;
			long long ok = -inf, ng = inf, md;
			while (ng - ok > 1) {
				md = (ok + ng) >> 1;
				if (sgt.query(-inf, md + 1) < m) ok = md;
				else ng = md;
			}
			cout << ng << " ";
			long long ret = base;
			ret -= tgt.query(-inf, ng);
			ret += ng * sgt.query(-inf, ng);
			ret += tgt.query(ng + 1, inf);
			ret -= ng * sgt.query(ng + 1, inf);
			cout << ret << endl;
		}
	}
	return 0;	
}

Measured memory_bytes: 28844
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w = sc.nextInt();
		int[][] ar=new int[10][10];
		for(int i = 0; i<10; i++){
			for(int j = 0; j<10; j++){
				ar[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i<10; i++){
			for(int j = 0; j<10; j++){
				for(int k = 0; k<10; k++){
					if(i!=j && j!=k && i!=k){
						ar[j][k]=Math.min(ar[j][k],ar[j][i]+ar[i][k]);
					}
				}
			}
		}
		int ans=0;
		for(int i = 0; i<h; i++){
			for(int j= 0; j<w; j++){
				int a = sc.nextInt();
				if(a!=1 && a!=-1){
					ans+=ar[a][1];
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 47068
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long N;
    cin >> N;
    
    long long i;
    for ( i = 1; i*i <= N; i++ ) {}
    
    cout << (i-1)*(i-1) << endl;
    
    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=0; i<n; i++)
        cin >> b[i];


    ll p=0, m=0;
    for(int i=0; i<n; i++)
    {
        if(a[i] > b[i])
            p += a[i]-b[i];
        else if(b[i] > a[i])
        {
            if((b[i]-a[i])%2 == 1)
                m += b[i]-a[i]-1;
            else
                m += b[i]-a[i];
        }

    }

    if(2*p > m)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;


}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s,t; cin >> s >> t;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

int A, B, C, X;
bool ans = false;

void rec(int a, int b, int c, int x) {
    if (a < b && b < c) {
        ans = true;
        return;
    }
    if (x == X) return;

    rec(a * 2, b, c, x + 1);
    rec(a, b * 2, c, x + 1);
    rec(a, b, c * 2, x + 1);
}

void solve() {
    cin >> A >> B >> C;
    cin >> X;

    rec(A, B, C, 0);

    cout << (ans ? "Yes" : "No") << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}



int main()
{
	int n, cnt = 0, max = 0;

	cin >> n;

	vector<long long int> h(n);

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

	for (int i = 0; i < n - 1; i++) {
		if (h[i] >= h[i + 1])
			cnt++;
		else {
			if (cnt > max)
				max = cnt;
			cnt = 0;
		}
	}

	if (cnt > max)
		max = cnt;

	cout << max << endl;

	return 0;

}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
    int a, b;
    char op;
    
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        switch(op){
            case '+' : printf("%d\n", a+b);    break;
            case '-' : printf("%d\n", a-b);    break;
            case '*' : printf("%d\n", a*b);    break;
            case '/' : printf("%d\n", a/b);    break;
            case '?' : return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll L[10000];
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>L[i];
    }
    ll ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(L[i]==L[j]) continue;
            for(int k=j+1;k<n;k++){
                if(L[i]==L[k]||L[j]==L[k]) continue;
                if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[j]+L[k]>L[i]) ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  long long a,b,ans,c,d;
  cin>>a>>b;
  if(b>a){
    swap(a,b);
  }
  ans=a*b;
    d=a%b;
  while(d!=0){
    a=b;
    b=d;
    d=a%b;
  }
  ans/=b;
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        a[i] = i + l;
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    int nin = 1e9, val = 0;

    for(int i = 0; i < n; i++) {
        if(nin > abs(a[i])) {
            nin = abs(a[i]);
            val = a[i];
        }
    }
    cout << sum -val << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
//const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
const ll MOD = 998244353LL;


int main(){
	string s;
	cin >> s;
	ll l = s.size();
	ll dp[l+3]={};
	bool ch[l+3]={};
	FOR(i,0,l)dp[i]=1;
	FOR(i,1,l){
		if(ch[i-1]){
			dp[i] = dp[i-2]+1;
		}else if(s[i]==s[i-1]){
			ch[i] = true;
			dp[i] = dp[i-1];
		}else{
			dp[i] = dp[i-1]+1;
		}
		if(ch[i-2]&&i>1){
			ch[i] = false;
			dp[i] = dp[i-1] + 1;
		}
	}
	cout << dp[l-1] << endl;
}


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

int main(){

    string s;

    cin >> s;

    int ans = 0;

    for(int i = 0; i < s.length()/2; ++i){
        if(s[i] != s[s.length()-1-i])++ans;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> to(n+1,vector<int>(0));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  vector<int> root(n+1,-1);
  root[1] = 0;
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int next : to[now]){
      if(root[next] == -1){
        root[next] = now;
        q.push(next);
      }
    }
  }//while
  rep1(i,n){
    if(root[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=2;i<=n;i++){
    cout << root[i] << endl;
  }
}

Measured memory_bytes: 10248
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    C = Counter(list(map(int, input().split())))
    MOD = 10 ** 9 + 7

    ans = 1
    num_zero = 0
    for k, v in C.items():
        if k == 0:
            num_zero += 1
        elif v == 2:
            ans *= 2
            ans %= MOD
        else:
            print(0)
            return
    
    if N % 2 != num_zero:
        print(0)
        return

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14704
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;

int a[3];
int main()
{
	int n,m;
	bool flag=true;
	cin>>n>>m;
	fill(a,a+3,-1);
	for(int i=0;i<m;i++)
	{
		int s,c;
		cin>>s>>c;
		s--;
		if(s==0 && c==0 && n!=1)
		{
			flag=false;
			break;
		}
		else if(a[s]!=-1 && a[s]!=c)
		{
			flag=false;
			break;
		}
		else
		{
			a[s]=c;
		}
	}
	if(!flag)cout<<-1<<"\n";
	else
	{
		for(int i=0;i<n;i++)
		{
			if(a[i]==-1)
			{
				if(i==0 && n!=1)cout<<1;
				else cout<<0;
			}
			else cout<<a[i];
		}
		cout<<"\n";
	}
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])
array = [T[0]]
arrays = []
s = 0
for i in range(1, len(T)):
    if ((T[i] - T[s]) <= K) and len(array) < C:
        array.append(T[i])
    else:
        arrays.append(array)
        array = [T[i]]
        s = i
print(len(arrays + [array]))

Measured memory_bytes: 18004
N = int(input())
A = list(map(int, input().split()))
A1 = []
for nums in A:
  A1.append(nums)
A.sort()
m1 = A[N//2-1]
m2 = A[N//2]
if m1 != m2:
  for nums in A1:
    if nums <= m1:
      print(m2)
    else:
      print(m1)

else:
  for nums in A1:
    print(m1)

Measured memory_bytes: 25224
#include<stdio.h>
int main(){
	long long int n,a[10000],i,saisyou,saidai,goukei=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(i==0){
			saisyou=a[i];
			saidai=a[i];
		}
		if(saisyou>a[i]){saisyou=a[i];}
		if(saidai<a[i]){saidai=a[i];}
		goukei+=a[i];
	}
	printf("%lld %lld %lld\n",saisyou,saidai,goukei);
	
	
	
	
	return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    --ch;--cw;--dh;--dw;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    constexpr int dx[]={-1,1,0,0};
    constexpr int dy[]={0,0,-1,1};
    deque<pair<int,int>> q;
    int d[h][w];
    rep(i,h)rep(j,w)d[i][j]=-1;
    d[ch][cw]=0;
    q.push_back({ch,cw});
    while(q.size()){
        int x=q.front().first;
        int y=q.front().second;
        q.pop_front();
        rep(i,4){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx<0||h<=nx||ny<0||w<=ny||s[nx][ny]=='#')continue;
            if(d[nx][ny]==-1||d[x][y]<d[nx][ny]){
                d[nx][ny]=d[x][y];
                q.push_front({nx,ny});
            }
        }
        for(int i=-2;i<=2;++i){
            int nx=x+i;
            for(int j=-2;j<=2;++j){
                int ny=y+j;
                if(nx<0||h<=nx||ny<0||w<=ny||s[nx][ny]=='#'||d[nx][ny]!=-1)continue;
                d[nx][ny]=d[x][y]+1;
                q.push_back({nx,ny});
            }
        }
    }
    cout<<d[dh][dw]<<"\n";
}


Measured memory_bytes: 9532
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int checkodd(lli a[],int n){
    int i,falg=0;
    for(i=0;i<n;i++){
        if((a[i]%2)!=0){ falg=1;break;}
    }
    return falg;
}
int checkfun(lli a[],int n){
    int i,val;
    static int al=0;
    
        val=checkodd(a,n);
        if(val==1){
            return al;
        }
        else
        {for(i=0;i<n;i++){
            a[i]/=2;}
            
        }
        al++;
        checkfun(a,n);
        
    }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  int n,al,i;
  cin>>n;
  lli a[n];
  for(i=0;i<n;i++){
      cin>>a[i];
  }
  al=checkfun(a,n);
  cout<<al;
  
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int H,W;
  int i,j;

  while(1){
    scanf("%d %d",&H,&W);
    if( H==0 && W==0 ) break;
    for(i=0;i<H;i++){
      if(i!=0 && i!=H-1){
	printf("#");
	for(j=0;j<W-2;j++){
	  printf(".");
	}
	printf("#");
      }else{
	for(j=0;j<W;j++){
	  printf("#");
	}
      }      
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

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

int dp[3005][3005][2];

void Main()
{
    arrayFill(dp, 0);
    int n, t;
    cin >> n >> t;
    vector<pint> ab(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    rep(i, n)
    {
        rep(j, t)
        {
            rep(k, 2)
            {
                // 入れない
                chmax(dp[i + 1][j][k], dp[i][j][k]);

                // 外側
                if (k == 0)
                {
                    chmax(dp[i + 1][j][1], dp[i][j][0] + ab[i].second);
                }

                // 内側
                if (j + ab[i].first <= t)
                {
                    chmax(dp[i + 1][j + ab[i].first][k], dp[i][j][k] + ab[i].second);
                }
            }
        }
    }

    int ans = 0;
    rep(k, 2)
    {
        chmax(ans, dp[n][t - 1][k]);
    }
    cout << ans << endl;
}

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


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

int main()
{
    int n;
    int cnt=0;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(s.count(x))
            cnt++;
        s.insert(x);
    }
    if(cnt&1)
        cout<<s.size()-1<<endl;
    else
        cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> x(N);
  REP(i, N) cin >> x[i];

  vector<int> y(M);
  REP(i, M) cin >> y[i];

  vector<int> dn(N-1);
  REP(i, N-1) (dn[i] = (i+1)*(N-1-i)) %= MOD;
  
  vector<int> dm(M-1);
  REP(i, M-1) (dm[i] = (i+1)*(M-1-i)) %= MOD;

  int p = 0;
  REP(i, M-1){
    (p += dm[i]*(y[i+1]-y[i])%MOD) %= MOD;
  }

  int ans = 0;
  REP(i, N-1){
    (ans += (p*(x[i+1]-x[i]))%MOD*dn[i]) %= MOD;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>

int main(void){
    int data[4][3][10]={0};
    int n,b,f,r,v;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        data[b-1][f-1][r-1]+=v;
    }

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",data[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
            for(int i=0;i<20;i++){
                printf("#");
            }
            printf("\n");
        }
    }

}


Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;

int main() {

	int n, m;
	cin >> n >> m;
	vector<int> h(n, 0);
	vector<vector<int>> j(n);
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		h[i] = temp;
	}

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		j[a - 1].push_back(b - 1);
		j[b - 1].push_back(a - 1);
	}

	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		for (auto e : j[i]) {
			if (h[i] <= h[e]) {
				p[i] = 1;
				break;
			}
		}
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] == 0) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 8992
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	c += (s[4] - 'a' + 1) * 0.01 * CLOCKS_PER_SEC;
	while(clock() < c);
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
string fie[1001];
int fiec[1001][1001];
int dy[8]={-1,-1,-1,0,0,1,1,1},dx[8]={-1,0,1,-1,1,-1,0,1};
struct data{
    int y;
    int x;
    int n;
};
queue<data> Q;
queue<int> lisy;
queue<int> lisx;
int main(){
    int H,W;
    cin>>H>>W;
    for(int i=0;i<H;i++)cin>>fie[i];
    for(int i=1;i<H-1;i++){
        for(int j=1;j<W-1;j++){
            int cou=0;
            for(int k=0;k<8;k++){
                if(fie[i+dy[k]][j+dx[k]]=='.')cou++;
            }
            if(fie[i][j]-'0'<=cou&&fie[i][j]!='.')lisy.push(i),lisx.push(j);
        }
    }
    int befn=0;
    while(1){
        if(lisy.size()==0)break;
        befn++;
        if(Q.size()==0){
            while(lisy.size()){
                int kariy,karix;
                kariy=lisy.front();
                karix=lisx.front(),lisy.pop(),lisx.pop();
                fie[kariy][karix]='.';
                for(int k=0;k<8;k++){
                    if(fiec[kariy+dy[k]][karix+dx[k]]==0&&fie[kariy+dy[k]][karix+dx[k]]!='.'){
                        fiec[kariy+dy[k]][karix+dx[k]]=1;
                        data kariba;
                        kariba.y=kariy+dy[k],kariba.x=karix+dx[k],kariba.n=befn+1;
                        Q.push(kariba);
                    }
                }
            }
        }
        while(Q.size()){
            data kari;
            kari=Q.front(),Q.pop();
            int cou=0;
            if(kari.y!=0&&kari.y!=H-1&&kari.x!=0&&kari.x!=W-1){
                for(int i=0;i<8;i++){
                    if(fie[kari.y+dy[i]][kari.x+dx[i]]=='.')cou++;
                }
                if(fie[kari.y][kari.x]-'0'<=cou&&fie[kari.y][kari.x]!='.'){
                        lisy.push(kari.y),lisx.push(kari.x);
                    //printf("[%d][%d]\n",kari.y,kari.x);
                    //for(int pp=0;pp<100000000;pp++){
                    //}
                }
                else fiec[kari.y][kari.x]=0;
            }
        }
    }
    cout<<befn<<endl;
    return 0;
}

Measured memory_bytes: 6220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

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

	string date;
	cin >> date;

	int year = stoi(date.substr(0, 4));
	int month = stoi(date.substr(5, 2));
	int day = stoi(date.substr(8, 2));

	if (year < 2019) {
		cout << "Heisei";
		return 0;
	}
	else if (year > 2019) {
		cout << "TBD";
		return 0;
	}
	else {
		if (month < 4) {
			cout << "Heisei";
			return 0;
		}
		else if (month > 4) {
			cout << "TBD";
			return 0;
		}
		else {
			if (day <= 30) {
				cout << "Heisei";
				return 0;
			}
			else {
				cout << "TBD";
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main ()
{
	int a,b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m,(n||m)){
		bool t[1000]; memset(t,1,sizeof(t));
		int cnt = 0;
		for (int i = 0; i < n-1; i++){
			int a = 0;
			while(a != m - 1){
				while(!t[cnt]) cnt = (cnt+1)%n;
				a++;
				cnt = (cnt+1)%n;
			}
			while(!t[cnt])
				cnt = (cnt+1)%n;
			t[cnt] = false;
		}
		int ans = max_element(t,t+n) - t;
		cout << ans + 1 << endl;
	}
    return 0;
}

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

int main() {
  long N;
  cin >> N;
  
  long count=0;
  for(long i=1; i<N; ++i) {
    for(long j=1; j<N; ++j) {
        if (i*j < N) count++;
        else break;
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {

        /*
         * Ａ大学は１フロア１０部屋、
         * ３階建ての公舎４棟を管理しています。公舎の入居・退去の情報を読み込み、各部屋の入居者数を出力するプログラムを作成して下さい。
         * 
         * n件の情報が与えられます。各情報では、４つの整数b, f, r,
         * vが与えられます。これは、b棟f階のr番目の部屋にv人が追加で入居したことを示します。vが負の値の場合、v人退去したことを示します。
         * 
         * 最初、全ての部屋には誰も入居していないものとします。 最初の行に情報の数 n が与えられます。
         * 
         * 続いて n 件の情報が与えられます。各情報には４つの整数 b, f, r, v が空白区切りで１行に与えられます。
         */
        int[][][] array_House = new int[4][3][10];

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int x = 0; x < n; x++) {
            int b = sc.nextInt() - 1;
            int f = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            int v = sc.nextInt();
            if(array_House[b][f][r] + v > 9){
                array_House[b][f][r] = 9;
            }else if(array_House[b][f][r] < 0){
                array_House[b][f][r] = 0;
            }else{
                array_House[b][f][r] += v;
            }
        }
        sc.close();

        for (int i = 0; i < array_House.length; i++) {
            for (int j = 0; j < array_House[i].length; j++) {
                for (int j2 = 0; j2 < array_House[i][j].length; j2++) {

                    System.out.print(" " + array_House[i][j][j2]);

                }
                System.out.println();
            }
            if (i < array_House.length - 1) {
                System.out.println("####################");
            }
        }

    }
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ret = 0;
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        int total = 500 * a + 100 * b + 50 * c;
        if (total == X) {
          ret += 1;
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n = int(input())
print("", end="")
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        print("", i, end="")
        continue
    while x > 1:
        if x % 10 == 3:
            print("", i, end="")
            break
        x //= 10
print()


Measured memory_bytes: 6160
import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;

/**
 * @author:26019
 */
public class Main {


    public static void main(String[] args) throws Exception {
        solve();
    }

    private static void solve() throws Exception {
        //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("C:\\Users\\26019\\Downloads\\out.txt"))));
        FastScanner cin = new FastScanner();
        int x = cin.nextInt();
        if (400 <= x && x <= 599) {
            System.out.println(8);
        } else if (600 <= x && x <= 799) {
            System.out.println(7);
        } else if (800 <= x && x <= 999) {
            System.out.println(6);
        } else if (1000 <= x && x <= 1199) {
            System.out.println(5);
        } else if (1200 <= x && x <= 1399) {
            System.out.println(4);
        }else if (1400 <= x && x <= 1599) {
            System.out.println(3);
        }else if (1600 <= x && x <= 1799) {
            System.out.println(2);
        } else if (1800 <= x && x <= 1999) {
            System.out.println(1);
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\26019\\Downloads\\P1190_9.in"))));
        StringTokenizer st = new StringTokenizer("");

        FastScanner() throws FileNotFoundException {
        }

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public String nextLine() { // 读取带空格的字符串
            String res = null;
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}


Measured memory_bytes: 32664
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VL pop(k, 0);
  REP(i,1,n+1) {
    pop[i % k]++;
  }
  ll ans = 0;
  REP(i,0,k) {
    if(i * 2 % k == 0) {
      ans += pop[i] * pop[i] * pop[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
<?php
while ($line = fgets(STDIN)) {
 $array[] = trim($line);
}
$str = $array[1];
$num = $array[0];

$abc = "abcdefghijklmnopqrstuvwxyz";
$len = strlen($abc);

$num = $num % $len;
if ($num == 0) {

} else if ($num < 0) {
$num = $num + $len;
}
$to = substr($abc . $abc, $num, $len);
$str = strtr($str, $abc, $to);
$str = strtr($str, strtoupper($abc), strtoupper($to));



            echo $str;
?>


Measured memory_bytes: 3956
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i, k;
    cin>>n;
    vector<long long> cnt(n);
    for(i=1;i<n;++i)
    {
        cin>>k;
        ++cnt[k-1];
    }
    for(i=0;i<n;++i)
    {
        cout<<cnt[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4788
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow - 1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}

/*-----------------------------------------------------MATH------------------------------------------------*/
ll mod = 1e9 + 7;
vector<int> arr;
void solve() {
   int a,b;
   cin>>a>>b;
   if(a==b) cout<<"Yes";
   else cout<<"No";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long x = sc.nextLong();
    sc.close();

    long cnt = 0;
    if(a == 0) {
        System.out.println(b/x+1);
    } else {
        System.out.println(b/x-(a-1)/x);
    }
  }
}


Measured memory_bytes: 23252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 第5回 ドワンゴからの挑戦状 予選
            // A - Thumbnail
            // 平均値を算出する
            // 平均値との距離の最小値を探索する
            // 距離が最小値のフレーム番号を答える
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                sum += a[i];
            }
            double dist = 110000.0;
            double median = (double) sum / (double) n;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                double tmp = Math.abs(median - (double) a[i]);
                if (dist > tmp) {
                    dist = tmp;
                    ans = i;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    char S[N];
    scanf("%s",S);

    if(S[K-1]=='A'){
        S[K-1]='a';


    }
     if(S[K-1]=='B'){
        S[K-1]='b';


    }
     if(S[K-1]=='C'){
        S[K-1]='c';


    }

    printf("%s\n",S);

    return 0;


}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
        int n,k; cin>>n>>k;
        double ans=0;
        rep2(i,1,n+1)
        {
                if(i>=k)
                {
                        double a=(double)1/n;
                        ans+=a;
                        continue;
                }
                int t=ceil(log2((double)k/i));
                double a=(double)1/n,b=pow(0.5,t);
                ans+=a*b;
        }
        printf("%.12lf\n",ans);
}


Measured memory_bytes: 256
// AOJ 0217: Walking in the Hospital
// 2017.8.6 bal4u@uu
// 2017.10.29 retry

#include <stdio.h>

char buf[35], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, p, d;
	int i, max, id;

	while (fgets(bp=buf, 10, stdin) && *buf != '0') {
		n = getint();
		for (max = 0, i = 0; i < n; i++) {
			fgets(bp=buf, 32, stdin);
			p = getint(), bp++, d = getint(), bp++, d += getint();
			if (d > max) id = p, max = d;
		}
		printf("%d %d\n", id, max);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> sum(n);
  long long ans = 0;
  for(int i = 0; i < n; i++){
    long long a, b;
    cin >> a >> b;
    ans -= b;
    sum.at(i) = a + b;
  }
  
  sort(sum.begin(), sum.end());
  reverse(sum.begin(), sum.end());
  for(int i = 0; i < n; i++){
    if(i % 2) continue;
    ans += sum.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include<stdio.h>

int main(){
 int n,i,j,k,count;
 while(scanf("%d",&n)!=EOF){
  for(i=0,count=0;i<10;i++)
   if(i<=n)
   for(j=0;j<10;j++)
    if((i+j)<=n)
     for(k=0;k<10;k++)
      if((i+j+k)<=n)
       if(n-i-j-k<10) count++;
  printf("%d\n",count);
 }
 return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const ll M=100000007;
const double EPS=1e-9;

ll xgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){ x=1; y=0; return a; }
	ll g=xgcd(b,a%b,y,x); y-=a/b*x;
	return g;
}

ll modinv(ll a,ll m){
	ll x,y;
	if(xgcd(a,m,x,y)==1) return (x+m)%m;
	return -1;
}

int n,id[100];
double p[100],w[100];

bool vis[100];

void dfs1(int u,vector<int> &cyc){
	if(vis[u]) return;
	vis[u]=true;
	cyc.push_back(u);
	dfs1(id[u],cyc);
}

double dfs2(int u,bool first){
	if(vis[u]) return 0;
	vis[u]=true;
	return 1/(first?p[u]:w[u])+dfs2(id[u],false);
}

int main(){
	ll fact[101]={1},factinv[101]={1};
	rep(i,100){
		fact[i+1]=(i+1)*fact[i]%M;
		factinv[i+1]=modinv(i+1,M)*factinv[i]%M;
	}

	for(;scanf("%d",&n),n;){
		rep(u,n) scanf("%lf%d%lf",p+u,id+u,w+u);

		int m=0;
		vector<int> cyc[100];
		fill(vis,vis+n,false);
		rep(u,n) if(!vis[u]) dfs1(u,cyc[m++]);

		double ans=0;
		ll ans2=fact[n];
		rep(i,m){
			double ex=1e70;
			ll cnt=0;
			rep(j,cyc[i].size()){
				fill(vis,vis+n,false);
				double tmp=dfs2(cyc[i][j],true);
				if(tmp<ex-EPS){
					ex=tmp;
					cnt=1;
				}
				else if(abs(ex-tmp)<EPS){
					cnt++;
				}
			}
			ans+=ex;
			ans2=ans2*cnt%M;
			ans2=ans2*factinv[cyc[i].size()]%M;
		}
		printf("%.11f %ld\n",ans,ans2);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
#define P pair<int,int>
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int n;
int t[111111];

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


Measured memory_bytes: 640
import java.util.Scanner;

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

        String[] array = scanner.nextLine().split(" ");
        long n = Integer.parseInt(array[0]);
        int m = Integer.parseInt(array[1]);
        int d = Integer.parseInt(array[2]);

        double p;
        if (d == 0) {
            p = n;
        } else {
            p = (n - d) * 2;
        }
        System.out.printf("%1.10f\n", (p * (m - 1)) / (n * n));
    }
}

Measured memory_bytes: 25684
///    *****       *     **    **   *******     *   **    ** //////
///    **         * *    ** *  **      **      * *   **  **  /////////
///    *****     *****   **  * **      **     *****   ****  /////////////
///       **    *******  **   ***  **  **    *******   **   ////////
///    *****   **     ** **    **  ******   **     **  **   /////
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back

void solve()
{
   int n,ans=1;
   cin>>n;
 for(int i=0;i<3;i++)
        ans*=n;
    cout<<ans;
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

vector<ll> Tree;

ll query(int node, int start, int end, int qstart, int qend)
{
	if (start > end || qend < start || qstart > end)
		return 0;
	if (qstart <= start && end <= qend)
		return Tree[node];
	int mid = (start + end) / 2;
	return max(query(2 * node, start, mid, qstart, qend),
			   query(2 * node + 1, mid + 1, end, qstart, qend));
}

void update(int node, int start, int end, int pos, ll val)
{
	if (start > end)
		return;
	if (start == end)
	{
		Tree[node] = max(Tree[node], val);
		return;
	}
	int mid = (start + end) / 2;
	if (pos <= mid)
		update(2 * node, start, mid, pos, val);
	else
		update(2 * node + 1, mid + 1, end, pos, val);
	Tree[node] = max(Tree[node * 2], Tree[node * 2 + 1]);
}

void solve()
{
	int n;
	cin >> n;
	Tree.resize(4 * n);
	vector<int> h(n), a(n);
	for (auto &x : h)
	{
		cin >> x;
		--x;
	}
	for (auto &x : a)
		cin >> x;
	vector<ll> dp(n + 1);
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int x = h[i];
		ll q = query(1, 0, n - 1, 0, x - 1);
		dp[x] = max(dp[x], q + a[i]);
		db(q, x, dp[x]);
		ans = max(ans, dp[x]);
		update(1, 0, n - 1, x, dp[x]);
	}
	cout << ans;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
        sum += v[i];
    }
    int res = 0;
    for(int i=0; i<n; i++){
        res += v[i]*(sum-v[i]);
    }
    cout << res/2;
    return 0;
}

Measured memory_bytes: 256
n,m =map(int, input().split( ))
if n>=m:
    print(0)
    exit()
###1ターンで「こまを一つ選び」動かす
#並列に動かすのではない
x = list(map(int, input().split( )))
x.sort()
y=[]

for i in range(m-1):
    y.append(x[i+1]-x[i])
y.sort()
#print(y)
tmp = 0
for i in range(n-1):###n-1個避けれる
    tmp += y[-i-1]
print(x[-1]-x[0]-tmp)

Measured memory_bytes: 56872