akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {

	int W , H , x , y , r ;

	scanf ( "%d%d%d%d%d" , &W , &H , &x , &y , &r );

	if ( x-r < 0 ) {
		printf ( "No\n" );
	} else if ( y-r < 0 ) {
		printf ( "No\n" );
	}else if ( x+r > W ) {
		printf ( "No\n" );
	}else if ( y+r > H ) {
		printf ( "No\n" );
	}else {
		printf ( "Yes\n" );
	}

	return 0 ;

}


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

int main(){
  int N;
  cin >> N;
  set<int> s;
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 14; j++){
      s.insert(4*i + 7*j);
    }
  }
  if(s.count(N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const ll inf = 1LL << 60;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////


int n;

//BIT 1-origin

ll sum(ll *bit, int i) {
	ll s = 0;
	while(i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll *bit, int i, ll x) {
	while(i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}

void range_add(ll *bit0, ll *bit1, int a, int b, ll x) { //[a, b]
	add(bit0, a, -x * (a - 1));
	add(bit1, a, x);
	add(bit0, b + 1, x * b);
	add(bit1, b + 1, -x);
}

ll range_sum(ll *bit0, ll *bit1, int a, int b) { //[a, b]
	return (sum(bit1, b) * b + sum(bit0, b)) 
		- (sum(bit1, a - 1) * (a - 1) + sum(bit0, a - 1));
}

ll bit0[200010], bit1[200010];

int N, M;
int A[100010];
ll S[200010];

void show_seg() {
	for(int i = 2 * M; i >= 1; i--) {
		debug(i, range_sum(bit0, bit1, i, i));
	}
}

void solve() {
	cin >> N >> M;
	n = 2 * M;
	rep(i, 0, N) {
		cin >> A[i];
	}
	rep(i, 0, N - 1) {
		if(A[i] < A[i + 1]) {
			range_add(bit0, bit1, A[i] + M + 1, A[i + 1] + M, 1);
			range_add(bit0, bit1, A[i + 1], A[i + 1], -(A[i + 1] - A[i]));
		}
		else {
			range_add(bit0, bit1, A[i] + 1, A[i + 1] + M, 1);
			range_add(bit0, bit1, A[i + 1], A[i + 1], -(A[i + 1] + M - A[i]));
		}
	}
	for(int i = 2 * M; i >= 1; i--) {
		S[i] = range_sum(bit0, bit1, i, i);
		if(i != 2 * M) S[i] += S[i + 1];
	}
	//debug(vec(S + 1, S + 2 * M + 1));
	ll res = inf;
	for(int i = 1; i <= M; i++) {
		MIN(res, S[i] + S[i + M]);
	}
	cout << res << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 5376
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=1005;
const double eps=1e-8;

struct edge {
    int next,to;
    double dist;
};

struct node {
    double x,y,r;
} p[maxn];

int fr[maxn];
int inq[maxn];
double ds[maxn];
edge e[maxn*maxn*4];
int tote=0;

inline int dcmp(double x) {
    if(fabs(x)<eps) return 0;
    return x>0?1:-1;
}

inline void addone(int u,int v,double w) {
    ++tote;e[tote].next=fr[u];fr[u]=tote;e[tote].to=v;e[tote].dist=w;
}

inline double euDist(double xi,double xj,double yi,double yj) {
    return sqrt((xj-xi)*(xj-xi)+(yj-yi)*(yj-yi));
}

inline double getDist(int i,int j) {
    if(dcmp(euDist(p[i].x,p[j].x,p[i].y,p[j].y)-p[i].r-p[j].r)<=0) return 0;
    return euDist(p[i].x,p[j].x,p[i].y,p[j].y)-p[i].r-p[j].r;
}

int q[maxn*maxn*4];

int main() {
    read(p[1].x);read(p[1].y);p[1].r=0;
    read(p[2].x);read(p[2].y);p[2].r=0;
    int n;
    read(n);
    REP(i,1,n) read(p[i+2].x),read(p[i+2].y),read(p[i+2].r);
    n+=2;
    memset(fr,-1,sizeof(fr));
    REP(i,1,n) REP(j,1,n) addone(i,j,getDist(i,j));
    REP(i,1,n) ds[i]=1e12;
    ds[1]=0;inq[1]=1;
    int l=1,r=0;q[++r]=1;
    for(;l<=r;) {
        int x=q[l++];inq[x]=0;
        RAL(i,x) if(dcmp(ds[e[i].to]-ds[x]-e[i].dist)>0) {
            ds[e[i].to]=ds[x]+e[i].dist;
            if(!inq[e[i].to]) {
                inq[e[i].to]=1;q[++r]=e[i].to;
            }
        }
    }
    printf("%.10lf\n",ds[2]);
    return 0;
}


Measured memory_bytes: 17024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int a, b, c, d, e;
string s;
int main(){
	cin >> a;
	cout << a / 2 + a % 2 << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void) {
  int n, ans[13] = {0, 1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60};
  scanf("%d", &n);
  printf("%d\n", ans[n]);
  return 0;
}


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

using namespace std;

int main(){
	string a,b;
	cin >>a>> b;
	int count1 = 0;
	int len = a.size();
	for(int i = 0 ; i < len; ++i){
        if(a[i]!=b[i]) count1++;
	}
	cout << count1;
	return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long 
const ll mod = 1000000007;

int N,M;
vector<int> a;

void solve(){
	ll dp[N+1];
	for(int i=0;i<N+1;i++) dp[i] = 0;

	dp[N] = 1;

	for(int i=N-1;0<=i;i--){
		if(a[i+1] == 1) dp[i] += dp[i+1];
		if(a[i+2] == 1) dp[i] += dp[i+2];

		dp[i] %= mod;
	}

	//for(int i=0;i<N;i++) cout << dp[i] << endl;

	cout << dp[0]%mod << endl;

}




int main(){
	cin >> N >> M;
	a.resize(N+2);
	for(int i=0;i<N+1;i++) a[i] = 1;
	a[N+1] = 0;
	int A;
	for(int i=0;i<M;i++){
		cin >> A;
		a[A] = 0;
	}
	solve();
	return 0;
}

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

using namespace std;

using ll = long long;

// https://lumakernel.github.io/ecasdqina/dynamic-programming/convex-hull-trick/LiChaoTree
// 最小化: Comp = less<T>, 最大化: Comp = greater<T>
template<class T = ll, class Comp = less<T> >
struct LiChaoTree {
	using Line = pair<T, T>;
	static inline T f(const Line& line, T x) { return line.first * x + line.second; }

	static Comp comp;

	int n;
	vector<Line> data;
	vector<int> used;
	vector<T> xs;

private:
	// [l, r)
	void add(int l, int r, const Line& line) {
		int l0 = l, r0 = r;
		int sz = 1;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1, sz <<= 1) {
			if (l & 1) add(l, l0, l0 + sz, line), l0 += sz, ++l;
			if (r & 1) --r, r0 -= sz, add(r, r0, r0 + sz, line);
		}
	}

	void add(int k, int l, int r, Line line) {
		if (!used[k]) {
			used[k] = true;
			data[k] = line;
			return;
		}

		T cur_ly = f(data[k], xs[l]), cur_ry = f(data[k], xs[r - 1]);
		T nex_ly = f(line, xs[l]), nex_ry = f(line, xs[r - 1]);

		if (comp(cur_ly, nex_ly) && comp(cur_ry, nex_ry)) return;
		if (comp(nex_ly, cur_ly) && comp(nex_ry, cur_ry)) {
			data[k] = line;
			return;
		}

		if (r - l == 1) return;

		int m = (l + r) >> 1;
		if (comp(cur_ly, nex_ly)) swap(data[k], line);
		if (comp(f(line, xs[m]), f(data[k], xs[m]))) {
			swap(data[k], line);
			add((k << 1) | 1, m, r, line);
		} else {
			add(k << 1, l, m, line);
		}
	}

public:
	// 前処理（事前にクエリのx座標を渡す必要あり）
	void addx(T x) { xs.emplace_back(x); }
	void prebuild() {
		sort(xs.begin(), xs.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());

		int sz = xs.size();
		n = 1;
		while (n < sz) n <<= 1;
		xs.resize(n, xs.back());

		data.resize(n << 1);
		used.resize(n << 1);
	}

	// 直線追加: ax + b
	void add(T a, T b) { add(0, n, Line(a, b)); }

	// 線分追加: ax + b (l <= x <= r)
	void add(T a, T b, T l, T r) {
		int li = lower_bound(xs.begin(), xs.end(), l) - xs.begin();
		int ri = upper_bound(xs.begin(), xs.end(), r) - xs.begin();
		add(li, ri, Line(a, b));
	}

	// ax+bが最小/最大となる(a,b)を取得
	Line get(T x) {
		int idx = -1;
		for (int i = lower_bound(xs.begin(), xs.end(), x) - xs.begin() + n; i > 0; i >>= 1) {
			if (!used[i]) continue;
			if (idx == -1 || comp(f(data[i], x), f(data[idx], x))) idx = i;
		}
		assert(idx > 0 && idx < (n << 1));
		return data[idx];
	}

	// ax+bの最小/最大値を取得
	T query(T x) { return f(get(x), x); }
};

template<class T, class Comp>
Comp LiChaoTree<T, Comp>::comp;

constexpr ll INF = 1e18;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll C;
	cin >> n >> C;
	vector<ll> h(n);

	LiChaoTree<> lct;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		lct.addx(h[i]);
	}
	lct.prebuild();

	ll dp = 0;
	lct.add(-2 * h[0], h[0] * h[0] + dp);
	for (int i = 1; i < n; i++) {
		dp = lct.query(h[i]) + h[i] * h[i] + C;
		lct.add(-2 * h[i], h[i] * h[i] + dp);
	}
	cout << dp << "\n";
	return 0;
}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		string s; cin >> s;
		double sh = stoi(s.substr(3, 2)) / 60.0 * 360;
		double lo = stoi(s.substr(0, 2)) * 5 / 60.0 * 360 + sh / 360.0 * 30;
		double dif = min(fabs(lo - sh), 360.0 - fabs(lo - sh));
		dump(lo); dump(sh); dump(dif);
		if (dif < 30.0)cout << "alert" << endl;
		else if (dif < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  int n, d;
  int p[10][10];
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> p[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      double dist = 0;
      for (int k = 0; k < d; k++) {
        dist += pow(p[i][k] - p[j][k], 2);
      }
      dist = sqrt(dist);
      if (floor(dist) == ceil(dist)) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

const ll N = 2e5+5, MOD = 1e9+7;
ll n, a, b;

ll fastexp(ll a, ll x, ll m) {
	if(x == 0) return 1;
	ll ans = 1;
	while(x > 0) {
		if(x&1) ans = (ans * a) % m;
		a = (a * a) % m;
		x /= 2;
	}
	return ans;
}

ll choose(ll n, ll k) {
	ll top = 1, bot = 1;
	for(int i = 1; i <= k; i++) {
		top *= n-i+1; top %= MOD;
		bot *= i; bot %= MOD;
	}
	return (top * fastexp(bot, MOD-2, MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> a >> b;

	if(n <= 2) {
		cout << 0 << '\n';
		return 0;
	}

	ll ans = (fastexp(2, n, MOD) - 1 + MOD) % MOD;
	ll ca = choose(n, a);
	ll cb = choose(n, b);
	ans = (ans - ca + MOD) % MOD;
	ans = (ans - cb + MOD) % MOD;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a, b, c;
    cin>>a>>b>>c;
    int ans = MAX2(0, c - a + b);
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

const int MOD = 1e9 + 7;
int num_b[200100];

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

  num_b[0] = 0;
  long ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      if (i == 0) {
        num_b[i] = 1;
      } else {
        num_b[i] = num_b[i-1] + 1;
      }
    } else {
      if (i == 0) {
        num_b[i] = 0;
      } else {
        num_b[i] = num_b[i-1];
        ans += num_b[i-1];
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  long A, B, x, tmp, r;
  cin >> A >>B;

  x = A * B;

  /* 自然数 a > b を確認・入替 */
  if(A<B){
    tmp = A;
    A = B;
    B = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  
  cout << x/B;
  
  return 0;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int ncr(int n,int r)
{
    int lob=1,hor=1;
    f(i,0,r-1)
    {
        lob=(lob*(n-i))%mod;
        hor=(hor*(i+1))%mod;
    }
    int ses=lob*bigmod(hor,mod-2);
    if(ses<0)ses+=mod;
    ses=ses%mod;
    return ses;
}
 main()
{
    fast
    int n,a,b;
    cin>>n>>a>>b;
    int ses=(bigmod(2,n)-1+mod)%mod;
    ses=(ses-ncr(n,a))%mod;if(ses<0)ses+=mod;ses=ses%mod;
     ses=(ses-ncr(n,b))%mod;if(ses<0)ses+=mod;ses=ses%mod;
    cout<<ses<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

int solve(int n, int c, const V& ss, const V& ts, const V& cs){
    V is(n);
    iota(begin(is), end(is), 0);
    sort(begin(is), end(is), [&](int i, int j){return ss[i] < ss[j];});

    vector<P> rs(c, P(0, 0));
    for(const auto& i : is){
        for(auto& r : rs){
            if(r.first < ss[i] || (r.first == ss[i] && r.second == cs[i])){
                r.first = ts[i];
                r.second = cs[i];
                break;
            }
        }
    }

    return c - count(begin(rs), end(rs), P(0, 0));
}

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

    int n, c;
    cin >> n >> c;
    V ss(n), ts(n), cs(n);
    for(int i = 0; i < n; i++){
        cin >> ss[i] >> ts[i] >> cs[i];
    }

    cout << solve(n, c, ss, ts, cs) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll l[100001];
ll r[100001];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
	}
	priority_queue<ll> L;
	priority_queue<ll, vector<ll>, greater<ll>> R;
	ll offL = 0, offR = 0, m = 0;
	L.push(-INF);
	R.push(INF);
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			offR += (r[i - 1] - l[i - 1]);
			offL -= (r[i] - l[i]);
		}
		if (l[i] < L.top() + offL) {
			m += L.top() + offL - l[i];
			R.push(L.top() + offL - offR);
			L.push(l[i] - offL);
			L.push(l[i] - offL);
			L.pop();
		}
		else if (R.top() + offR < l[i]) {
			m += l[i] - (R.top() + offR);
			L.push(R.top() + offR - offL);
			R.push(l[i] - offR);
			R.push(l[i] - offR);
			R.pop();
		}
		else {
			L.push(l[i] - offL);
			R.push(l[i] - offR);
		}
	}
	cout << m << endl;
}


Measured memory_bytes: 3572
n,ans,chg=int(input()),0,1
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
while a!=b and chg:
	chg=0
	for i in range(n):
		de,td=b[i-1]+b[i-n+1],b[i]-a[i]
		if td>=de:
			x=td//de
			b[i]-=x*de
			ans+=x
			chg=1
if a!=b:
	print(-1)
else:
	print(ans)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}

void solve() {
    ll N, X; cin >> N >> X;
    vector<ll> x(N);
    rep(i, N) cin >> x[i];

    ll res = abs(X-x[0]);
    if(N == 1){
        cout << res << endl;
        return;
    }

    rep(i, N-1){
        res = gcd(res, abs(x[i] - x[i+1]));
    }

    cout << res << endl;
}

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


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N, x;
	vector<int> a;

	cin >> N;
	cin >> x;
	inputVector(a, N);

	int ret = 0;
	if (a[0] > x) {
		ret += a[0] - x;
		a[0] = x;
	}
	for (int i = 1; i < N; i++) {
		ret += max(0ll, a[i] + a[i - 1] - x);
		a[i] -= max(0ll, a[i] + a[i - 1] - x);
	}
	cout << ret << endl;

    return 0;
}


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

int main() {
    int d;
    cin >> d;
    if (d == 25) cout << "Christmas" << endl;
    else if (d == 24) cout << "Christmas Eve" << endl;
    else if (d == 23) cout << "Christmas Eve Eve" << endl;
    else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int WHITE = 0;
int GRAY = 1;
int BLACK = 2;

int i, j, n, e, v, sum, M[100][100];

int prim(){
    int u, minv;
    int d[100], p[100], color[100];

    for(i=0;i<n;i++){
        d[i] = 100000000;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] =0;
    

    while(1){
        minv = 100000000;
        u = -1;
        for(i=0;i<n;i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1)
        break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v] != BLACK && M[u][v] != 100000000){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    sum = 0;
    for(i=0;i<n;i++){
        if(p[i] != -1)
        sum += M[i][p[i]];
    }
    return sum;
}

int main(){
    scanf("%d", &n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d", &e);
            M[i][j] = (e == -1) ? 100000000 : e;
        }
    }

    printf("%d\n", prim());

    return 0;
}

Measured memory_bytes: 1776
import java.util.Scanner;

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

    String c = scanner.next();

    // 母音か子音かを判定する（a, i, u, e, oのどれかなら母音）
    // 母音なら"vowel"、子音なら"consonant"
    // *データ型どうしの比較は「==」
    // *オブジェクトどうしの比較は「.equals」
    if(c.equals("a") || c.equals("i") || c.equals("u")
       || c.equals("e") || c.equals("o")) {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }
  }
}

Measured memory_bytes: 35588
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1

# for x in range(1, n+1):
#     score = math.floor(a*x/b) - a* math.floor(x/b)
#     if max_score < score:
#         max_score = score
#     elif x > b:
#         break

if b > n:
    max_score = math.floor(a*n/b)
else:
    max_score = math.floor(a*(b-1)/b)

print(max_score)

Measured memory_bytes: 9104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class abc85_c
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int sum = input[1];
            int tmp=0;
            int i,j,k;

            for(i=n; i>=0; i--)
            {
                for(j=0; i+j<=n; j++)
                {
                    tmp += 10000*n-5000*i-9000*j;
                    k = n-i-j;
                    if(tmp == sum && i+j+k == n)
                    {
                        WriteLine(k+" "+i+" "+j);
                        return;
                    }
                    tmp = 0;
                }
            }
            WriteLine("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n,d; cin>>n>>d;
	int ans=0;
	rep(i,1,n+1){
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				int k=i/j;
				if(j/10==0 && k/10==0){
					//cout<<i<<" "<<j<<" "<<i/j<<endl;
					if((k*10+j)<=d)ans++;
					if((j*10+k)<=d)ans++;
					if(j==k && k*10+k<=d)--ans;
				}
			}
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3572
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<cstring>
#include<queue>

using namespace std;

string str;
int main()
{	
	char str_a[110], str_b[110], str_c[110];
	int len_a, len_b, len_c;
	int a=0,b=0,c=0;
	char next = 'a';
	cin >> str_a >> str_b >> str_c;

	len_a = strlen(str_a);
	len_b = strlen(str_b);
	len_c = strlen(str_c);

	while (1) {
		if (next == 'a') {
			if (len_a == 0) {
				cout << "A" << endl;
				break;
			}
			next = str_a[a++];
			len_a--;
		}
		else if (next == 'b') {
			if (len_b == 0) {
				cout << "B" << endl;
				break;
			}
			next = str_b[b++];
			len_b--;
		}
		else if (next == 'c') {
			if (len_c == 0) {
				cout << "C" << endl;
				break;
			}
			next = str_c[c++];
			len_c--;
		}
	}
	return 0;
}

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

int cnt,ccnt = 0;
int len;
string s, ss, tmp;
int flag = 0;
int fflag=0;
char c;
int cc=0;
vector<string> v_list;
pair<string,int> ps;
int main() {
	while (cin >> s) {
		if (s == "0") {
			break;
		}
		map<string,int> m;
		fflag=0;
		//v_list.push_back(s);
		len = s.length();
		queue<pair<string,int> > qq;
		qq.push(make_pair(s,0));
		while (!qq.empty()) {
			ps = qq.front();
			qq.pop();
			c = ps.first[0];
			ccnt=ps.second;
			flag = 0;

			for (int i = 1; i < len; i++) {
				if (c != ps.first[i]) {
					//cout<<ps.first[i]<<endl;//deb
					flag = 1;
					cc=i;
					break;
				}
			}
			if (flag) {
				for (int i = cc-1; i < len - 1; ++i) {
					tmp = ps.first;
					if (ps.first[i] != ps.first[i+1]) {
						if (ps.first[i] != 'r' && ps.first[i+1] != 'r') {
							tmp[i] = 'r';
							tmp[i + 1] = 'r';
							if(m[tmp])continue;
							m[tmp]=ps.second;
							qq.push(make_pair(tmp,ccnt+1));
						}
						if (ps.first[i] != 'g' && ps.first[i+1] != 'g' ){
							tmp[i] = 'g';
							tmp[i + 1] = 'g';
							if(m[tmp])continue;
							m[tmp]=ps.second;
							qq.push(make_pair(tmp,ccnt+1));
						}
						if (ps.first[i] != 'b' && ps.first[i+1] != 'b') {
							tmp[i] = 'b';
							tmp[i + 1] = 'b';
							if(m[tmp])continue;
							m[tmp]=ps.second;
							qq.push(make_pair(tmp,ccnt+1));
						}
					}
				}
			} else {
				cout << ccnt << endl;
				fflag=1;
				break;
			}
		}
		if(!fflag){printf("NA");cout<<endl;};
	}
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int l = in(), r = in();
    ans += (r - l + 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
S=list(input())

flag=0

for i in range(len(S)):
    if (i+1)%2==0:
        if S[i]=='R':
            flag+=1
    elif (i+1)%2==1:
        if S[i]=='L':
            flag+=1
if flag==0:
    print('Yes')
else :
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<long> A(N), B(N);
  for (int i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  long ans = 0;
  for (int i = N - 1; i >= 0; i--)
  {
    long mod = (A[i] + ans) % B[i];
    if (mod != 0)
      ans += B[i] - mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int k;
    cin>>k;

    int cur=0;
    for(int i=1;i<=k;++i)
    {
        cur=((cur*10)%k+7)%k;
        if(!cur)
        {
            cout<<i;
            return;
        }
    }

    cout<<-1;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

int poker(int& a){
    int i = 0;
    int pow[13] = {2,3,4,5,6,7,8,9,10,11,12,13,1};
    for ( i = 0; i <13; ++i) {
        if (pow[i] == a){
            break;
        }
    }
    return i;
}

int main() {
    int a,b = 0;
    int apow,bpow = 0;
    cin >> a >> b;
    apow = poker(a);
    bpow = poker(b);
    if (apow > bpow){
        cout << "Alice" << endl;
    } else if (apow < bpow) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  map<int, int> amap;
  ll ans = 1;
  amap[-1] = 3;
  for(int i=0;i<N;++i) {
    ans *= amap[A[i]-1]-amap[A[i]];
    ans %= mod;
    amap[A[i]]++;
  }
  cout<<ans<<endl;
}



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

int n;
long long a, b;

int main() {
	scanf("%d", &n);
	a = b = 1LL;
	for(int i=0;i<n;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		long long v1 = (a+x-1)/x; 
		long long v2 = (b+y-1)/y;
		a = max(v1, v2)*x;
		b = max(v1, v2)*y;
	}
	cout<<a+b<<endl;
	
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n)  for (int i = 0; i < n; i++)
#define loop(i,a,n)  for (int i = a; i <= n; i++)
#define deb(x) cout << #x << " = " << x <<'\n'
typedef long long ll;

int main(){
    string st;
    cin >> st;
    if(st[st.size()-1] == 's'){
        cout << st << "es";
    }else{
        cout << st << 's';
    }
    cout << endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    int n, a, b;
    cin >> n >> a >> b;

    print(a < b ? a : b, a + b - n > 0 ? a + b - n : 0);

    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())

S = ["".join(["." for i in range(W+2)])]
for i in range(H):
    S.append("."+input()+".")
S.append("".join(["." for i in range(W+2)]))

isok = True
for h in range(1,H+1):
    for w in range(1,W+1):
        if S[h][w] == "#":
            b = 0
            if S[h][w-1] == "#": b+=1
            if S[h][w+1] == "#": b+=1
            if S[h-1][w] == "#": b+=1
            if S[h+1][w] == "#": b+=1
            if b==0:
                isok = False
                break
    if not isok: break

if isok:
    print("Yes")
else:
    print("No")

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

#define PI 3.14159265358979323846

int main(){
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);

	if(x == a*a*b){
		double ans = 0.0000000000000;
		printf("%.16f",ans);
		return 0;
	}

	if(x<= a*a*b/2.0){ //半分以下の場合
		double tan = (double)2.0*x/(double)(a*b*b);
		double radian = atan(tan);
		double degree = 90.000000000000 - radian * 180.0000000000 / PI;
		printf("%.16f",degree);
		//printf("%.16f",tan);

	}else{ //半分超える場合
		double tan = (double)(a*a*a) / (double)((a*a*b - x)*2.0);
		double radian = atan(tan);
		double degree = 90.000000000000 - radian * 180.0000000000 / PI;
		printf("%.16f",degree);
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm> 
#include<cmath>
#include<cstring>
#define int long long 
using namespace std;
int n;
int a[3000303];
int ans;

signed main()
{
  int i,j,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&a[i]);
  int sum=0,pd=0;
  for(i=1;i<n;i++)
    {
      if(!pd)
	    sum+=a[i]*2,pd=1;
	     else
	       sum-=a[i]*2,pd=0;
	}
  ans=(sum+a[i]*2)/2;
  printf("%d ",ans);
  for(i=1;i<n;i++)
    {
	  printf("%d ",a[i]*2-ans);
	  ans=a[i]*2-ans;
	}
} 

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a[3], cnt[101] = {};
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 3; i++)cnt[a[i]]++;
	int ans = 0;
	for (int i = 1; i <= 100; i++)if (cnt[i])ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int n;
    cin>>n>>s;
    int m=s.length();
    int a;
    string ans="";
    string t;
    for(int i=0;i<m;i++){
    	a=s[i]-'A';
    	a+=n;
    	a%=26;
    	t="A";
    	for(int i=0;i<a;i++){
    		t[0]++;
    	}
    	ans+=t;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

class UF {
	vector<int> root;

public:
	UF(int n)
	{
		root = vector<int>(n, -1);
	}

	int getRoot(int x)
	{
		if(root[x] == -1) return x;
		return root[x] = getRoot(root[x]);
	}

	void update(int x, int y)
	{
		x = getRoot(x);
		y = getRoot(y);
		if(x == y) return;
		if(x > y) swap(x, y);
		root[y] = x;
	}
};

int main()
{
	int n, mm;
	cin >> n >> mm;
	int p[100001];
	for(int i = 0; i < n; i++){
		cin >> p[i];
		p[i]--;
	}
	UF uf(n);
	for(int i = 0; i < mm; i++){
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		uf.update(x, y);
	}
	map<int, vector<int> > m;
	for(int i = 0; i < n; i++){
		int r = uf.getRoot(i);
		if(m.find(r) == m.end()) m[r] = vector<int>();
		m[r].push_back(i);
	}
	int ans = 0;
	for(auto itr = m.begin(); itr != m.end(); itr++){
		vector<int> indexList = (*itr).second;
		set<int> pSet;
		for(int i = 0; i < indexList.size(); i++){
			pSet.insert(p[indexList[i]]);
		}
		for(int i = 0; i < indexList.size(); i++){
			if(pSet.find(indexList[i]) != pSet.end()) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11904
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] cnt = new int[n];
		for (int i = 0; i < n; i++) {
			cnt[sc.nextInt()]++;
		}
		sc.close();

		int min = 0;
		for (int i = 0; i < n; i++) {
			if (cnt[i] > 0) {
				min = i;
				break;
			}
		}
		int max = n;
		for (int i = n - 1; i > 0; i--) {
			if (cnt[i] > 0) {
				max = i;
				break;
			}
		}

		if (min != (max + 1) / 2) {
			System.out.println("Impossible");
			return;
		}
		if (max % 2 == 0 && cnt[min] != 1) {
			System.out.println("Impossible");
			return;
		}
		if (max % 2 == 1 && cnt[min] != 2) {
			System.out.println("Impossible");
			return;
		}

		for (int i = min + 1; i <= max; i++) {
			if (cnt[i] < 2) {
				System.out.println("Impossible");
				return;
			}
		}
		System.out.println("Possible");
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

int a, b;

int main() {
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  for(int i=1; i<=s.size(); i++) {
    if(i%2 == 0 && s[i-1] == 'R') {
      cout << "No" << endl;
      return 0;
    }
    else if(i%2 != 0 && s[i-1] == 'L') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3636
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
pll a[100017];
void solve(){
	ll n,i,x,tot;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		a[i]=mp(x,i);
	}
	tot=0;
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i].second%2 == 1 and i%2==0)
			tot++;
	}
	cout<<tot;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5208