akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {
    string s, t, u; cin >> s >> t >> u;
    cout << s[0] << t[0] << u[0] << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k, q, i;
    cin >> n >> k >> q;
    int res[n+1] = {0};
    for(i=0; i<n; i++){
        res[i] = k-q;
    }
    for(i=0; i<q; i++){
        int input;
        cin >> input;
        res[input-1]++;
    }
    for(i=0; i<n; i++){
        if(res[i] > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 1024
#d
h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
s = [input() for _ in range(h)]
inf = 99999999
dist = [[inf]* w for i in range(h)]
queue = []
queue.append([ch-1,cw-1])
dist[ch-1][cw-1] = 0

dx=[1,0,-1,0]
dy=[0,1,0,-1]

wx=[-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2]
wy=[-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2]
import sys
warp = 0
wall = []
while True:
    while queue!=[]:
        y,x = map(int, queue.pop())

        if x == dw-1 and y ==dh-1:
            print(dist[y][x])
            sys.exit()

        for i in range(len(dx)):#まず壁探知
            next_x = x +dx[i]
            next_y = y +dy[i]

            if 0 <= next_x < len(s[0]) and 0 <= next_y < len(s):
                if dist[next_y][next_x] == inf: 
                    if s[next_y][next_x] == ".":
                        queue.append([next_y,next_x])
                        dist[next_y][next_x] = dist[y][x]
                    else:
                        wall.append([y,x]) 
    wall = list(map(list, set(map(tuple, wall))))
    while wall != []:
        y,x = map(int, wall.pop())
        for i in range(len(wx)):
            next_x = x +wx[i]
            next_y = y +wy[i]

            if 0 <= next_x < len(s[0]) and 0 <= next_y < len(s):
                if dist[next_y][next_x] == inf: 
                    if s[next_y][next_x] == ".":
                        queue.append([next_y,next_x])
                        dist[next_y][next_x] = dist[y][x]+1
    queue = list(map(list, set(map(tuple, queue))))
    
    if queue == []:
        print("-1")
        sys.exit()

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

int	main()
{
	int	X, N;
	cin >> X >> N;
	if (N == 0) {
		cout << X << endl;
		return 0;
	}
	set<int>	p_set;
	int 		p;
	for (int i = 0; i < N; ++i) {
		cin >> p;
		p_set.insert(p);
	}
	int	argmin = 0;
	int	diff, min_diff;
	min_diff = diff = abs(0 - X);	
	for (int i = 1; i <= 101; ++i) {
		if (p_set.count(i)) continue;
		diff = abs(i - X);
		if ((min_diff > diff)) {
			min_diff = diff;
			argmin = i;
		}
	}
	cout << argmin << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <queue>

int main(){
    int x, y, a, b, c;
    std::cin >> x >> y >> a >> b >> c;
    std::priority_queue<std::pair<int, int>> pq;
    int t[] = {a, b, c};
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < t[i]; j++){
            int tmp;
            std::cin >> tmp;
            pq.push({tmp, i});
        }
    }
    unsigned long long ans = 0;
    int total = 0;
    int count[2] = {0, 0}; // {a, b, c}
    int limit[2] = {x, y};
    while(total < x+y){
        auto p = pq.top();
        pq.pop();
        switch (p.second) {
        case 0:
            if(count[0] < limit[0]){
                ans += p.first;
                total++;
                count[0]++;
            }
            break;
        case 1:
            if(count[1] < limit[1]){
                ans += p.first;
                total++;
                count[1]++;
            }
            break;
        case 2:
            ans += p.first;
            total++;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>

int main(void)
{
	char a[81];
	int n=0,i,j;
	while(scanf("%s",a)!=EOF){
		i=0;
		j=0;
		while(a[i]!='\0'){
			if(a[i]>='0'&&a[i]<='9'){
				j*=10;
				j+=a[i]-'0';
			}else{
				n+=j;
				j=0;
			}
			i++;
		}
		n+=j;
	}
	printf("%d\n",n);
	return 0;
}

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

int main(void) {
	int N;
	long long sum = 0;
	cin >> N;

	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 3624
//file_name:ABC43_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    int ans = 99999999;
    rep(i,201){
        int ans2 = 0;
        rep(j,n){
            ans2 += (i-100-a[j])*(i-100-a[j]);
        }
        ans = min(ans,ans2);
    }




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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200000
#define ll long long
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
struct D{int c[2]; D(){} D(int a, int b){c[0]=a,c[1]=b;} inline D operator + (D x){return D(c[0]+x.c[0],c[1]+x.c[1]);}}f[MAXN+5];
inline bool operator < (D a, D b){return 1ll*a.c[1]*b.c[0] < 1ll*b.c[1]*a.c[0];} struct I{int i; I(int _i=0){i=_i;}}; set<I> S;
inline bool operator < (I a, I b){return f[a.i]<f[b.i]?true:f[b.i]<f[a.i]?false:a.i<b.i;} int fa[MAXN+5], _fa[MAXN+5], n; ll Ans;
inline int getf(int x){return x^_fa[x]?_fa[x]=getf(_fa[x]):x;} inline void Union(int x, int y){(x=getf(x))^(y=getf(y))?_fa[x]=y:0;}
int main()
{
	n = read(); for(rint i = 2; i <= n; fa[i++] = read()); for(rint i = 1; i <= n; ++f[i].c[read()], i++);
	_fa[1] = 1; for(rint i = 2; i <= n; _fa[i] = i, S.insert(i++));
	for(rint v, p; S.size(); Ans += 1ll*f[p].c[1]*f[v].c[0], f[p] = f[p]+f[v], p>1?S.insert(p),0:0, Union(v,p))
		v = S.begin()->i, S.erase(S.begin()), (p=getf(fa[v]))>1?S.erase(S.find(p)),0:0; printf("%lld\n",Ans); return 0;
}

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

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

int main() {
    int H, W;
    cin >> H >> W;
    string field[H];
    rep(i, H) {
        cin >> field[i];
    }

    int sum_road = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '.') sum_road++;
        }
    }

    int sy = 0, sx = 0, gy = H - 1, gx = W - 1;
    
    int dist[H][W];
    memset(dist, -1, sizeof(dist));
    dist[sy][sx] = 0;

    queue<pair<int, int>> que;
    que.push(pair<int, int>(sy, sx));

    while(!que.empty()) {
        int vy = que.front().first;
        int vx = que.front().second;
        que.pop();

        for (int dir = 0; dir < 4; dir++) {
            int ny = vy + dy[dir];
            int nx = vx + dx[dir];

            if (ny < 0 || ny >= H || nx < 0 || nx >= W) {
                continue;
            }
            if (field[ny][nx] == '#') continue;
            if (dist[ny][nx] == -1) {
                dist[ny][nx] = dist[vy][vx] + 1;
                que.push(pair<int, int>(ny, nx));
            }
        }
    }

    if (dist[gy][gx] == -1) cout << -1 << endl;
    else {
        int g = dist[gy][gx];
        sum_road -= g + 1;
        cout << sum_road << endl;
    }
    
    return 0;
}

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

int main()
{
    int n, d, a, sum = 0;

    cin >> n >> d;

    for( int i = 0; i < n; i++ )
    {
        cin >> a;
        a < d ? : sum += a - d;
    }

    if( sum == 0 )
        cout << "kusoge" << endl;
    else
        cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3108
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.math;
import std.array;

void main() {
  int x, y, a, b, c;
  readf("%d %d %d %d %d\n", &x, &y, &a, &b, &c);
  auto p = readln.chomp.split.map!(to!int).array.sort().array;
  auto q = readln.chomp.split.map!(to!int).array.sort().array;
  auto r = readln.chomp.split.map!(to!int).array.sort().array;

  int[] red = p[$-x..$];
  int[] green = q[$-y..$];

  int i=0, j=0, k=0;
  while((i<x || j<y) && k<c) {
    if(i<x && j<y) {
      if(red[i] < green[j]) {
        if(red[i] < r[$-k-1]) {
          red[i] = r[$-k-1];
          i++; k++;
        }
        else break;
      }
      else {
        if(green[j] < r[$-k-1]) {
          green[j] = r[$-k-1];
          j++; k++;
        }
        else break;
      }
    }
    else if(i<x) {
      if(red[i] < r[$-k-1]) {
        red[i] = r[$-k-1];
        i++; k++;
      }
      else break;
    }
    else {
      if(green[j] < r[$-k-1]) {
        green[j] = r[$-k-1];
        j++; k++;
      }
      else break;
    }
  }
  long sum = 0;
  foreach(rd; red) sum+=rd;
  foreach(gn; green) sum+=gn;
  writeln(sum);
}


Measured memory_bytes: 13384
#include <iostream>
#include <vector>

using namespace std;

const int MAX = 1000000000;

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

    vector<unsigned> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    int m = 0;
    for (auto &x : v)
    {
        while (x % 2 == 0)
        {
            x /= 2;
            ++m;
        }
    }

    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long INT;
char S[8010]; 
INT A[4010][3]; 
int main(){
	INT i, j, n, s=0;
	cin>>n>>S;
	for(i=n-1;i>=0;i--){
		if(S[i]=='R')A[i][0]++;
		if(S[i]=='G')A[i][1]++;
		if(S[i]=='B')A[i][2]++;
		for(j=0;j<3;j++)A[i][j] += A[i+1][j];
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(S[i]=='R'&& S[j] == 'G') s += A[j+1][2] - (S[j+j-i]=='B'?1:0);
			if(S[i]=='R'&& S[j] == 'B') s += A[j+1][1] - (S[j+j-i]=='G'?1:0);
			if(S[i]=='B'&& S[j] == 'G') s += A[j+1][0] - (S[j+j-i]=='R'?1:0);
			if(S[i]=='G'&& S[j] == 'R') s += A[j+1][2] - (S[j+j-i]=='B'?1:0);
			if(S[i]=='B'&& S[j] == 'R') s += A[j+1][1] - (S[j+j-i]=='G'?1:0);
			if(S[i]=='G'&& S[j] == 'B') s += A[j+1][0] - (S[j+j-i]=='R'?1:0);
		}
	}
	cout << s;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

template< class T >
const vector<T> operator*( const vector<T>& a, const vector<T>& b )
{
	T size = a.size();
	vector<T> ret( size );
	REP( i , size ) ret[i] = a[b[i]];
	return ret;
}

template< class T >
const vector<T> operator~( const vector<T>& a )
{
	T size = a.size();
	vector<T> ret( size );
	REP( i , size ) ret[a[i]] = i;
	return ret;
}

template< class T >
void makeUnitPermutation( vector<T>& a )
{
	T size = a.size();
	REP( i , size ) a[i] = i;
}

void print( const vector<ll>& v )
{
	for( ll i = 0, end = v.size() - 1; i < end; ++i )
		cout << v[i] + 1 << " ";
	cout << v[v.size()-1] + 1 << endl;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> p( n );
	vector<ll> q( n );
	REP(i,n) {cin>>p[i]; --p[i];}
	REP(i,n) {cin>>q[i]; --q[i];}

	auto pInv = ~p;
	auto qInv = ~q;
	auto cycle = q * pInv * qInv * p;

	auto kk = ( k - 1 ) / 6;
	auto cycleK = cycle; makeUnitPermutation( cycleK );
	{
		auto x = cycle;
		while (kk > 0)
		{
			if (kk & 1) cycleK = cycleK * x;
			x = x * x;
			kk >>= 1;
		}
	}

	auto center = cycleK; makeUnitPermutation( center );
	REP(i,( k - 1 ) % 6 + 1)
	{
		if( i == 0 ) center = p;
		else if( i == 1 ) center = q;
		else if( i == 2 ) center = center * pInv;
		else if( i == 3 ) center = cycle * pInv;
		else if( i == 4 ) center = cycle * qInv;
		else if( i == 5 ) center = cycle * p * qInv;
	}

	auto ans =cycleK * center * ( ~cycleK );

	print( ans );
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 100010;

V<int> g[maxn];

int dfs(int v, int p) {
	V<int> vec;
	for (int to : g[v]) if (to != p) {
		vec.pb(dfs(to, v));
	}

	V<int> cnt(30);

	int dup = -1;
	for (int i = 0; i < 30; ++i) {
		for (int x : vec) {
			if ((x >> i) & 1) {
				cnt[i]++;
			}
		}
		if (cnt[i] >= 2) {
			dup = i;
		}
	}

	for (int i = dup + 1; i < 30; ++i) {
		if (cnt[i] == 0) {
			int mask = (1 << i);
			for (int x : vec) {
				mask |= x;
			}
			mask &= ~((1 << i) - 1);
			dump(mp(v, mask));
			return mask;
		}
	}
}

int main() {
	int N; cin >> N;
	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].pb(b); g[b].pb(a);
	}
	int res = dfs(0, -1);
	for (int i = 30; i >= 0; --i) {
		if ((res >> i) & 1) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

const int maxn = 1e6;

long long a[maxn];
int main() {
	ios::sync_with_stdio(false);
  cin.tie(0);
  int n = 0;
  cin >> n;
  long long total = 0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  	total += a[i];
  }
  long long res = 1e18;
  long long sum = 0;
  for(int i=0;i<n;i++) {
  	sum += a[i];
    res = min(res, abs(total - sum * 2));
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	map<int,int>m;
	int a[n];
	for(int i=0;i<n;i++)	cin>>a[i],m[a[i]]++;
	
	int ans=0;
	for(auto x:m){
		int k=x.second;
		ans+=(k*(k-1))/2;
	}

	for(int i=0;i<n;i++){
		int k=m[a[i]];
		ans-=(k*(k-1))/2;
		m[a[i]]--;
		
		k=m[a[i]];
		ans+=(k*(k-1))/2;

		cout<<ans<<"\n";
		ans-=(k*(k-1))/2;;
		m[a[i]]++;
		k=m[a[i]];
		ans+=(k*(k-1))/2;

	}
	// cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ri = n-1, li = 0;
    int ans = INF;
    int cw = 0, cr = 0;
    rep(i,n){
        if(s[i] == 'R')cr++;
        else cw++;
    }
    ans = min(cr,cw);
    int cnt = 0;
    while(li < ri){
        if(s[li] == 'W' && s[ri] == 'R'){
            cnt++;
            li++;
            ri--;
            // cout << li << " " << ri << endl;
            continue;
        }
        if(s[li] == 'R')li++;
        if(s[ri] == 'W')ri--;
    }
    ans = min(ans,cnt);

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define mod 1000000007
#define N 200001
typedef long long ll;
using namespace std;
ll inv[N],fac[N],ifac[N];
int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;

  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<=h+w;i++){
    inv[i]=(-mod/i)*inv[mod%i]%mod;
    fac[i]=fac[i-1]*i%mod;
    ifac[i]=ifac[i-1]*inv[i]%mod;
    //cout<<inv[i]<<" "<<fac[i]<<" "<<ifac[i]<<endl;
  }
  ll ans=0;
  for(int i=1;i<=h-a;i++){
    ll tmp=1;
    tmp=1ll*tmp*fac[i+b-2]%mod*ifac[i-1]%mod*ifac[b-1]%mod;
    tmp=1ll*tmp*fac[(w-b-1)+h-i]%mod*ifac[w-b-1]%mod*ifac[h-i]%mod;
    ans=(ans+tmp)%mod;
  }
  cout<<(ans+mod)%mod<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n,m; cin >> n >> m;
  int AC = 0, penalty = 0;
  vector<bool> ACed(n,false);
  vector<int> WA(n,0);
  rep(i,m){
    int q; string o; cin >> q >> o;
    q--;
    if(o == "AC"){
      if(!ACed[q]){
        ACed[q] = true;
        AC++;
      }
    }else{
      if(!ACed[q]) WA[q]++;
    }
  }
  int WA_sum = 0;
  rep(i,n){
    if(ACed[i]) WA_sum += WA[i];
  }
  
  cout << AC << " " << WA_sum << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int l[2][4];
	for (int i = 0; i < 4; i++){
		cin >> l[0][i] >> l[1][i];
	}
	for (int i = 0; i < 4; i++){
		switch (l[0][i]){
		case 1:
			cout << l[1][i] * 6000 << endl;
			break;
		case 2:
			cout << l[1][i] * 4000 << endl;;
			break;
		case 3:
			cout << l[1][i] * 3000 << endl;
			break;
		case 4:
			cout << l[1][i] * 2000 << endl;
			break;
		default:
			break;
		}
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3088
#include <stdio.h>
int N[6]={1,5,2,3,0,4},S[6]={4,0,2,3,5,1};
int E[6]={3,1,0,5,4,2},W[6]={2,1,5,0,4,3},O[6]={0,1,2,3,4,5};
void cpy(int *a,int *b,char dir){
    int i,*d;
    if (dir=='N'){d=N;}
    else if (dir=='S'){d=S;}
    else if (dir=='E'){d=E;}
    else if (dir=='W'){d=W;}
    else {d=O;}
    for(i=0;i<6;i++){b[i]=a[d[i]];}
}
int main(void){
    int i,buf,d[6],c[6];char od[101];
    for(i=0;i<6;i++){scanf("%d",&d[i]);}
    scanf("%s",od);
    for(i=0;od[i];i++){
        cpy(d,c,'O');cpy(c,d,od[i]);
    }
    printf("%d\n",d[0]);
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,cnt=0,cnt2=0;
    cin >> a >> b >> c;
    if(a == 5) {
        cnt++;
    }else if(a == 7) {
        cnt2++;
    }
    
    if(b == 5) {
        cnt++;
    }else if(b == 7) {
        cnt2++;
    }
    
    if(c == 5) {
        cnt++;
    }else if(c == 7) {
        cnt2++;
    }
    
    if(cnt == 2 && cnt2 == 1) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

typedef long long ll;

map <int, int> M;
int n;
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int a; scanf("%d", &a);
        res += M[i - a];
        M[i + a]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 20712
n, k = map(int, input().split())
ans = 0

def base_10_to_n(x, n):
    if int(x / n):
        return base_10_to_n(int(x / n), n) + str(x % n)
    return str(x % n)

print(len(str(base_10_to_n(n, k))))

Measured memory_bytes: 2940
S = input()

S_rev = S[::-1]
total = 0

for i in range(len(S)):
  if S[i] != S_rev[i]:
    total += 1

if total % 2 == 0:
  total = int(total / 2)
else:
  total = int(total / 2) + 1

print(total)

Measured memory_bytes: 9016
#include <stdio.h>
#include <string.h>

void insertionSort(int *a, int n);
void printArray(int *a, int n);
void swap(int *a, int *b);

int main(void)
{
	int i;
	int n;
	int a[1000];
	
	scanf("%d", &n);
	
	memset(a, 0, sizeof(a));
	
	for (i = 0; i < n; i++){
		scanf(" %d", &a[i]);
	}
	
	insertionSort(a, n);
	
	return (0);
}

void insertionSort(int *a, int n)
{
	int i;
	int tmpIndex;
	
	printArray(a, n);
	
	for (i = 1; i < n; i++){
		tmpIndex = i;
		while ((tmpIndex > 0) && (*(a + tmpIndex - 1) > *(a + tmpIndex))){
			swap((a + tmpIndex - 1), (a + tmpIndex));
			tmpIndex--;
		}
		printArray(a, n);
	}

}

void printArray(int *a, int n)
{
	int i;
	
	for (i = 0; i < n; i++){
		printf("%d%c", *(a + i), (i == (n - 1))? '\n' : ' ');
	}
}

void swap(int *a, int *b)
{
	int tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;
}


Measured memory_bytes: 2044
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int a, b, min = 1000000000, sum, tmp;
    for(int a = 1; a < N; a++)
    {
        tmp = a;
        sum = 0;
        b = N - a;
        while(tmp > 0)
        {
            sum += tmp % 10;
            tmp /= 10;
        }
        while(b > 0)
        {
            sum += b % 10;
            b /= 10;
        }
        if(min > sum)
            min = sum;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
HOME- ITP1-ITP1_4-A
Discussion Solution Statistics Submit
 
Computation - A / B Problem
Time Limit : 1 sec, Memory Limit : 65536 KB
?????????

???????????´??° a ??¨ b ?????????????????§?????\?????????????¨??????????????????°?????????????????????????????????

    a ?? b ??? d (??´??°)
    a ?? b ????????? ??? r (??´??°)
    a ?? b ??? f (???????°???°?????°)

Constraints

Constraints (??¶?´?)??????????????§?????§????????????????????¨???????????\???????????????????????????????????±????????????????????????????????°????????§?????¨???????????°??????????????¶??´????????¢?????´?????????????§£?????????????¨??¨??????????????????±???????????????????????????????????¢????????¶?´??????\??????????????¨???????????????

    1 ??? a, b ??? 109

Input

1?????????????????´??° a, b ????????????????????????
Output

d, r, f ????????????????????§????????£????????????????????????????????????f??????????????????0.00001??\????????????????????£????????????????????¨????????????
Sample Input

3 2

Sample Output

1 1 1.50000
-}
=end


def aux(s)
  f = s.split
  a = f[0].to_i
  b = f[1].to_i
  format("%d %d %.5f", a/b, a%b, a.to_f/b)
end

s = gets
puts aux(s)

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

void solved(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	while(a && c){
		c -= b;
		if(c <= 0){
			cout<<"Yes"<<endl;break;
		}
		a -= d;
		if(a <= 0){
			cout<<"No"<<endl;break;
		}
	}
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 3624
def main():
    X, K, D = map(int, input().split())

    if X >= 0:
        use = min(X // D, K)
        K -= use
        X -= use * D
        if K % 2:
            X -= D

    else:
        use = min((-X) // D, K)
        K -= use
        X += use * D
        if K % 2:
            X += D

    print(abs(X))


if __name__ == '__main__':
    main()

# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

using namespace std;
typedef long long ll;
typedef pair<int, ll> P;

int N;
vector<vector<P>> edge;
ll dis[100000];

void dfs(int pos) {
	for (int i = 0; i < edge[pos].size(); i++) {
		P next = edge[pos][i];
		if (dis[next.first] == -1) {
			dis[next.first] = dis[pos] + next.second;
			dfs(next.first);
		}
	}
}

int main() {

	for (int i = 0; i < 100000; i++)dis[i] = -1;

	cin >> N;
	edge.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--, b--;
		edge[a].push_back(make_pair(b, c));
		edge[b].push_back(make_pair(a, c));
	}

	dis[0] = 0;
	dfs(0);

	for (int i = 0; i < N; i++) {
		if (dis[i] % 2 == 0)cout << 0 << endl;
		else cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include<utility>
#include<math.h>
#include<vector>
#include<math.h>
using namespace std;
typedef long long int ll;
const long long int N=1000;
ll n,w,k,m,temp,arr[N+1][N+1],dp[N+1][N+1],visited[N+1][N+1];



void maxi(ll& a,ll b)
{
    a=max(a,b);
}

int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>w;
    ll weight,value;
    vector<pair<ll,ll>> store;
    for(auto i=0;i<n;i++)
    {
        cin>>weight>>value;
        store.push_back(make_pair(weight, value));
    }
    vector<ll> dp(w+1,0);
    dp[0]=0;
    
        for(auto j=0;j<store.size();j++)
        {
            for(auto wt=w-store[j].first;wt>=0;wt--)
            {
                maxi(dp[wt+store[j].first], dp[wt]+store[j].second);
            }
        }
    ll ans=0;
    for(auto i=0;i<w+1;i++)
        maxi(ans,dp[i]);
    cout<<ans;
  
    return 0;
        
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split())) + [0]

    result = 0
    for i in range(N):
        tmp = max(0, A[i] + A[i - 1] - X)
        result += tmp
        A[i] -= tmp
    print(result)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
vl x;
/******* define variable end *******/
int solve() {
	x.resize(5);
	REP(i, 5){
		cin >> x[i];
		if(x[i] == 0){
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    if(b>(a-1)*(a-2)/2){
        cout<<-1;
        return 0;
    }
    cout<<a-1+(a-1)*(a-2)/2-b<<endl;
    for(c=2; c<=a; c++) cout<<"1 "<<c<<endl;
    e=(a-1)*(a-2)/2-b;
    for(c=2; c<=a; c++){
        for(d=c+1; d<=a; d++){
            if(e>0)
            cout<<c<<" "<<d<<endl;
            e--;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define LOCAL

#undef _GLIBCXX_DEBUG

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

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

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

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

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

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

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

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353LL;

int main() {
	IOS;
	bool suc = true;
	int n; cin >> n; set<int > a;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (a.count(k)) suc = false;
		a.insert(k);
	}
	if (suc) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 12956
s = input()
ans = "YES"
while s != "":
    if len(s) < 5:
        ans = "NO"
        break
    elif s[len(s) - 5:] == "dream" or s[len(s) - 5:] == "erase":
        s = s[:len(s) - 5]
    elif s[len(s) - 6:] == "eraser":
        s = s[:len(s) - 6]
    elif s[len(s) - 7:] == "dreamer":
        s = s[:len(s) - 7]
    else:
        ans = "NO"
        break
print(ans)


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
const ll INF = 1e9, MOD = INF + 7;

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

const int N = 3e5 + 5;

vector<int> g[N];
int ans[N];

void dfs(int v, int p = 0) {
	for(int u : g[v]) if (u != p) {
		ans[u] += ans[v];
		dfs(u, v);
	}
}

int main(){
	
	sync;

	int n, q; cin >> n >> q;
	for(int i = 0; i < n - 1; i++) {
		int v, u; cin >> v >> u;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	
	while(q--) {
		int v, x; cin >> v >> x;
		ans[v] += x;
	}

	dfs(1);

	for(int i = 0; i < n; i++) cout << ans[i + 1] << ends;

	return 0;
}


Measured memory_bytes: 25856
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int b,c,d,ans;
char a;
int main()
{
	for(int i=1;i<=3;i++)
	{
		scanf("%c",&a);
		if ((a=='a') && (b==0))
		{
			ans++;
			b=1;
		}
        if ((a=='b') && (c==0))
		{
			ans++;
			c=1;
		}
		if ((a=='c') && (d==0))
		{
			ans++;
			d=1;
		}
	}
	if (ans==3) printf("Yes");
	else printf("No");
	return 0;
}


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

#define F first
#define S second
#define int long long
#define inf 1000000000

using namespace std;

vector<vector<int> > dp;
vector<vector<bool> > v, used;

int getmn(int i, int j){
    if (i == 0 && j == 0){
        return 0;
    } else if (i == 0){
        return dp[i][j-1];
    } else if (j == 0){
        return dp[i-1][j];
    } else {
        return min(dp[i][j-1], dp[i-1][j]);
    }
    return 0;
}

void getdp(int i, int j, const int& di, const int& dj){
    dp[di][dj] = min(dp[di][dj], getmn(i, j)+1);
    if (i != 0 && !v[i-1][j] && !used[i-1][j]){
        used[i-1][j] = true;
        getdp(i-1, j, di, dj);
    }
    if (j != 0 && !v[i][j-1] && !used[i][j-1]){
        used[i][j-1] = true;
        getdp(i, j-1, di, dj);
    }
}

signed main(){
    int n, m;
    cin >> n >> m;
    dp.assign(n, vector<int>(m, inf));
    v.assign(n, vector<bool>(m, false));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char c;
            cin >> c;
            if (c == '.'){
                v[i][j] = true;
            }
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (v[i][j]){
                dp[i][j] = getmn(i, j);
            } else {
                used.assign(i+1, vector<bool>(j+1, false));
                used[i][j] = true;
                getdp(i, j, i, j);
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}























Measured memory_bytes: 3692
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// input
	people := inputLineAsNumArray(1)[0]
	nums := inputLineAsNumArray(2)
	days, remain := nums[0], nums[1]

	eaten := 0
	for i:=0; i<people; i++ {
		interval := inputLineAsNumArray(1)[0]
		eaten += days / interval + 1
		if days % interval == 0 {
			eaten--
		}
	}


	fmt.Println(eaten + remain)
}

func inputLineAsNumArray(length int) []int {
	line := strings.Split(readLine(), " ")
	var nums []int
	for i := 0; i < length; i++ {
		num, _ := strconv.Atoi(line[i])
		nums = append(nums, num)
	}
	return nums
}

func readLine() string {
	sc.Scan()
	return sc.Text()
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin>>n>>k;
	vector<int> h(n+1, INT_MAX);
	for(int i=1; i<n+1; i++)
		cin>>h[i];
	vector<int> sol(n+1, INT_MAX);
	sol[1] = 0;
	for(int i=2; i<n+1; i++) {
		for(int j=1; j<=k && i-j > 0; j++) {
			sol[i] = min(sol[i],abs(h[i]-h[i-j])+sol[i-j]);
		}
	}
	cout<<sol[n]<<endl;

}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// factorial
long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) * n) % MOD;
}

long long modpow(long long m, long long p) {
    if (p == 0) return 1;
    if (p % 2)
        return m * modpow(m, p - 1) % MOD;
    else {
        long res = modpow(m, p / 2);
        return res * res % MOD;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x;
    cin >> x;
    ll ans = (x + 10) / 11 * 2;
    if ((x - 1) % 11 < 6) ans--;

    out(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n,a[200005],ans=0,ps=0;
    cin >> n;
    rep(i,1,n){
        cin >> a[i];
        ans=(ans+a[i])%mod;
        ps=(ps+a[i]*a[i]%mod)%mod;
    }
    cout << ((ans*ans%mod+mod-ps)%mod)*((ll)5e8+4)%mod << endl;
    return 0;
}

Measured memory_bytes: 5196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size

int ispar(int x){
	int n=0,s[10],r,l;
	while(x>0){
		s[n] = x%10;
		x /= 10;
		++n;
	}
	l = 0;
	r = (n-1);
	while(r>l){
		if(s[l]!=s[r]){
			return 0;
		}
		++l;
		--r;
	}
	return 1;
}

int main(void){
	int i,a,b,ans=0;
	cin >> a >> b;
	for(i=a; i<=b; ++i){
		ans += ispar(i);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	string Str;
	cin >> Str;
	int flag=0;
	for(long i=0; i<Str.size(); i++){
		if(flag==0 && Str[i]=='C'){flag=1;}
		if(flag==1 && Str[i]=='F'){flag=2;}
	}
	if(flag==2){cout << "Yes" <<endl;}
	else{cout <<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

int main(){
	SYNC;
	ll l=(ll)1e9,r=(ll)(1e10)-1;
	char c;
	while(l<=r)
	{
		ll k=(l+r)>>1;
		cout<<"? "<<k<<endl;
		cin>>c;
		if(c=='Y')r=k-1;
		else l=k+1;
	}
	ll t=l;
	while(t<=(ll)1e17)t*=10;
	cout<<"? "<<t-1<<endl;
	cin>>c;
	if(c=='Y')
	{
		t/=10;
		while(t>0)
		{
			cout<<"? "<<t+1<<endl;
			cin>>c;
			if(c=='N')break;
			t/=10;
		}
		if(t==0)t=1;
		else t*=10;
		cout<<"! "<<t<<endl;
		return 0;
	}
	else
	{
		while(1)
		{
			t/=10;
			cout<<"? "<<t-1<<endl;
			cin>>c;
			if(c=='Y')break;
		}
		cout<<"! "<<t<<endl;
		return 0;
	}
}

Measured memory_bytes: 636
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void) {
	long long int A, B;
	scanf("%lld%lld", &A, &B);
	long long int tmp, r;
	long long int x = A * B;
	if (A < B) {
		tmp = A;
		A = B;
		B = tmp;
	}

	/* ユークリッドの互除法 */
	r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A %B;
	}

	/* 最小公倍数を出力 */
	printf("%lld\n", x / B);


	return 0;


}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n, k, a[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    int g = 0;
    forn(i, 1, n) {
        cin >> a[i];
        g = __gcd(g, a[i]);
    }
    sort(a + 1, a + 1 + n);
    if (a[n] < k || k % g != 0)
        cout << "IMPOSSIBLE\n";
    else
        cout << "POSSIBLE\n";

    return 0;
}


Measured memory_bytes: 640
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> l(n); rep(i, n)cin >> l[i];
	int res = 0;
	rep(i, n - 2)for (int j = i + 1; j < n - 1; ++j)for (int k = j + 1; k < n; ++k)
	{
		if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k])
		{
			if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j])++res;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3628
a, b = map(int, input().split())
a_, b_ = a % 4, b % 4
if a % 2:
    if a_ == b_:
        print(a)
    elif a_ == (b_-1) % 4:
        print(a^b)
    elif a_ == (b_-2) % 4:
        print(a^(b-1)^b)
    else:
        print(a^(b-2)^(b-1)^b)
else:
    if a_ == b_:
        print(b)
    elif a_ == (b_-1) % 4:
        print((b-1)^b)
    elif a_ == (b_-2) % 4:
        print((b-2)^(b-1)^b)
    else:
        print((b-3)^(b-2)^(b-1)^b)

Measured memory_bytes: 3316
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

ans = 0
for i,h in enumerate(H):
    for to in es[i]:
        if H[to] >= h:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 42840