akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<cmath>
#include<iomanip>
#include<cstdlib>
#include<sstream>
#include<climits>
#include<cassert>
#include<time.h>

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define pb push_back
#define ss second
#define ff first
#define vi vector<int>
#define vl vector<ll>
#define s(n) scanf("%d",&n)
#define ll long long
#define mp make_pair
#define PII pair <int ,int >
#define PLL pair<ll,ll>
#define inf 1000*1000*1000+5
#define v(a,size,value) vi a(size,value)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define tri pair < int , PII >
#define TRI(a,b,c) mp(a,mp(b,c))
#define xx ff
#define yy ss.ff
#define zz ss.ss
#define in(n) n = inp()
#define vii vector < PII >
#define vll vector< PLL >
#define viii vector < tri >
#define vs vector<string>
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end());
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
#define ok if(debug)
#define trace1(x) ok cerr << #x << ": " << x << endl;
#define trace2(x, y) ok cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)    ok      cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)  ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                     << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                    << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
ll MOD = int(1e9) + 7;

int debug = 1;
const int N = int(1e6) + 5;
using namespace std;
int a[N],freq[N];
int main()
{
        int i,j,n,t;
        ios::sync_with_stdio(false);
        cin>>n;
        int flag = 0;
        rep(i,n)cin>>a[i];
        sort(a,a+n);
        if(n == 2)
        {
                cout<<"Possible";
        }
        else if(a[0] == a[1])
        {
                if(a[2] == a[0])flag = 1;
                if(a[n-1] != a[0]*2 - 1 )
                        flag = 1;
                rep(i,n)freq[a[i]]++;
                f(i,a[0]+1,2*a[0])if(freq[i]< 2)flag  = 1;
                if(flag)cout<<"Impossible";
                else cout<<"Possible";
        }
        else
        {
                if(a[n-1] != a[0]*2)
                        flag = 1;
                rep(i,n)freq[a[i]]++;
                f(i,a[0]+1,2*a[0]+1)if(freq[i]< 2)flag  = 1;
                if(flag)cout<<"Impossible";
                else cout<<"Possible";
        }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector<long long> x;
	long long temp;
	for(int i=0;i!=3*n;++i){
		cin>>temp;
		x.push_back(temp);
	}
	sort(x.begin(),x.end());
	long long ans=0;
	int i=0,j=3*n-1;
	while(i<j){
		ans+=x[j-1];
		++i;
		j-=2;
	}
	cout<<ans;
}

Measured memory_bytes: 6128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c, k] <- getIntList
  let diff = a - b
  print $ if odd k then (- diff) else diff

Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

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

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//実行部
void Main()
{
  str a, b, c; cin >> a>>b>>c;printf("%c%c%c\n",a[0],b[1],c[2]);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int k = stdIn.nextInt();

		int[] numArray = new int[n + 1];
		for (int i = 0; i < numArray.length; i++) {
			numArray[i] = i;
		}

		long cnt = 0;

		for (int i = k; i <= n; i++) {
			long min = min(i);
			long max = max(i, n);

			cnt += max - min + 1;
		}

		//i=n+1のときは単純に+1
		cnt += 1;

		System.out.println(cnt % 1000000007L);
		stdIn.close();

	}


	private static long max(long k, long n) {

		long sum = n * (n+1) / 2;
		long sub = (n-k) * (n-k+1)/2;

		return sum - sub;
	}

	private static long min(long k) {

		return k * (k - 1) / 2;
	}

}

Measured memory_bytes: 36352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[63][2][2][2][2][2];
int a[63],b[63],f[10];

int main(void){
	int i,j,k;
	ll l,r,ans=0ll;
	cin >> l >> r;
	for(i=0; i<60; ++i){
		b[i] = l&1; l >>= 1;
		a[i] = r&1; r >>= 1;
	}
	reverse(a,a+60);
	reverse(b,b+60);
	dp[0][1][1][1][0][1] = 1ll;
	for(i=0; i<60; ++i){
		for(j=0; j<128; ++j){
			for(k=0; k<7; ++k){
				f[k] = ((j&(1<<k))?1:0);
			}
			if(f[5] == 0 && f[6] == 1){
				continue;
			}
			if(f[0] && f[5]<f[6]){
				continue;
			}
			if(f[1] && f[5]>a[i]){
				continue;
			}
			if(f[2] && f[6]<b[i]){
				continue;
			}
			if(f[4] && f[3]>f[6]){
				continue;
			}
			add_mod(dp[i+1][((f[0]&&(f[5]==f[6]))?1:0)][((f[1]&&(f[5]==a[i]))?1:0)][((f[2]&&(f[6]==b[i]))?1:0)][f[5]][((f[4] && (f[3]==f[6]))?1:0)],dp[i][f[0]][f[1]][f[2]][f[3]][f[4]]);
		}
	}
	for(j=0; j<32; ++j){
		for(k=0; k<5; ++k){
			f[k] = (j&(1<<k))?1:0;
		}
		if(f[4]){
			continue;
		}
		add_mod(ans,dp[60][f[0]][f[1]][f[2]][f[3]][f[4]]);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
ll A[MAX_N];
ll sum[MAX_N];


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

  cin >> N; rep(i, N) cin >> A[i];
  sort(A, A+N);
  sum[0] = A[0];
  for (int i = 1; i < N; ++i) sum[i] = sum[i-1] + A[i];

  int ans = 1;
  for (int i = N-2; i >= 0; --i) {
    if (sum[i]*2 >= A[i+1]) ++ans;
    else break;
  }

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


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, ans = 1000000007;
    cin >> N;
    for (int64_t i = 1; i * i <= N; i++){
        if (N % i != 0) {
            continue;
        }
        int64_t a = N / i, keta = 0;
        while (a > 0) {
            keta++;
            a /= 10;
        }
        ans = keta;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))
xi = [list(map(int, input().split())) for i in range(m)]
ans = []
ans.append(min(ai)+ min(bi))
for i in range(0,m):
    ans.append(ai[xi[i][0]-1] + bi[xi[i][1]-1] - xi[i][2])

print(min(ans))

Measured memory_bytes: 42400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 410;
ll dp[N][N];
ll seq[N];
ll presum[N];
int n;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> seq[i];
        presum[i] = presum[i-1] + seq[i];
    }
    memset(dp, 0x3f3f3f3f3f3f3f3f, sizeof dp);
    for(int i = 1; i <= n; i ++) dp[i][i] = 0;
    for(int len = 1; len < n; len ++) {
        for(int i = 1; i + len <= n; i ++) {
            int j = i + len;
            for(int k = i; k < j; k ++) {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+presum[j]-presum[i-1]);
            }
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}

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

#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())

using namespace std;

typedef vector<long long> vi;

typedef pair<long long, int> pii;

const int maxn = 1e5 + 100;

int n, A, B;
long long x[maxn], y[maxn];
int a[maxn], b[maxn];
bool vis[maxn];
long long D, ans;
vi hx, hy;
vector<vector<pii> > ax, ay;
vector<set<pii> > sx, sy;

long long F(vector<pii> &v, pii l, pii r) {
	return lower_bound(ALL(v), r) - lower_bound(ALL(v), l);
}

void dfs(int U) {
	if(vis[U]) {
		return;
	}
	vis[U] = 1;
	int X = x[U], Y = y[U];
	long long l = X - D, r = X + D, u = Y + D, d = Y - D;
	int i;

	i = lower_bound(ALL(hx), l) - hx.begin();
	if(i < SZ(hx) && hx[i] == l) {
		pii t = make_pair(d, -1), tt = make_pair(u + 1, -1);
		ans += F(ax[i], t, tt);
		set<pii>::iterator it;
		for(;;) {
			it = sx[i].lower_bound(t);
			if(it != sx[i].end() && it->first <= u) {
				int V = it->second;
				sx[i].erase(it);
				dfs(V);
			}
			else {
				break;
			}
		}
	}

	i = lower_bound(ALL(hx), r) - hx.begin();
	if(i < SZ(hx) && hx[i] == r) {
		pii t = make_pair(d, -1), tt = make_pair(u + 1, -1);
		ans += F(ax[i], t, tt);
		set<pii>::iterator it;
		for(;;) {
			it = sx[i].lower_bound(t);
			if(it != sx[i].end() && it->first <= u) {
				int V = it->second;
				sx[i].erase(it);
				dfs(V);
			}
			else {
				break;
			}
		}
	}

	i = lower_bound(ALL(hy), d) - hy.begin();
	if(i < SZ(hy) && hy[i] == d) {
		pii t = make_pair(l + 1, -1), tt = make_pair(r, -1);
		ans += F(ay[i], t, tt);
		--t.first;
		set<pii>::iterator it;
		for(;;) {
			it = sy[i].lower_bound(t);
			if(it != sy[i].end() && it->first <= r) {
				int V = it->second;
				sy[i].erase(it);
				dfs(V);
			}
			else {
				break;
			}
		}
	}

	i = lower_bound(ALL(hy), u) - hy.begin();
	if(i < SZ(hy) && hy[i] == u) {
		pii t = make_pair(l + 1, -1), tt = make_pair(r, -1);
		ans += F(ay[i], t, tt);
		--t.first;
		set<pii>::iterator it;
		for(;;) {
			it = sy[i].lower_bound(t);
			if(it != sy[i].end() && it->first <= r) {
				int V = it->second;
				sy[i].erase(it);
				dfs(V);
			}
			else {
				break;
			}
		}
	}
	return;
}

int main() {
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 1; i <= n; ++i) {
		int X, Y;
		scanf("%d%d", &X, &Y);
		x[i] = X + Y;
		y[i] = X - Y;
		hx.push_back(x[i]);
		hy.push_back(y[i]);
	}
	D = max(abs(x[A] - x[B]), abs(y[A] - y[B]));
	sort(ALL(hx));
	hx.resize(unique(ALL(hx)) - hx.begin());
	sort(ALL(hy));
	hy.resize(unique(ALL(hy)) - hy.begin());
	ax.resize(SZ(hx));
	sx.resize(SZ(hx));
	ay.resize(SZ(hy));
	sy.resize(SZ(hy));
	for (int i = 1; i <= n; ++i) {
		a[i] = lower_bound(ALL(hx), x[i]) - hx.begin();
		b[i] = lower_bound(ALL(hy), y[i]) - hy.begin();
		ax[a[i]].push_back(make_pair(y[i], i));
		sx[a[i]].insert(make_pair(y[i], i));
		ay[b[i]].push_back(make_pair(x[i], i));
		sy[b[i]].insert(make_pair(x[i], i));
	}
	for (auto &x: ax) {
		sort(ALL(x));
	}
	for (auto &x: ay) {
		sort(ALL(x));
	}
	dfs(A);
	return !printf("%lld\n", ans / 2);
}

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

int main(void){
    int n;cin >> n;
    int a[n];rep(i,n)cin >> a[i];
    sort(a,a+n,greater<int>());
    
    ll m = 1,sum = a[0];
    for(int i = 1;i < n;i++){
        if(m+2 <= n-1){
            sum += a[i]*2;
            m += 2;
        } else if(m+1 <= n-1){
            sum += a[i];
            m++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N-1);
  for(int i=0;i<N-1;i++)cin>>v[i];
  int ans=0;
  ans+=v[0];
  for(int i=1;i<N-1;i++)ans+=min(v[i],v[i-1]);
  ans+=v[N-2];
  fin(ans);
}


Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
Items = [list(map(int, input().split())) for i in range(N)]

# dp[i][a][b] := i個目の薬品までで薬品Aがaグラム、薬品Bがbグラムの混合液を作るために必要な最小予算
dp = [[[float('inf')] * 401 for j in range(401)] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(1, N + 1):
    ai, bi, ci = Items[i - 1]
    for a in range(401):
        for b in range(401):
            if a - ai >= 0 and b - bi >= 0:
                dp[i][a][b] = min(dp[i][a][b], dp[i - 1][a][b], dp[i - 1][a - ai][b - bi] + ci)
            else:
                dp[i][a][b] = min(dp[i][a][b], dp[i - 1][a][b])

ans = float('inf')
i = 1
while Ma * i <= 400 and Mb * i <= 400:
    ans = min(ans, dp[N][Ma * i][Mb * i])
    i += 1

print(ans if ans != float('inf') else -1)


Measured memory_bytes: 135260
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define Init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

ll H = 0, W = 0;
vector<vector<ll>> m(100, vll(100));
vector<vector<ll>> diff(100, vll(100, INF));

void bfs(ll i, ll j, ll num = 0) {
  if (i < 0 || j < 0 || H <= i || W <= j) {
    return;
  }
  if (m[i][j]) {
    return;
  }
  if (diff[i][j] <= num + 1) {
    return;
  }

  diff[i][j] = num + 1;
  bfs(i - 1, j, num + 1);
  bfs(i + 1, j, num + 1);
  bfs(i, j - 1, num + 1);
  bfs(i, j + 1, num + 1);
};

signed main() {
  Init();
  cin >> H >> W;
  ll white_count = 0;
  rep(i, H) {
    string S;
    cin >> S;
    rep(j, W) {
      if (S[j] == '.') {
        m[i][j] = 0;
        white_count++;
      } else {
        m[i][j] = 1;
      }
    }
  }

  bfs(0, 0, 0);
  if (diff[H - 1][W - 1] == INF) {
    COUT(-1);
    return 0;
  }
  ll ans = white_count - diff[H - 1][W - 1];
  COUT(ans);

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

struct UnionFind {
    vector<int> par;
    
    //要素nで初期化
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    //xが属する集合の根を返す
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    //xとyが同じ集合に属しているかを判定
    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    //xが属する集合と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;
    }
    
    //xが属する集合のサイズ
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
	int n,m;cin>>n>>m;
	vector<int> p(n);
	for(int i = 0; i < n; i++) {
		cin>>p[i];
	}
	vector<P> a(m);
	ll x,y;
	for(int i = 0; i < m; i++) {
		cin>>x>>y;
		a[i] = mp(x,y);
	}

	UnionFind uf(n+1);
	for(int i = 0; i < m; i++) {
		uf.merge(a[i].fs,a[i].sc);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if ((p[i] == i + 1) || (uf.issame(p[i],i + 1))){
			ans ++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()

    ans = ''
    while N > 0:



        ans = chr(ord('a')+ (N-1) % 26) + ans
        N = (N-1) // 26


    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 68596
a, b, k = map(int, input().split())
s = []
for i in range(k):
    if a+i > 0 and a+i <= b:
        s.append(a+i)
for i in reversed(range(k)):
    if b-i > 0 and b-i > a and b-i not in s:
        s.append(b-i)
for j in s:
    print(j)

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

int main() {
    int K;
    priority_queue<long long, vector<long long>, greater<>> q;
    cin >> K;
    if (K < 10) {
        cout << K << endl;
        return 0;
    }
    for (int i=1; i < 10; i++) {
        q.push(i);
    }
    for (int i = 0; i < K-1; i++) {
        long long n = q.top();
        q.pop();
        int a = n / 10 % 10 - n % 10;
        if (a == 1 || (a == 0 && n % 10 != 9)) {
            q.push(n + 1);
        }
        if (n % 10 == 0) {
            q.push(n * 10);
        } else {
            q.push(n * 10 + (n % 10 - 1));
        }
    }
    cout << q.top() << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 168, task c , 2020/05/17
//ms,
/*
*/

int main(void){
  int A, B, H, M;
  double theta;
  double d;

  cin >>A >>B >>H >>M;

  theta = (H/6.0 + M/360.0 - M/30.0)*M_PI;
  d=sqrt(A*A + B*B - 2*A*B*cos(theta));

  printf("%15.11f", d);

  return 0;
}
/*
出力はprintfで
*/


Measured memory_bytes: 4192
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;

int Count(int Price, int Pay) {
	int C = 0;
	while (Price != 0) {
		C += Price % Pay;
		Price /= Pay;
	}
	return C;
}


int main() {
	//解説見ました。---すごい
	int N;
	cin >> N;
	int Answer = 9999;
	for (int SixPay = 0; SixPay <= N; SixPay++) {
		int C = Count(SixPay, 6);
		C += Count(N - SixPay, 9);
		Answer = min(Answer, C);
	}
	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        boolean[] dp = new boolean[S.length() + 1];

        dp[0] = true;

        for (int i = 0; i < S.length(); i++) {
            if (!dp[i]) {
                continue;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    dp[end] = true;
                }
            }
        }

        if (dp[S.length()]) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 32952
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define mod 1000000007
#define inf 999999999
#define rep(i, n) for(int i = 0; i < n; i++)
#define For(i, a, n) for(int i = a; i < n; i++)
#define out(n) cout << n << endl;
#define vout(v) rep(i, v.size()) out(v[i]);

int main(){
  ll n, m;
  cin >> n >> m;
  ll x[n], y[m];

  rep(i, n) {
    cin >> x[i];
  }

  rep(i, m) {
    cin >> y[i];
  }

  ll xan = 0, yan = 0;

  rep(i, n) {
    xan += (2 * (i + 1) - 1 - n) * x[i];
    xan %= mod;
  }

  rep(i, m) {
    yan += (2 * (i + 1) - 1 - m) * y[i];
    yan %= mod;
  }

  cout << xan * yan % mod << endl;
}


Measured memory_bytes: 1792
n = int(input())

l = input().split()

res = []

for i in range(n):
    
    
    for j in range(len(l)-1,-1,-1):
        if(l[j] == str(j+1)):
            res.append(l[j])
            del(l[j])
            break
    


            

if(l != []):
    print(-1)
else:
    print("\n".join(res[::-1]))


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

int main(void){
  
  // 以下エラトステネスの篩のコピペ　
  // pが素数の数、prime[i-1]でi番目の素数
  // prime[0]=2, prime[1]=3, ....であることに気を付ける
  // 特に、prime[-1]=0, prime[p]=0なので注意！！
  // 
    ll N= 1000*1000  ;
    ll prime[N];
    bool is_prime[N+1]; 
    ll p=0;
      
  for(ll i=0; i<=N; i++) is_prime[i]=true;
  is_prime[0] = is_prime[1]=false;
  for(ll i=2; i<=N; i++){
    if(is_prime[i]){
      prime[p++] =i;
      for(ll j=2*i ; j<= N; j+= i ) is_prime[j] = false; 
    }
  }
  //コピペ終了　
  //以下この問題特有
    ll A, B;
    cin >> A>> B;
    ll C;
    while(B!=0){
      C = A%B;
      A = B;
      B = C; 
    }
    ll G = A; 
   // dの素因数の数を数える

  int answer=1; 
  for(int i=1; i< p; i++){
    ll q = prime[i-1]; 
    if(G%q==0){
      answer++;
      while(G%q==0){
        G = G/q;
      }
    }
  }
  if(G!=1) answer++;
  cout<< answer << endl; 
}
    

Measured memory_bytes: 3840
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    int n,f=0;
    cin>>n;
    while(n!=0)
    {
        if((n%10)==7) {f=1;break;}
        n=n/10;
    }
    if(f==1) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        Integer[] p = new Integer[A];
        Integer[] q = new Integer[B];
        Integer[] r = new Integer[C];
        for(int i = 0;i<A;i++){
            p[i] = sc.nextInt();
        }

        for(int i =0;i<B;i++){
            q[i] = sc.nextInt();
        }

        for(int i=0;i<C;i++){
            r[i] = sc.nextInt();
        }
        Arrays.sort(p,Collections.reverseOrder());
        Arrays.sort(q,Collections.reverseOrder());
        Arrays.sort(r,Collections.reverseOrder());

        long[] ABmaxans = new long[X+Y+1];
        int xcounter = 0;
        int ycounter = 0;

        for(int i = 1;i<X+Y+1;i++){
            if(xcounter > X -1){
                ABmaxans[i] = ABmaxans[i-1] + q[ycounter];
                ycounter++;
            } else if(ycounter > Y -1) {
                ABmaxans[i] = ABmaxans[i-1] + p[xcounter];
                xcounter++;
            } else if(p[xcounter] > q[ycounter]){
                ABmaxans[i] = ABmaxans[i-1] + p[xcounter];
                xcounter++;
            } else {
                ABmaxans[i] = ABmaxans[i-1] + q[ycounter];
                ycounter++;
            }
        }

        long Csum = 0;
        long ans = 0;
        for(int i = 0;i<X+Y;i++){

            ans = Math.max(ans,ABmaxans[X+Y-i]+Csum);

            if(i < r.length){
                Csum += r[i];
            }

        }

        System.out.println(ans);






    }

}









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

#define REP(i, n) for(long long int i = 0; i < (long long int)(n); i++)
#define lint long long int

const lint MOD = 1000000007;

// mod. m での a の逆元 a^{-1} を計算する
lint modinv(lint a, lint m) {
    lint b = m, u = 1, v = 0;
    while (b) {
        lint t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// mod. m でのa個のものからb個のものを選ぶ場合の数を計算する
lint combination(lint a, lint b, lint m) {
	if (a < b) {
		return 0;
	}
	else {
		lint c = 1;
		for (lint i = 1; i <= a; i++) {
			c = c * i % m;
		}
		for (lint i = 1; i <= b; i++) {
			c = c * modinv(i, m) % m;
		}
		for (lint i = 1; i <= (a - b); i++) {
			c = c * modinv(i, m) % m;
		}
		return c;
	}
}

int main() {
	lint N, K;
	cin >> N >> K;

	for(lint i = 1; i <= K; i++) {
		lint num_red = combination(N - K + 1, i, MOD);
		lint num_blue = combination(K - 1, i - 1, MOD);
		cout << num_red * num_blue % MOD << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
ans = []
for i in range(0,n-1):
    if(a[i]==a[i+1]):
        ans.append(a[i])
if len(ans) <2:
    print(0)
    sys.exit()
        
if (ans[0]==ans[1] and ans[1]!=ans[2]):
    print(ans[0]*ans[2])
    sys.exit()

print(ans[0]*ans[1])

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

int main(){
  ll x;
  cin >> x;
  ll dx[1000000];
  dx[0] = 0;
  for (int i=1; i < 1000000; ++i){
    dx[i] = dx[i-1] + (long long) i;
    if (dx[i] >= x) {
      cout << i << endl;
      break;
    }
  }
    
  
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;

int n,m,k,i,j,id;
vector<int> cc_id;//どの連結成分か
vector<int> cc_num;//連結成分のsize


void dfs(Graph &G,int v,int &cnt){
    cc_id[v]=id;//vスタートの連結成分は全てidにしておく
    cnt++;//連結成分の個数
    for(auto next:G[v]){//vを親としてdfsを続ける
        if(cc_id[next]==-1){//訪れていなければ
            dfs(G,next,cnt);
        }
    }
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    Graph G(n);

    vector<int> a(m),b(m);
    for(i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        G[a[i]].push_back({b[i]});
        G[b[i]].push_back({a[i]});        
    }
    vector<int> c(k),d(k);
    for(i=0;i<k;i++){
        cin>>c[i]>>d[i];
        c[i]--;d[i]--;
    }

    id=0;
    cc_id.assign(n,-1);//-1ならまだ訪れていない
    for(i=0;i<n;i++){
        if(cc_id[i]==-1){//訪れていないとき    
            int cnt=0;
            dfs(G,i,cnt);//sizeを調べる
            id++;//同じ連結成分ならおなじid
            cc_num.push_back(cnt);//size
        }
    }

    vector<int> ans(n,0);
    for(i=0;i<n;i++){ans[i]=cc_num[cc_id[i]]-1-(int)G[i].size();}//自分と自分の周り(友達)をのぞく
    for(i=0;i<k;i++){
        if(cc_id[c[i]]==cc_id[d[i]]){//同じ連結成分にブロック関係があったら除く
            ans[c[i]]--;
            ans[d[i]]--;
        }
    }

    for(i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

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

int n,k;
int l;
int main() {
	cin>>n>>k;
	if(n%2==0) {
		l=n/2;
	} else {
		l=n/2+1;
	}
	if(l>=k) {
		printf("YES");
		return 0;
	} else {
		printf("NO");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
map<ll,int>mapi;
int main(){
	std::ios::sync_with_stdio(false);
	int t;
	cin>>t;
	while(t--){
		ll a,b,c,d,a1,cnt,val;
		cin>>a>>b>>c>>d;
		if(a<b||d<b){
			cout<<"No"<<endl;
		}
		else{
			if(c>=b-1){
				cout<<"Yes"<<endl;
			}
			else{
				val=b-(a%b);
				if(val%(__gcd(d,b)))
					val/=__gcd(b,d);
				else{
					val/=__gcd(b,d);
					val--;
				}
				c-=a%b;
				//cout<<val<<" "<<endl;
				if(val>c/(__gcd(b,d))||val<0||c<0){
					cout<<"No"<<endl;
				}
				else{
					cout<<"Yes"<<endl;
				}

			}
		}
	}
} 
	

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

int main(){
  int N,M;
  cin >> N >> M;
  
  scc_graph G(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    G.add_edge(a,b);
  }
  
  vector<vector<int>> V = G.scc();
  cout << V.size() << endl;
  for(int i=0;i<V.size();i++){
    cout << V[i].size() << " ";
    for(int j=0;j<V[i].size();j++){
      cout << V[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 40616
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int cnt[27];
int main(){
string data;
  while(getline(cin, data)) {
	  transform(data.begin(),data.end(),data.begin(),::toupper);
	  auto p=data.begin();
	  while(p!=data.end()){
	    if('A'<=*p&&*p<='Z')++cnt[*p-'A'];
	    ++p;
	  }
  }
  for(int i=0;i<26;++i){
    cout << (char)('a'+i) << " : " << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const ll MOD = 1000000007;

const double PI = 3.1415926535897932;
/******define variable start******/
ll n;
string s;
/*******define variable end*******/
ll solve(){
    cin >> n >> s;
    ll ans = 0;
    for(ll i = 0; i < n-2; i++){
        if(s.substr(i, 3) == "ABC"){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll 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 (int)end_solve;
}

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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int m=n+1;
    int ans=0;
    for(int i=0; i<n; i++){
        if(p[i] < m){
            m=p[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let vs: Vec<i32> = (0..n).map(|_| sc.cin()).collect();
    let mut ans = 0;
    for m1 in 0..(n+1) {
        for m2 in 0..(n+1) {
            if m1 + m2 > n { continue; }
            if m1 + m2 > k { continue; }
            if m1 + m2 == 0 { continue; }
            let mut us: Vec<i32> =
                (0..m1).map(|i| vs[i]).chain((n-m2..n).map(|i| vs[i])).collect();
            ;
            us.sort();
            for i in 0..k - m1 - m2 {
                if i >= us.len() { break; }
                if us[i] < 0 { us[i] = 0; }
            }
            ans = max(ans, us.iter().sum::<i32>());
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#define N 2000000
#define A 10000

int c[A];

int main(){

  int i;
  int *a, *b;
  int n, tmp;

  scanf("%d",&n);

  a = (int *)malloc(sizeof(int) * n);
  b = (int *)malloc(sizeof(int) * n);

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

  tmp = c[0];
  for(i = 1; i < A; i++){
    c[i] += c[i - 1];
  }

  for(i = n - 1; i >= 0; i--){
    b[c[a[i]] - 1] = a[i];
    c[a[i]]--;
  }

  for(i = 0; i < n; i++){
    printf("%d", b[i]);
    if(i < n - 1) printf(" ");
  }

  printf("\n");


  free(a);
  free(b);

  return 0;
}

Measured memory_bytes: 16056
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
string S;
cin >> S;
int ans = 0;
int cnt = 0;
REP(i,S.size()){

    if(S[i] == 'A'||S[i] == 'C' || S[i] == 'T' || S[i] == 'G'){
cnt++;
ans = max(ans,cnt);
    }
    else
    {
        cnt = 0;
    }
    
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(k > a) {
        k -= a; // leftovers
        a = 0;
    } else {
        a -= k;
        k = 0;
    }
    b -= k;
    if(b < 0) b = 0;
    cout << a << " " << b;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let line = read_vector::<usize>();
	let (w, h, x, y) = (line[0], line[1], line[2], line[3]);
	if x * 2 == w && y * 2 == h {
		println!("{:.6} 1", (w * h / 2) as f64);
	} else {
		println!("{:.6} 0", (w * h) as f64 / 2.0);
	}
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 4352
#include <stdio.h>

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

	if (a==b) 
      printf("%d\n", c);
  	else if (b==c)
      printf("%d\n", a);
	else
      printf("%d\n", b);
      
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    ll x;
    cin >> x;
    ll cur = 100;
    for(int d = 0; ; d++) {
        if(cur >= x) {
            cout << d << endl;
            exit(0);
        }
        else {
            cur *= 1.01;
        }
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define MAX 3005
#define PB push_back
#define MP make_pair
#define pii pair<long long,long long>
#define read(a) scanf("%d",&a)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define clr(a) memset(a,0,sizeof(a))
#define MOD 10000000000
#define INF 10000000000000

using namespace std;

int node,edge;

int main()
{
    //freopen("inn.txt","r",stdin);
    int test=1;
    //cin>>test;
    while(test--){
        string s,t;
        cin>>s>>t;
        int n=s.size(),m=t.size();
        int ar[MAX][MAX];
        clr(ar);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(s[i-1]==t[j-1]) ar[i][j]=ar[i-1][j-1]+1;
                else ar[i][j]=max(ar[i-1][j],ar[i][j-1]);
            }
        }
        string str;
        int i=n,j=m;
        while(i>0 && j>0){
            if(ar[i][j]==ar[i][j-1]) j--;
            else if(ar[i][j]==ar[i-1][j]) i--;
            else str+=s[i-1],i--,j--;
            //p1(str);
        }
        reverse(str.begin(),str.end());
        cout<<str<<endl;
    }

    return 0;
}




Measured memory_bytes: 35584
#include <stdio.h>

int main(void)
{
	int T,J,S,Y,H;
	scanf("%d%d%d%d%d",&T,&J,&S,&Y,&H);
	if(T<40) T=40;
	if(J<40) J=40;
	if(S<40) S=40;
	if(Y<40) Y=40;
	if(H<40) H=40;
	int Sum,Ave;
	Sum =T+J+S+Y+H;
	Ave =Sum/5;
	printf("%d\n",Ave);
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        String a = "Yes";
        if(W < x + r || H < y +r || 0 > x -r || 0 > y - r) {
            a = "No";
        }
        System.out.println(a);
    }

}


Measured memory_bytes: 26412
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    int n,k;
  	cin >> n >> k;
    double ret = 0;
    for ( int i = 1 ; i <= n ; i++ ){
        double tmp = 1.0 / n;
        int now = i;
        while( now < k ){
            now *= 2;
            tmp /= 2;
        }
        ret += tmp;
    }
    cout << fixed << setprecision(10) << ret << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        fig: [chars; h],
    }
    for row in fig.iter() {
        let row_str = row
            .iter()
            .fold(String::new(), |acc, s| acc + &s.to_string());
        println!("{}", &row_str);
        println!("{}", &row_str);
    }
}


Measured memory_bytes: 4352
import java.util.*;
import java.io.PrintWriter;
public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        String A =sc.next();
        String B =sc.next();
        if(A.equals(B)){
            out.println("H");
        }else{
            out.println("D");
        }

        out.flush();
    }
}



Measured memory_bytes: 22868
#include <iostream>
#include<vector>
#include<algorithm>
#define ll long long 
#define rep(n) for(int i=0;i<n;++i)
using namespace std;
int main(void){
    // Your code here!

int n;
cin>>n;
vector<int> vec1(n+1), vec2(n);
rep(n+1){
    cin>>vec1[i];
}

rep(n){
    cin>>vec2[i];
}

ll sum=0;

rep(n){
    int a= min(vec1[i], vec2[i]);
    vec1[i]-=a;
    vec2[i]-=a;
    int b= min(vec1[i+1],vec2[i]);
    vec1[i+1]-=b;
    vec2[i]-=b;
    sum+=(a+b);
}
cout<<sum;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    int wcount=0,bcount=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0 && s[i]=='0')wcount++;
        else if(i%2==1 && s[i]=='1')wcount++;
    }
    for(int i=0;i<s.size();i++){
        if(i%2==0 && s[i]=='1')bcount++;
        else if(i%2==1 && s[i]=='0')bcount++;
    }

    cout << min(wcount, bcount) << endl;

    return 0;
}


Measured memory_bytes: 3704