akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    map<ll, ll>mp;
    ll now = 0;
    mp[0]++;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        now += a;
        mp[now]++;
    }
    ll ans = 0;
    for (auto i : mp) {
        ans += i.second * (i.second - 1)/2;
    }
    cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
char a[1005][1005];
ll dp[1005][1005];

int main()
{
    FAST_IO;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==1 && j==1){
                dp[i][j]=1;
                continue;
            }
            if(a[i][j]!='#'){

                if(i-1>=1 && a[i-1][j]!='#'){
                    dp[i][j]+=dp[i-1][j]; dp[i][j]%=mod;
                }


                if(j-1>=1 && a[i][j-1]!='#'){
                    dp[i][j]+=dp[i][j-1]; dp[i][j]%=mod;
                }
            }

        }
    }
    cout<<dp[n][m];
    return 0;

}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int c[501],s[501],f[501],t[500];
int main()
{
	int n,i,j,tmp;
	scanf("%d",&n);
	for(i=1;i<n;i++)
		scanf("%d %d %d",&c[i],&s[i],&f[i]);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	for(i=1;i<=n-1;i++)
	{
		tmp=s[i]+c[i];
		for(j=i+1;j<=n-1;j++)
		{
			if(tmp<=s[j])
				tmp=s[j]+c[j];
			else if((tmp-s[j])%f[j]==0)
				tmp+=c[j];
			else
				tmp+=f[j]-(tmp-s[j])%f[j]+c[j];
		}
		t[i]=tmp;
	}
	for(i=1;i<=n;i++)
		printf("%d\n",t[i]);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
#define qwq 6005
int n,k;
int c[qwq],p[qwq];
ll ans=-1e15-7;
ll maxn[qwq];
void dfs(int u){
	memset(maxn,-0x3f,sizeof(maxn));maxn[0]=0;
	int v=p[u];
	ll sum=0;
	int cnt=1;
	while(true){
		sum+=c[v];
		ans=std::max(ans,sum);
		maxn[cnt]=std::max(maxn[cnt-1],sum);
		if(v==u)break;
		v=p[v];
		++cnt;
		if(cnt>k)return ;
	}
	if(cnt<k&&sum>0){
		ans=std::max(ans,sum*(k/cnt)+maxn[k%cnt]);
		if(k/cnt-1>0)ans=std::max(ans,sum*(k/cnt-1)+maxn[cnt]);
	}
//	printf("%d %d\n",u,cnt);
	return ;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]);
	for(int i=1;i<=n;++i)scanf("%d",&c[i]);
	for(int i=1;i<=n;++i){
		dfs(i);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    string s;
    int q;
    cin>>s>>q;
    string t;
    rep(qi,q){
        int ty;
        cin>>ty;
        if(ty==1){
            swap(s,t);
        }
        else{
            int f; char c;
            cin>>f>>c;
            if(f==1){
                t+=c;
            }else{
                s+=c;
            }
            
        }
    }
    reverse(t.begin(),t.end());
    t+=s;
    cout<<t<<endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin >> s;
  ll X,Y;
  cin >> X >> Y;

  ll n = s.size();
  vll x, y;
  ll now = 0;
  ll cur = 0;
  REP(i, n){
    if(s[i] == 'T'){
      if(cur%2==0)
        x.push_back(now);
      else
        y.push_back(now);
      cur++;
      now = 0;
    }
    else
      now++;
  }
  if(cur%2==0)
    x.push_back(now);
  else
    y.push_back(now);

  if(y.size() == 0)
    y.push_back(0);

  //0 to n:-n to 0, n to 2n: 0 to n
  vector<vector<bool>> dpx(n, vector<bool>(2*n+1, false));
  vector<vector<bool>> dpy(n, vector<bool>(2*n+1, false));
  dpx[0][x[0]+n] = true;
  dpy[0][y[0]+n] = dpy[0][-y[0]+n] = true;
  REP1(i, x.size()){
    REP(j, 2*n+1){
      if(0 <= j-x[i])
        dpx[i][j] = dpx[i-1][j-x[i]] || dpx[i][j];

      if(j+x[i] < 2*n)
        dpx[i][j] = dpx[i-1][j+x[i]] || dpx[i][j];
    }
  }

  REP1(i, y.size()){
    REP(j, 2*n+1){
      if(0 <= j-y[i])
        dpy[i][j] = dpy[i-1][j-y[i]] || dpy[i][j];
      if(j+y[i] < 2*n)
        dpy[i][j] = dpy[i-1][j+y[i]] || dpy[i][j];
    }
  }


  if(dpx[x.size()-1][X+n] && dpy[y.size()-1][Y+n])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;


}


Measured memory_bytes: 34432
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n,h,w;
  cin >> n >> h >> w;

  int ans = 0;
  REP(i,n){
    int a,b;
    cin >> a >> b;
    if(a >= h && b >= w) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC082C_GoodSequence();

#if 1
int main()
{
	ABC082C_GoodSequence();
	fflush(stdout);
	return 0;
}
#endif

static void ABC082C_GoodSequence()
{
	int N;
	get1int(N);

	std::map<int, int> numCount;
	for (int i = 0; i < N; i++) {
		int t;
		get1int(t);
		numCount[t]++;
	}

	int rmv = 0;
	for (auto it = numCount.begin(); it != numCount.end(); it++) {
		int tmp = it->second - it->first;
		if (tmp >= 0) {
			rmv += tmp;
		}
		else {
			rmv += it->second;
		}
	}
	printf("%d\n", rmv);
}


Measured memory_bytes: 4736
#include<stdio.h>
void swap(int *x,int *y){
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
}
    int partition(int array[],int left,int right){
        int i,j,pivot;
        i=left;
        j=right +1;
        pivot=left;
        do{
            do{i++;}while(array[i]<array[pivot]);
            do{j--;}while(array[pivot]<array[j]);
            if(i<j){
                swap(&array[i],&array[j]);
            }
        }while(i<j);
        swap(&array[pivot],&array[j]);
        return j;
    }
void sort(int array[],int left,int right){
    int pivot;
    if(left<right){
        pivot=partition(array,left,right);
        sort(array,left,pivot-1);
        sort(array,pivot+1,right);
    }
}


int main()
{
    int n,a;
    scanf("%d",&n);
    int array[100000]={0};
    for(int i=1;i<=n;i++){
        scanf("%d",&array[i]);
    }
    sort(array,1,n);
    a=array[n/2+1]-array[n/2];
    printf("%d",a);


    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1ll))/2ll+(m*(m-1ll))/2ll;
}

Measured memory_bytes: 256
(defn AcCepted [S]
  (let [tmp (remove #(Character/isLowerCase %) (drop-last (drop 2 S)))]
    (if (and
          (= \A (first S))
          (Character/isLowerCase (second S))
          (Character/isLowerCase (last S))
          (= 1 (count tmp))
          (= \C (first tmp)))
      "AC"
      "WA")))

(-> (read-line) AcCepted println)

Measured memory_bytes: 64728
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
long long dp[101000] = {0};
  
int main()
{
  int X;
  cin >> X;
  dp[0] = 1;
  int a = 100;
  REP(i,X+1){
    REP(j,6){
      if(dp[i] != 0){
        dp[i+j+a] = dp[i] + 1;
      }
    }
  }

  if(dp[X]>0){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  if (s == "RSR") {
    cout << 1 << endl;
    return 0;
  };
  int ans = 0;
  for (char c : s) {
    if (c == 'R') ans++;
  };
  cout << ans << endl;
  return 0;
}

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

ll l, r;

int main(){
  cin >> l >> r;
  ll res = 1e9;
  const ll ub = (long)min(l + 2019LL, r);
  for(ll i = l; i <= ub - 1; i++){
    for(int j = l + 1; j <= ub; j++){
      res = min(res, ((i * j) % 2019LL));
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    ll ans=LINF;
    for(int j=0;j<=100;j++){
        ll sum=0;
        for(int i=0;i<n;i++){
            sum+=(j-a[i])*(j-a[i]);
        }
        chmin(ans,sum);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n,m;
int main(){FAST;
cin>>n>>m;
ll l,r;
cin>>l>>r;
for(ll i=1;i<m;i++){
	ll x,y;cin>>x>>y;
	r=min(y,r);
	l=max(x,l);
}
if(l<=r){
	cout<<r-l+1;
}
else cout<<0;
return 0;
}




Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int n,i;cin>>n;
	if(n==0){return false;}
	map<pair<int,int>,int>futon;
	//02
	//1
	//3
	map<pair<int,int>,int>head;//1が頭 -1が足
	vector<pair<int,int>>miru(n);
	for(i=0;i<n;i++){
		int x,y;char d;
		cin>>x>>y>>d;
		
		miru[i]=mp(x,y);
		if(d=='x'){futon[mp(x,y)]=0;futon[mp(x+1,y)]=2;}
		else{futon[mp(x,y)]=1;futon[mp(x,y+1)]=3;}
	}
	queue<pair<int,int>>que;
	int dx[8]={1,0,-1,0,1,0,-1,0};
	int dy[8]={0,1,0,-1,0,1,0,-1};
	for(i=0;i<n;i++){
		if(head[miru[i]]==0){
			que.push(miru[i]);
			head[miru[i]]=1;
		}
		while(que.size()){
			int x=que.front().fir;
			int y=que.front().sec;
			int h=head[mp(x,y)];
			int d=futon[mp(x,y)];
			que.pop();
			pair<int,int> ter;
			int sor;
			
			ter=mp(x+dx[d],y+dy[d]);
			sor=head[ter];
			if(sor==h){cout<<"No"<<endl;return true;}
			if(sor==0){head[ter]=-h;que.push(ter);}
		
			ter=mp(x+dx[d+1],y+dy[d+1]);
			if(futon.count(ter)>0){
				sor=head[ter];
				if(sor==-h){cout<<"No"<<endl;return true;}
				if(sor==0){head[ter]=h;que.push(ter);}
			}
		
			ter=mp(x+dx[d+2],y+dy[d+2]);
			if(futon.count(ter)>0){
				sor=head[ter];
				if(sor==-h){cout<<"No"<<endl;return true;}
				if(sor==0){head[ter]=h;que.push(ter);}
			}
			
			ter=mp(x+dx[d+3],y+dy[d+3]);
			if(futon.count(ter)>0){
				sor=head[ter];
				if(sor==-h){cout<<"No"<<endl;return true;}
				if(sor==0){head[ter]=h;que.push(ter);}
			}
		}
	}
	cout<<"Yes"<<endl;return true;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 8084
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int dfs(int s, int g) {
	if (s == g)return 0;
	int n = 1;
	while (1) {
		int a = g / n, b = s / n;
		if (g < 0 && g%n)a--;
		if (s > 0 && s%n)b++;
		if (a - b > 0)n <<= 1;
		else {
			n >>= 1;
			int x = s / n, y = g / n;
			if (s > 0 && s%n)x++;
			if (g < 0 && g%n)y--;
			return y - x + dfs(s, x*n) + dfs(y*n, g);
		}
	}
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int s, d; scanf("%d%d", &s, &d);
		printf("%d\n", dfs(s, d));
	}
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string sh; cin >> sh;
	for (int i = 0; i < 3; ++i)
	{
		if (sh[i] == '7')
		{
			cout << "Yes" << endl;
			return 0;
		}

	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main
{

    public void run( )
    {
        Scanner sc = new Scanner( System.in );

        int n = sc.nextInt( );
        int[] ar = new int[ n ];
        int[] arSort = new int[ n ];
        for ( int i = 0; i < n; i++ )
        {
            ar[ i ] = sc.nextInt( );
            arSort[ i ] = ar[ i ];
        }

        Arrays.sort( arSort );

        int a = arSort[ n / 2 - 1 ];
        int b = arSort[ n / 2 ];

        for ( int i = 0; i < n; i++ )
        {
            if ( ar[ i ] <= a )
            {
                System.out.println( b );
            } else
            {
                System.out.println( a );
            }
        }

    }

    public static void main( String[] args )
    {
        new Main( ).run( );
    }
}

Measured memory_bytes: 100576
def rr(): return input().rstrip()
def rri(): return int(rr())
def rrl(): return list(map(int, rr().split()))
def rrt(): return tuple(map(int, rr().split()))
from collections import defaultdict
def mus(d=lambda: 0): return defaultdict(lambda: defaultdict(d))
def dd0(d=lambda: 0): return defaultdict(d)
def ms(x, y, d=0): return [[0]*y for i in range(x)]
def ar(x, d=0): return [d]*x
def ppm(m, n=0, x=0, y=0): print("\n".join(("\t".join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))
def ppa(a, n): print("\t".join(map(str, a[0:n])))
def ppl(a=0, x=[1]): x[0]=a or (x[0]+1); print("-"+"- -"*14+"-# "+str(x[0]-2)+" #-"+"- -"*14+"-")
def fltn(a): (i for sub in a for i in sub)
def yn(x): return "YES" if x else "NO"
from itertools import accumulate
from itertools import groupby
def grp(x): return ((i, sum(1 for _ in g)) for i, g in groupby(x))
import math
#def rnar(): return (*rrl(), rrl())
#def rn(): return (*rrl(),)
def dpp(a, b=""): print(")#| {} |#(o) ? {} ? (".format(a, b))

def read():
    #return rnar()
    return (rr(), rr())

def solve(s, t):
    dp = ms(len(s)+1, len(t)+1)
    for i in range(1, len(s)+1):
        for j in range(1, len(t)+1):
            if s[i-1] == t[j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i][j-1], dp[i-1][j])
    tl = dp[len(s)][len(t)]
    #ppm(dp, len(s)+1, len(t)+1)

    if tl == 0: return ''
    
    i = len(s); j = len(t)
    ts = []
    while (i > 0) and (j > 0):
        if s[i-1] == t[j-1]:
            ts.append(s[i-1])
            i -= 1; j -= 1;
        else:
            if dp[i-1][j] == dp[i][j]:
                i -= 1
            else:
                j -= 1

    ts = "".join(reversed(ts))

    return ts

if __name__ == "__main__":
    #test_count = rri()
    test_count = 1
    for _ in range(test_count):
        input_data = read()
        result = solve(*input_data)
        print(result)


Measured memory_bytes: 111708
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] squares = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                squares[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(squares));

        sc.close();
    }

    static int solve(char[][] squares) {
        int H = squares.length;
        int W = squares[0].length;

        int[][] leftCounts = new int[H][W];
        for (int r = 0; r < H; ++r) {
            int leftCount = 0;
            for (int c = 0; c < W; ++c) {
                leftCounts[r][c] = leftCount;

                if (squares[r][c] == '.') {
                    ++leftCount;
                } else {
                    leftCount = 0;
                }
            }
        }

        int[][] rightCounts = new int[H][W];
        for (int r = 0; r < H; ++r) {
            int rightCount = 0;
            for (int c = W - 1; c >= 0; --c) {
                rightCounts[r][c] = rightCount;

                if (squares[r][c] == '.') {
                    ++rightCount;
                } else {
                    rightCount = 0;
                }
            }
        }

        int[][] upCounts = new int[H][W];
        for (int c = 0; c < W; ++c) {
            int upCount = 0;
            for (int r = 0; r < H; ++r) {
                upCounts[r][c] = upCount;

                if (squares[r][c] == '.') {
                    ++upCount;
                } else {
                    upCount = 0;
                }
            }
        }

        int[][] downCounts = new int[H][W];
        for (int c = 0; c < W; ++c) {
            int downCount = 0;
            for (int r = H - 1; r >= 0; --r) {
                downCounts[r][c] = downCount;

                if (squares[r][c] == '.') {
                    ++downCount;
                } else {
                    downCount = 0;
                }
            }
        }

        int result = 0;
        for (int r = 0; r < H; ++r) {
            for (int c = 0; c < W; ++c) {
                if (squares[r][c] == '.') {
                    result = Math.max(result,
                            1 + leftCounts[r][c] + rightCounts[r][c] + upCounts[r][c] + downCounts[r][c]);
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 110136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

string S[105];
int N;
int P[105];

int num[105];
int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i] >> P[i];
	}

	vector<pair<string, int> > V;

	for (int i = 1; i <= N; i++) {
		V.push_back(make_pair(S[i], -P[i]));
		num[P[i]] = i;
	}

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

	for (int i = 0; i < N; i++) {
		int val = -V[i].second;

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


	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;

  return 0;
}


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

int dp[500][500];

int main() {
    int n, i, j, k;
    while(cin >> n, n) {
        vector<int> w(n);
        for(i = 0; i < n; i++)
            cin >> w[i];
        for(i = 0; i < 500; i++) {
            for(j = 0; j < 500; j++) {
                dp[i][j] = 0;
            }
        }
        for(i = 2; i <= n; i++) {
            for(j = 0; j < n - i + 1; j++) {
                if(abs(w[j] - w[j + i - 1]) <= 1 && (i == 2 || dp[j + 1][j + i - 2] > 0)) {
                    dp[j][j + i - 1] = i;
                }
                for(k = j + 1; k < j + i - 1; k++) {
                    if(dp[j][k] > 0 && dp[k + 1][j + i - 1] > 0) dp[j][j + i - 1] = i;
                }
            }
        }
        for(i = 2; i <= n; i++) {
            for(j = 0; j < n - i + 1; j++) {
                for(int m = j; m <= j + i - 1; m++) {
                    dp[j][j + i - 1] = max(dp[j][j + i - 1], dp[j][m] + dp[m + 1][j + i - 1]);
                }
            }
        }
        cout << dp[0][n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 4076
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


int MAX_INDEX = 40;


int main(){
    long long N;
    cin >> N;

    if(N % 2 == 0){
        long long half = N / 2;
        long long M = N * half - N;

        cout << M << endl;

        for(int i = 1; i <= half; ++i){
            for(int j = i + 1; j <= N - i; ++j){
                cout << i << " " << j << endl;
                cout << N - i + 1 << " " << j << endl;
            }
        }
    }
    else{
        long long _N = N - 1;
        long long half = _N / 2;
        long long M = _N * half - _N + N - 1;

        cout << M << endl;

        for(int i = 1; i <= half; ++i){
            for(int j = i + 1; j <= _N - i; ++j){
                cout << i << " " << j << endl;
                cout << _N - i + 1 << " " << j << endl;
            }
        }

        for(int i = 1; i <= _N; ++i){
            cout << i << " " << N << endl;
        }
    }
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce


k = int(input())


def f_gcd(*numbers):
    return reduce(gcd, numbers)

def gcd_list(numbers):
    return reduce(gcd, numbers)


sum = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
             sum += f_gcd(i,j,l)

print(sum)

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

int main() {
    int t = 1;
    while(t--) {
        string s;
        cin>>s;
        int ans = 0;
        if(s[0] == 'R'){
            ans++;
            if(s[1] == 'R') {
                ans++;
                if(s[2] == 'R')
                    ans++;
            }
        } else if(s[1] == 'R') {
            ans++;
            if(s[2] == 'R')
                ans++;
        }
        else {
            if(s[2] == 'R')
                ans++;
        }

        cout<<ans;     
    }
    return 0;
}

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

int main(){
	
	int a, b, c, n;
	cin >> n;
	a = n / 100;  b = n % 100 / 10;
	c = n % 100 % 10;
	if ( a == c ){
		cout << " Yes " << endl;
	} else {
		cout << " No " << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}
 
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d) {
    cout << "Left";
  } else if (a+b<c+d) {
    cout << "Right";
  } else {
    cout << "Balanced";
  }
  return 0;
}

Measured memory_bytes: 256
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 25 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

int n;
int t_max;
vector<double> prr;
double dp[3000][3000];
// bool vis[3000][3000];

double fun(int ind, int curr_tails){

	if(dp[ind][curr_tails]!=-1){
		return dp[ind][curr_tails];
	}
	// vis[ind][curr_tails] = 1;

	double pos1 = 0,pos2 = 0;

	if(curr_tails<t_max){
		pos1 = (1-prr[ind]);
		if(ind-1>=0){
			if(dp[ind-1][curr_tails+1] == -1){
				dp[ind-1][curr_tails+1] = fun(ind-1, curr_tails+1);
			}
			pos1 *= dp[ind-1][curr_tails+1];
		}
	}

	pos2 = prr[ind];
	if(ind-1>=0){
		if(dp[ind-1][curr_tails] == -1){
			dp[ind-1][curr_tails] = fun(ind-1, curr_tails);
		}
		pos2 *= dp[ind-1][curr_tails];
	}
	
	return dp[ind][curr_tails] = pos1 + pos2;
}


signed main(){

    fastio;

    cin>>n;
    for(int i=0;i<3000;i++)
    	for(int j=0;j<3000;j++)
    		dp[i][j] = -1;

    if(n&1) t_max = n/2;
    else t_max = n/2 - 1;
    
    prr = vector<double>(n);

    for(int i=0;i<n;i++) cin>>setprecision(10)>>prr[i];

    cout<<setprecision(10)<<fun(n-1, 0);


    return 0;
}

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

int main(){
	string s;cin>>s;
	int Max=0;
	rep(i,s.size()){
		for(int j=i;j<s.size();j++){
			if(s[j]!='A'&&s[j]!='G'&&s[j]!='T'&&s[j]!='C'){
				break;
			}
			Max=max(Max,j-i+1);
		}
	}
	cout<<Max<<endl;
}

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

int main(){
	int n,flag=1;;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	a[0]--;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]) flag=0;
		if(a[i]>a[i-1]) a[i]--;
	}
	if(flag) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  int k;
  cin >> s >> k;

  set<string> st;
  rep(i, s.size()) {
    string t = "";
    reps(j, i, s.size()) {
      t += s[j];
      if(!st.count(t)) st.insert(t);
      if((int)st.size() > k) st.erase(--st.end());
    }
  }
  cout << *(--st.end()) << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>

using namespace std;

typedef long long ll;

int main() {
   ll N;
   cin >> N;
   string S;
   cin >> S;
   ll Q;
   cin >> Q;
   ll k[Q];
   for (ll i = 0; i < Q; i++) {
      cin >> k[i];
   }

   ll SD[N + 1], SM[N + 1], SDM[N + 1], SDMC[N + 1];
   SD[0] = 0;
   SM[0] = 0;
   SDM[0] = 0;
   vector<ll> Cid;
   for (ll i = 0; i < N; i++) {
      if (S[i] == 'D') {
         SD[i + 1] = SD[i] + 1; 
      } else {
         SD[i + 1] = SD[i];
      }
      if (S[i] == 'M') {
         SM[i + 1] = SM[i] + 1;
         SDM[i + 1] = SDM[i] + SD[i];
      } else {
         SM[i + 1] = SM[i];
         SDM[i + 1] = SDM[i];
      }
      if (S[i] == 'C') {
         Cid.push_back(i);
         // SDMC[i + 1] = SDM[i];
         // SDMC[i + 1] = SDMC[i] + SDM[i];
      } else {
         // SDMC[i + 1] = SDMC[i];
         // SDMC[i + 1] = 0;
      }
   }
   /*
   cout << "SD" << endl;
   for (ll i = 0; i <= N; i++) {
      cout << i << " " << SD[i] << endl;
   }
   cout << "SM" << endl;
   for (ll i = 0; i <= N; i++) {
      cout << i << " " << SM[i] << endl;
   }
   cout << "SDM" << endl;
   for (ll i = 0; i <= N; i++) {
      cout << i << " " << SDM[i] << endl;
   }
   */
   for (ll ktmp = 0; ktmp < Q; ktmp++) {
      ll count = 0;
      for (ll c = 0; c < Cid.size(); c++) {
         ll minid = Cid[c] - k[ktmp];
         if (minid < 0) count += SDM[Cid[c] + 1];
         else {
            count += SDM[Cid[c] + 1];
            count -= SDM[minid + 1];
            count -= SD[minid + 1] * (SM[Cid[c] + 1] - SM[minid + 1]);
         }
      }
      cout << count << endl;
   }

   return 0;
}


Measured memory_bytes: 33012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  string t="";
  rep(i,s.length()) {
    if (s[i]=='B') {
      if (i+1 < s.length() && s[i+1] == 'C') {
        t+='D'; i++; continue;
      } else {
        t+='B';
      }
    }
    t+=s[i];
  }
 ll ans=0;
  int d = 0;
  for (int i=t.length()-1; i>=0; i--) {
    if (t[i]=='D') d++;
    if (t[i]=='A') ans+=d;
    if (t[i]=='B' || t[i] == 'C') d = 0;
  }
   cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int N, K;
vector<int> a;

int main()
{
    int i,in,l,r,ans,count;
    cin >> N >> K;
    rep0(i, N) {scanf("%d",&in); a.push_back(in);}
    sort(a.begin(),a.end());

    r=a[N-1];l=0;ans=(l+r)/2;

    while(r-l>1)
    {
        count=0;
        rep0(i,N){
            count+=(a[i]-1)/ans;
            //cout<<count<<endl;
            if(count>K) break;
        }
        if(count<=K) {r=ans;ans=(l+r)/2;}
        else {l=ans;ans=(l+r-1)/2+1;}
    }
    
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll n; cin >> n;
    vector<ll> a(n);
    FOR(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end(), std::greater<ll>());
    if (n%2 != 0) a.push_back(0);
    ll diff = 0;
    for(int i=0; i < n; i+= 2) {
        diff += a[i] - a[i+1];
    }
    cout << diff << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long mi(long long a, long long b, long long h) {

    if(h%2 == 0) {
        return 0;
    } else {
        return a*b;
    }

}

int main() {

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

    long long a,b,c;
    cin >> a >> b >> c;

    long long M = mi(a, b, c);
    M = min(M, mi(a, c, b));
    M = min(M, mi(b, a, c));
    M = min(M, mi(b, c, a));
    M = min(M, mi(c, a, b));
    M = min(M, mi(c, b, a));

    cout << M;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define int long long
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    int minm=INT_MAX;
    int dp[n];
    for(int i=0;i<n;++i)
    {
        dp[i]=INT_MAX;
    }
    for(int i=0;i<min(k,n);++i)
    {
        dp[i]=abs(arr[i]-arr[0]);
    }
    for(int i=k;i<n;++i)
    {
        for(int j=i-1;j>=i-k;--j)
        {
            dp[i]=min(abs(arr[i]-arr[j])+dp[j],dp[i]);
        }
    }
    //for(int i=0;i<n;++i) cout<<dp[i]<<" ";
    cout<<dp[n-1];
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();

}


Measured memory_bytes: 5176
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    cin >> a;
    vector<pair<int, int>> vec(a);

    for (int i = 0; i < a; ++i)
    {
        int a;
        cin >> a;
        vec[i].first = a - 1;
        vec[i].second = i;
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < a; ++i)
        cout << vec[i].second + 1 << " ";
    cout << "\n";
}


Measured memory_bytes: 1664