akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;

int par[200001],n,k,l,pa[200001];
int ans[200001] ;
void init(int n) {
	
	for (int i = 1; i <= n;i++) {
		pa[i] = i;
		par[i] = i;
		ans[i] = 1;
	}
}

int root(int x) {
	if (par[x] == x)return x;
	else return par[x] = root(par[x]);
}
int roo(int x) {
	if (pa[x] == x)return x;
	else return pa[x] = roo(pa[x]);
}


void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	par[x] = y;
}
void unit(int x, int y) {
	x = roo(x);
	y = roo(y);
	if (x == y)return;
	pa[x] = y;
}

int main() {
	
	cin >> n >> k >> l;
	init(n);
	
	for(int i = 0;i < k; i++) {
		int p, q;
		cin >> p >> q;
		unite(p, q);
	}
	for (int i = 0; i < l; i++) {
		int r, s;
		cin >> r >> s;
		unit(r, s);
	}
	map<int,int> str[200001];
	for (int i = 1; i <= n; i++) {
		str[root(i)][roo(i)]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << str[root(i)][roo(i)] << endl;
	}

	
	return 0;
}


Measured memory_bytes: 20864
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    long long a, b, c;
    long long ans = 0;
    cin >> a >> b >> c;
    if(a+b >= c){
        ans = b + c;
    }
    else {
        ans = a + 2*b + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int sum[110][26];

signed main()
{
    int N; cin>>N;
    string s; cin>>s;

    REP(i,N) sum[i+1][s[i]-'a']++;
    REP(i,N) REP(j,26)
        sum[i+1][j]+=sum[i][j];

    int ans=0;
    for(int i=1;i<=N-1;i++){
        int cnt=0;
        REP(j,26){
            if(sum[i][j]>0 and sum[N][j]-sum[i][j]>0) cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
v1 ... vn

n 10^5 even
vi 10^5
 */
#define MAX 100000
int n,v[100000];
int even[MAX+1], odd[MAX+1];

template<class T>
auto comp_idx(T* ptr){
  return [ptr](int l_idx, int r_idx){
    return ptr[l_idx] > ptr[r_idx];
  };
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>v[i];
    if(i%2==0){
      even[v[i]]++;
      cerr<<"hoge"<<endl;
    } else {
      odd[v[i]]++;      
    }
  }

  int even_idx[MAX+1], odd_idx[MAX+1];
  REP(i,MAX+1){
    even_idx[i] = i;
    odd_idx[i] = i;
  }
  
  sort(even_idx, even_idx+MAX+1, comp_idx(even));
  sort(odd_idx, odd_idx+MAX+1, comp_idx(odd));

  int sub=0;
  if(even_idx[0]==odd_idx[0]){
    sub = max(even[even_idx[0]]+odd[odd_idx[1]], even[even_idx[1]]+odd[odd_idx[0]]);
  } else {
    sub = even[even_idx[0]]+odd[odd_idx[0]];
  }

  cout<<n-sub<<endl;
  return 0;
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
#define mod 1000000007
ll power(ll x,ll p){ll a=1;while(p>0){if(p%2==0){x*=x;p/=2;}else{a*=x;p--;}}return a;}
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 0, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll k) { ll a = 1, b = 1; rep(i, 0, k) { a = a * (n - i + 1) % mod; b = b * i % mod; }return a * mpower(b, mod - 2) % mod; }

const double PI = 3.14159265358979323846;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
	ll N, K, s = 0;
	scanf("%lld%lld", &N, &K);
	rep(l, K, N + 2) {
		//printf("%lld\n", (N - l + 1) * l + 1);
		s += (N - l + 1) * l + 1;
		s %= mod;
	}
	printf("%lld\n", s);
	return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

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

		long n = sc.nextLong();
		long m = sc.nextLong();

		long ans = 0;

		if (2 * n > m) {
			ans = m / 2;
		} else {
			ans = n + (m - 2 * n) / 4;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=10;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
char s[N],t[N];
int ans;

int main(){
	scanf("%s%s",s,t);
	Rep(i,0,2)if(s[i]==t[i])ans++;
	printf("%d\n",ans);
	return 0;	
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

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 REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI p(n); rep(i, n)cin >> p[i];
	VB f(n); rep(i, n)f[i] = (p[i] != i + 1);
	int ans = 0;
	rep(i, n) {
		if (!f[i]) {
			ans++;
			f[i] = true;
			f[i + 1] = true;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = 1E9;
const double EPS = 1E-9;

int a[N];
int n, m;

int g[N][N];
int main() {
    ios_base::sync_with_stdio(false);

#ifdef CF_DEBUG
    freopen("../cf/input.txt","r",stdin);
#endif
    cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            g[i][j] = gcd(i,j);
        }
    }
    LL res=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                int v=g[i][j];
                res+=gcd(v,k);
            }
        }
    }
    cout<<res;
    return 0;
}

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

int main(){
   double xA, yA, xB, yB, xC, yC, xD, yD;
   while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
       double t = (yA-yB)*(yC-yD) + (xC-xD)*(xA-xB);
       cout << (abs(t) < 1e-10 ? "YES" : "NO") << endl;
   }
   return 0;
}

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

int main(){	
	int N;
	cin >> N;
	string s[N];
	for (int i=0; i<N; i++) {
		cin >> s[i];
	}
	int A = 0, B = 0, BA = 0, res = 0;
	for (int i=0; i<N; i++) {
		if (s[i][0] == 'B') B++; 
		if (s[i][s[i].length()-1] == 'A') A++; 
		if (s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') {
			B--;
			A--;
			BA++;
		}
		for (int j=0; j<s[i].length()-1; j++) {
			if (s[i][j] == 'A' && s[i][j+1] == 'B') res++;
		}
	}
	if (A>0 && BA > 0) {
		A--;
		BA++;
	}
	if (B>0 && BA > 0) {
		B--;
		BA++;
	}
	cout << res+min(N-1, min(A, B))+max(BA-1, 0) << endl;
	return 0;
}


Measured memory_bytes: 768
N, M = map(int,input().split())
st = [[] for _ in range(N)]
cp = [[] for _ in range(M)]
for i in range(N):
    a, b = map(int,input().split())
    st[i] = [a, b]
for j in range(M):
    c, d = map(int,input().split())
    cp[j] = [c, d]
for i in range(N):
    ne = 10**12
    p = 0
    for j in range(M):
        dis = abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
        if dis < ne:
            p = j
            ne = dis
    print(p+1)

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
class Tree:
    __slots__ = ['id', 'p', 'sibling', 'degree', 'depth', 'height', 'type', 'c']
    def __init__(self, id):
        self.id = id
        self.p = -1
        self.sibling = -1
        self.degree = 0
        self.depth = -1
        self.height = 0
        self.type = "leaf"
        self.c = []
    def __str__(self):
        return f"node {self.id}: parent = {self.p}, sibling = {self.sibling}, degree = {self.degree}, depth = {self.depth}, height = {self.height}, {self.type}"
def solve():
    n = int(input())
    if n == 1:
        input()
        print("node 0: parent = -1, sibling = -1, degree = 0, depth = 0, height = 0, root")
        return
    tree = tuple(Tree(i) for i in range(n))
    leaf_li = set()
    for _ in range(n):
        id, *c = map(int, readline().replace("-1", "").split())
        if c != []:
            tree[id].type = "internal node"
            tree[id].c = c
            for j in c:
                tree[j].p = id
            len_c = len(c)
            tree[id].degree = len_c
            if len_c == 2:
                tree[c[0]].sibling = c[1]
                tree[c[1]].sibling = c[0]
        else:
            leaf_li.add(id)
    for i in leaf_li:
        a = i
        cnt = 1
        while tree[a].p != -1 and tree[tree[a].p].height < cnt:
            tree[tree[a].p].height = cnt
            cnt += 1
            a = tree[a].p
    root = 0
    while tree[root].p != -1:
        root = tree[root].p
    tree[root].type = "root"
    tree[root].depth = 0
    tree[root].height = max(tree[i].height for i in tree[root].c) + 1
    def depth_check(id, d):
        d += 1
        for i in tree[id].c:
            tree[i].depth = d
            if tree[i].type != "leaf":
                depth_check(i, d)
    depth_check(root, 0)
    print("\n".join(map(str, tree)))
solve()



Measured memory_bytes: 5644
n, l = map(int, input().split())

if l >= 0:
    s = (n + 1) * n / 2 + (l - 1) * n - (l - 1) - 1
    print(int(s))
elif n + l > 0:
    s = (n + 1) * n / 2 + (l - 1) * n
    print(int(s))
else:
    s = (n + 1) * n / 2 + (l - 1) * n - (n + l - 1)
    print(int(s))


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

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

int main(void){
    int n, m;
    int ans;

    cin >> n >> m;

    map<ll, vector<ll>> part;
    rep(i, n){
        ll tmp_a, tmp_b;
        cin >> tmp_a >> tmp_b;

        if(!part.count(tmp_a)){
            part[tmp_a] = {};
        }
        part[tmp_a].push_back(tmp_b);
    }

    ll sum = 0;
    priority_queue<ll> cost;
    for(int i = 1; i <= m; i++){
        for(ll p : part[i]){
            cost.push(p);
        }
        if(cost.size() != 0){
            sum += cost.top();
            cost.pop();
        }
    }


    cout << sum << endl;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

vector<pll> Factor(ll n){
    vector<pll> prime;
    ll sq = sqrt(n) + 1;

    for(int i = 2; i <= sq; ++i){
        sq = sqrt(n) + 1;
        if(n%i == 0){
            prime.push_back(make_pair(i, 0));
            while(n%i == 0){
                n /= i;
                prime[prime.size()-1].second++;
            }
        }
    }

    if(n != 1){
        prime.push_back(make_pair(n, 1));
    }

    return prime;
}

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

    vector<pll> fac = Factor(n);

    cout << n << ":";

    rep(i, fac.size()){
        rep(j, fac[i].second)cout << " " << fac[i].first;
    }
    cout << endl;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string agc("ACTG");
	int64 N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<int64> pos;
	pos.push_back(-INF);
	REP(i, s.size()-1) {
		if (s[i] == 'A' && s[i+1] == 'C') pos.push_back(i);
	}
	pos.push_back(INF);
	REP(i, Q) {
		int64 l, r;
		cin >> l >> r; l--;
		int64 lp = distance(pos.begin(), lower_bound(all(pos), l));
		int64 rp = distance(pos.begin(), lower_bound(all(pos), r));
		int64 minus = 0;
		if (pos[rp-1] == r-1)  minus = 1;
		cout << rp-lp-minus << endl;
	}
}


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

#define N 1000000

typedef struct h{
    char data[13];
struct h *next;
}H;

H table[N];

void init() {
    int i;

    for (i = 0; i < N; i++) {
        table[i].next = NULL;
        *table[i].data = NULL;
    }
}

int hash(char *x) {
    int sum = 0;
    while (*x)
        sum += *x++;
    sum = (sum*sum) / 2 ;
    return (sum+(*--x)+(*--x))%N;
}

int find(char *x) {
    H *p;
    int h;

    h = hash(x);
    for (p = table[h].next; p != NULL; p = p->next)
        if (strcmp(p->data,x) == 0)
            return 1;

    return 0;
}

void insert(char *x) {
    H *p;
    H *New;
    int h;

    if (find(x))
        return;

    if ((New = (H *)malloc(sizeof(H))) == NULL)
        exit(1);

    h = hash(x);
    strcpy(New->data, x);
    p = table[h].next;
    table[h].next = New;
    New->next = p;
}

/*void Delete(char *x) {
    H *p;
    H *q;
    int h;

    h = hash(x);

    for (p = table[h].next, q = &table[h]; p != NULL; q = p, p = p->next)
        if (strcmp(p->data, x) == 0) {
            q->next = p->next;
            break;
        }

    if (p != NULL)
        free(p);
}*/

int main(void) {
    int i, j, n;
    char com[7], data[13];

    init();

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, data);

        if (com[0] == 'i')
            insert(data);
        else if (com[0] == 'f') 
            if (find(data))
                printf("yes\n");
            else
                printf("no\n");
        /*else
            Delete(data);*/
    }
    


    return 0;
}

Measured memory_bytes: 32648
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
ll h[M];
ll cache[M];
ll dp(ll x){
    if(x>n) return inf;
    if(x==n) return 0;
    ll &ans=cache[x];
    if(ans!=-1) return ans;
    ans=min(dp(x+1)+abs(h[x+1]-h[x]),dp(x+2)+abs(h[x+2]-h[x]));
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    mst(cache,-1);
    rep(i,1,n+1){
        cin >> h[i];
    }
    ll answer=dp(1);
    cout << answer;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 4224
from collections import deque
INF = 1001001001
di = (-1, 0, 1, 0)
dj = ( 0,-1, 0, 1)

h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0
for si in range(h):
    for sj in range(w):
        if s[si][sj] == '#': continue
        dist = [[INF] * w for _ in range(h)]
        dist[si][sj] = 0
        q = deque([(si,sj)])
        while q:
            i,j = q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if (ni<0 or ni>=h or nj<0 or nj>=w): continue
                if s[ni][nj] == '#': continue
                if dist[ni][nj] != INF: continue
                q.append((ni,nj))
                dist[ni][nj] = dist[i][j] + 1
        for i in range(h):
            for j in range(w):
                if dist[i][j] == INF: continue
                ans = max(ans, dist[i][j])
print(ans)


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

int main()
{
	ios::sync_with_stdio(false);
	
	int n,sum=0;
	cin>>n;
	
	for(int i=1;i<=n;i++)
		sum+=i;
	
	cout<<sum<<endl;
	return 0;
}

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

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

    ll n;
    cin >> n;

    vector<ll> a(3*n);
    rep(i, 3*n) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());
    ll res = 0;
    rep(i, n) res += a[2*i+1];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int n, m, a[101], r, sum;

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i <= n; i++)
    if (4 * m * a[i] >= sum)
      r++;
  if (r >= m)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s[26][26];
  int single[26];
  string si;
  for(int i = 0; i < n; i++){
    
    cin >> si;
    bool first = true;
    if(si.size() == 1){
      single[si[0]-'a'] = 1;
    }else{
      for(int j = 0; j < s[si[0]-'a'][si[1]-'a'].size(); j++){
        if(si == s[si[0]-'a'][si[1]-'a'][j]) first = false;
      }
    	if(first) s[si[0]-'a'][si[1]-'a'].push_back(si);
    }
  }
  int sum = 0;
  for(int j =0; j < 26; j++){
    for(int i =0; i < 26; i++){
      sum += s[j][i].size();
    }
    sum += single[j];
  }
  
  cout << sum << endl;
}
  

Measured memory_bytes: 14248
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


typedef vector<int> V;
typedef vector<V> MATRIX;

int W,H,D,SIZE;
int table[25][25];


bool gauss_jordan(MATRIX A){

	MATRIX C(SIZE,V(SIZE+1));

	for(int row = 0; row < SIZE; row++){
		for(int col = 0; col < SIZE+1; col++)C[row][col] = A[row][col];
	}

	int base_row;
	for(int i = 0; i < SIZE; i++){
		base_row = i;
		for(int row = i+1; row < SIZE; row++){
			if(abs(C[row][i]) > abs(C[base_row][i])){
				base_row = row;
			}
		}

		if(abs(C[base_row][i]) == 0)continue; //操作不要

		if(base_row != i)swap(C[base_row],C[i]);

		for(int row = 0; row < SIZE; row++){
			if(row == i || C[row][i] == 0)continue;

			for(int col = i; col < SIZE+1; col++){
				C[row][col] -= C[i][col];
				C[row][col] += 2;
				C[row][col] %= 2;
			}
		}
	}

	bool FLG;

	for(int row = 0; row < SIZE; row++){
		if(C[row][SIZE] != 0){
			FLG = false;
			for(int col = 0; col < SIZE; col++){
				if(C[row][col] != 0){
					FLG = true;
					break;
				}
			}
			if(!FLG)return false;
		}
	}
	return true;
}




void func(){

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&table[row][col]);
		}
	}

	SIZE = H*W;

	MATRIX A(SIZE,V(SIZE+1));

	int dist;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			for(int a = 0; a < H; a++){
				for(int b = 0; b < W; b++){
					dist = abs(row-a)+abs(col-b);
					if(dist == 0 || dist == D){
						A[row*W+col][a*W+b] = 1;
					}else{
						A[row*W+col][a*W+b] = 0;
					}
				}
			}
			A[row*W+col][SIZE] = table[row][col];
		}
	}

	if(gauss_jordan(A)){
		printf("1\n");
	}else{
		printf("0\n");
	}
}

int main(){

	while(true){
		scanf("%d %d %d",&W,&H,&D);
		if(W == 0 && H == 0 && D == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 7608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll a,b,c;
  cin>>a>>b>>c;

  if(c>=a&&c<=b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using ll = long long;

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

    int min = 1000;
    for (int i = 0; i < S.length() - 2; i++) {
        int num = (int)(S[i] - '0') * 100 + (int)(S[i + 1] - '0') * 10 + (int)(S[i + 2] - '0');
        min = std::min(min, std::abs(num - 753));
    }
    std::cout << min << std::endl;
}


Measured memory_bytes: 256
import Data.Array (listArray, (!))

main = do
    [month,day] <- (map read . words) `fmap` getLine
    if month == 0 || day == 0 then return () else do
        putStrLn (dayName month day)
        main

dayName month day = dayNames !! index
    where
    index = (offset + daysToMonth!month + day) `mod` 7

dayNames = ["Monday", "Tuesday", "Wednesday", "Thursday",
            "Friday", "Saturday", "Sunday"]
offset = 2

daysToMonth =
    listArray (1,12) (scanl (+) 0 [31,29,31,30,31,30,31,31,30,31,30,31])

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll n;cin>>n;
    ll a[100010],b[100010];
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    ll al[100010],ar[100010],bl[100010],br[100010];
    al[0]=a[0];
    ar[0]=a[0];
    bl[n-1]=b[n-1];
    br[n-1]=b[n-1];
    rep(i,1,n){
        if(a[i]>a[i-1]){
            al[i]=a[i];
            ar[i]=a[i];
        }
        else{
            al[i]=1;
            ar[i]=ar[i-1];
        }
    }
    for(int i=n-2;i>=0;i--){
        if(b[i]>b[i+1]){
            bl[i]=b[i];
            br[i]=b[i];
        }
        else{
            bl[i]=1;
            br[i]=br[i+1];
        }
    }
    ll an=1;
    rep(i,0,n){
        if(al[i]>br[i]||bl[i]>ar[i])an=0;
        else{
            ll tmp=min(ar[i],br[i])-max(al[i],bl[i])+1;
            an*=tmp;
            an%=1000000007;
        }
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
#include <tuple>
#include <map>
#include <stack>
#include <queue>
#include <ctype.h>
#include <iomanip>
#include <bitset>
#include <set>
#include <ios>
#include <cstdlib>
using namespace std;
using ll = long long;
int main() {
    int a,b; cin >> a >> b;
    if ((a+b)%2==0) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

using namespace std;

#define LL long long

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

    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) cin >> b[i];
    sort(b.begin(), b.end());
    for (int i = 0; i < n; ++i) cin >> c[i];
    sort(c.begin(), c.end());

    LL ans = 0;
    for (int i = 0; i < n; ++i) {
        LL t1 = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        LL t2 = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        ans += t1 * t2;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    /*変数定義，入力*/
    int N;
    cin >> N;
    vector<int> l(N);  rep(i, N) cin >> l[i];
    int count = 0;
    /*演算*/
    std::sort(l.begin(), l.end(), std::greater<int>() );

    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N - 1; j++){
            if(l.at(j) <= (float)l.at(i)/2.0) break;
            for(int k = j + 1; k < N; k++){
                if(l.at(k) <= l.at(i) - l.at(j)) break;
                count ++;
            }
        }
    }
    /*出力*/
    cout << count << endl;
    /*終了*/
    return 0;
}

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

using namespace std;

const int INF = 1001001001;

struct Edge {
	int to, cost;
	Edge(){}
	Edge(int to, int cost) : to(to), cost(cost){}
};

struct State {
	Edge e;
	int ltime;
	bool moved;
	State(Edge e, int ltime, bool moved) : e(e), ltime(ltime), moved(moved){}
	bool operator > (const State &rhs) const {
		return (e.cost > rhs.e.cost);
	}
};

int main()
{
	int N, M, L, K, A, H;

	while (scanf("%d %d %d %d %d %d", &N, &M, &L, &K, &A, &H) && N){
		vector<Edge> G[128];
		bool able[128] = {0};
		int dp[128][128];

		for (int i = 0; i < N; i++){
			fill(dp[i], dp[i] + 128, INF);
		}

		for (int i = 0; i < L; i++){
			int x;
			scanf("%d", &x);
			able[x] = true;
		}
		able[A] = able[H] = true;

		for (int i = 0; i < K; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			G[a].push_back(Edge(b, c));
			G[b].push_back(Edge(a, c));
		}

		priority_queue< State, vector<State>, greater<State> > pq;
		pq.push(State(Edge(A, 0), M, 0));

		while (!pq.empty()){
			State tmp = pq.top(); pq.pop();
			if (dp[tmp.e.to][tmp.ltime] <= tmp.e.cost) continue;
			dp[tmp.e.to][tmp.ltime] = tmp.e.cost;

			if (tmp.e.to == H) break;

			for (int i = 0; i < G[tmp.e.to].size(); i++){
				Edge nxt = G[tmp.e.to][i];
				if (nxt.cost > tmp.ltime) continue;
				if (dp[nxt.to][tmp.ltime - nxt.cost] > tmp.e.cost + nxt.cost){
					pq.push(State(Edge(nxt.to, tmp.e.cost + nxt.cost), tmp.ltime - nxt.cost, 1));
				}
			}

			if (!able[tmp.e.to] || !tmp.moved) continue;
			for (int i = 1; i + tmp.ltime <= M; i++){
				if (dp[tmp.e.to][tmp.ltime + i] > tmp.ltime + i){
					pq.push(State(Edge(tmp.e.to, tmp.e.cost + i), tmp.ltime + i, 0));
				}
			}
		}

		int ans = *min_element(dp[H], dp[H] + M + 1);
		if (ans != INF) printf("%d\n", ans);
		else printf("Help!\n");
	}

	return (0);
}

Measured memory_bytes: 2784
<?php
$num = trim(fgets(STDIN));
$str_num = str_split(trim(fgets(STDIN)));
$ans = 0;
for($i=0; $i-1<$num; $i++){
	if($str_num[$i]!=$str_num[$i+1]){
		$ans+=1;
	}
}
echo $ans . "\n";

Measured memory_bytes: 10872
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void input(int& rnLimit, vector<llong>& rvnCostA, vector<llong>& rvnCostB)
{
  int nCostASiz, nCostBSiz;
  cin >> nCostASiz >> nCostBSiz >> rnLimit;
  rvnCostA.resize(nCostASiz + 1);
  rvnCostB.resize(nCostBSiz + 1);

  for (int i = 1; i < rvnCostA.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostA[i] = rvnCostA[i - 1] + nOneCost;
  }

  for (int i = 1; i < rvnCostB.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostB[i] = rvnCostB[i - 1] + nOneCost;
  }
}

int calcMaxSelect(int nLimit, const vector<llong>& cnrvnCostA, 
                            const vector<llong>& cnrvnCostB)
{
  int nMaxSelCnt = 0;
  int nBgnB = cnrvnCostB.size() - 1;
  int nxA = 0;

  while (nxA < cnrvnCostA.size()  &&
         cnrvnCostA[nxA] <= nLimit   )
  {
    int nxB = nBgnB;

    while (cnrvnCostB[nxB] > nLimit - cnrvnCostA[nxA])
      nxB--;

    nMaxSelCnt = max(nMaxSelCnt, nxA + nxB);
    nBgnB = nxB;

    nxA++;
  }
  return nMaxSelCnt;
}
 
int main()
{
  int nLimit;
  vector<llong> vnCostA, vnCostB;

  input(nLimit, vnCostA, vnCostB);
  cout << calcMaxSelect(nLimit, vnCostA, vnCostB) << endl;

  return 0;
}

Measured memory_bytes: 6372
sx, sy, tx, ty = map(int, input().split())
path = ''
for _ in range(tx - sx):
  path += 'R'
for _ in range(ty - sy):
  path += 'U'
for _ in range(tx - sx):
  path += 'L'
for _ in range(ty - sy):
  path += 'D'

  
path += 'D'
for _ in range(tx - sx + 1):
  path += 'R'
for _ in range(ty - sy + 1):
  path += 'U'
path += 'L'
path += 'U'
for _ in range(tx - sx + 1):
  path += 'L'
for _ in range(ty - sy + 1):
  path += 'D'
path += 'R'

print(path)

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n, m;
    cin >> n >> m;
    auto comp = [](const P &p1, const P &p2) {
        return p1.first > p2.first;
    };
    auto comPair = [](const P &firstElof, const P &secondElof) {
        return firstElof.second < secondElof.second;
    };
    priority_queue<P, vector<P>, decltype(comp)> escape(comp);
    priority_queue<P, vector<P>, decltype(comPair)> que(comPair);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        escape.push(P(a, b));
    }
    ll ans = 0;
    auto p1 = escape.top().first;
    repeat(i, 1, m + 1) {
        while (!escape.empty() && p1 <= i) {
            que.push(escape.top());
            escape.pop();
            p1 = escape.top().first;
        }
        if (!que.empty()) {
            ans += que.top().second;
            que.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin>>n;
	int a[n];
	forr(i,n) cin>>a[i];
	int ans = INF;
	for(int i=0;i<=100;i++){
		int curr = 0;
		for(int j=0;j<n;j++){
			curr+=(i-a[j])*(i-a[j]);
		}
		ans = min(ans,curr);
	}
	cout<<ans;
}

Measured memory_bytes: 3648
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月21日 星期日 21时14分45秒
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)
 
const int N=2005;
 
int B[N][N],W[N][N];
 
void add(int bit[N][N],int x,int y){
	bit[x][y]++;
}
 
int sum(int bit[N][N],int x,int y){
	return bit[x][y];
}
 
int get(int bit[N][N],int x1,int y1,int x2,int y2){
	if(!(x1<=x2 && y1<=y2)) return 0;
	return sum(bit,x2,y2)-sum(bit,x2,y1-1)-sum(bit,x1-1,y2)+sum(bit,x1-1,y1-1);
}
 
void solve(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x,y;
		char ch;
		scanf("%d %d %c",&x,&y,&ch);
		x%=2*k,y%=2*k;
		x++,y++;
		if(ch=='W') add(W,x,y);
		else add(B,x,y);
	}
 
	for(int i=1;i<=2*k;i++){
		for(int j=1;j<=2*k;j++){
			W[i][j]+=W[i][j-1];
			B[i][j]+=B[i][j-1];
		}
	}
	for(int j=1;j<=2*k;j++){
		for(int i=1;i<=2*k;i++){
			W[i][j]+=W[i-1][j];
			B[i][j]+=B[i-1][j];
		}
	}
 
 
	int ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			int tmp=0;
			tmp+=get(W,1,1,i,j)+get(W,i+1,j+1,i+k,j+k);
			tmp+=get(W,i+k+1,j+k+1,2*k,2*k)+get(W,1,j+k+1,i,2*k)+get(W,i+k+1,1,2*k,j);
			tmp+=get(B,1,j+1,i,j+k)+get(B,i+k+1,j+1,2*k,j+k);
			tmp+=get(B,i+1,1,i+k,j)+get(B,i+1,j+k+1,i+k,2*k);
			ans=max(ans,tmp);
 
			tmp=0;
			tmp+=get(B,1,1,i,j)+get(B,i+1,j+1,i+k,j+k);
			tmp+=get(B,i+k+1,j+k+1,2*k,2*k)+get(B,1,j+k+1,i,2*k)+get(B,i+k+1,1,2*k,j);
			tmp+=get(W,1,j+1,i,j+k)+get(W,i+k+1,j+1,2*k,j+k);
			tmp+=get(W,i+1,1,i+k,j)+get(W,i+1,j+k+1,i+k,2*k);
			ans=max(ans,tmp);
		}
	}
 
	printf("%d\n",ans);
}
 
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a = a+b;
  c = c+d;
  if(a==c){
    cout << "Balanced" << endl;
  }else if(a > c){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

int main()
{
    string t, h;
    int n, tPoint = 0, hPoint = 0, curRes;
    cin >> n;
    while(n--) {
        cin >> t >> h;
        curRes = t.compare(h);
        if (curRes > 0)
            tPoint +=3;
        else if(curRes < 0)
            hPoint += 3;
        else {
            tPoint++;
            hPoint++;

        }
    }
    cout << tPoint << " " << hPoint << endl;
    return 0;
}


Measured memory_bytes: 3224
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

typedef long long LL;

#ifdef __GNUC__
#define popcount __builtin_popcount
#elif _MSC_VER >= 1400
#include <intrin.h>
#define popcount __popcnt
#else
static inline int popcount(unsigned int b) {
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
}
#endif

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		string x;
		cin >> x;
		int cnt = count(x.begin(), x.end(), '1');
		vector<vector<int>> m(2, vector<int>(n, 1));
		int d[2] = { max(cnt - 1, 1), cnt + 1 };
		int r[2] = {};
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 2; ++j) {
				if (i) {
					m[j][n - 1 - i] = (m[j][n - i] * 2) % d[j];
				}
				if (x[n - 1 - i] != '0') {
					r[j] = (r[j] + m[j][n - 1 - i]) % d[j];
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			if (cnt == 0) {
				cout << 1 << endl;
			} else if (cnt == 1 && x[i] != '0') {
				cout << 0 << endl;
			} else {
				int ans = 1;
				int inc = x[i] == '0';
				int a = (r[inc] + (inc ? 1 : -1) * m[inc][i] + d[inc]) % d[inc];
				while (a) {
					++ans;
					a = a % popcount(a);
				}
				cout << ans << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6048
module Queue' = struct
  type 'a t = {
    mutable front : int;
    mutable mask  : int;
    mutable index : int;
    mutable length : int;
    mutable elems : (string * int) array
  }

  let capacity (t: (string * int) t) = t.mask + 1

  let is_empty (t: (string * int) t) = t.length = 0

  let create ?(capacity=1) () =
    { front = 0;
      mask  = capacity - 1;
      index = 0;
      length = 0;
      elems = Array.make capacity ("",0)}

  let enq (t: (string * int) t) (a: string * int) =
    let (elems: (string * int) array) = t.elems in
    elems.(t.index) <- a;
    t.length <- t.length + 1;
    t.index <- (t.index + 1) mod (capacity t)

  let deq (t: (string * int) t) =
    let (elems: (string * int) array) = t.elems in
    let (front: int) = t.front in
    let (res: string * int) = elems.(front) in
    t.front <- (t.front + 1) mod (capacity t);
    t.length <- t.length - 1;
    res
end

let () =
  let open Queue' in
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q:(string * int) t) = create ~capacity:n () in
  for i=1 to n do
    enq q (Scanf.scanf "%s %d\n" (fun a b -> a,b));
  done;
  let (sum:int ref) = ref 0 in
  while not (is_empty q) do
    let (p:string),(t:int) = deq q in
    if t <= quantum then (sum := !sum+t; Printf.printf "%s %d\n" p !sum)
    else (enq q (p,t-quantum); sum := !sum+quantum)
  done

Measured memory_bytes: 10616
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy
#import numpy as np

s=input().strip("\n")
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;

#define all(i) (i).begin(), (i).end()
#define rall(i) (i).rbegin(), (i).rend()

int main() {
	int k;
	cin >> k;
	vector<i64> a(k);
	for (int i = 0; i < k; ++i) cin >> a[i];

	reverse(all(a));
	i64 Max = 2, Min = 2;

	for (int i = 0; i < k; ++i) {
		if (Min <= a[i]) Min = a[i];
		Min = ((Min - 1) / a[i] + 1) * a[i];

		if (Max < a[i]) return cout << -1 << endl, 0;
		Max = (Max / a[i] + 1) * a[i] - 1;

		if (Min > Max) return cout << -1 << endl, 0;
	}

	cout << Min << " " << Max << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007
#define int ll


// int main(){
// ios::sync_with_stdio(0);
// cin.tie(0);
//     ll n;cin>>n;
//     map<ll,ll>mp[n+1];
//     mp[1][]
//     ll sum=1;
//     rep(i,2,n+1){
//         ll tmp=i;ll cnt=0,tm=1;
//             for(ll j=2;j*j<=i;j++){
//                 cnt=0;
//                 while(tmp%j==0){
//                     tmp/=j;
//                     cnt++;
//                 }
//                 tm*=(cnt+1);
//                 if(tmp==1)break;
//             }
//             if(tmp!=1)tm*=2;
//             //cout<<i<<" :"<<tm<<"\n";
//             sum+=tm*i;
//     }
//     cout<<sum;

 
// return 0;
// }




// C++ program to count number of factors 
// of an array of integers 


const int MAX = 10000001; 

// array to store prime factors 
int factor[MAX] = { 0 }; 

// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
	factor[1] = 1; 

	// Initializes all the positions with their value. 
	for (int i = 2; i < MAX; i++) 
		factor[i] = i; 

	// Initializes all multiples of 2 with 2 
	for (int i = 4; i < MAX; i += 2) 
		factor[i] = 2; 

	// A modified version of Sieve of Eratosthenes to 
	// store the smallest prime factor that divides 
	// every number. 
	for (int i = 3; i * i < MAX; i++) { 
		// check if it has no prime factor. 
		if (factor[i] == i) { 
			// Initializes of j starting from i*i 
			for (int j = i * i; j < MAX; j += i) { 
				// if it has no prime factor before, then 
				// stores the smallest prime divisor 
				if (factor[j] == j) 
					factor[j] = i; 
			} 
		} 
	} 
} 

// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
	if (n == 1) 
		return 1; 

	int ans = 1; 

	// stores the smallest prime number 
	// that divides n 
	int dup = factor[n]; 

	// stores the count of number of times 
	// a prime number divides n. 
	int c = 1; 

	// reduces to the next number after prime 
	// factorization of n 
	int j = n / factor[n]; 

	// false when prime factorization is done 
	while (j != 1) { 
		// if the same prime number is dividing n, 
		// then we increase the count 
		if (factor[j] == dup) 
			c += 1; 

		/* if its a new prime factor that is factorizing n, 
		then we again set c=1 and change dup to the new 
		prime factor, and apply the formula explained 
		above. */
		else { 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		} 

		// prime factorizes a number 
		j = j / factor[j]; 
	} 

	// for the last prime factor 
	ans = ans * (c + 1); 

	return ans; 
} 

// Driver program to test above function 
signed main() 
{ 
	// generate prime factors of number 
	// upto 10^6 
	generatePrimeFactors(); 
    ll n;cin>>n;
    ll sum=0;
	for (int i = 1; i < n+1; i++) 
		sum+= i*calculateNoOFactors(i);
        cout<<sum; 

	return 0; 
} 


Measured memory_bytes: 81756
#include<iostream>
#include<cstdio>
#include<cstring>
#define ls (rt<<1)
#define rs ((rt<<1)+1)
#include<queue>
#define INF (21001010)
using namespace std;
int Pos[505005],n,K,val[4001010],P[4001010],V[4001010];
int h[4001010],m1,De[4001010],Clock,A[4001010];
priority_queue <int,vector<int>,greater<int> > Q;
struct edge{
	int nxt,To;
	edge(int nxt=0,int To=0):
	nxt(nxt),To(To){}
}q[8001010];
struct Node{
	int val,pos;
	Node(int val=0,int pos=0):
	val(val),pos(pos){}
};
void Pushup(int rt){
	val[rt]=val[ls]+val[rs];
	if (V[ls]<V[rs]){
		V[rt]=V[ls]; P[rt]=P[ls];
	}
	else{
		V[rt]=V[rs]; P[rt]=P[rs];
	}
}
void Update(int rt,int l,int r,int pos,int num){
	if (l==r){
		val[rt]=1; P[rt]=l; V[rt]=num; return;
	}
	int mid=(l+r)>>1;
	if (pos<=mid) Update(ls,l,mid,pos,num);
	else Update(rs,mid+1,r,pos,num);
	Pushup(rt);
}
int Query(int rt,int l,int r,int L,int R){
	if (l>=L&&r<=R) return val[rt];
	int mid=(l+r)>>1;
	int res=0;
	if (L<=mid) res+=Query(ls,l,mid,L,R);
	if (R>mid) res+=Query(rs,mid+1,r,L,R);
	return res;
}
Node QueryP(int rt,int l,int r,int L,int R){
	if (l>=L&&r<=R) return Node(V[rt],P[rt]);
	int mid=(l+r)>>1;
	Node res; res.val=0;
	if (L<=mid)
		res=QueryP(ls,l,mid,L,R);
	if (R>mid){
		Node x=QueryP(rs,mid+1,r,L,R);
		if (!res.val||res.val>x.val) res=x;
	}
	return res;
}
void Addedge(int x,int y){
	q[++m1]=edge(h[x],y); h[x]=m1; De[y]++;
}
void Topo(){
	for (int i=1;i<=n;i++) if (!De[i]) Q.push(i);
	while (!Q.empty()){
		int x=Q.top(); Q.pop();
		A[x]=++Clock;
		for (int i=h[x];i;i=q[i].nxt){
			int y=q[i].To;
			De[y]--;
			if (!De[y]) Q.push(y);
		}
	}
}
void Build(int rt,int l,int r){
	if (l==r){
		V[rt]=INF;return;
	}
	int mid=(l+r)>>1;
	Build(ls,l,mid); Build(rs,mid+1,r);
	Pushup(rt);
}
int main(){
	scanf("%d %d",&n,&K);
	for (int i=1;i<=n;i++){
		int x; scanf("%d",&x);
		Pos[x]=i; 
	}
	Build(1,1,n);
	for (int i=n;i>=1;i--){
		if (Pos[i]<n&&K>1)
			if (Query(1,1,n,Pos[i]+1,min(n,Pos[i]+K-1))>0)
				Addedge(Pos[i],QueryP(1,1,n,Pos[i]+1,min(n,Pos[i]+K-1)).pos);
		if (Pos[i]-K+1<=Pos[i]-1&&Pos[i]-1>=1)
			if (Query(1,1,n,max(Pos[i]-K+1,1),Pos[i]-1)>0)
				Addedge(Pos[i],QueryP(1,1,n,max(Pos[i]-K+1,1),Pos[i]-1).pos);
		Update(1,1,n,Pos[i],i);
	}
	Topo();
	for (int i=1;i<=n;i++) printf("%d\n",A[i]);
}

Measured memory_bytes: 99060