akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll minn = 0x3f3f3f3f3f3f3f3f;
    ll minN = 0x3f3f3f3f3f3f3f3f;
    ll maxx = 0;
    ll maxX = 0;
    vector<ll> A;
    vector<ll> B;
    for(int i = 1; i <= n; i++)
    {
        ll x, y;
        cin >> x >> y;
        A.push_back(x + y);
        B.push_back(x - y);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    cout << max(B.back() - B[0], A.back() - A[0]) << "\n";
    return 0;
}


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

int main()
{
    typedef std::pair<int,int> FL;
    int n;
    std::cin >> n;
    std::map<FL, int>m;
    for (int i = 1; i <= n; i++) {
        int l = i%10;
        int f = i;
        for (int j = i; j > 0; j/=10)
            f = j;
        m[FL(l,f)]++;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        int l = i%10;
        int f = i;
        for (int j = i; j > 0; j/=10)
            f = j;
        ans += m[FL(f,l)];
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
A = [0] * (N + 1)
mx = -2
pos = 0 
for i in range(N):
        if S[i] == "E":
                A[i + 1] = A[i] + 1   
        else:
                A[i + 1] = A[i] - 1   
        if mx < A[i + 1]: 
                pos = i + 1 
                mx = A[i + 1]
print(S[:pos - 1].count("W") + S[pos:].count("E"))

Measured memory_bytes: 15480
from sys import stdin


def main() -> None:
    a, b = [int(s) for s in input().split()]
    s = next_str()
    flg = False

    for i, c in enumerate(s):
        if i == a:
            if c != '-':
                flg = True
        else:
            if c == '-':
                flg = True

    print(["Yes", "No"][flg])


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int r, D, n = 0;
int B(int x) {
	n++;
	cout << r * x - D << "\n";
	if (n == 10) {
		return 0;
	}
	return B(r * x - D);
}
int main() {
	/*int A, B, ans;
	cin >> A >> B;
	if (A >= 13) {
		ans = B;
	}
	else if (A >= 6 && A <= 12) {
		ans = B / 2;
	}
	else {
		ans = 0;
	}
	cout << ans;*/
	int x;
	cin >> r >> D >> x;
	B(x);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

struct pkt
{
    ll x, h;
};

bool por(pkt a, pkt b)
{
    return a.x < b.x;
}

vector<ll> T;
int l, size;

void Stworz(int n)
{
    int p = 1;
    while (p < n)
        p *= 2;
    l = p;
    size = 2 * p - 1;
    for (int i = 0; i <= size; ++i)
        T.push_back(0);
}

ll Pyt(int a)
{
    a += l;
    ll s = 0;
    while (a != 0)
    {
        s += T[a];
        a /= 2;
    }
    return s;
}

void Dodaj(int a, int b, ll x)
{
    a += l;
    b += l;
    T[a] += x;
    if (a != b)
        T[b] += x;
    while (a / 2 != b / 2)
    {
        if (a % 2 == 0)
            T[a + 1] += x;
        if (b % 2 == 1)
            T[b - 1] += x;
        a /= 2;
        b /= 2;
    }
}

int Szukaj(vector<pkt>& a, int akt, ll D)
{
    int l = akt, p = a.size() - 1, s, r = -1;
    while (l <= p)
    {
        s = (l + p) / 2;
        if (a[s].x - a[akt].x <= D)
        {
            r = s;
            l = s + 1;
        }
        else
            p = s - 1;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, d, a;
    cin >> n >> d >> a;
    d *= 2;
    vector<pkt> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].h;
    sort(p.begin(), p.end(), por);
    vector<int> nast(n);
    for (int i = 0; i < n; ++i)
        nast[i] = Szukaj(p, i, d);
    Stworz(n);
    for (int i = 0; i < n; ++i)
        Dodaj(i, i, p[i].h);
    ll odp = 0;
    for (int i = 0; i < n; ++i)
    {
        ll ilePkt = Pyt(i);
        if (ilePkt <= 0)
            continue;
        ll ile = ilePkt / a;
        if (ilePkt % a != 0)
            ++ile;
        Dodaj(i, nast[i], -ile * a);
        odp += ile;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 10352
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
ll N, X;
ll x[MAX_N+1];
ll sum[MAX_N+1];

ll f(ll c) {
  if (c == 1) return 5ll;
  else return 2*c+1;
}

int main() {
  cin >> N >> X;
  rep(i, 1, N) cin >> x[i];
  rep(i, 1, N) sum[i] = x[i] + sum[i-1];

  ll ans = INFLL;
  for (int k = 1; k <= N; ++k) {
    ll tmp = N*X + k*X;
    ll n = N, c = 1;
    while (n > 0) {
      ll t = f(c);
      ll ub = n, lb = (n-k >= 0 ? n-k : 0);
      ll tmp_sum = sum[ub] - sum[lb];
      if (tmp > INFLL || t * tmp_sum > INFLL) {
        tmp = INFLL; break;
      }
      tmp += t * tmp_sum;
      n = lb;
      ++c;
    }
    ans = min(ans, tmp);
  }

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


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

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

ll tc;


void solve(){


    vector<ll>v1,v2;
    ll n,m,xx,k,now=0;
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++){
        cin>>xx;
        now+=xx;
        v1.push_back(now);
    }
    now=0;
    for(int i=1; i<=m; i++){
        cin>>xx;
        now+=xx;
        v2.push_back(now);
    }
    ll mx=0;
    for(int i=0; i<n; i++){
        if(v1[i]<=k){
            ll x=i+1;
            ll y=k-v1[i];
            ll z=upper_bound(v2.begin(),v2.end(),y)-v2.begin();
            z--;
            if(z>=0)x+=z+1;
            mx=max(mx,x);
        }
    }
    for(int i=0; i<m; i++){
        if(v2[i]<=k){
            ll x=i+1;
            ll y=k-v2[i];
            ll z=upper_bound(v1.begin(),v1.end(),y)-v1.begin();
            z--;
            if(z>=0)x+=z+1;
            mx=max(mx,x);
        }
    }
    cout<<mx<<endl;
}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 7856
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M, K[10], s[10][10], p[10], ans = 0;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < M; i++) cin >> p[i];
	for (int i = 0; i < pow(2, N); i++) {
		int X[10], I = i;
		for (int j = 0; j < N; j++) {
			X[j] = I % 2;
			I /= 2;
		}
		for (int j = 0; j < M; j++) {
			int z = 0;
			for (int k = 0; k < K[j]; k++) {
				if (X[s[j][k]]) z++;
			}
			if (z % 2 != p[j]) goto NEXT;
		}
		ans++;
	NEXT:;
	}
	cout << ans;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(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 same(ll x, ll y) {
        return root(x) == root(y);
    }

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


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    UnionFind tree(N);
    int ans = 0;
    int a[55],b[55];
    rep(i,0,M){
      int s,t; cin >> s >> t;
      s--; t--;
      a[i] = s;
      b[i] = t;
    }
    rep(i,0,M){
        tree.init(N);
        rep(j,0,M){
            if(i == j) continue;
            tree.unite(a[j],b[j]);
        }
      bool flag = false;
            rep(i,0,N){
                rep(j,0,N){
                    if(!(tree.same(i,j))){
                        flag = true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(flag) ans++;
    }

    cout << ans << endl;
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    ll N;
    cin >> N;
    ll bikkuri[N+1];
    bikkuri[0] = 1;
    ll x[N];
    ll d[N];
    ll t,ans;
    Rep(i,N){
        bikkuri[i+1] = bikkuri[i]*(i+1);
        bikkuri[i+1] %= MOD;
        cin >> x[i];
        if(i != 0)d[i-1] = x[i]-x[i-1];
    }
    t = 0;
    ans = 0;
    Rep(i,N-1){
        ans *= i+1;
        ans %= MOD;
        t = t*(i+1) + bikkuri[i];
        t %= MOD;
        ans += t*d[i];
        ans %= MOD;
        //cout << t << ans << endl;
    }
    cout << ans << endl;
    //cin >> N;
}

Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
string maxn(string a,string b)
{
    if(a.size()>b.size())
		return a;
    if(a.size()<b.size())
		return b;
    return a>b?a:b;
}
const int mp[11]={0,2,5,5,4,5,6,3,7,6};
int a[11];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>a[i];
    vector<string>dp(10005,"$");
    dp[0]="";
    for(int i=0;i<=n;i++)
	{
        if(dp[i]=="$") 
			continue;
        for(int j=1;j<=m;j++)
            if(i+mp[a[j]]<=n)
                dp[i+mp[a[j]]]=maxn(dp[i+mp[a[j]]],dp[i]+char(a[j]+'0'));
    }
    cout<<dp[n]; 
    return 0;
}

Measured memory_bytes: 43776
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

signed main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    rep(i, n) {
        cout << s[i] << t[i];
    }

    return 0;
}


Measured memory_bytes: 3132
N=int(input())
S=[input() for s in range(N)]

alphabet="abcdefghijklmnopqrstuvwxyz"

A=[[0 for x in range(len(alphabet))]for y in range(N)]

for i in range(N):
  for j in range(len(S[i])):
    a=alphabet.index(S[i][j])
    A[i][a]+=1

ans=[]

A=list(zip(*A))
for i in range(len(alphabet)):
  a=min(A[i])
  ans.append(alphabet[i]*a)
print("".join(ans))

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


int main()
{
	long long int n,w;
	cin>>n>>w;
	long long int val[n],wt[n];
	for(long long int i = 0; i < n ;i++)
	cin>>wt[i]>>val[i];
	long long int dp[n+1][w+1] = {0};
	for(long long int i = 0 ; i<=n ;i++)
	{
		for(long long int j = 0; j<=w ;j++)
		{
			if(j == 0 || i == 0)
				dp[i][j] = 0;
			else 
				{
					if(j < wt[i-1])								
						dp[i][j] = dp[i-1][j];
					else
						dp[i][j] = max(dp[i-1][j] , dp[i-1][j-wt[i-1]] + val[i-1]);
				}
		}
	}
	cout<<dp[n][w]<<'\n';
	return 0;
}

Measured memory_bytes: 79104
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    ll n;
    cin>>n;
    char s1[n],s2[n];
    cin>>s1>>s2;
    char s[2*n];
    ll j=0;
    for(int i=0;i<n;i++)
    {
        s[j++]=s1[i];
        s[j++]=s2[i];
    }
    for(int i=0;i<2*n;i++)
    cout<<s[i];
    cout<<endl;
}


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

int64_t fib2(int64_t p1, int64_t p2, int N);

int64_t fib1(int N) {
  return fib2(2,1,N);
}

int64_t fib2(int64_t x, int64_t y, int N){
  if (N == 0)
    return x;
  else if (N == 1)
    return y;
  else
    return  fib2(y, x+y, N-1);
}

int main() {
  int N;
  cin >> N;
  cout << fib1(N) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<int> L(N);
    L[0] = A[0];
    for (int i = 1; i < N; i++)
        L[i] = gcd(L[i - 1], A[i]);

    reverse(A.begin(), A.end());
    vector<int> R(N);
    R[0] = A[0];
    for (int i = 1; i < N; i++)
        R[i] = gcd(R[i - 1], A[i]);
    reverse(R.begin(), R.end());

    int ans = 1;
    for (int i = 0; i < N; i++) {
        int l = i - 1;
        int r = i + 1;

        if (l < 0)
            ans = max(ans, R[r]);
        else if (r >= N)
            ans = max(ans, L[l]);
        else
            ans = max(ans, gcd(L[l], R[r]));
    }

    cout << ans << endl;

    return 0;
}


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

int main(){

  int n;
  cin >> n;
  ll a[n][n];
  rep(i,n) rep(j,n){
    cin >> a[i][j];
  }

  ll cnt[(1<<n)];
  rep(i,(1<<n)){
    cnt[i]=0;
  }
  rep(i,(1<<n)){
    rep(j,n){
      rep(l,n){
	if((i&(1<<j)) &&(i&(1<<l))) cnt[i]+=a[j][l];
      }
    }
    cnt[i]/=2;
  }

  ll dp[(1<<n)];
  rep(i,1<<n) dp[i]=0;

  rep(mask,1<<n){
    for(int mask2=mask;mask2>0;mask2=((mask2-1)&mask)){
      dp[mask]=max(dp[mask-mask2]+cnt[mask2],dp[mask]);
    }
    //    cout << bitset<3>(mask) << " " << cnt[mask] << endl;
  }
  cout << dp[(1<<n)-1] << endl;

  
  
  return 0;

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=0;
    cin>>n;
    rep1(i,n){
        int ans=0;
        rep1(y,sqrt(i))rep1(z,sqrt(i)){
            int a=(y+z)*(y+z)-4*(y*y+z*z+y*z-i);
            if(a>0&&pow((int)sqrt(a),2)==a&&sqrt(a)-y-z>=2&&((int)sqrt(a)-y-z)%2==0) ans++;
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define  __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{
    __;

    int a,b,c;

    cin>>a>>b>>c;

    if((a>c && b<c) || (a<c && b>c)) cout<<"Yes";

    else cout<<"No";

    return 0;
}


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

int V;
int dist[20][20];
int dp[(1<<20)-1][15];
int seen[(1<<20)-1][20];

int rec(int bit, int v){    
    if(dp[bit][v]!=INF||seen[bit][v]==true)return dp[bit][v];
    seen[bit][v]=true;

    if(bit==0&&v==0)return dp[bit][v]=0;

    if(!(bit&(1<<v)))return INF;

    int pbit=bit&~(1<<v);

    rep(u,V){
        dp[bit][v]=min(rec(pbit,u)+dist[u][v],dp[bit][v]);
    }
    return dp[bit][v];
}

int main(){
    cin>>V;
    int E; cin>>E;
    rep(i,V)rep(j,V)dist[i][j]=INF;
    rep(i,E){
        int s,t,v; cin>>s>>t>>v;
        dist[s][t]=v;
    }

    int ans=INF;
    rep(i,1<<V)rep(j,V){
        dp[i][j]=INF;
        seen[i][j]=false;
    }
    ans=min(ans,rec((1<<V)-1,0));
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 7588
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    int L = A + B;
    int R = C + D;

    if (L > R) {
        cout << "Left" << endl;
    } else if (L < R) {
        cout << "Right" << endl;
    } else if (L == R) {
        cout << "Balanced" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            Solve();

        }
        static long Xmin;
        static long Xmax;
        static long Ymin;
        static long Ymax;
        static void Solve()
        {
            //var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = int.Parse(Console.ReadLine());
            //var S = Console.ReadLine();
            var Points = new Tuple<long, long>[N+1];
            var max = 0L;
            var min = long.MaxValue;
            var max2 = 0L;
            var min2 = long.MaxValue;
            var map = new long[N + 1];
            for (int i = 0; i < N; i++)
            {
                var XY = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var X = XY[0];
                var Y = XY[1];
                Points[i] = new Tuple<long, long>(X, Y);
                max = Max(max, X + Y);
                min = Min(min, X + Y);
                max2 = Max(max2, Y - X);
                min2 = Min(min2, Y - X);
            }

            //var ng = -1;
            //var ok = 1000000000;
            //while(ng < ok)
            //{
            //    var mid = (ng + ok) / 2;
            //    if (Check(mid))
            //    {
            //        ok = mid;
            //    }
            //    else
            //    {
            //        ng = mid;
            //    }
            //}
            Sort(map);
            Reverse(map);
            Console.WriteLine(Max(max- min,max2 - min2));
        }

        //static bool Check(long mid)
        //{
        //    for (int i = 1; i <= N; i++)
        //    {
        //        if(Xmin >=)
        //    }

        //    return true;
        //}
    }

}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, k;
    vector<double> p(n + 1);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        double x;
        cin >> x;
        double cur = (x + 1) * x / (2.0 * x);
        //DBG(cur);
        p[i] = cur;
    }
    double ans = 0;
    for (int i = 2; i <= n; i++)
    {
        p[i] += p[i - 1];
        //DBG(p[i]);
    }
    p[0] = 0;
    for (int i = k; i <= n; i++)
    {
        ans = max(ans, p[i] - p[i - k]);
        //DBG(ans);
    }
    cout << ans << "\n";
    return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    int k;
    cin >> k;

    cout << v[0] + v[1] + (int)(pow(2,k) * v[2]) << endl;


    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;
    vector<string> v={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
    cin >> s;
    REP(i,SZ(v)){
        if(s==v[i]){
            cout << 7-i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = []
p = []
for i in range(n):
  x,y = map(int,input().split())
  s += [(x,y)]
for i in range(m):
  x,y = map(int,input().split())
  p += [(x,y)]

def dist(p1, p2):
  return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


for i in range(n):
  ans = 1
  min_d = dist(s[i], p[0])
  for j in range(1, m):
    d = dist(s[i], p[j])
    if d < min_d:
      ans = j+1
      min_d = d
  print(ans)
  
  

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
int MOD = 1e9 + 7;
class Prime{
    vector<bool>Isprime;
    vector<int>prime;
public:
    int size;
    Prime(int n) : Isprime(n+1,true),size(n+1){
        Isprime[0] = Isprime[1] = false;
        for(int i = 2; i<=size; i++){
            if(!Isprime[i])continue;
            prime.push_back(i);
            for(int j = 2;i*j <=size;j++) Isprime[i*j] = false;
        }
    }
    bool isPrime(int n){assert(n<=size);return (n<=size? Isprime[n]:false);}
    int indexOf(int i){return (i<prime.size()?prime[i]:INF);}
};
signed main(){
    int n;
    cin >> n;
    Prime p(10000000);
    vector<int>q(n);
    erep(e,q) cin >> e;
    auto dp = vectors(n,2,0LL);
    dp[0][0] = (p.isPrime(q[0]) ? 1:0);
    rep(i,q.size()){
        if(i == 0)continue;
        if(p.isPrime(q[i])){
            dp[i][0] = (q[i] > q[i-1] and p.isPrime(q[i-1]) ? dp[i-1][0]:0); dp[i][0] %= MOD;
            dp[i][0] += (i - 2 >= 0 and q[i] > q[i - 2]  and p.isPrime(q[i-2]) ? dp[i-1][1] : 0); dp[i][0] %= MOD;
            dp[i][1] = dp[i-1][0];
        } else {
            dp[i][1] = dp[i-1][0];  dp[i][1] %= MOD;
        }
    }
    cout << (dp[n-1][0] + dp[n-1][1]) % MOD << endl;
}







Measured memory_bytes: 15476
n = int(input())
a = list(map(int,input().split()))
l = [0 for i in range(n+1)]
ans = 0
for i in range(n):
    l[a[i]] += 1
for i in range(n+1):
    ans += (l[i]*(l[i]-1))//2
al = []
for i in range(n):
    a0 = ans - (l[a[i]]*(l[a[i]]-1))//2 + ((l[a[i]]-1)*(l[a[i]]-2)//2)
    al.append(a0)
for i in al:
    print(i)

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll X;
  cin >> X;
  ll d = 0;
  auto f = [&](ll x) {
    ll res = (x+d)*(x+d)*(x+d)*(x+d)*(x+d)-x*x*x*x*x;
    debug(x, res);
    return res;
  };
  while(d < 200) {
    ll ng = -(d+1)/2-1, ok = 200;
    while (ok - ng > 1) {
      ll mid = (ok+ng)/2;
      if (f(mid) >= X) ok = mid;
      else ng = mid;
    }
    if (f(ok) == X) {
      cout << ok+d << " " << ok << endl;
      return 0;
    }
    d++;
  }
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPul(i, n) for (ull i = 0; i < (ull)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define REPRul(i, n) for(ull i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define FORul(i, m, n) for(ull i = m; i < (ull)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

map<ll, ull> fList;
ull f(ll x){
  if(fList.find(x)==fList.end()){
    fList[-1]=0;
    fList[0]=1;
    FORl(i,1,x+1){
      fList[i]=(fList[i-2]+fList[i-1])%1000000007;
    }
  }
  return fList[x];
}

int main() {
  int n,m;cin>>n>>m;
  vector<ll> a(m+2);
  a[0]=-1;
  FOR(i,1,m+1){
    ll b;cin>>b;
    a[i]=b;
  }
  a[m+1]=n+1;
  
  vector<ull> b(m+1);
  ull bMax=0;
  REP(i,m+1){
    b[i]=a[i+1]-a[i]-2;
    if(b[i]>bMax){
      bMax=b[i];
    }
  }
  f(bMax);
  ull ans=1;
  REP(i,b.size()){
    ull tmp=f(b[i]);
    ans*=tmp;
    ans%=1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>
int main(){
  int year,month,day;
  while (scanf("%d %d %d",&year,&month,&day)!=EOF){
    if (year<1868)
      puts("pre-meiji");
    else if (year==1868 && month<9)
      puts("pre-meiji");
    else if (year==1868 && month==9 && day<8)
      puts("pre-meiji");
    else if (year<1912)
      printf("meiji %d %d %d\n",year-1868+1,month,day);
    else if (year==1912 && month<7)
      printf("meiji %d %d %d\n",year-1868+1,month,day);
    else if (year==1912 && month==7 && day<=29)
      printf("meiji %d %d %d\n",year-1868+1,month,day);
    else if (year<1926)
      printf("taisho %d %d %d\n",year-1912+1,month,day);
    else if (year==1926 && month<12)
      printf("taisho %d %d %d\n",year-1912+1,month,day);
    else if (year==1926 && month==12 && day<=24)
      printf("taisho %d %d %d\n",year-1912+1,month,day);
    else if (year<1989)
      printf("showa %d %d %d\n",year-1926+1,month,day);
    else if (year==1989 && month<1)
      printf("showa %d %d %d\n",year-1926+1,month,day);
    else if (year==1989 && month==1 && day<=7)
      printf("showa %d %d %d\n",year-1926+1,month,day);
    else
      printf("heisei %d %d %d\n",year-1989+1,month,day);
  }
  return 0;
}

Measured memory_bytes: 608
h,w = gets.strip.split.map(&:to_i)
c = []
for i in 0..9
  c[i] = gets.strip.split.map(&:to_i)
end
#魔力データ完了c

dt = []
h.times do
  dt << gets.strip.split.map(&:to_i)
end
dt.flatten!
dt.reject!{|v| v==-1}
cnt = Array.new(10,0)
for i in 0..dt.size-1
  cnt[dt[i]] += 1
end
#集計完了cnt

#各数字を１に変えるための魔力の最小値をそれぞれ求める
#ワーシャル–フロイド法(?)
sh = Array.new(9)
for i in 0..8
  sh[i] = Array.new(10)
end
for i in 0..9
  sh[0][i] = c[i][1]
end
for i in 1..8 #経由する数
  for j in 0..9 #どこから来たか
    sh[i][j] = sh[i-1][0]+c[j][0]
    for k in 1..9 #増やす寄り道先,minを使ってもOK
      if sh[i-1][k]+c[j][k] < sh[i][j]
        sh[i][j] = sh[i-1][k]+c[j][k]
      end
    end
    if sh[i][j] > sh[i-1][j] #minを使ってもOK
      sh[i][j] = sh[i-1][j]
    end
  end
end
sum = 0
for i in 0..9
  sum += sh[8][i]*cnt[i]
end
puts sum

Measured memory_bytes: 15520
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	for (int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n, greater<int>());
	ll ans = a[0];
	for (int i=2, idx=1; i<n; idx+=(i&1), i++) {
		ans += a[idx];
	}
	cout << ans;
}

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

int main()
{
  ios::sync_with_stdio(false);
  int a, b, k, n;
  cin >> a >> b >> k;

  n = min(a, b);
  while (k)
  {
    if (a % n == 0 && b % n == 0)
      k--;

    n--;
  }

  cout << ++n << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;

bool is_prime[10000001];
ll cnt[10000001];
vector<int> p;

void init(){
    cnt[1] = 1;
    for(int i = 2; i <= 10000000; i++){
        is_prime[i] = true;
        cnt[i] = 1;
    }
    for(int i = 2; i*i <= 10000000; i++){
        if(is_prime[i]){
            for(int j = 2; j*i <= 10000000; j++) is_prime[i*j] = false;
        }
    }
    for(int i = 2; i <= 10000000; i++){
        if(is_prime[i]) p.push_back(i);
    }
    for(int i : p){
        for(int j = 1; i*j <= 10000000; j++){
            int tmp = j;
            int cur = 2;
            while(tmp%i == 0){
                tmp /= i;
                cur++;
            }
            cnt[i*j] *= cur;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    init();
    ll ans = 0;
    for(ll i = 1; i <= N; i++) ans += cnt[i]*i;
    cout << ans << endl;
}

Measured memory_bytes: 95304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
 	LL(n,q);
	STR(s);
	for(int i = 0; i < n-1; ++i){
		if(s[i]=='A'&&s[i+1]=='C')s[i]='a';
	}
	vector<ll> rui(n+2,0);
    for(int i = 0; i < n; ++i){
		rui[i+1]+=rui[i];
		if(s[i]=='a')rui[i+1]++;
	}
 
	for(int i = 0; i < q; ++i){
		LL(l,r);
		cout<<rui[r-1]-rui[l-1]<<endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	int h, w;
	while (cin >> h >> w)
	{
		if (h*w)
		{
			loop(i, h)
			{
				loop(j, w)
				{
					cout << "#";
				}
				cout << endl;
			}
			cout << endl;
		}
		else break;
	}
}


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

int main() {
  int M;
  cin >> M;
  ll S = 0, D = 0;
  for (int i = 0; i < M; i++) {
    ll d, c;
    cin >> d >> c;
    S += d * c;
    D += c;
  }
  cout << D - 1 + (S - 1) / 9 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll a[(1 << 19)][2];
int n;
void zeta() {
    for (int i = 0; i < n; i++) {
        for (int b = 0; b < (1 << n); b++) {
            if (b & (1 << i)) {
                ll ar[4] = {a[b][0], a[b][1], a[b^(1<<i)][0], a[b^(1<<i)][1]};
                sort(ar, ar + 4);
                reverse(ar, ar + 4);
                a[b][0] = ar[0];
                a[b][1] = ar[1];
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    n = N;
    for (int i = 0; i < (1 << N); i++) {
        fill(a[i], a[i] + 2, 0);
        cin >> a[i][0];
    }
    zeta();
    ll m = a[1][0] + a[1][1];
    for (int i = 1; i < (1 << N); i++) {
        m = max(m, a[i][0] + a[i][1]);
        cout << m << endl;
    }
}


Measured memory_bytes: 9216
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <array>

int main() {
  std::array<std::int_fast32_t, 3> input;
  std::cin >> input[0] >> input[1] >> input[2];
  std::sort(input.begin(), input.end());
  std::cout << (input[0] == 5 && input[1] == 5 && input[2] == 7 ? "YES" : "NO") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main() {
    int n;
    cin >> n;
    set<ll> A;
    for (size_t i = 0; i < n; i++)
    {
        int a = 0;
        cin >> a;
        A.insert(a);
    }
    if (A.size() == n) cout << "YES";
    else cout << "NO";
    return 0;

}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,q;scanf("%d%d%d",&n,&m,&q);
    vector<vector<int>> a(n+1,vector<int>(n+1));
    for(int i=0;i<m;i++){
        int l,r;scanf("%d%d",&l,&r);
        a[l][r]++;
    }
    for(int i=1;i<=n;i++)for(int j=0;j<n;j++)a[i][j+1]+=a[i][j];
    for(int i=0;i<n;i++)for(int j=1;j<=n;j++)a[i+1][j]+=a[i][j];
    for(int i=0;i<q;i++){
        int l,r;scanf("%d%d",&l,&r);
        int ans=a[r][r]+a[l-1][l-1]-a[r][l-1]-a[l-1][r];
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<cstdlib>
#include<stack>
#include<cstdio>
using namespace std;

stack<int> st;
int solve(string);

int main(){
    string str;
    
    while(cin>>str){
        if(str=="+"|| str=="-" || str=="*" || str=="/")
            st.push(solve(str));
        else
            st.push(atoi(str.c_str()));
        if(getchar() == '\n'){
            cout << st.top()<<endl;
            return 0;
        }
    }
}

int solve(string str){
    int b = st.top(); st.pop();
    int a = st.top(); st.pop();
    if(str=="+") return a+b;
    else if(str=="-") return a-b;
    else if(str=="*") return a*b;
    else if(str=="/") return a/b;
    return 0;
}


Measured memory_bytes: 3172
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}


bitset<2000001>b;
int main() {
    b[0] = 1;
    int n;in(n);
    int sum = 0;
    REP(i,0,n){
        int c;in(c);
        b|=b<<c;
        sum+=c;
    }
    
    REP(i,(sum+1)/2,sum+1){
        if(b[i]){
            return printf("%d",i),0;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}




Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

	ll count = 1;
	while (H / 2 > 0)
	{
		count++;
		H /= 2;
	}

	ll sum = 0;
	rep(i, count) sum += (ll)1 << i;

	cout << sum << endl;


	
	return 0;
}

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

using namespace std;
#define ull unsigned long long
#define ll long long
const int inf = 1e9;
const int MAXN = 4e6+4;

vector<vector<int>> vect(3e5+1, vector<int>(0));
vector<bool> was(3e5+1, false);
vector<int> dp(3e5+1, 0);
vector<int> depth(3e5+1, 0);


void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        double re=(double)i*1.08;
        if((int)floor(re)==n){
            cout<<i;
            return;
        }
    }
    cout<<":(";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for(int i=0;i<n;i++) solve();
    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
 
int cnt, A[500010];
 
int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N;
  cin >> N;
  REP(i, N) cin >> A[i];
  stack<P> stk;
  stk.push(P(0, N));
  while (!stk.empty()) {
    P p = stk.top(); stk.pop();
    int left = p.first, right = p.second, mid = (left + right) / 2;
    if (left + 1 < right) {
      stk.push(P(mid, right));
      stk.push(P(left, mid));
      cnt += right - left;
    }
  }
  sort(A, A + N);
  REP(i, N) {
    cout << A[i] << (i == N-1 ? '\n' : ' ');
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3176
def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    r = 0
    b = 0
    for c in s:
        if c == "0":
            r += 1
        else:
            b += 1

    print(min(r, b) * 2)


if __name__ == "__main__":
    resolve()


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

using namespace std;
int c[200001];
int main()
{
    int n,x,k ;
    cin >> n >> k ;
    set<int>s;
    vector<int>v;

    for(int i = 0 ; i < n ;i++)
    {
        cin >> x;
        c[x]++;
        s.insert(x);
    }
    set<int>::iterator it = s.begin() ;
    x=0;
    v.clear();
    if(k<s.size())
    {
        for( it ; it!=s.end() ;it++)
        {
            v.push_back(c[*it]);
        }
        sort(v.begin(),v.end());
        x=0;
        for(int i = 0 ; i < s.size()-k ;i++)
        {
            x+=v[i];
        }
        cout << x <<"\n";
    }
    else
    {
        cout << 0;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n,t;
    cin>>n>>t;
    vector<pair<int,int>> d;
    for(int i = 0;i < n;++i) {
        int a,b;
        cin>>a>>b;
        d.emplace_back(a,-b);
    }
    sort(d.begin(),d.end());
    vector<vector<int>> dp(n,vector<int>(t+1,0));
    for(int i = 0;i < t;++i) {
        dp[0][min(t,i+d[0].first)]=-d[0].second;
    }
    for(int i = 1;i < n;++i) {
        int a=d[i].first;
        int b=-d[i].second;
        for(int j = 0;j < t;++j) {
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            int nt=j+a;
            nt=min(nt,t);
            dp[i][nt]=max(max(dp[i][nt],dp[i-1][nt]),dp[i-1][j]+b);
        }
    }
    int ans=0;
    for(int i = 0;i < t+1;++i) {
        ans=max(ans,dp[n-1][i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n; cin >>n;
  long long ans = 0; // max: 2 x 10^5 * 10^9
  int bef = 0, now;
  for (int i = 0; i < n; i++) {
    cin >> now;
    if (bef > now) ans += bef - now;
    bef = max(bef, now); // 高い方に合わせる
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588