akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(ll, x, t);
	out(max(x - t, 0ll));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb emplace_back
#define MP make_pair
#define dbg(x) cout << #x << ": " << x << endl
#define check(k, i, j) ((k>=i) && (k<=j))
#define ff first
#define ss second
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;
using namespace std;
int dx[]={1,1,0,-1,-1,-1, 0, 1}; 
int dy[]={0,1,1, 1, 0,-1,-1,-1};

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

// ===================================== //

int main(){

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

    FAST_IO;
    int x;
    cin >> x;
    cout << !(x==1) << endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;

const int M = 100001+3;
ll solve( ll N );


int main(void) {
	
	ll N;
	cin >> N;
	cout << solve(N) << endl;
	
	return 0;
}


ll solve( const ll N ) {

	int ans = 0;

	//?´????????????¨???
	vector< int > v(M,0);

	v[0]++;
	v[v.size()-1]--;
	for( ll i = 0; i < N; i++ ) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b+1]--;
	}

	for( ll i = 0; i+1 < M; i++ )
		v[i+1] += v[i];

	for( int i = 0; i < M; i++)
		if( min(v[i],i) > ans && (v[i] >= i) )
			ans = min(v[i],i);

	return max(ans-1,0);

}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll n,K;
vector<pll> vec;

bool ok(ll cri)
{
    ll res = 0;
    rep(i,n){
        if(cri < vec[i].fi){
            continue;
        }
        res += (cri-vec[i].fi)/vec[i].se + 1;
    }
    return res >= K;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> K;
    vec.resize(n);
    rep(i,n){
        cin >> vec[i].fi >> vec[i].se;
    }
    ll l = 0,r = 2000000000000000005;
    while(r-l > 1){
        ll mid = (l+r)/2;
        if(ok(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

using namespace std;

int N,A;
int x[51];
long long dp[3000][52][52];

int main() {
  scanf("%d%d",&N,&A);
  for(int i=0;i<N;++i) {
    scanf("%d", &x[i]);
  }
  memset(dp, 0,sizeof(dp));
  dp[0][0][0]=1;
  for(int i=0;i<2600;++i) {
    for(int j=0;j<N;++j) {
      for(int k=0;k<N;++k) {
        dp[i+x[j]][j+1][k+1] += dp[i][j][k];
        dp[i][j+1][k] += dp[i][j][k];
      }
    }
  }
  long long answer =0;
  for(int i=1;i<=N;++i) {
    answer += dp[i*A][N][i];
  }
  printf("%lld\n", answer);
  return 0;
}


Measured memory_bytes: 63616
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >>  B >> X;
  cout << double(B)/double(X) << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t m, k;
    cin >> m >> k;

    if (m == 0) {
        if (k == 0) {
            cout << "0 0" << endl;
        } else {
            cout << "-1" << endl;
        }

        return 0;
    }

    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << "-1" << endl;
        }

        return 0;
    }

    auto n = (1 << m);
    if (k >= n) {
        cout << "-1" << endl;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        if (i == k) {
            continue;
        }
        cout << i << " ";
    }

    cout << k << " ";

    for (int i = n - 1; i >= 0; --i) {
        if (i == k) {
            continue;
        }
        cout << i << " ";
    }

    cout << k << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) {
        cout << s << "\n";
    } else {
        cout << s.substr(0, k) << "...\n";
    }
}


Measured memory_bytes: 3624
A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a*a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1
    prime_num[i].append(n)
    

#print(prime_num)
print(len(set(prime_num[0])&set(prime_num[1])))


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

int main()
{
	long long int n, k, ans = 0;
	int h[200001];

	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	sort(h, h + n);

	for (int j = (n - k - 1); j >= 0; j--)
	{
		ans += h[j];
	}

	cout << ans << endl;
}

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

    bool ans = true;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ans = false;

    cout << (ans ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
vector<ll> a(n);
for(int i = 0; i < n; i++)
    cin >> a[i];
vector<ll> sums(n + 1,0);
rep(i,n){
    sums[i + 1] = sums[i] + a[i];
}
for(int i = k + 1; i <= n; i++){
    if(sums[i] - sums[i - k] > sums[i - 1] - sums[i - k - 1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; 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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    int ans=0;
    queue<int> w;
    stack<int> r;
    for(int i=0;i<n;i++){
        if(s[i]=='W') w.push(i);
        if(s[i]=='R') r.push(i);
    }
    //できる限り置換
    while(!(r.empty() || w.empty())){
        int x1=r.top(); r.pop();
        int x2=w.front(); w.pop();
        //cout << x1 << " " << x2 << endl;
        s[x1]='W'; s[x2]='R';
        if(x1<x2) break;
        ans++;
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 4428
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(long i=0;i<(long)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main()
{
  long N=IN(),calc=0;int X=IN(),MOD=IN(),vis[100001],val[100001];
  if(N<=MOD){rep(i,N){calc+=X;X=1l*X*X%MOD;}return OUT(calc),0;}
  else
  {
    rep(i,MOD+1)
    {
      val[i+1]=X;
      if(vis[X])
      {
        rep(j,vis[X]){calc+=val[j+1];}
        rep(j,i-vis[X]+1){calc+=1l*(N-2*vis[X]+i-j)/(i+1-vis[X])*val[j+vis[X]+1];}
        return OUT(calc),0;
      }
      vis[X]=i+1;X=1l*X*X%MOD;
    }	
  }
}

Measured memory_bytes: 2084
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
    int H,W,i,j;
    while(1){
        cin>> H>> W;
        if(H==0 && W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if((i+j)%2==0){
                    cout<< "#";
                }
                else{
                    cout<< ".";
                }
            }
        cout<< endl;
        }
    cout<< endl;
    }
    return 0;
}

Measured memory_bytes: 1152
n = int(input())
t_pre = 0
x_pre = 0
y_pre = 0
ans = "Yes"

for _ in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - x_pre) + abs(y - y_pre)
    t_interval = t - t_pre
    if d <= t_interval and (t_interval - d) % 2 == 0:
        t_pre = t
        x_pre = x
        y_pre = y
    else:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
void nuri(int,int);

int N,a[100000],b[100000],cco[100000]={0},coun[100000]={0},col[100000]={0},maxN;
vector< vector<int> > to;

int main(){
	maxN=0;
	cin>>N;
	to.resize(N+1);
	for(int i=0;i<N-1;i++){
		cin>>a[i]>>b[i];
		to[a[i]].push_back(i);
		to[b[i]].push_back(i);
		coun[a[i]]++;
		coun[b[i]]++;
		if(coun[a[i]]>maxN)maxN=coun[a[i]];
		if(coun[b[i]]>maxN)maxN=coun[b[i]];
	}
	cout<<maxN<<endl;
	nuri(1,-1);
	for(int i=0;i<N-1;i++)cout<<col[i]<<endl;
	return 0;
}
void nuri(int start,int nuse){
	int j=1,k;
	for(int i=0;i<to[start].size();i++){
		k=to[start][i];
		if(j==nuse)j++;
		if(col[k]==0){
			col[k]=j;
			if(start==a[k])nuri(b[k],j);
			else nuri(a[k],j);
			j++;
		}
	}
}

Measured memory_bytes: 8064
<?php
fscanf(STDIN,"%d %d %d %d %d",$W,$H,$x,$y,$r);
if($x - $r >= 0 && $x + $r <= $W && $y - $r >= 0 && $y + $r <= $H){
    echo "Yes";
}else{
    echo "No";
}
?>

Measured memory_bytes: 15288
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll n; cin >> n;
    ll ans = 1000000000000;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) ans = min(ans, i + (n / i) - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0;
  while (input[i] != 0) {
    arr = input[i].split(" ");
    if (arr[0] == 0 && arr[1] == 0 ) {
      break;
    }

    count = 0
    for (j = 1; j <= arr[0] - 2; j++) {
      for (k = j + 1; k <= arr[0] - 1; k++) {
        for (l = k + 1; l <= arr[0]; l++) {
          if (j + k + l == arr[1]) {
            count++;
          }
        }
      }
    }
    console.log(count);
    i++;
  }
});

Measured memory_bytes: 8696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	long long n;

	std::cin >> n;

	std::vector<std::pair<long long, long long> > v(n);

	for (long long i = 0; i < n; i++)
	{
		long long a, b;

		std::cin >> a >> b;

		v[i] = { a, b };
	}

	std::vector<std::vector<double> > v2(n, std::vector<double>(n, 0));

	for (long long i = 0; i < n; i++)
	{
		for (long long j = i + 1; j < n; j++)
		{
			double x = v[i].first - v[j].first;
			double y = v[i].second - v[j].second;
			v2[i][j] = v2[j][i] = std::sqrt(x * x + y * y);
		}
	}

	std::vector<int> vv(n);
	for (int i = 0; i < n; i++)
	{
		vv[i] = i + 1;
	}

	double ans = 0;
	long long count = 0;

	do {
		for (size_t i = 0; i < n - 1; i++)
		{
			ans += v2[vv[i] - 1][vv[i + 1] - 1];
		}
		count++;
	} while (std::next_permutation(vv.begin(), vv.end()));

	printf("%.8lf\n", ans / count);

	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void printArray(const int *arr, int n);
void printArray(const vector<int> &arr);

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
int a[300000], s[300000];
vector<int> pos[300000];

void bf(int n){
    vector<int> v;
    vector<bool> used;
    for(int i=0;i<n;++i){
        v.pb(i);
        v.pb(i);
    }
    do{
        used.assign(n, 0);
        set<int> wew;
        for(int i=0;i<v.size();++i){
            if(used[v[i]]) continue;
            used[v[i]] = true;
            int xors = 0;
            for(int j=i+1;j<v.size();++j){
                if(v[i] == v[j]){
                    wew.insert(xors);
                    break;
                }
                xors ^= v[j];
            }
        }
        if(wew.size() == 1){
            printf("%d:", *wew.begin());
            for(int x : v){
                printf(" %d", x);
            }
            puts("");
        }
        if(v[0] >= n/2) break;
    }while(next_permutation(v.begin(), v.end()));
}

int main(){
	scanf("%d %d", &n, &k);
    // bf(1<<n);
    if(k >= (1<<n) || (n==1 && k>=1)) return puts("-1"), 0;
    int b = 1<<n;
    if(k==0){
        for(int i=0;i<b;++i){
            a[2*i] = a[2*i+1] = i;
        }
    }
    else{
        a[0] = a[b-1] = 0;
        a[b] = a[2*b-1] = k;
        for(int i=1;i<b-1;++i){
            a[i] = a[i+b] = i + (i>=k);
        }
        reverse(a+1, a+b-1);
        for(int i=0;i<2*b;++i){
            s[i+1] = s[i] ^ a[i];
            pos[a[i]].pb(i);
        }
        bool bisa = true;
        for(int i=0;i<b;++i){
            if((s[pos[i][1]+1] ^ s[pos[i][0]]) != k) bisa = false;
        }
        if(!bisa) return puts("-1"), 0;
    }
    for(int i=0;i<2*b;++i)
        printf("%d ", a[i]);
    puts("");
	return 0;
}

/* Template Function */
void printArray(const int * a, int n){
	for(int i=0;i<n;++i){
		printf("%d ", a[i]);
	}
	puts("");
}

void printArray(const vector<int> &arr){
	for(int x : arr){
		printf("%d ", x);
	}
	puts("");
}

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

int main() {
    int Q;
    cin >> Q;
    int c, a, n;
    while (Q--) {
        cin >> c >> a >> n;
        int can = min(c, min(a, n));
        c -= can;
        a -= can;
        n -= can;
        int cca = min(c / 2, a);
        c -= cca * 2;
        a -= cca;
        int ccc = c / 3;
        cout << can + cca + ccc << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  string ans = "~";
  int m = s.size();
  int n = t.size();
  rep(i, m - n + 1) {
    if(s[i] != t[0] && s[i] != '?') continue;
    bool ok = true;
    string tmp = s;
    rep(j, n) {
      if(tmp[i + j] != t[j] && tmp[i + j] != '?')
        ok = false;
      else
        tmp[i + j] = t[j];
    }
    replace(all(tmp), '?', 'a');
    if(ok) ans = min(ans, tmp);
  }
  cout << (ans == "~" ? "UNRESTORABLE" : ans) << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) { 
	Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        double[]a = new double[n];
        for(int i = 0; i < n; i++){
            a[i] = scn.nextDouble();
        }
        Arrays.sort(a);
        double max = 0l;
        for(int i = 0; i < n-1; i++){
            a[i+1] = (a[i]+a[i+1])/2;
            max = a[i+1];
        }
        System.out.println(max);
    }
} 


Measured memory_bytes: 23252
n = int(input())
a = [int(i) for i in input().split()]
a_max = max(a)
count = {}
for i in range(a_max+2):
    count[i] = 0
for i in a:
    if i != 0:
        count[i-1] += 1
        count[i] += 1
        count[i+1] += 1
    if i == 0:
        count[i] += 1
        count[i+1] += 1
        
print(max(count.values()))

Measured memory_bytes: 20256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;  
  string s;
  cin >> n >> a >> b >> s;
  int total = 0, abroad = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'a'){
      if(total < a+b){
        cout << "Yes" << endl;
        total++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else if(s[i] == 'b'){
      if(total < a+b && abroad < b){
        cout << "Yes" << endl;
        total++;
        abroad++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 848
using System;

namespace abca153
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = a % b;

            if (a < b)
                Console.WriteLine(1);
            else if (c > 0)
                Console.WriteLine(a/b + 1);
            
            
            if (a%b==0)
                Console.WriteLine(a/b);
            Console.ReadKey();
                
        }
    }
}


Measured memory_bytes: 13140
from typing import List, Tuple


def rectangle(max_width: int, hist: List[int]) -> int:
    stack: List[Tuple[int, int]] = []  # (height, x_position)
    ans = 0
    for i, h in enumerate(hist):
        j = i
        while stack and stack[-1][0] > h:
            pre_h, j = stack.pop()
            ans = max(ans, (i - j) * pre_h)

        if not stack or stack[-1][0] < h:
            stack.append((h, j))

    ans = max(ans, max((max_width - j) * h for h, j in stack))
    return ans


if __name__ == "__main__":
    H, W = map(lambda x: int(x), input().split())
    hist = [0] * W

    result = 0
    for _ in range(H):
        one_row = list(map(int, input().split()))
        hist = list(map(lambda pre, cur: (pre + 1) * (cur ^ 1), hist, one_row))
        result = max(result, rectangle(W, hist))

    print(result)



Measured memory_bytes: 7336
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toInt

  //
  val dp = Array.ofDim[Long](N+1, 4)
  val init = Long.MinValue / 3
  for (i <- 0 to N; j <- 0 to 3)
    dp(i)(j) = init

  dp(0)(0) = 0
  for (i <- 0 until N; j <- 0 to 2) {
    if ((i+j) % 2 == 1) { // 使わない
      dp(i+1)(j) = Math.max(dp(i+1)(j), dp(i)(j))
    }
    else {
      dp(i+1)(j+1) = Math.max(dp(i+1)(j+1), dp(i)(j))
      dp(i+1)(j) = Math.max(dp(i+1)(j), dp(i)(j) + A(i+1))
    }
  }

  if (N % 2 == 0)
    println(Math.max(dp(N)(1), dp(N)(0)))
  else
    println(Math.max(dp(N)(2), dp(N)(1)))
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 82980
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M, C;
  cin >> N >> M >> C;
  long long B[M];
  for (int i = 0; i < M; i++) cin >> B[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    long long cost = C;
    for (int j = 0; j < M; j++) {
      long long A;
      cin >> A;
      cost += B[j] * A;
    }
    if (cost > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    b = [0 for _ in range(N)]
    base = (N//2)
    cnt = 1
    
    flg = False
    if N % 2 == 0:
        flg = True
    
    for i, val in enumerate(A):
        
        if flg == True:
            if i == 0:
                b[base] = val
            elif i % 2 == 1:
                b[base-cnt] = val
            else:
                b[base+cnt] = val
                cnt+=1
        else:
            if i == 0:
                b[base] = val
            elif i % 2 == 1:
                b[base+cnt] = val
            else:
                b[base-cnt] = val
                cnt+=1
    
    print(*b)
    
        
if __name__ == "__main__":
	main()


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


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;

int r1[500][500];
int r2[500][500];
int UF1[250000];
int UF2[250000];
pair<int,pair<int,int> > k1[500000];
pair<int,pair<int,int> >k2[500000];
int cost1[250001];
int cost2[250001];
int FIND1(int a){
	if(UF1[a]<0)return a;
	return UF1[a]=FIND1(UF1[a]);
}
int FIND2(int a){
	if(UF2[a]<0)return a;
	return UF2[a]=FIND2(UF2[a]);
}
void UNION1(int a,int b){
	a=FIND1(a);
	b=FIND1(b);
	if(a==b)return ;
	UF1[a]+=UF1[b];
	UF1[b]=a;
}
void UNION2(int a,int b){
	a=FIND2(a);
	b=FIND2(b);
	if(a==b)return;
	UF2[a]+=UF2[b];
	UF2[b]=a;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<250001;i++)cost1[i]=cost2[i]=999999999;
		for(int i=0;i<250000;i++)UF1[i]=UF2[i]=-1;
		cost1[0]=cost2[0]=0;
		int b1,c1,d1,e1;
		int b2,c2,d2,e2;
		scanf("%d%d%d%d",&b1,&c1,&d1,&e1);
		for(int i=0;i<c1;i++){
			for(int j=0;j<b1;j++){
				scanf("%d",&r1[i][j]);
			}
		}
		scanf("%d%d%d%d",&b2,&c2,&d2,&e2);
		for(int i=0;i<c2;i++)
			for(int j=0;j<b2;j++)
				scanf("%d",&r2[i][j]);
		int now1=0;
		for(int i=0;i<c1-1;i++){
			for(int j=0;j<b1;j++){
				k1[now1++]=make_pair(max(r1[i][j],r1[i+1][j]),make_pair(b1*i+j,b1*(i+1)+j));
			}
		}
		for(int i=0;i<c1;i++){
			for(int j=0;j<b1-1;j++)
				k1[now1++]=make_pair(max(r1[i][j],r1[i][j+1]),make_pair(b1*i+j,b1*i+j+1));
		}
		int now2=0;
		for(int i=0;i<c2-1;i++){
			for(int j=0;j<b2;j++){
				k2[now2++]=make_pair(max(r2[i][j],r2[i+1][j]),make_pair(b2*i+j,b2*(i+1)+j));
			}
		}
		for(int i=0;i<c2;i++){
			for(int j=0;j<b2-1;j++)
				k2[now2++]=make_pair(max(r2[i][j],r2[i][j+1]),make_pair(b2*i+j,b2*i+j+1));
		}
		std::sort(k1,k1+now1);
		std::sort(k2,k2+now2);
		for(int i=0;i<now1;i++){
			UNION1(k1[i].second.first,k1[i].second.second);
			cost1[-UF1[FIND1((e1-1)*b1+d1-1)]]=min(cost1[-UF1[FIND1((e1-1)*b1+d1-1)]],k1[i].first);
		}
		for(int i=0;i<now2;i++){
			UNION2(k2[i].second.first,k2[i].second.second);
			cost2[-UF2[FIND2((e2-1)*b2+d2-1)]]=min(cost2[-UF2[FIND2((e2-1)*b2+d2-1)]],k2[i].first);
		}
		for(int i=249999;i>=0;i--){
			cost1[i]=min(cost1[i],cost1[i+1]);
			cost2[i]=min(cost2[i],cost2[i+1]);
		}
		int ret=999999999;
		for(int i=0;i<=a;i++)ret=min(ret,cost1[i]+cost2[a-i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll mod = 998244353;
int n, s;
vector<ll> A(3030, 0);
vector< vector<ll> > dp(3030, vector<ll>(3030, 0));

int main() {
    cin >> n >> s;
    for(int i = 0; i < n; ++i) cin >> A.at(i);
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= s; ++j) {
            dp[i+1][j] += dp[i][j]*2;
            dp[i+1][j] %= mod;
            if(j+A.at(i) <= s) {
                dp[i+1][j+A.at(i)] += dp[i][j];
                dp[i+1][j+A.at(i)] %= mod;
            }
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 74872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long int N,M,d,t;
    vector<int> D,T;

    cin >> N;//N問
    for (int i = 0; i < N; i++){
        cin >> d;
        D.push_back(d);
    }
    sort(D.begin(),D.end());//昇順にソート

    cin >> M;//N問
    for (int i = 0; i < M; i++){
        cin >> t;
        T.push_back(t);
    }
    sort(T.begin(),T.end());//昇順にソート


    int j = 0;
    for (int i = 0; i < M; i++){
        if (T[i] == D[j]) {
            j++;
        }else if (T[i] > D[j]){
            j++;
            i--;
        }else{
            cout << "NO" << endl;
            break;
        }
        if (i == M-1){
            cout << "YES" << endl;
        }
    }



    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
set<int> s;
int main(){
  cin>>n;
  int tmp;
  REP(i,n){
    cin>>tmp;
    s.insert(tmp);
  }
  cout<<s.size()<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        s = input()
        s = "".join(sorted(s))
        cnt[s] += 1

    ans = 0
    for n in cnt.values():
        ans += n*(n-1)//2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18196
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

const int MAXN = 1010;
const int MAXX = 5010;
vector<int> G[MAXN];
int N, x[MAXN], dp[MAXN], dp2[MAXN][MAXX];
bool ok = true;

int solve_dp(vector<int> &a, vector<int> &b, int &lim) {
    int M = a.size();
    rep(i,0,MAXN) repq(j,0,lim) dp2[i][j] = INF;
    dp2[0][0] = 0;
    rep(i,0,M) repq(j,0,lim) {
        if(dp2[i][j] == INF) continue;

        // choose a
        if(j + a[i] <= lim) {
            chmin(dp2[i+1][j+a[i]], dp2[i][j] + b[i]);
        }

        // choose b
        if(j + b[i] <= lim) {
            chmin(dp2[i+1][j+b[i]], dp2[i][j] + a[i]);
        }
    }
    return *min_element(dp2[M], dp2[M]+lim+1);
}

void solve(int p, int par=-1) {
    bool leaf = true;
    vector<int> a, b;
    for(auto to : G[p]) {
        if(to == par) continue;
        leaf = false;
        solve(to, p);
        a.push_back(x[to]);
        b.push_back(dp[to]);
    }
    if(leaf) dp[p] = 0;
    else {
        int val = solve_dp(a, b, x[p]);
        if(val == INF) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        dp[p] = val;
    }
}

signed main() {
    cin >> N;
    rep(i,0,N-1) {
        int p; cin >> p; p--;
        G[p].push_back(i+1);
    }
    rep(i,0,N) {
        cin >> x[i];
        dp[i] = INF;
    }
    
    solve(0);
    cout << (!ok ? "IMPOSSIBLE" : "POSSIBLE") << endl;
    return 0;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int s=0;
	for(int i=1;i<=k;i++)
		s+=a[i];
	cout<<s;
}



Measured memory_bytes: 3604
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

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

    vector<ll> a(n);

    map<ll, ll> mp;
    ll sum = 0;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
        mp[a[i]]++;
    }

    int Q;
    cin >> Q;

    while(Q--)
    {
        int b, c;
        cin >> b >> c;

        sum -= b * mp[b];
        sum += c * mp[b];

        mp[c] += mp[b];
        mp[b] = 0;

        cout << sum << endl;
    }
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}




Measured memory_bytes: 9864
#include <iostream>
using namespace std;
int main() {
    int n;cin>>n;
    int  h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
from sys import stdin
import numpy as np
from operator import itemgetter

K = int(stdin.readline().rstrip().split()[0])
#N, K = [int(x) for x in stdin.readline().rstrip().split()]
#A = [int(x) for x in stdin.readline().rstrip().split()]

MOD = 10**9 + 7

array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])


Measured memory_bytes: 21876
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
        return 0;
    }
    k-=a;
    if(b>=k){
        cout<<a<<endl;
        return 0;
    }
    k-=b;
    cout<<a-k<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 500010
#define MOD 998244353
#define G 3
inline int fuck(int x, int p) {
    int y = 1;
    while (p) {
        if (p & 1) y = 1LL * y * x % MOD;
        x = 1LL * x * x % MOD;
        p >>= 1;
    }
    return y;
}
inline void NTT(int *a, int n, int e) {
    for (int i = 1, j = 0; i < n - 1; i++) {
        for (int t = n; ~j & t; j ^= t) t >>= 1;
        if (i < j) std::swap(a[i], a[j]);
    }
    for (int k = 1; k < n; k <<= 1) {
        int t = k << 1, wn = fuck(G, (MOD - 1) / t);
        for (int i = 0; i < n; i += t) {
            for (int j = 0, w = 1; j < k; j++, w = 1LL * w * wn % MOD) {
                int x = a[i + j], y = 1LL * w * a[i + j + k] % MOD;
                a[i + j] = (x + y) % MOD;
                a[i + j + k] = (x - y + MOD) % MOD;
            }
        }
    }
    if (e) {
        std::reverse(a + 1, a + n);
        for (int i = 0, w = fuck(n, MOD - 2); i < n; i++) a[i] = 1LL * a[i] * w % MOD;
    }
}

int A[MAXN], B[MAXN];
inline void mul(int *a, int *b, int len) {
    int t = 1;
    while (t < len * 2) t <<= 1;
    memset(A, 0, sizeof(int) * t);
    memset(B, 0, sizeof(int) * t);
    memcpy(A, a, sizeof(int) * len);
    memcpy(B, b, sizeof(int) * len);
    NTT(A, t, 0);
    NTT(B, t, 0);
    for (int i = 0; i < t; i++) A[i] = 1LL * A[i] * B[i] % MOD;
    NTT(A, t, 1);
    memcpy(a, A, sizeof(int) * len);
}
int n, t0, t1, frc[MAXN], inv[MAXN];
char buf0[MAXN], buf1[MAXN];
int a[MAXN], b[MAXN];
int main() {
    scanf("%s%s", buf0 + 1, buf1 + 1);
    n = strlen(buf0 + 1);
    for (int i = 1; i <= n; i++) {
        t0 += buf0[i] == '1' && buf1[i] == '1';
        t1 += buf0[i] == '1' && buf1[i] == '0';
    }
    frc[0] = 1;
    for (int i = 1; i < MAXN; i++) frc[i] = 1LL * frc[i - 1] * i % MOD;
    inv[MAXN - 1] = fuck(frc[MAXN - 1], MOD - 2);
    for (int i = MAXN - 1; i; i--) inv[i - 1] = 1LL * inv[i] * i % MOD;
    a[0] = 1;
    int p = t1;
    int len = t0 + 1;
    for (int i = 0; i < len; i++) b[i] = inv[i + 1];
    while (p) {
        if (p & 1) mul(a, b, len);
        mul(b, b, len);
        p >>= 1;
    }
    int ans = 0;
    for (int i = 0; i < len; i++) {
        (ans += 1LL * a[i] * frc[t0] % MOD * frc[t1] % MOD * frc[t0 + t1] % MOD) %= MOD;
    }
    (ans += MOD) %= MOD;
    printf("%d\n", ans);
    return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;

void solve() {
  char str[1010];
  scanf("%s", str + 1);
  rep(i, 1, 3) putchar(str[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


Measured memory_bytes: 3768
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String,Integer> result = new LinkedHashMap<String,Integer>();
		result.put("AC",0);
		result.put("WA",0);
		result.put("TLE",0);
		result.put("RE",0);
		for(int i = 0;i < n; i++) {
			String key = sc.next();
			result.put(key,result.get(key)+1);
		}
		for(String key: result.keySet()) {
			System.out.println(key + " x " + result.get(key));
		}
	}
}

Measured memory_bytes: 59452
#include <iostream> 
#include <cmath>
 
 using namespace std; 
 typedef long long ll;
 
int main(void){ 
     long double a,b,c;
      cin >> a >> b >> c;
 long double eps = 1.0E-14;
 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){ 
      cout << "Yes" << endl; 
      } else { 
          cout << "No" << endl; 
          }
 return 0; 
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(string S){
	// set<string> st;
	string n = "", o = "";
	// n = n + S[0];
	ll res = 0;
	// st.insert(n);
	// n = "";
	rep(i, S.length()) {
		n = n + S[i];
		// cout << n << endl;
		if (n != o) {
			o = n;
			n = "";
			res++;
		}
	}
	cout << res << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 772
@D=map[glob<>],@@=0..$'-<>=~$";map{$j=0;for$x(glob){$k=($i+$j++)%3;$_[$k][$_]+=$D[$x-1][$_]for@@}++$i}<>;$\=1e15;for$i(@@){for$j(@@){$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]for@@}}print

Measured memory_bytes: 1792
N,K=map(int,input().split())
h=list(map(int,input().split()))

DP=[10000000000]*N

DP[0]=0
for i in range(1,N):
    temp=[]
    if i<K:
        for j in range(i):
            temp.append(DP[j]+abs(h[j]-h[i]))
    else:
        for j in range(1,K+1):
            temp.append(DP[i-j]+abs(h[i]-h[i-j]))
    DP[i]=min(temp)

print(DP[N-1])

Measured memory_bytes: 52576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

#define rep1(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (long long i = (long long)(n); i <= (long long)(m); i++)
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;

int main() {
    long long a, b, m;
    cin >> a >> b >> m;
    long long refrigerators[a], microwaves[b], tickets[m][3];
    long long lowest_refrigerator = 1e5 + 1;
    long long lowest_microwave = 1e5 + 1;
    rep1(i, a) {
        cin >> refrigerators[i];
        lowest_refrigerator = min(lowest_refrigerator, refrigerators[i]);
    }
    rep1(i, b) {
        cin >> microwaves[i];
        lowest_microwave = min(lowest_microwave, microwaves[i]);
    }
    rep1(i, m) {
        cin >> tickets[i][0];
        cin >> tickets[i][1];
        cin >> tickets[i][2];
    }
    long long lowest = lowest_microwave + lowest_refrigerator;
    rep1(i, m) {
        long long refrigerator_index = tickets[i][0] - 1;
        long long microwave_index = tickets[i][1] - 1;
        long long discount = tickets[i][2];
        lowest = min(lowest, refrigerators[refrigerator_index] + microwaves[microwave_index] - discount);
    }
    cout << lowest << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main(){
  int n, m;
  cin >> n >> m;
  dsu d(n);
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--;b--;
    d.merge(a,b);
  }
  int size = d.groups().size();
  int ans = size - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8912
#!/usr/bin/env python3

import sys
import math
sys.setrecursionlimit(10 ** 6)


def main():
	n, m = map(int, sys.stdin.readline().split())
	score = 0
	if n >= 2:
		score += math.factorial(n) // math.factorial(n-2) // math.factorial(2)
	if m >= 2:
		score += math.factorial(m) // math.factorial(m-2) // math.factorial(2)
	print(score)

main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		int[] res = new int[N+1];
		for (int i=0; i<M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i=0; i<M; i++) {
			res[a[i]]++;
			res[b[i]]++;
		}
		for (int i=1; i<res.length; i++) {
			System.out.println(res[i]);
		}
	}
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD =1e9+7;

long mp(long x, long n){
  long ans = 1;
  for(int i=1; i<=n; i++){
    ans = ans*x %MOD;
  }
  return ans;
}


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  if(N%2==1){
    if(A[0]!=0){
      cout << "0" << endl;
      return 0;
    }
    for(int i=1; i<N; i+=2){
      if(A[i]==i+1 && A[i+1]==i+1) continue;
      cout << "0" << endl;
      return 0;
    }
    cout << mp(2, N/2) << endl;
    return 0;
  }
  for(int i=0; i<N; i+=2){
    if(A[i]==i+1 && A[i]==i+1) continue;
    cout << "0" << endl;
    return 0;
  }
  cout << mp(2, N/2) << endl;
  return 0;
}

Measured memory_bytes: 640