akhauriyash/Code-Regression huggingface dataset:
//ALDS1_8A
#include <iostream>
#include <string>
using namespace std;

struct Node{
 int key;
 Node *right,*left,*parent;
};

Node *root,*NIL;
void insert(int k){
 Node *y=NIL;
 Node *x=root;
 Node *z;
 z=new Node;
 z->key=k;
 z->left=NIL;
 z->right=NIL;
 while(x!=NIL){
  y=x;
  if(z->key<x->key){
   x=x->left;
  }else{
   x=x->right;
  }
 }
 z->parent=y;
 if(y==NIL){
  root=z;
 }else{
  if(z->key<y->key){
   y->left=z;
  }else{
   y->right=z;
  }
 }
}

void inorder(Node *u){
 if(u==NIL) return;
 inorder(u->left);
 cout<<" "<<u->key;
 inorder(u->right);
}

void preorder(Node *u){
 if(u==NIL) return;
 cout<<" "<<u->key;
 preorder(u->left);
 preorder(u->right);
}

int main(){
 int n,x;
 string com;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>com;
  if(com=="insert"){
   cin>>x;
   insert(x);
  }else if(com=="print"){
   inorder(root);
   cout<<endl;
   preorder(root);
   cout<<endl;
  }
 }
 return 0;
}

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

long long int N, a, i;
string s;

bool solve(string ss){
    while(ss.begin() != ss.end()){
        //cout << ss << endl;
        if(ss.begin() == ss.end())return true;
        switch(ss[0]){
            case 'e':
                if(ss.find("erase") != 0){
                    return false;
                }else{
                    if(ss[5] == 'r'){
                        ss.erase(ss.begin(), ss.begin() + 6);
                    }else{
                        ss.erase(ss.begin(), ss.begin() + 5);
                    }
                }
                break;
            case 'd':
                if(ss.find("dream") != 0){
                    return false;
                }else{
                    ss.erase(ss.begin(), ss.begin() + 5);
                    if(ss.begin() == ss.end())return true;
                    if(ss.find("er") == 0 && ss.find("erase") != 0){
                        ss.erase(ss.begin(), ss.begin() + 2);
                    }
                }
                break;
            default:
                return false;
        }
    }
    return true;
}

int main(){
    cin >> s;
    puts(solve(s)?"YES":"NO");
    return 0;
}


Measured memory_bytes: 512
x, y, a, b, c = map(int,input().split())
red = sorted(list(map(int,input().split())),reverse=True)[:x]
green = sorted(list(map(int,input().split())),reverse=True)[:y]
white = sorted(list(map(int,input().split())),reverse=True)

l = sorted(red+green+white,reverse=True)[:x+y]
print(sum(l))


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

int main() {
    int x, temp, ans = 1;
    cin >> x;
    for(int i = 2; i * i <= x; i++) {
        temp = i;
        while(i * temp <= x) {
            temp *= i;
            ans = max(ans, temp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  sort(A,A+N,greater<int>());
  lint ans=A[0];
  int t=2;
  FOR(i,1,N){
    if(t==N)break;
    ans+=A[i];
    t++;
    if(t==N)break;
    ans+=A[i];
    t++;
    if(t==N)break;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll k,x;
    cin>>k>>x;
    ll t = x - k +1;
    while(t<x+k){
    	cout<<t<<" ";
    	t++;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}

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

    SPEED;
    cout.precision(8);
    cout << fixed;
    ll n;
    cin>>n;
    set<ll> a,b;
    while(n--){
        ll x,y;
        cin>>x>>y;
        a.insert(x+y);
        b.insert(x-y);
    }   
    auto itr1 = a.begin();
    auto itr2 = a.end(); itr2--;
    auto itr3 = b.begin();
    auto itr4 = b.end(); itr4--;
    ll amax = *itr2; 
    ll amin = *itr1;
    ll bmax = *itr4;
    ll bmin = *itr3; 
    ll op1 = amax - amin;
    ll op2 = bmax - bmin;
    ll op3 = -bmin - amin;
    ll op4 = -amin - bmin;
    cout<<max({op1,op2,op3,op4});
    purvansh11();
    return 0;
}

Measured memory_bytes: 27232
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<100000;i++)
	{
		double c=i*0.08 , d=i*0.1;
		int e=c , f=d;
		if (e==a && f==b)  {cout<<i;re 0;}
	}
	cout<<-1;
	re 0;
}


Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	double t,x;
	cin>>t>>x;
	printf("%.10f\n",t/x);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	public static int Main(string[] args)
	{
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		for (int i = 0; i < s.Length;i++){
			if(s==t){
				Console.WriteLine("Yes");
				return 0;
			}
			else{
				s = s.Substring(s.Length - 1, 1) + s.Substring(0, s.Length - 1);
			}
		}
		Console.WriteLine("No");
		return 0;
	}
}


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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int o = h1*60 + m1;
    int t = h2*60 + m2 -k;
    cout << t - o << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll l,r;
	cin>>l>>r;
	ll ans=10000;
	if(r-l>=2100)ans=0;
	else{
		for(int i=l;i<r;i++)for(int j=i+1;j<=r;j++){
			ll p=i%2019,q=j%2019;
			ans=min(ans,(p*q)%2019);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007
#define PI acos(-1.0)
#define ll long long int
#define INF 1000000001

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll fact(ll x){
  ll res=1;
  while(x>1){
    res*=x;
    res%=MOD;
    x--;
  }
  return res%MOD;
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n,m;cin>>n>>m;
  // P(fact(1000000));
  if(n>m+1 || m>n+1){
    P(0);
    return 0;
  }
  if(n==m){
    P((2*fact(n)*fact(m))%MOD);
    return 0;
  }
  P((fact(n)*fact(m))%MOD);
  return 0;
}


Measured memory_bytes: 256
//
// Created on 2020/04/12.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int a,b,c;
    cin>>a>>b>>c;

    ans = max(c-(a-b),0);

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;
const LL INV = (N + 1LL) / 2LL;

LL tot = 1LL,sum = 0;
LL dp[3005][3005],tmp[3005][3005];
LL a[3005];

int main(){
	LL n,q,u,v;
	cin >> n >> q;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(a[i] > a[j]) dp[i][j] = 1;
		}
	}
	while(q --){
		cin >> u >> v;
		for(LL i = 1;i <= n;i ++){
			if(i == u || i == v) continue;
			tmp[u][i] = (INV * ((dp[u][i] + dp[v][i]) % N)) % N;
			tmp[i][u] = (INV * ((dp[i][u] + dp[i][v]) % N)) % N;
			tmp[v][i] = (INV * ((dp[v][i] + dp[u][i]) % N)) % N;
			tmp[i][v] = (INV * ((dp[i][v] + dp[i][u]) % N)) % N;
		}
		for(LL i = 1;i <= n;i ++){
			if(i == u || i == v) continue;
			dp[u][i] = tmp[u][i]; dp[i][u] = tmp[i][u];
			dp[v][i] = tmp[v][i]; dp[i][v] = tmp[i][v];
		}
		tmp[u][v] = (INV * ((dp[u][v] + dp[v][u]) % N)) % N;
		tmp[v][u] = (INV * ((dp[v][u] + dp[u][v]) % N)) % N;
		dp[u][v] = tmp[u][v]; dp[v][u] = tmp[v][u];
		tot = (tot * 2) % N;
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = i + 1;j <= n;j ++){
			sum = (sum + dp[i][j]) % N;
		}
	}
	cout << (sum * tot) % N << '\n';
	return 0;
}

Measured memory_bytes: 141312
# include<bits/stdc++.h>
using namespace std;
int main(){
	long int n;
  	cin >> n;
  	long int a = 1, b = n;
  	for(int i = 2; i < sqrt(n)+1; i++  ){
    	if(n % i == 0){
        	a = i;
          	b = n/i;
        }
    }
  cout << a + b -2 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void* realloc2(void* asumi, size_t iguti) {
	void* ogurayui = realloc(asumi, iguti);
	if (ogurayui == NULL) exit(2);
	return ogurayui;
}

int N, M;
int s[16], e[16];
int* cars[16];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int info, data;
		if (scanf("%d%d", &info, &data) != 2) return 1;
		if (info == 0) {
			if (s[data] >= e[data]) {
				puts("error!!!!!");
				return 1;
			}
			printf("%d\n", cars[data][s[data]++]);
		} else {
			int minLane = 0, minScore = -1;
			int j;
			for (j = 1; j <= N; j++) {
				int score = e[j] - s[j];
				if (minScore < 0 || score < minScore) {
					minScore = score;
					minLane = j;
				}
			}
			cars[minLane] = realloc2(cars[minLane], sizeof(int) * (e[minLane] + 1));
			cars[minLane][e[minLane]++] = data;
		}
	}
	return 0;
}



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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;

    ist >> N;

    vector<int> A;

    for (int i = 1; i < N; i++)
    {
        int tmp;
        ist >> tmp;
        A.emplace_back(tmp);
    }

    /* ------- 計算 ------- */

    int buka_num[N] = {0};

    for (auto a : A)
    {
        buka_num[a - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        ost << buka_num[i] << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 5048
EPS = 1e-7
N, K = map(int, input().split())
pts = []
Cs = []
for _ in range(N):
    x, y, c = map(int, input().split())
    pts.append(x + y * 1j)
    Cs.append(c)

Rs = [0] * N


def cands():
    for i in range(N):
        yield pts[i]
        for j in range(i + 1, N):
            pt = pts[j] - pts[i]
            ab = -2 * pt
            l = ab * ab.conjugate()
            c = pt * pt.conjugate() + Rs[i] - Rs[j]
            d = Rs[i] - c * c / l
            if d.real < 0:
                continue
            m = (d / l) ** 0.5
            off = m * (ab.imag - ab.real * 1j)
            yield -ab * c / l + off + pts[i]
            yield -ab * c / l - off + pts[i]


def ok(secs):
    for i in range(N):
        Rs[i] = secs * secs / Cs[i] / Cs[i]
    for cand in cands():
        count = 0
        for pt, r in zip(pts, Rs):
            xy = pt - cand
            if (xy * xy.conjugate()).real < r + EPS:
                count += 1
                if count == K:
                    return True
    return False


lo = 0
hi = 1e10
for _ in range(100):
    mid = (lo + hi) / 2
    if ok(mid):
        hi = mid
    else:
        lo = mid
print(hi)


Measured memory_bytes: 49372
#include<stdio.h>
int main() {
int N,i,sum=0,highest=0;
scanf("%d",&N);
for(i=1;i<=N;i++)
{
  int d;
  scanf("%d",&d);    
  sum=sum+d;
  if(highest<d) 
  {
    highest=d;
  }
  else 
  {
   highest=highest;
  }
}
 sum=sum-(highest/2);
 printf("%d",sum);
    return 0;
    }

Measured memory_bytes: 1732
#include<stdio.h>
#define MAXN 220000
int a[MAXN],n,k;

int read()
{
	int ans=0,p=1;
	char c = getchar();
	while (c<'0'||c>'9')
	{
		if(c=='-')
			p=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		ans = ans*10+c-'0';
		c=getchar();
	}
	return ans*p;
//	int a;
//	scanf("%d",&a);
//	return a;
}

int solve(int m)
{
	int ans=0;
	for(int i = 1; i <= n; i++)
	{
		ans += a[i]/m;
		if(a[i]%m==0)
			ans--;
		if(ans>k)
			return 0;
	}
	return 1;
}

int main()
{
	n=read(),k=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}	
	int A = 1, B = 2e9;
	while(A < B)
	{
		int mid = (A+B)>>1;
		if(solve(mid) != 1)
		{
			A = mid+1;
		}
		else 
		{
			B = mid;
		}
	}
	printf("%d",B);
	return 0;
}

Measured memory_bytes: 2328
n, m, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

def gen_list(li, n, m):
    if len(li[0]) == n:
        return li
    
    res = []
    for d in li:
        base = [i for i in range(d[-1], m+1)]
        for x in base:
            tmp = d.copy()
            tmp.append(x)
            res.append(tmp)
    return gen_list(res, n, m)

base = [[i] for i in range(1, m+1)]
A_list = gen_list(base, n, m)
ans = 0
for A in A_list:
    tmp = 0
    for d in query:
        if A[d[1]-1] - A[d[0]-1] == d[2]:
            tmp += d[3]
        if tmp > ans:
            ans = tmp

print(ans)

Measured memory_bytes: 45448
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
	int i,n;
	int a[205];
	scanf("%d", &n);
	for(i = 1 ; i <= 2 * n ; i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a + 1 , a + 1 + 2 * n);
	int ans = 0;
	for(i = 1 ; i <= 2 * n ; i++)
	{
		if(i % 2 == 1)
		{
			ans = ans + a[i];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template<typename T = int>T in() { T x; cin >> x; return x; }
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()
int main()
{
	int ans = 0;
	REP(i, 4)
	{
		char c = in<char>();
		c == '+' ? ans++ : ans--;
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
  int n,a[200];
  cin >> n; 
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  int ma = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      if(ma < abs(a[i]-a[j]))
        ma = abs(a[i]-a[j]);
    }
  }
  cout << ma << endl;
}


Measured memory_bytes: 3576
abcd=input()

for i in range(8):
    op=['-']*3
    for j in range(3):
        if (i>>j)&1:
            op[j]='+'
    if eval(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3])==7:
        print(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3]+'=7')
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
//



//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  int ans = 0 ;
  
  REP(i,n){
    int a ;
    cin >> a ;
    if(a==2){
      continue ;
    }
    if(a==1){
      ans++ ;
      continue ;
    }
    for(int j = 2;j*j<=a;j++){
      if(a%j==0){
        ans++ ;
        break ;
      }
    }
  }
  cout << n-ans <<endl ;
  
  
  
  return 0 ;
}








Measured memory_bytes: 3212
// atcoder/abc129/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    const int H = 2000 + 5;
    const int W = 2000 + 5;
    static char g[H][W];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }

    const int inf = 1 << 27;
    static int mx_w[H][W];
    static int mx_h[H][W];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        mx_h[i][j] = mx_w[i][j] = (g[i][j] == '#' ? -inf : 1);
      }
    }

    for (int i = 0; i < h; ++i) {
      for (int j = 1; j < w; ++j) {
        if (g[i][j] == '#') continue;
        setmax(mx_w[i][j], mx_w[i][j - 1] + mx_w[i][j]);
      }
      for (int j = w - 2; 0 <= j; --j) {
        if (g[i][j] == '#') continue;
        setmax(mx_w[i][j], mx_w[i][j + 1]);
      }
    }

    for (int j = 0; j < w; ++j) {
      for (int i = 1; i < h; ++i) {
        if (g[i][j] == '#') continue;
        setmax(mx_h[i][j], mx_h[i - 1][j] + mx_h[i][j]);
      }
      for (int i = h - 2; 0 <= i; --i) {
        if (g[i][j] == '#') continue;
        setmax(mx_h[i][j], mx_h[i + 1][j]);
      }
    }

    int mx = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        setmax(mx, mx_h[i][j] + mx_w[i][j] - 1);
      }
    }
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 35584
#include<stdio.h>

int main(void)
{
   int n;
   char s[100];
   int i;

   scanf("%d",&n);
   for(i=1;i<=n;i++)
     scanf("%s",&s[i]);

   for(i=1;i<=n;i++)
     if(s[i]=='Y')
       n=1;

   if(n==1)
    printf("Four\n");
   else
    printf("Three\n");

   return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a, b;
    cin >> a >> b;
    a--, b--;
    vector<bool> ans(3, true);
    ans[a] = ans[b] = false;
    rep(i, 3) if (ans[i]) {
        cout << i + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll sqrtTbl(2 * n + 5, -1);
  rep(i, 2 * n + 5) {
    for (ll j = 0; j * j <= i; j++) {
      if(j*j == i) sqrtTbl[i] = j;
    }
  }

  
  ll m = sqrt(2*n + 5) + 1;
  repLRE(i, 1, n){
    ll ans = 0;
    repLRE(a, 2, m){
      repLRE(b, 2, m){
        ll k = 2*i - a*a - b*b;
        bool ok = k >= 0 && sqrtTbl[k] != -1;
        if(!ok) continue;
        ll c = sqrtTbl[k];
        ll x2 = a - b + c;
        if(x2 % 2 == 1) continue;
        ll x = (a - b + c)/2;
        if(x < 1) continue;
        ll y = a - x;
        if(y < 1) continue;
        ll z = c - x;
        if(z < 1) continue;
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int n;
	string str;
	cin>>n>>str;
	vint pos[10];
	for(int i=0; i<n; i++){
		pos[str[i]-'0'].pb(i);
	}

	vector<string> pins;
	for(int i=0; i<1000; i++){
		if(i<10){
			pins.pb("00"+to_string(i));
		} else if(i<100){
			pins.pb("0"+to_string(i));
		} else {
			pins.pb(to_string(i));
		}
	}

	int ans=0;
	for(auto x : pins){
		int d=x[0]-'0';
		if(!pos[d].empty()){
			int s=pos[d][0];
			d=x[1]-'0';
			auto itr=upper_bound(all(pos[d]),s);
			if(itr!=pos[d].end()){
				d=x[2]-'0';
				itr=upper_bound(all(pos[d]),*itr);
				if(itr!=pos[d].end()){
					ans++;
				}
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 512
s = input()

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print("Yes")
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print("Yes")
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print("Yes")
else:
    print("No")

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

bool isSquare(int n) {
    int a = (int)sqrt(n);
    return a * a == n;
}

void solve() {
    int n, d; cin >> n >> d;
    vector<vector<int>> v(n, vector<int>(d));
    for (int i = 0; i < n; ++i) for (int j = 0; j < d; ++j) cin >> v[i][j];

    int result = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int ans = 0;
            for (int k = 0; k < d; ++k) {
                ans += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            }
            if (isSquare(ans)) result++;
        }
    }
    cout << result << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	vec(A)
	cin>>N;
	fx(N){
		vecp(A)
	}
pb(A,INT_MAX)
	int ans=0;
	bool d=false;
	for(int x=1;x<=N;x++){
		if(A.at(x-1)<A.at(x)){
			while(x<N&&A.at(x-1)<=A.at(x)){
				x++;
			}
		}else if(A.at(x-1)>A.at(x)){
			while(x<N&&A.at(x-1)>=A.at(x)){
				x++;
			}
		}else{
			while(x<N&&A.at(x-1)==A.at(x)){x++;}
			if(A.at(x-1)<A.at(x)){
			while(x<N&&A.at(x-1)<=A.at(x)){
				x++;
			}
		}else if(A.at(x-1)>A.at(x)){
			while(x<N&&A.at(x-1)>=A.at(x)){
				x++;
			}
		}
        }
		ans++;
	}
	ce(ans)
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    double d[100];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>d[i];
    sort(d+1,d+n+1);
    d[0]=(d[1]+d[2])/2.0;
    for(int i=3;i<=n;i++)
        d[0]=(d[0]+d[i])/2.0;
    cout<<d[0];
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

int main(){
    ll n, x, a[100001];
    cin >> n >> x;
    ll cnt = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    if(a[0] > x){
        cnt += a[0] -x;
        a[0] = x;
    }
    for(ll i = 1; i < n; i++){
        if(a[i-1] + a[i] > x){
            cnt += a[i-1] + a[i] -x;
            a[i] = x - a[i-1];
        }
    }
    cout << cnt << endl;
}

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

int main(){
  int N,K,Y,X;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;

  int fair = 0;
  if(N <= K){
    fair = X*N;
  }else{
    fair = X*K + Y*(N - K);
  }

  std::cout << fair << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100010
#define mp make_pair
#define pb push_back
using namespace std;

struct data{
	int l,r,ind;
}arr[3*MAXN];

int tree[4*MAXN],lazy[4*MAXN],ans[MAXN];
vector<pair<int,int>>v;

void update(int x,int y,int val,int l,int r,int node){
	if(lazy[node]){
		tree[node]+=lazy[node];
		if(l!=r){
			lazy[node<<1]+=lazy[node];
			lazy[node<<1|1]+=lazy[node];
		}
		lazy[node]=0;
	}
	if(r<x || l>y)
		return ;
	if(l>=x && r<=y){
		tree[node]+=val;
		if(l!=r){
			lazy[node<<1]+=val;
			lazy[node<<1|1]+=val;
		}
		return ;
	}
	int mid=(l+r)>>1;
	update(x,y,val,l,mid,node<<1);
	update(x,y,val,mid+1,r,node<<1|1);
	tree[node]=tree[node<<1]+tree[node<<1|1];
}

int query(int id,int l,int r,int node){
	if(lazy[node]){
		tree[node]+=lazy[node];
		if(l!=r){
			lazy[node<<1]+=lazy[node];
			lazy[node<<1|1]+=lazy[node];
		}
		lazy[node]=0;
	}
	if(l==r)
		return tree[node];
	int mid=(l+r)>>1;
	if(id<=mid)
		return query(id,l,mid,node<<1);
	else
		return query(id,mid+1,r,node<<1|1);
}

int main(){
	int n,m,le,ri,id,prv=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>le>>ri;
		arr[i].l=le;arr[i].r=ri;arr[i].ind=i;
		v.pb(mp(ri-le+1,i));
	}
	sort(v.begin(),v.end());
	for(int d=1;d<=m;d++){
		id=lower_bound(v.begin(),v.end(),mp(d,0))-v.begin();
		id--;		
		ans[d]=v.size()-id-1;
		for(int i=prv;i<=id;i++){
			update(arr[v[i].second].l,arr[v[i].second].r,1,0,m,1);
		}
		for(int i=0;i<=m;i+=d){
			ans[d]+=query(i,0,m,1);
		}
		prv=id+1;
	}
	for(int i=1;i<=m;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 9324
#include <stdio.h>
#include <ctype.h>

int main(void){
	char c;

	while(1){
		scanf("%c",&c);

		if(c == '\n'){
			printf("\n");
			return 0;
		}

		if(islower(c)){
			printf("%c", toupper(c));
		}else if(isupper(c)){
			printf("%c", tolower(c));
		}else{
			printf("%c", c);
		}
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int A,B;
        cin >> A >> B;
        A--;B--;
        uf.unite(A,B);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans,uf.consize(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6424
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int mxN=200005;
int ok[200005]={};
int cnt=0;
void dfs(vector<int> adj[],int s)
{
ok[s]=1;
cnt++;
for(int i=0;i<adj[s].size();i++)
{
if(!ok[adj[s][i]])
{
dfs(adj,adj[s][i]);
}
}
}
int main()
{
int n,m;
cin>>n>>m;
vector<int> adj[n+1];
int x,y;
while(m--)
{
cin>>x>>y;
adj[x].push_back(y);
adj[y].push_back(x);
}
int ans=0;
for(int i=1;i<=n;i++)
{
cnt=0;
if(!ok[i])
{
dfs(adj,i);
}
ans=max(ans,cnt);
}
cout<<ans;
}


Measured memory_bytes: 24700
from collections import deque
# N = int(input())
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
MOD = 10 ** 9 + 7
A_p = []
A_n = []
for a in A:
  if a >= 0:
    A_p.append(a)
  else:
    A_n.append(-a)

A_p.sort(reverse=True)
A_n.sort(reverse=True)
A_p = deque(A_p)
A_n = deque(A_n)

p_top = 0
n_top = 0
ans_p = deque([])
ans_n = deque([])
for i in range(K):
  if len(A_p) == 0:
    ans_n.append(A_n.popleft())
  elif len(A_n) == 0:
    ans_p.append(A_p.popleft())
  elif A_p[0] >= A_n[0]:
    ans_p.append(A_p.popleft())
  else:
    ans_n.append(A_n.popleft())
if len(ans_n) % 2 == 1:
  if len(ans_p) == 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_n) == 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_p) > 0 and len(ans_n) > 0 and len(A_p) > 0 and len(A_n) > 0 and ans_p[-1] * A_p[0] >= ans_n[-1] * A_n[0]:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_p) > 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_n) > 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
ans = 1
for a in ans_p:
  ans = (a * ans) % MOD
for a in ans_n:
  ans = (-a * ans) % MOD
if ans != 0 and len(ans_n) % 2 == 1:
  ans = 1
  A_abs = [abs(a) for a in A]
  A_abs.sort()
  for i in range(K):
    ans = (ans * A_abs[i]) % MOD
  ans = (-ans) % MOD
print(ans)




Measured memory_bytes: 108484
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    a, b = input_nums()
    if b*2 >= a:
        print(0)
    else:
        print(a-b*2)

if __name__ == '__main__':
    main()

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

int main(){
    long long x;
    cin>>x;
    for(long long i=1;i<1000;i++){
        long long b=i*i*i*i*i-x;
        long long c;
        if(b<0){
            b=-b;
             c=pow(b,0.2);
            c=-c;
        }
        else{
             c=pow(b,0.2);
        }
        if(i*i*i*i*i-c*c*c*c*c==x){
            cout<<i<<" "<<c<<endl;
            break;
        }
        
    }
}

Measured memory_bytes: 4096
n = int(input())
ans = [0, 0, 0, 0]
for _ in range(n):
    a = input()
    if a == "AC":
        ans[0]+=1
    elif a=="WA":
        ans[1]+=1
    elif a == "TLE":
        ans[2]+=1
    else:
        ans[3]+=1
print("AC x ", ans[0])
print("WA x ", ans[1])
print("TLE x ", ans[2])
print("RE x ", ans[3])

Measured memory_bytes: 74736
#include <iostream>
#include <set>
#define endl '\n'

using namespace std;

int main() {
  set<string> s;

  int n = 0;
  cin >> n;

  string temp;

  for (int i = 0; i < n; i++) {
    cin >> temp;
    s.insert(temp);
  }

  cout << s.size();

  return 0;
}

Measured memory_bytes: 15556
#include <stdio.h>

int main(void){
	int A[100][100] ={0};
	int B[100][100] ={0};
	long long C[100][100] ={0};
	int i,j,k;
	int n,m,l;
	scanf("%d %d %d",&n,&m,&l);

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}

		for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&B[i][j]);
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				C[i][j] += (A[i][k] * B[k][j]);
			}
			if(j) printf(" ");
			printf("%lld",C[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

vector<ll>v[200000];
ll N;
ll res;

int main(){
	cin>>N;
	for(int i=1;i<N;i++){
		int p,q;
		cin>>p>>q;
		p--;
		q--;
		v[p].push_back(q);
		v[q].push_back(p);
	}
	for(ll i=0;i<N;i++){
		sort(v[i].begin(),v[i].end());
		res+=(i+1)*(N-i);
		for(ll j:v[i]){
			if(j>i)break;
			res-=(j+1)*(N-i);
		}
	}
	cout<<res<<endl;
}


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

using namespace std;

#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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    string S;

    cin >> S;

    for(auto& s:S){
        s = 'x';
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int A = Integer.parseInt(sc.next());
        final int B = Integer.parseInt(sc.next());
        final int C = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        long ans = 1000000000;
        int min = Math.min(x, y);
        int max = Math.max(x, y);
        long[] sum = new long[3];
        
        sum[0] = A*x + B*y;
        sum[1] = 2 * C * max;
        if (x >= y) {
            sum[2] = 2 * C * min + (max - min) * A;
        } else {
            sum[2] = 2 * C * min + (max - min) * B;
        }
        for (int i = 0; i < 3; i++) {
            ans = Math.min(ans, sum[i]);
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

int main(){

	map<char, string> m;

	m['A'] = "XY";
	m['B'] = "YX";
	m['X'] = ".Z";
	m['Y'] = "X.";
	m['Z'] = "WB";
	m['W'] = "BY";
	m['.'] = "..";

	string s;
	while(cin >> s, s!="#"){
		char pos = 'A';
		rep(i, s.size()){
			pos = m[pos][s[i]-'0'];
		}
		cout << (pos=='B'?"Yes":"No") << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
          if(i==0 || j==0)  dp[i][j]=0;
          else{
          if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
          else {
            dp[i][j]=dp[i][j-1]>dp[i-1][j]?dp[i][j-1]:dp[i-1][j];}}
    }}
    string ans = "";
	int i = n, j = m;
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i][j - 1]) j--;
		else if (dp[i - 1][j] == dp[i][j]) i--;
		else {
			ans += s[i - 1];
			i--, j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
    //cout<<dp[n][m];
    return 0;
}


Measured memory_bytes: 35456
# -*- coding:utf-8 -*-
# AIZU ONLINE JUDGE
# Introduction to Algorithms and Data Structures
# ALDS1_6_C
# Sort II - Quick Sort

def partition(A,B,p,r):
    x = A[r]
    i = p-1
    for j in xrange(p,r):
        if A[j] <= x:
            i += 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
            tmp = B[i]
            B[i] = B[j]
            B[j] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    tmp = B[i+1]
    B[i+1] = B[r]
    B[r] = tmp
    return i+1

def quick_sort(A,B, p, r):
    # q??????????????????p??¨r????????????????????°??????????????§???
    # ?????????p?????????q-1???????????§???????????????????????????q+1???r????¶???????
    # ?????§??????????????§????????????????????¨?????????
    if p < r:
        # ???????????£?????§?????????????°??????°?????????
        q = partition(A,B,p,r)
        quick_sort(A,B,p,q-1)
        quick_sort(A,B,q+1,r)

# alds1_2_c??????
def stable_check(sorted_values,sorted_suits,default_values,default_suits,n):
    for i in set(sorted_values):
        check_ss = []
        check_ds = []
        if i in sorted_values:
            for x in xrange(n):
                if i == sorted_values[x]:
                    check_ss.append(sorted_suits[x])
                if i == default_values[x]:
                    check_ds.append(default_suits[x])
            for x in xrange(len(check_ss)):
                if check_ss[x]!=check_ds[x]:
                    return "Not stable"
    return "Stable"

def main():
    n = input()
    A = []
    B = []
    for i in xrange(n):
        b,a = raw_input().split()
        A.append(int(a))
        B.append(b)
    cpA=list(A)
    setA = set(A)
    cpB=list(B)
    quick_sort(A,B,0,n-1)

    # Stable Check
    print stable_check(A,B,cpA,cpB,n)
    for i in xrange(n):
        line = "%s %s"%(B[i],A[i])
        print line

if __name__ == '__main__':
    main()

Measured memory_bytes: 13072
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if( x >= 30 ) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    sc.close();
  }
}

Measured memory_bytes: 35708
l =    [2,	3,	5,	7,	11,	13,	17,	19,	23,	29,	31,	37,	41,	43,	47,	53,	59,	61,	67,	71,
        73,	79,	83,	89,	97]
ans = 0
l3, l5, l15, l25, l75 = 0, 0, 0, 0, 0
n = int(input())
for i in l:
  temp = n
  c = 1
  while temp >= i:
    temp //= i
    c += temp
  if c >= 3:
    l3 += 1
  if c >= 5:
    l5 += 1
  if c >= 15:
    l15 += 1
  if c >= 25:
    l25 += 1
  if c >= 75:
    l75 += 1
ans += l75
ans += l25 * (l3-1)
ans += l15 * (l5-1)
ans += (l3-2) * l5*(l5-1) // 2
print(ans)

Measured memory_bytes: 3064
# include <stdio.h>

int main (void) {
    int D, N;

    scanf("%d%d", &D, &N);

    if (D == 0) {
        if (N == 100) {
            printf ("%d\n", N + 1);
        } else {
            printf ("%d\n", N);
        }
    }
    if (D == 1) {
        if (N == 100) {
            printf ("%d\n", 101 * 100);
        } else {
            printf ("%d\n", N * 100);
        }
    }
    if (D == 2) {
        if (N == 100) {
            printf ("%d\n", 101 * 10000);
        } else {
            printf ("%d\n", N * 10000);
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string side[4],Longitudinal[5];
int mox[2][2]={{1,-1},{0,-1}},moy[2][2]={{-1,1},{-1,0}};
char str[5]="URDL";
void serch(int x,int y,int then)
{
    if(then==-1)then=3;
    if(x==0&&y==0){
        cout<<endl;
        exit(0);
    }
    for(int i=0;i<4;i++){
        int now=(then+i)%4;
        if(now%2==0){
            if(y+moy[0][now/2]<5&&y+moy[0][now/2]>-1&&side[y+moy[1][now/2]][x]=='1'){
                cout<<str[now];
                serch(x,y+moy[0][now/2],now-1);
            }
        }
        else{
            if(x+mox[0][now/2]<5&&x+mox[0][now/2]>-1&&Longitudinal[y][x+mox[1][now/2]]=='1'){
                cout<<str[now];
                serch(x+mox[0][now/2],y,now-1);
            }
        }
    }
}
int main()
{
    for(int i=0;i<4;i++)cin>>Longitudinal[i]>>side[i];
    cin>>Longitudinal[4];
    cout<<"R";
    serch(1,0,0);
}

Measured memory_bytes: 1180
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] chars = scanner.next().toCharArray();
        Set<Character> charSet = new HashSet<>();
        for (char c : chars) {
            if (!charSet.add(c)) {
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 21844
/*
 * RD
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
//#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powm(ll a, ll b, ll m);


void solve()
{
	int n,h,w;
	cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
ll powm(ll a,ll b, ll m) {
	ll te=1;
	while(b) {
		if(b&1) te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Measured memory_bytes: 256