akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

bool check(char c) {
    return ('0' <= c and c <= '9');
}

int toint(string s) {
    int n = (int)s.size();
    int ret = 0;
    rep(i, n) {
        if(s[i] == 'm') {
            if(i - 1 >= 0 and check(s[i - 1])) ret += 1000 * (s[i - 1] - '0');
            else ret += 1000;
        }
        if(s[i] == 'c') {
            if(i - 1 >= 0 and check(s[i - 1])) ret += 100 * (s[i - 1] - '0');
            else ret += 100;
        }
        if(s[i] == 'x') {
            if(i - 1 >= 0 and check(s[i - 1])) ret += 10 * (s[i - 1] - '0');
            else ret += 10;
        }
        if(s[i] == 'i') {
            if(i - 1 >= 0 and check(s[i - 1])) ret += 1 * (s[i - 1] - '0');
            else ret += 1;
        }
    }
    return ret;
}

string tomcxi(int x) {
    string ret = "";
    if(x >= 1000) {
        int m = x / 1000;
        if(m >= 2) ret += (char)('0' + m);
        ret += 'm';
        x %= 1000;
    }
    if(x >= 100) {
        int c = x / 100;
        if(c >= 2) ret += (char)('0' + c);
        ret += 'c';
        x %= 100;
    }
    if(x >= 10) {
        int y = x / 10;
        if(y >= 2) ret += (char)('0' + y);
        ret += 'x';
        x %= 10;
    }
    if(x >= 1) {
        int i = x;
        if(i >= 2) ret += (char)('0' + i);
        ret += 'i';
    }
    return ret;
}

void solve() {
	string s, t; cin >> s >> t;
    cout << tomcxi(toint(s) + toint(t)) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	int t; cin >> t; rep(i, t)solve();
	//solve();
    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>

int main()
{
    int h,w,i,j,k,num=0;
	int a[501][501];
	static int ans[251000][4];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			scanf("%d",&(a[i][j]));
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(a[i][j]%2==1&&(i!=h-1||j!=w-1))
			{
				if(j!=(w-1))//右
				{
					a[i][j]--;
					a[i][j+1]++;
					ans[num][0]=i+1;
					ans[num][1]=j+1;
					ans[num][2]=i+1;
					ans[num][3]=j+2;
				}
				else//下
				{
					a[i][j]--;
					a[i+1][j]++;
					ans[num][0]=i+1;
					ans[num][1]=j+1;
					ans[num][2]=i+2;
					ans[num][3]=j+1;
				}
				num++;
			}
		}
	}
	printf("%d\n",num);
	for(k=0;k<num;k++)
	{
		printf("%d %d %d %d\n",ans[k][0],ans[k][1],ans[k][2],ans[k][3]);
	}
}


Measured memory_bytes: 4992
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    for(int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
    for(int i = 1; i <= m; i++) cin >> b[i], b[i] += b[i - 1];

    int ans = 0;
    for(int i = 0; i <= n; i++){
        if(a[i] > k) continue;
        auto it = upper_bound(iter(b), k - a[i]);
        ans = max(ans, i + (int)(it - b.begin()) - 1);
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6364
import math
prime = [i for i in range(2, 10**5+1)]
for i in range(2, math.floor(math.sqrt(10**5))+1):
    prime = [p for p in prime if (p == i or p % i != 0)]
isPrime = [False for i in range(10**5+1)]
for p in prime:
    isPrime[p] = True
cntPrime = [0 for i in range(10**5+1)]
for i in range(2, 10**5+1):
    if i % 2 == 1 and isPrime[i] and isPrime[(i+1)//2]:
        cntPrime[i] = cntPrime[i-1]+1
    else:
        cntPrime[i] = cntPrime[i-1]

Q = int(input())
for i in range(Q):
    l, r = [int(_) for _ in input().split()]
    print(cntPrime[r]-cntPrime[l-1])

Measured memory_bytes: 59508
#include <iostream>
#define N 100
using namespace std;

int main(){
  int n,m,l;
  long long a[N][N]={},b[N][N]={},c[N][N]={};
  cin>>n>>m>>l;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }

  for(int j=0;j<m;j++){
    for(int k=0;k<l;k++){
      cin>>b[j][k];
    }
  }

  for(int i=0;i<n;i++){
    for(int k=0;k<l;k++){
      for(int j=0;j<m;j++){
	
	c[i][k]+=a[i][j]*b[j][k];

      }
    }
  }
  
  for(int i=0;i<n;i++){
    for(int k=0;k<l;k++){
      if(k==l-1) cout<<c[i][k]<<endl;
      else cout<<c[i][k]<<" ";
    }
  }
 
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; ++i){
      int t;
      cin >> t;
      if (i % 2 == 0) continue;
      if (t % 2 == 0) continue;
      ans += 1;
    }

    cout << ans << endl;
}


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

int per[100005],rank[100005],size[100005];

int find(int a);
int unite(int a,int b);
int unite(int a,int b);
int same(int a,int b);
long long comb(int a,int b);

int main(void){
  int N,M,a[100005],b[100005],i,q,r;
  long long ans[100005];
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  M=atoi(p);
  
  for(i=0;i<M;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    a[i]=atoi(p);
    p=strtok(NULL," \n");
    b[i]=atoi(p);
  }
  
  for(i=1;i<N+1;i++){
    per[i]=i,rank[i]=0,size[i]=1;
  }
  
  ans[M]=comb(N,2);
  
  for(i=M-1;i>=0;i--){
    if(same(a[i],b[i])){
      ans[i]=ans[i+1];
    }else{
      r=find(a[i]),q=find(b[i]);
      ans[i]=ans[i+1]-size[r]*size[q];
      unite(a[i],b[i]);
    }
  }
  
  for(i=1;i<=M;i++){
    printf("%lld\n",ans[i]);
  }
  
  return 0;
}

int find(int a){
  if(per[a]==a){
    return a;
  }
  return per[a]=find(per[a]);
}

int unite(int a,int b){
  int p,q;
  p=find(a),q=find(b);
  if(same(a,b)){
    return 0;
  }else{
    if(rank[p]>rank[q]){
      per[q]=p,size[p]+=size[q],size[q]=0;
    }else if(rank[p]<rank[q]){
     per[p]=q,size[q]+=size[p],size[p]=0; 
    }else{
      per[q]=p,rank[p]++,size[p]+=size[q],size[q]=0;
    }
  }
  return 0;
}

int same(int a,int b){
  if(find(a)==find(b)){
    return 1;
  }else{
    return 0;
  }
}


long long comb(int a,int b){
  long c,d,i;
  
  for(i=0,c=1;i<b;i++){
    c*=(a-i);
  }
  for(i=1,d=1;i<=b;i++){
    d*=i;
  }
  return c/b;
}


Measured memory_bytes: 3968
using System;
namespace practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            while (n-- > 0)
            {
                int hit = 0, Out = 0, score = 0;
                while (true)
                {
                    string word = Console.ReadLine();
                    if (word == "HIT")
                    {
                        hit++;
                        if (hit == 4)
                        {
                            score++;
                            hit--;
                        }
                    }
                    else if (word == "OUT")
                    {
                        Out++;
                        if (Out == 3)
                        {
                            Console.WriteLine(score);
                            break;
                        }
                    }
                    else if (word == "HOMERUN")
                    {
                        score += hit + 1;
                        hit = 0;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 8968
from math import log2


def inpl():
    return list(map(int, input().split()))


N, K = inpl()

bunshi = 0
for i in range(1, N + 1):
    if i >= K:
        bunshi += (N - i + 1) * (2**17)
        break

    tmp = log2(i) - log2(K)
    X = abs(tmp // 1)
    bunshi += 2**(17 - X)

print('{:.15f}'.format(bunshi / (N * (2**17))))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
 
int main() {
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

vector<int> G[10010];
ll c[10010];
int vis[10010];
int N;
int xx;
int d[10010];

void bfs(int startv)
{
    queue<int> que;

    que.push(startv);
    vis[startv] = true;

    while (!que.empty())
    {

        int nv = que.front();//現在の頂点
        que.pop();
        d[nv] = (int)c[xx];
        for (int i = 0; i < (int)G[nv].size(); i++)
        {
            int next_v = G[nv][i];

            if (vis[next_v] == false) {
                que.push(next_v);
                vis[next_v] = true;
            }
        }
        xx--;
    }
    return;
}

int main() {
    cin >> N;
    xx = N - 1;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, N) cin >> c[i];
    ll sum = 0;

    sort(c, c + N);
    rep(i, N - 1) sum += c[i];
    cout << sum << endl;

    int emax = 0, sv = 0;
    rep(i, N) {
        if ((int)G[i].size() > emax) {
            emax = (int)G[i].size();
            sv = i;
        }
    }
    bfs(sv);
    rep(i, N) {
        cout << d[i] << ' ';

    }
    cout << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<map>
#define maxn 100005
using namespace std;
long long remainder[maxn];
long long a[maxn];
map<long long,long long>number_l;
int main()
{
    long long n,m,answer=0;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        remainder[i]=remainder[i-1]+a[i];
        remainder[i]%=m;
        answer+=number_l[remainder[i]];
        number_l[remainder[i]]++;
    }
    answer+=number_l[0];/**自己为起点自己为终点没有算进去，要补上**/
    printf("%lld\n",answer);
    return 0;
}


Measured memory_bytes: 5760
import math

def getgcd(a,b):
    [a,b]=[min(a,b),max(a,b)]
    aa=a
    bb=b
    while aa!=0:
        [aa,bb]=[bb%aa,aa]
    return bb

while(1):
    [a,b,c]=[int(x) for x in raw_input().split()]
    if a==0:
        break
    else:
        bunbo=2*a
        if b**2-4*a*c<0:
            print 'Impossible'
        else:
            bunsi=[-b+math.sqrt(b**2-4*a*c),-b-math.sqrt(b**2-4*a*c)]
            if int(bunsi[0])!=bunsi[0]:
                print 'Impossible'
            else:
                gcd=[getgcd(bunbo,abs(x)) for x in bunsi]
                [p,q]=[int(bunbo/gcd[0]),-int(bunsi[0]/gcd[0])]
                [r,s]=[int(bunbo/gcd[1]),-int(bunsi[1]/gcd[1])]
                if p>r:
                    print p,q,r,s
                elif p<r:
                    print r,s,p,q
                else:
                    if q<s:
                        print r,s,p,q
                    else:
                        print p,q,r,s

Measured memory_bytes: 4432
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int naive(const vector<pair<int, int>> &AB, const int T) {

	int res = 0;
	for (int bit = 0; bit < (1 << AB.size()); bit++) {

		int last = 0, sum = 0, time = 0;
		for (int i = 0; i < AB.size(); i++) {

			if (bit & (1 << i)) {
				int tmp = last;
				if (chmax(last, AB[i].first)) time += tmp;
				else time += AB[i].first;
				sum += AB[i].second;
			}
			if (time >= T) break;
		}

		if (time < T) if(chmax(res, sum)) DMP(bit);

	}

	return res;

}

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

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

	int N, T;
	cin >> N >> T;

	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end());
	
	vector<int> dp(T+1);
	for (int i = 0; i < N; i++) {
		for (int j = T - 1; j >= 0; j--) {
			chmax(dp[min(j + AB[i].first, T)], dp[j] + AB[i].second);
		}
	}
	
	cout << dp[T] << "\n";
	DMP(naive(AB, T));

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint k,t;
    cin>>k>>t;
    vec a(t);
    rep(i,t)cin>>a[i];
    lint mx=*max_element(all(a));
    lint tmp=mx-(k-mx+1);
    cout<<max(tmp,0LL)<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
dd = {}
N,K = map(int,input().split())
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        if j not in dd.keys():
            dd[j] = 1
print(N-len(dd))

Measured memory_bytes: 9188
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x,y; cin>>x>>y;
	//a+b=x
	//2a+4b=y
	if(y%2==1)
	{
		cout<<"No\n"; return 0;
	}
	y>>=1;
	if(y>=x&&x>=y-x)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}


Measured memory_bytes: 3644
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

sa = list(input())
sb = list(input())
sc = list(input())
turn = "a"
while True:
    if turn == "a":
        if len(sa) == 0:
            print("A")
            exit()
        else:
            s = sa.pop(0)
            turn = s
    if turn == "b":
        if len(sb) == 0:
            print("B")
            exit()
        else:
            s = sb.pop(0)
            turn = s
    if turn == "c":
       if len(sc) == 0:
           print("C")
           exit()
       else:
           s = sc.pop(0)
           turn = s

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


int main(){
    map<ll,ll> upper,lower;
    ll n; cin >> n;
    for(ll i=1;i<=n;i++){
        ll a; cin >> a;
        upper[i-a]++;
        lower[i+a]++;
    }
    ll ans=0;
    for( auto i = upper.begin(); i != upper.end() ; ++i ) {
        ans+=(i->second)*lower[i->first];
        //std::cout << i->first << " " << i->second << " " << lower[i->first] << "\n";
    }
    cout << ans << endl;
}



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

typedef long long ll;
const int maxn=1<<18,mod=924844033;
int n,size[maxn];
ll fac[maxn],finv[maxn],a[maxn<<1],b[maxn<<1],c[maxn<<1];
vector<int> g[maxn];

inline ll qpow(ll a,ll n){
	ll res=1;
	while(n){
		if(n&1)
			res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}
void dfs(int pos,int fa){
	size[pos]=1;
	for(int i=0,v;i<g[pos].size();++i)
		if((v=g[pos][i])!=fa){
			dfs(v,pos);
			size[pos]+=size[v];
			++a[size[v]];
			++a[n-size[v]];
		}
}
inline int rev(int id,int len){
	int res=0;
	for(int i=1;i<len;i<<=1){
		res<<=1;
		if(id&i)
			res|=1;
	}
	return res;
}
inline void fft(ll*a,int len,int dft){
	for(int i=0;i<len;++i)
		if(i<rev(i,len))
			swap(a[i],a[rev(i,len)]);
	for(int i=2;i<=len;i<<=1){
		ll w=qpow(5,(mod-1)/i);
		if(dft==-1)
			w=qpow(w,mod-2);
		for(int j=0;j<len;j+=i){
			ll ww=1;
			for(int k=0;k<(i>>1);++k,ww=ww*w%mod){
				ll x=a[j+k],y=a[j+k+(i>>1)]*ww%mod;
				a[j+k]=(x+y)%mod;
				a[j+k+(i>>1)]=(x-y+mod)%mod;
			}
		}
	}
	if(dft==-1){
		int inv=qpow(len,mod-2);
		for(int i=0;i<len;++i)
			a[i]=a[i]*inv%mod;
	}
}

int main(){
	fac[0]=1;
	for(int i=1;i<maxn;++i)
		fac[i]=fac[i-1]*i%mod;
	finv[maxn-1]=qpow(fac[maxn-1],mod-2);
	for(int i=maxn-1;i;--i)
		finv[i-1]=finv[i]*i%mod;
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	for(int i=1;i<n;++i)
		a[i]=a[i]*fac[i]%mod;
	for(int i=0;i<=n;++i)
		b[i]=finv[n-i];
	fft(a,maxn<<1,1);
	fft(b,maxn<<1,1);
	for(int i=0;i<(maxn<<1);++i)
		c[i]=a[i]*b[i]%mod;
	fft(c,maxn<<1,-1);
	for(int i=1;i<=n;++i)
		printf("%lld\n",(n*fac[n]%mod*finv[i]%mod*finv[n-i]%mod-finv[i]*c[n+i]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 44928
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,v,P;
int a[201010],b,q[202020];
long long sum[202020];
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&P);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
	if(a[i]>=a[n-P+1]) ans++;
	else if(a[i]+m<a[n-P+1]) continue;
	else
	{
		int num=1;
		while(a[i+1]==a[i]) i++,num++;
		if(v<=i+P-1) ans+=num;
		else if(((long long)a[i]+m)*(n-P+1-i)-sum[n-P+1]+sum[i]>=((long long)v-i-P+1)*m) ans+=num;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  string t="";
  for(int i=0;i<5;++i){
    t+="hi";
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

XY = np.asarray( list(map(int, input().split())) )

Ainv = np.asarray([[2, -0.5], [-1, 0.5]])

x, y = Ainv.dot(XY)

if x.is_integer() and y.is_integer():
  if x >= 0 and y>= 0:
  	print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 27180
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool isprime(T n){
if(!(n&1)) return false;
for(T i=3; i*i < n; i+=2){
if(n%i==0) return false;
}
return true;
}

#define N 100000
bitset<N> primes;
void sieve(){  // nが素数ならばbitset[n]==1
    primes[0]=1; primes[1]=1;
    for(int i=4; i<N; i+=2){
        primes |= (bitset<N>(1)<<i);
    }
    for(int i=3; i<N; i+=2){
        if(primes[i]) continue;
        if(!isprime(i)) continue;
        for(int j=i*3; j<N; j+=2*i){
            primes |= (bitset<N>(1)<<j);
        }
    }
    primes = ~primes;
}

int main()
{
    sieve();
    int n ;cin >> n;
    vint v;
    FOR(i, 3, 55556){
        if(primes[i]){
            if((i-1)%3!=0) continue;
            int k = (i-1)/3;
            if(k%10==0) v.push_back(i);
            if(v.size()==n) break;
        }
    }
    prvec(v);
    // pr(v.size());
    return 0;}

Measured memory_bytes: 3640
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
mean = a.reduce(:+).to_f / n.to_f
min = 10000
ans = 0
0.upto(n-1) do |i|
  diff = (mean - a[i]).abs
  if min > diff
    ans = i
    min = diff
  end
end
puts ans


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,a[200010],b[200010],ans;
map<int,int>mp;
int bit[200010];
int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    rep(j,n+1){
        b[j]=b[j-1]+a[j-1]-k;
    }
    rep(i,n+1)mp[b[i]]=1;
    int now=0;
    for(P p:mp){
        if(p.se){
            mp[p.fi]=now;
            now++;
        }
    }
    rep(i,n+1){
        b[i]=mp[b[i]];
    }
    n++;
    rep(i,n){
        ans+=sum(b[i]+1);
        add(b[i]+1,1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 18816
s=list(input())
cnt=0
for i in range(len(s)-1):
    if int(s[i])==int(s[i+1])==0:
        s[i+1]="1"
        cnt+=1
    elif int(s[i])==int(s[i+1])==1:
        s[i+1]="0"
        cnt+=1
print(cnt)



Measured memory_bytes: 3956
program iroha_easy
    implicit none
    integer a, b, c
    read *, a, b, c
    if(a .eq. 5 .and. b .eq. 5 .and. c .eq. 7)then
        print *, 'YES'
    else if(a .eq. 5 .and. b .eq. 7 .and. c .eq. 5)then
        print *, 'YES'
    else if(a .eq. 7 .and. b .eq. 5 .and. c .eq. 5)then
        print *, 'YES'
    else
        print *, 'NO'
    end if
end program

Measured memory_bytes: 2860
n = gets.to_i
s = readlines.map(&:chomp)
h = Hash.new(0)
max = 0
s.each do |i|
  h[i] += 1
  max = h[i] if max < h[i]
end

ans = []
h.each do |a,b|
  ans << a if b == max
end

puts ans.sort

Measured memory_bytes: 51300
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int ans = b;
    if (a < 6) ans = 0;
    else if (a < 13) ans /= 2;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
  int n;
  cin >> n;
  LL ans = 0;
  for(int i = 1;i<=n; i++) {
    if(i%3 == 0 && i%5 ==0) continue;
    if(i%3 == 0) continue;
    if(i%5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 5984
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
using namespace std;
const int N=1e6+69, base=1024*1024, mod=1e9+7;
LL dp[N][5],n,a;
int32_t main(void) {
    boost;
    cin>>n;
    f1(i,n) {
        cin>>a;
        dp[i][0]=dp[i-1][0]+a;
    }
    f1(i,n) {
        cin>>a;
        dp[i][1]=max(dp[i][0],dp[i-1][1])+a;
    }
    cout<<dp[n][1];
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto N = readln.chomp.to!int;
	foreach(i;1..10) {
		if(pow(2, i) > N) {
			pow(2, i-1).writeln;
			break;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    set<int> s;
	int a;

	int i;

	rep(i, 3) {
		cin >> a;

		s.insert(a);
	}

	Out(s.size());
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

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

	string N;
	cin >> N;
	int sum = 0;
	for (auto c : N) {
		sum += c - '0';
	}
	cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";

	return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  double sum = 0;
  for(int i=0; i<n; i++)
{
  	double l;
  	cin >> l;
  	sum += 1/l;
  }
  cout << 1/sum << endl;
  return 0;
}


Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var set = {
  	"gray" : false,
    "brown" : false,
    "green" : false,
    "water" : false,
    "blue" : false,
    "yellow" : false,
    "orange" : false,
    "red" : false,
    "all" : 0
  };
  var notall = 0;
  for(var i = 0; i < N; i++){
    if(list[i] >=1 && list[i] <= 399 && !set["gray"]){
       set["gray"] = true;
      notall++;
    }
    if(list[i] >=400 && list[i] <= 799 && !set["brown"]){
       set["brown"] = true;
      notall++;
    }
    if(list[i] >=800 && list[i] <= 1199 && !set["green"]){
       set["green"] = true;;
      notall++;
    }
    if(list[i] >=1200 && list[i] <= 1599 && !set["water"]){
       set["water"] = true;
      notall++;
    }
    if(list[i] >=1600 && list[i] <= 1999 && !set["blue"]){
       set["blue"] = true;
      notall++;
    }
    if(list[i] >=2000 && list[i] <= 2399 && !set["yellow"]){
       set["yellow"] = true;
      notall++;
    }
    if(list[i] >=2400 && list[i] <= 2799 && !set["orange"]){
       set["orange"] = true;
      notall++;
    }
    if(list[i] >=2800 && list[i] <= 3199 && !set["red"]){
       set["red"] = true;
      notall++;
    }
    if(list[i] >=3200){
       set["all"]++;
    }
  }
  myerr(set);
  var min = notall;
  var max = notall + set["all"];
  if(min == 0 && set["all"] >=1){
     min = 1;
  }
  myout(min + " " + max);
}
Main(myin());

Measured memory_bytes: 22216
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    vector<pair<ll,ll>> val(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        val[i].first = a[i] + b[i];
        val[i].second = i;
    }
    sort(val.rbegin(),val.rend());
    ll ans = 0;
   for(int i = 0; i < n; i++){
       if(i%2 == 0) ans += a[val[i].second];
       else ans -= b[val[i].second];
   }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#coding: utf-8

def maxHeapify(A, i):
    l = 2 * i
    r = 2 * i  + 1

    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i

    if r <= H and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest)

def buildMaxHeap(A):
    for i in range(H//2, 0, -1):
        maxHeapify(A, i)

H = int(input())
A = [0] + list(map(int,input().split()))
buildMaxHeap(A)
A.pop(0)
print(" " + " ".join([str(num) for num in A]))



Measured memory_bytes: 63844
open Printf
open Scanf

type node = { p : int option; l : int option; r : int option }
              
let id x = x

let find_root tr =
  let rec iter i = match tr.(i) with
      {p = Some j} -> iter j
    | _ -> i
  in iter 0

let preorder tr n =
  let rec iter ls = function
      None -> ls
    | Some i -> let ts1 = iter ls tr.(i).r in
                let ts2 = iter ts1 tr.(i).l in i :: ts2
  in iter [] (Some n)

let inorder tr n =
  let rec iter ls = function
      None -> ls
    | Some i -> let ts1 = iter ls tr.(i).r in
                let ts2 = iter (i :: ts1) tr.(i).l in ts2
  in iter [] (Some n)

let postorder tr n =
  let rec iter ls = function
      None -> ls
    | Some i -> let ts1 = iter (i::ls) tr.(i).r in
                let ts2 = iter ts1 tr.(i).l in ts2
  in iter [] (Some n)

let () =
  let n = scanf "%d\n" id in
  let btree = Array.make n {p = None; l = None; r = None} in
  let rec read n =
    if n = 0 then ()
    else begin
        let i, l, r = scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
        begin
          btree.(i) <- {btree.(i) with l = (if l <> (-1) then Some l else None);
                                       r = (if r <> (-1) then Some r else None)};
          if l <> (-1) then btree.(l) <- {btree.(l) with p = Some i};
          if r <> (-1) then btree.(r) <- {btree.(r) with p = Some i}
        end;
        read (n-1)
      end
  in
  read n;
  let r = find_root btree in
  printf "Preorder\n";
  preorder btree r |> List.iter (fun x -> printf " %d" x); printf "\n";
  printf "Inorder\n";
  inorder btree r |> List.iter (fun x -> printf " %d" x); printf "\n";
  printf "Postorder\n";
  postorder btree r |> List.iter (fun x -> printf " %d" x); printf "\n"

Measured memory_bytes: 2352
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end


n = gets.strip.to_i
xy = readlines.map {|line| line.strip.split.map(&:to_i) }
xy=xy.uniq

nodes = {}
xy.each_with_index do |(x, y), i|
  k = [x,y].to_s
  nodes[k]=i
end


edges = []

xy.sort_by(&:first).each_cons(2) do |(lx, ly), (rx, ry)|
  c = [(lx-rx).abs, (ly-ry).abs].min
  f = nodes[[lx,ly].to_s]
  t = nodes[[rx,ry].to_s]
  edges << [f, t, c]
end

xy.sort_by(&:last).each_cons(2) do |(lx, ly), (rx, ry)|
  c = [(lx-rx).abs, (ly-ry).abs].min
  f = nodes[[lx,ly].to_s]
  t = nodes[[rx,ry].to_s]
  edges << [f, t, c]
end

uf = UnionFind.new(n+1)
result = 0

edges.sort_by(&:last).each do |f, t, c|
  next if uf.same_parent?(f, t)

  uf.unite(f, t)
  result += c
end

p result

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

#define hey(x) cerr << #x << " : " << x << "\n";
#define int long long int
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int, int> >
#define vvpi vector<vector<pair<int, int> > >
#define all(v) (v).begin(), (v).end()   
#define rall(v) (v).rbegin(), (v).rend()
#define pii pair<int, int>
#define pb push_back
#define SZ(x) (int)(x).size()
#define inf 1e12
#define F first
#define S second
#define fill(v, val) memset((v), val, sizeof(v))
#define PI 3.1415926535897932384626
#define out cout << fixed << setprecision(12)
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define hey2(x, y) cerr << #x << " : " << x << "," << #y << " : " << y << '\n';

const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const double pi = acos(-1);

void read(vi &a) {
    for(int i : a)
        cin >> i;
}
void print(vi &a) {
    for(int i : a)
        cout << i << ' ';
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n][3], dp[n][3];
    fill(dp, 0);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < 3; ++i) {
        dp[0][i] = a[0][i];
    }
    // dp[i][0] = max(dp[i - 1][1], dp[i - 2]) + a[i][0];
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            dp[i][j] = a[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
        }
    }

    int ans = -inf;
    for(int i = 0; i < 3; ++i)
        ans = max(ans, dp[n - 1][i]);
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 8268
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
print(int((N*(N+1))/2))
'''
sum = 0
for i in range(N):
    sum += (i+1)
print(sum)
'''

Measured memory_bytes: 9100
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

ll MODpow(ll n, ll m, ll mod) {
    ll result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= mod;
        }

        m /= 2;
        n *= n;
        n %= mod;
    }

    return result;
}

int main() {
    string S;
    cin >> S;

    constexpr ll C = 13;
    constexpr ll MOD = 1e9 + 7;
    reverse(S.begin(), S.end());

    vector<ll> num(C, 0);
    {
        if (S[0] == '?') {
            for (ll j = 0; j < 10; j++) {
                num[j] = 1;
            }
        } else {
            ll mod = (S[0] - '0') % C;
            num[mod] = 1;
        }
    }
    for (ll i = 1; i < S.size(); i++) {
        vector<ll> copy = num;
        num.assign(C, 0);
        if (S[i] == '?') {
            for (ll j = 0; j < 10; j++) {
                ll mod = j * MODpow(10, i, C) % C;
                for (ll k = 0; k < C; k++) {
                    (num[(k + mod) % C] += copy[k]) %= MOD;
                }
            }
        } else {
            ll mod = (S[i] - '0') * MODpow(10, i, C) % C;
            for (ll k = 0; k < C; k++) {
                (num[(k + mod) % C] = copy[k]) %= MOD;
            }
        }
    }

    cout << num[5] << endl;
}

Measured memory_bytes: 512
import math
alen, blen, cang = map(float, input().split())
h = math.sin(math.radians(cang)) * blen
#print(h)
S = 0.5 * alen * h
if cang < 90.0:
    L = alen + blen + math.sqrt((alen - math.sqrt(blen**2.0 - h**2.0)) ** 2.0 + h**2.0)
else:
    L = alen + blen + math.sqrt((alen + math.sqrt(blen**2.0 - h**2.0)) ** 2.0 + h**2.0)
print(S)
print(L)
print(h)


Measured memory_bytes: 5664