akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  cin >> n;
  if (n == 0)
    return !printf("%lld\n", 0);
  ll a = 2, m = 1;
  string ans = "";
  while (n) {
    if (n % a) {
      ans = "1" + ans;
      n -= m;
    } else {
      ans = "0" + ans;
    }
    a *= 2;
    m *= -2;
  }
  cout << ans << endl;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string s; cin >> s;
    bool ans = 1;
    sort(s.begin(), s.end());
    REPI(i, s.length() - 1){
        if(s[i] == s[i + 1]){
            ans = 0;
            break;
        }
    }
    ans ? cout << "yes" : cout << "no";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
#define foreach(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)

int main()
{
    rep(i,9)rep(j,9) cout << i + 1 << "x" << j + 1 << "=" << (i+1)*(j+1) << endl;
    return 0;
}

Measured memory_bytes: 1116
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = inf;
    for(int i = 0; i <= n - m; ++ i) {
        int res = 0;
        rep(j, m) {
            if(s[i + j] != t[j]) ++ res;
        }
        chmin(ans, res);
    }
    cout << ans << endl;
}

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

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

using namespace std;

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

typedef pair<int, int> P;

const int inf = 1 << 25;

struct edge
{
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

vector< vector<edge> > graph;
vector< vector<int> > mincost;

void dijkstra(int s)
{
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  mincost[s][s] = 0;
  while(!que.empty()) {
    int cost, now;
    tie(cost, now) = que.top(); que.pop();
    if(mincost[s][now] < cost) continue;
    for(edge& e : graph[now]) {
      if(e.cost + cost < mincost[s][e.to]) {
	mincost[s][e.to] = e.cost + cost;
	que.push(P(mincost[s][e.to], e.to));
      }
    }
  }
  //return *max_element(all(mincost[s]));
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, R;
  cin >> N >> R;
  graph.resize(N);
  rep(i, R) {
    int s, t, d;
    cin >> s >> t >> d; s--, t--;
    graph[s].emplace_back(t, d);
    graph[t].emplace_back(s, d);
  }

  mincost.resize(N, vector<int>(N, inf));
  int maxdist = 0;
  rep(i, N) dijkstra(i); //maxdist = max(maxdist, dijkstra(i));
  rep(i, N) reps(j, i+1, N) maxdist = max(maxdist, mincost[i][j]);

  vector<P> ep;
  rep(i, N) reps(j, i+1, N) {
    if(mincost[i][j] == maxdist) ep.emplace_back(i, j);
  }

  vector<int> ans;
  rep(i, N) {
    bool flag = true;
    for(auto& p : ep) {
      int s, t; tie(s, t) = p;
      if(mincost[s][i] + mincost[i][t] == maxdist) flag = false;
    }
    if(flag) ans.push_back(i+1);
  }
  
  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i] << endl;
  
  return 0;
}

Measured memory_bytes: 28328
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2 || a==2 && b==1) cout<<3<<endl;
    if(a==2 && b==3 || a==3 && b==2) cout<<1<<endl;
    if(a==1 && b==3 || a==3 && b==1) cout<<2<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;


vector<string> split(string s,char c){
	stringstream ss(s);
	string t;
	vector<string> ret;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}




int main(){
	string s;
	vector<string> v;
	string ope[4]={"+","-","*","/"};
	while(getline(cin,s)){
		v=split(s,' ');
		stack<double> t;
		double a,b,c;
		for(int i=0; i<v.size(); i++){
			for(int j=0; j<4; j++){
				if(v[i]==ope[j]){
					a=t.top();
					t.pop();
					b=t.top();
					t.pop();
					if(j==0)c=b+a;
					else if(j==1)c=b-a;
					else if(j==2)c=b*a;
					else c=(double)b/a;
					t.push(c);
					break;
				}
				if(j==3){
					c=atof(v[i].c_str());
					t.push(c);
				}
			}
		}
		printf("%.15lf\n", t.top());
	}
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

void Acout(int A[],int N){
    rep(i,N){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
}

int main(){
    int N;
    cin>>N;
    int a[N];
    rep(i,N)cin>>a[i];
    int Q;
    cin>>Q;
    int t;
    int ans=0;

    rep(i,Q){
        int f=0;
        int b=N;
        int c=0;
        cin>>t;
        while(f<b){
            int h = int((b+f)/2);
            if(a[h]==t){
                ans++;
                break;
                }
            else if(a[h]>t)b=h;
            else f=h+1;
            c++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int a, b;
  while((cin >> a >> b), a, b){
    int n1=0, n2=0, n3=0;
    a = b-a;
    while(a>=1000){
      n3++;
      a-=1000;
    }
    while(a>=500){
      n2++;
      a-=500;
    }
    while(a>=100){
      n1++;
      a-=100;
    }
    cout << n1 << " " << n2 << " " << n3 << endl;
  }
  return 0;
}

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

typedef long long ll;
const int N = 200233, mod = 1000000007;
int n, a[N], ans = 0;

int qpow(int b, int p) {
  int r = 1;
  for (; p; p >>= 1) {
    if (p & 1) r = (ll) r * b % mod;
    b = (ll) b * b % mod;
  }
  return r;
}

struct int0 {
  int a, b;
  int0 (int a = 0, int b = 0) : a(a), b(b) {}
  int0 operator + (const int0 &d) const {
    if (b < d.b) return *this;
    if (b > d.b) return d;
    return int0((a + d.a) % mod, b);
  }
  int0 operator * (const int0 &d) const {
    return int0((ll) a * d.a % mod, b + d.b);
  }
  int0 operator * (const int &d) const {
    return d == 0 ? int0(a, b + 1) : int0((ll) a * d % mod, b);
  }
  int0 inv() {
    return int0(qpow(a, mod - 2), -b);
  }
  int val() {
    return b ? 0 : a;
  }
};

int S, cnt[N];
int0 d[N], c[N];
inline int0 ask(int x) {
  int0 ret(0, 0);
  for (; x; x -= x & -x) {
    ret = ret + c[x];
  }
  return ret;
}
inline void add(int x, int0 y) {
  for (; x <= n; x += x & -x) {
    c[x] = c[x] + y;
  }
}
inline int solve(int *a, int flag) {
  S = 1;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    cnt[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    cnt[a[i]]++;
  }
  for (int i = n; i; i--) {
    cnt[i - 1] += cnt[i];
    cnt[i] -= n - i;
    S = (ll) S * (cnt[i] <= 0 ? 0 : cnt[i]) % mod;
  }
  if (!S) return 0;
  d[0] = int0(1, 0);
  for (int i = 1; i <= n; i++) {
    d[i] = d[i - 1] * ((ll) (cnt[i] - 1) * qpow(cnt[i], mod - 2) % mod);
  }
  for (int i = 1; i <= n; i++) {
    c[i] = int0(0, 0);
  }
  for (int i = 1; i <= n; i++) {
    int0 t = ask(a[i] - flag);
    ret = (ret + (ll) (t * d[a[i]]).val() * S) % mod;
    add(a[i], d[a[i]].inv());
  }
  return (ll) ret * (mod + 1) / 2 % mod;
}

inline int solve2(int *a) {
  for (int i = 1; i <= n; i++) {
    c[i] = int0(0, 0);
  }
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    ret = (ret + ask(a[i] - 1).val()) % mod;
    add(a[i], int0(1, 0));
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  ans = solve(a, 0);
  reverse(a + 1, a + n + 1);
  ans = (ans + mod - solve(a, 1)) % mod;
  ans = (ans + (ll) S * solve2(a)) % mod;
  printf("%d\n", ans);
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;


int main(){
  bool flg = false;
  int N=0;
  cin >> N;
  char col[N];
  for(int i=0;i<N;i++){
    cin >> col[i]; 
    if(col[i] == 'Y') flg = true;
  }
  if(flg) cout << "Four" << endl;
  else cout << "Three" << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define INF 1998244353
int H;
int W;
int a[1010][1010];
int w[1010];
int cost[15][15];
bool used[15];
long long ans;
void dfs(int now,int f,int x)
{
	if(now==1)
	{
		w[x]=min(w[x],f);
		return;
	}
	used[now]=true;
	w[x]=min(w[x],f+cost[now][1]);
	for(int i=0;i<=9;i++)
	{
		if(!used[i])
		{
			dfs(i,f+cost[now][i],x);
		}
	}
	used[now]=false;
}
int main()
{
	scanf("%d %d",&H,&W);
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			scanf("%d",&cost[i][j]);
		}
	}
	for(int i=0;i<=9;i++)
	{
		w[i]=INF;
	}
	w[1]=0;
	for(int i=0;i<=9;i++)
	{
		if(i==1)
		{
			continue;
		}
		for(int j=0;j<=9;j++)
		{
			used[j]=false;
		}
		dfs(i,0,i);
	}
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			scanf("%d",&a[i][j]);
			if(a[i][j]!=-1)
			{
				ans+=1ll*w[a[i][j]];
			}
		}
    }
    printf("%lld\n",ans);
    return 0;
} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define Forp(i,s,e) for (ll i = s; i <= e; i++)
#define Forn(i,s,e) for (ll i = s; i >= e; i--)


#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<p.f<<" "<<p.s;return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}


int main(){_
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i = 0 ; i < n ; i++)
        cin >> arr[i];
    ll arr1[n];
    for(ll i = 0 ; i < n ; i++){
        arr1[i] = arr[i] - (i+1);
    }
    sort(arr1,arr1+n);
    ll mid;
    if(n%2 == 0){
        mid = arr1[n/2]+arr1[n/2 - 1];
        if(mid%2 == 0){
            ll temp = mid/2;
            ll total = 0;
            for(ll i = 0 ; i < n ; i++){
                total+=abs(arr1[i] - temp);
            }
            cout << total << endl;
            return 0;
        }
        else{
            ll total1 = 0, total2 = 0;
            ll temp1 = floor(mid*1.0/2);
            ll temp2 = ceil(mid*1.0/2);
            for(ll i = 0 ; i < n ; i++){
                total1+=abs(arr1[i] - temp1);
                total2+=abs(arr1[i] - temp2);

            }
            cout << min(total2,total1) << endl;
            return 0;
        }
    }
    else{
        mid = arr1[n/2];
        ll total = 0;
        for(ll i = 0 ; i < n ; i++){
            total+=abs(arr1[i] - mid);
        }
        cout << total << endl;
        return 0;
    }

    return 0;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000

int bfs(vector<vector<int>> &E,int start,int next,int K){
	vector<int> dis(E.size(),Inf);
	dis[start] = 0;
	dis[next] = 0;
	queue<int> que;
	que.push(start);
	que.push(next);
	while(que.size()!=0){
		int now = que.front();
		que.pop();
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i];
			if(dis[to]!=Inf)continue;
			dis[to] = dis[now] + 1;
			que.push(to);
		}
	}
	
	int cnt = 0;
	for(int i=0;i<E.size();i++){
		if(dis[i]<=K/2)cnt++;
	}
	
	return cnt;
}

		


int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<vector<int>> E(N,vector<int>(0));

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

	int maxi = 0;
	if(K%2==1){
		for(int i=0;i<N;i++){
			for(int j=0;j<E[i].size();j++){
				maxi = max(maxi,bfs(E,i,E[i][j],K));
			}
		}
	}
	else{
		for(int i=0;i<N;i++){
			maxi = max(maxi,bfs(E,i,i,K));
		}
	}
	cout<<N-maxi<<endl;
	
	
	return 0;
}


Measured memory_bytes: 384
N = int(input())

m = int(N**0.5) + 2
l = [0]*(N+1)

for x in range(1, m):
    for y in range(1, m):
        for z in range(1, m):
            r = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if r <= N:
                l[r] += 1
                # print(r, (x, y, z))

for i in range(1, N+1):
    print(l[i])

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

typedef long long LL;
const int N = 2e5 + 10;
const LL inf = 0x3fffffffffffffffLL;

int n, Q, A, B, x[N];

#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1

LL S_add[N<<2], S_sub[N<<2], lazy[N<<2];
int l[N<<2], r[N<<2];

void maintain(int o){
	S_add[o] = min(S_add[lson], S_add[rson]);
	S_sub[o] = min(S_sub[lson], S_sub[rson]);
}

void build(int o, int ll, int rr){
	l[o] = ll;
	r[o] = rr;
	lazy[o] = 0;
    if(ll < rr){
		int mid = gmid;
		build(lson, ll, mid);
		build(rson, mid+1, rr);
		maintain(o);
    } else {
		if(ll == A){
			S_add[o] = ll;
			S_sub[o] = -ll;
		} else {
			S_add[o] = S_sub[o] = inf;
		}
    }
}

void add(int o, int ll, int rr, LL v);
int pushdown(int o){
	int mid = gmid;
	if(lazy[o]){
		add(lson, l[o], mid, lazy[o]);
		add(rson, mid+1, r[o], lazy[o]);
		lazy[o] = 0;
	}
	return mid;
}

void add(int o, int ll, int rr, LL v){
    if(l[o] == ll && r[o] == rr){
		if(S_add[o] == inf){
			return;
		}
		S_add[o] += v;
		S_sub[o] += v;
		lazy[o] += v;
		return;
    }
    int mid = pushdown(o);
    if(rr <= mid)	add(lson, ll, rr, v);
    else if(ll > mid)	add(rson, ll, rr, v);
    else{
		add(lson, ll, mid, v);
		add(rson, mid+1, rr, v);
    }
    maintain(o);
}

void update(int o, int p, LL v){
    if(l[o]==r[o]){
        S_sub[o] = min(S_sub[o], v - p);
        S_add[o] = min(S_add[o], v + p);
        return;
    }
    int mid = pushdown(o);
    if(p <= mid)	update(lson, p, v);
    else	update(rson, p, v);
    maintain(o);
}

void query(int o, int ll, int rr, LL &sub, LL &add){
	if(l[o]==ll && r[o]==rr){
		sub = S_sub[o];
		add = S_add[o];
		return;
	}
	int mid = pushdown(o);
	if(rr <= mid)	query(lson, ll, rr, sub, add);
	else if(ll > mid)	query(rson, ll, rr, sub, add);
	else{
		LL sub1, add1;
		query(lson, ll, mid, sub, add);
		query(rson, mid+1, rr, sub1, add1);
		sub = min(sub, sub1);
		add = min(add, add1);
	}
}

LL query_sub(int r){
    LL x, y;
    query(1, 1, r, x, y);
    return x;
}

LL query_add(int l){
	LL x, y;
	query(1, l, n, x, y);
	return y;
}

int main(){
	while(~scanf("%d %d %d %d", &n, &Q, &A, &B)){
		for(int i=1; i<=Q; i++)	scanf("%d", x+i);
        build(1, 1, n);
        x[0] = B;
        for(int i=1; i<=Q; i++){
            int d = abs(x[i]-x[i-1]);

			LL sum0 = query_sub(x[i]) + x[i];
			LL sum1 = query_add(x[i]) - x[i];

			sum0 = min(sum0, sum1);

            add(1, 1, n, d);
            update(1, x[i-1], sum0);
        }

        LL x, y, ans = inf;
        for(int i=1; i<=n; i++){
			query(1, i, i, x, y);
			ans = min(ans, min(x+i, y-i));
        }
        printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int fun(vector<int> &v)
{
	sort(v.begin(),v.end());

	if(v.size()%2 == 1)
	{
		int ans = 0;
		int m = v[(v.size()/2)];

		for(int i = 0; i < v.size(); i++)
		{
			ans += abs(v[i]-m);
		}
		return ans;
	}
	else
	{
		int ans1 = 0,ans2 = 0;
		int m1 = v[v.size()/2];
		int m2 = v[v.size()/2 - 1];
		for(int i = 0; i < v.size(); i++)
		{
			ans1 += abs(v[i]-m1);
			ans2 += abs(v[i]-m2);
		}
		return min(ans1,ans2);
	}
}
int32_t main()
{

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

    IOS


    int n;
    cin >> n;

    vector<int> v(n);

   map<int, int> mp;	

   int sum = 0;

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



   cases 
   {
   	int x,y;
   	cin >> x >> y;

   	int k = mp[x];
   	sum -= x*k;
   	mp.erase(x);
   	mp[y] += k;
   	sum += y*k;
   	cout << sum << endl;
   }


    return 0;
}


Measured memory_bytes: 7956
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (w, h, x, y) = listOfDouble()
    val d = w * h / 2.0
    val s = if (w / 2.0 == x && h / 2.0 == y) 1 else 0

    println("${d} ${s}")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 37896
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();

  ll ans = 0;

  // m = 1 ~ 10^7 について行う
  ll lasta = LINF;
  REP(m, 1, min(N, 10000001LL)){
    if (N % (m+1) == 0 && (N / (m+1))<m){
      ans += m;
      lasta = N / (m+1);
    }
  }


  // a = 最後に出た答え - 1 ~ 1 について行う
  for (ll a = min(lasta-1, N / 10000001 + 2); a >= 1; a--){
    if (N%a == 0 && a<(N/a - 1)){
      ans += N/a - 1;
    }
  }


  cout << ans << endl;
  
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    string s,t;
    cin >> N >> s >> t;
    for(int i = N; i >= 1; i--) {
        string x = s.substr(N-i,N);
        string y = t.substr(0,i);
        if(x == y) {
            cout << N*2-i << endl;
            return 0;
        }
    }
    cout << N*2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<vector<char>> m;int w,h;
void search(int y,int x){
    if(y<0 || x<0 || y>=h || x>=w || m[y][x] == '0' || m[y][x] == 'c') return;
    m[y][x] = 'c';
    search(y+1,x);
    search(y-1,x);
    search(y,x+1);
    search(y,x-1);
    search(y+1,x+1);
    search(y+1,x-1);
    search(y-1,x+1);
    search(y-1,x-1);
    return;
}
int main(){
    int ans,i,j;vector<char> emp;char s;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0) break;
        m = {};
        for(i=0;i<h;i++){
            m.push_back(emp);
            for(j=0;j<w;j++) {
                cin >> s;
                m[i].push_back(s);
            }
        }
        ans = 0;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(m[i][j] == '1'){
                    search(i,j);ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int modi = 1e9 + 7;

void solve(){
	int n,k;
	cin >> n >> k;
	ll a[n];
	forn(i,0,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);		
	int p1 = 0, p2 =n-1;
	vi chosen;
	int req = k;
	if(a[0]<=0){
		ll ans = 1;
		if(k&1)
		for(int i =0;i<k;i++){
			ans = (ans*a[i]+modi)%modi;
		}
		else{
			for(int i =n-1;i>=(n-k);--i)
				ans = (ans*a[i]+modi)%modi;

		}
		cout << (ans+modi)%modi << endl;return;
	}
	while(req>0){
		// cout << req << endl;
		if((a[p1]*a[p1+1]) > a[p2]*a[p2-1]){
			chosen.pb(p1);
			p1++;
			// k--;
			req--;
		}
		else{

			if(req==1){
				chosen.pb(p1);
				k--;
				p1++;
				req--;
			}
			else{
				if(	a[p1]*a[p1+1] > a[p2]*a[p2-1] ){
					chosen.pb(p1);
					chosen.pb(p1+1);
					p1+=2;
				}
				else{
					chosen.pb(p2);
					chosen.pb(p2-1);
					p2-=2;
				}
				req-=2;
			}		
		}
	}
	ll ans =1;
	for(auto e: chosen){
		ans = (ans*a[e]+modi)%modi;
	}
	cout << (ans+modi)%modi << endl;
}

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

	// int t;cin >> t;while(t--)
		solve();
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<int, int>

int main() {
  int n;
  cin >> n;
  ll a[n], l;
  cin >> l;
  REP(i, n) cin >> a[i];
  ll mx = 0, ind = 0;
  REP(i, n-1){
    if(mx < a[i+1] + a[i]){
      ind = i+1;
      mx = a[i+1] + a[i];
    }
  }
  if(mx < l){
    cout << "Impossible" << endl;
    return 0;
  }
  else{
    cout << "Possible" << endl;
    REP(i, ind-1) cout << i+1 << endl;
    for(int i = n-1; i >= ind; i--) cout << i << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  if(N == 0){
    cout << 2 << endl;
    return 0;
  }
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  int64_t a = 1;
  int64_t b = 2;
  for(int i = 0; i < N - 1; ++i){
    int64_t c = a;
    a += b;
    b = c;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;

long long A[1000];
long long B[1000];
long long C[1000];
long long AB_sum[1000000];
int C_AB_pair_index[1000];
int main(){
    int X;
    int Y;
    int Z;
    int K;
    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++){
        cin >> A[i];
    }
    for(int i = 0; i < Y; i++){
        cin >> B[i];
    }
    for(int i = 0; i < Z; i++){
        cin >> C[i];
    }

    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            AB_sum[i * X + j] = A[i] + B[j];
        }
    }
    sort(AB_sum, AB_sum + X * Y);
    sort(C, C + Z);

    for(int i = 0; i < Z; i++){
        C_AB_pair_index[i] = X * Y - 1;
    }
    priority_queue <pair <long long, int> > pq;
    for(int i = 0; i < Z; i++){
        pq.push(make_pair(AB_sum[C_AB_pair_index[i]] + C[i], i));
    }

    for(int i = 0; i < K; i++){
        auto top = pq.top();
        pq.pop();
        cout << top.first << endl;
        C_AB_pair_index[top.second] --;
        pq.push(make_pair(AB_sum[C_AB_pair_index[top.second]] + C[top.second], top.second));
    }
    return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]a = new int[n];

    int cou = 0;
    for(int i=0; i<n; i++) {
    	a[i] = sc.nextInt();
    	if(a[i] != i+1) {
    		cou++;
    	}
    }   	
    if(cou<=2) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
    }
}

Measured memory_bytes: 35580
#include <stdio.h>

int main(void){
    int K, N, A0, A, B;
    int distance, diff, max_diff;
    int i;
    distance = 0;
    max_diff = 0;

    scanf("%d%d", &K, &N);
    scanf("%d", &A0);
    A = A0;
    for(i = 0; i < N-1; i++){
        scanf("%d", &B);
        diff = B - A;
        distance += diff;
        if(diff > max_diff)
            max_diff = diff;
        A = B;
    }
    diff = K - B + A0;
    distance += diff;
    if(diff > max_diff)
        max_diff = diff;

    distance -= max_diff;
    printf("%d\n", distance);

    return 0;
}


Measured memory_bytes: 128
B = input().split()

while True:
    B[2] = int(B[2]) - int(B[1])
    B[0] = int(B[0]) - int(B[3])
    if int(B[2]) <= 0:
        print("Yes")
        break
    elif int(B[0]) <= 0:
        print("No")
        break

Measured memory_bytes: 9076
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

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

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;


	cin >> n;
    ll ans[n+1];
    mem(ans,0);
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                ll tmp=pow(x + y + z, 2) - x * y - y * z - z * x;
                if ( tmp<=n)
                    ans[tmp]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << endl;
    }

eNd();
  return 0;
 
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->right!=NIL) x=x->right;
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y; 
  if(x->right!=NIL) return treeMinimum(x->right);
 
  y=x->p;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->p;
    return y;
    
  }
} 
void treeDelete(Node z){
  
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || x->right==NIL)
    y=z;
  else y=treeSearch(z,z->key);
  if(y->left!=NIL)
    x=y->left;
  else x=y->right;
  if(x!=NIL)
    x->p=y->p;
  if(y->p==NIL)
    root=x;  
  else if(y==y->p->left)
    y->p->left;
  else y->p->left=x;
  if(y!=z){
    z->key=y->key;
    y=z;
  }
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key<x->key) x=x->left;
     else x=x->right;
   }
   z->p=y;
   if(y==NIL)
     root=z;
   else if(z->key<y->key)
     y->left=z;
   else y->right=z;
 }


void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u!=NIL){
 printf(" %d",u->key);  
  preorder(u->left);
  preorder(u->right);
}
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

int number=0;
int ans=0;

void CountDivisor(int x){
    number=0;
    for(int i=1; i<=x; i++){
        if(x%i==0)
            number++;
    }
}

int main(void)
{
    //input
    int x;
    cin >> x;
    
    //calculate
    for(int i=1; i<=x; i+=2){
        CountDivisor(i);
        if(number==8)
            ans++;
    }
        
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> v(M);
  REP(i,M) {
    cin >> v[i].fi >> v[i].se;
  }

  sort(ALL(v), [](auto a, auto b){return a.se < b.se;});

  int ans = 0;
  int x = 0;

  REP(i,M) {
    if (v[i].fi <= x) {
      /* do nothing */
    }
    else {
      ans++;
      x = v[i].se - 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve(){
	string s,t;
	cin>>s>>t;
	int l1=s.size();
	int l2=t.size();
	vector<pair<int,string>> v;
	for(int i=0;i<=(l1-l2);i++){
		string r="";
		for(int j=0;j<i;j++)
		r+=s[j];
		r+=t;
		for(int j=i+l2;j<l1;j++)
		r+=s[j];
		int cnt=0;
		for(int j=0;j<l1;j++){
			if(r[j]!=s[j])
			cnt++;
		}
		//cout<<r<<"\n";
		pair<int,string> p;
		p.first=cnt;
		p.second=r;
		v.push_back(p);
	}
	sort(v.begin(),v.end());
	cout<<v[0].first;
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}



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

int main(){
  cout << fixed << setprecision(12);

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

  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b <<endl;

  return 0;
}


Measured memory_bytes: 3288
s = list(input())

ks = set(s)
ans = 100000

for k in ks:
    count = 0
    t = s[:]
    while True:
        if len(set(t)) <= 1:
            break

        new_t = []
        for i in range(len(t)-1):
            if t[i] == k or t[i+1] == k:
                new_t.append(k)
            elif s[i+1] != k:
                new_t.append(s[i+1])
        t = new_t[:]
        count += 1
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 40432
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val hn = readLine()!!.split(" ").map(String::toInt)

    val dp = IntArray(N) { Integer.MAX_VALUE }
    dp[0] = 0

    for (i in 1 until N) {
        for (l in Math.max(i - K, 0)..i - 1) {
            dp[i] = Math.min(dp[i], Math.abs(hn[i] - hn[l]) + dp[l])
        }

    }
    println(dp.last())
}


Measured memory_bytes: 49916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll x, y, ans;
  cin >> x >> y;
  if ((x*y<0 && x+y>=0) || (x>0 && y==0)) ans = x+y+1;
  else if (x*y>0 && x>y) ans = x-y+2;
  else if ((x>=0 && y<0 && x+y<=0) || (x<0 && y>0 && x+y<0)) ans = -x-y+1;
  else ans = -x+y;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int L,R,d,i,f;
	f=0;
	scanf("%d%d%d",&L,&R,&d);
	for(i=L;i<=R;i++)
	{
		if(i%d==0)
		f=f+1;
	}
	printf("%d",f);
}

Measured memory_bytes: 1728
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i + 1; j < n; j++) {
                if (arr[minj] > arr[j]) {
                    minj = j;
                }
            }
            if (minj != i) {
                int tmp = arr[minj];
                arr[minj] = arr[i];
                arr[i] = tmp;
                count++;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(arr[i]);
        }
        System.out.println(sb);
        System.out.println(count);
    }
}


Measured memory_bytes: 26168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n,W;
int w[N],v[N];
int dp[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	W=read();
	me(dp,INF,sizeof(dp));

	dp[0]=0;

	for(int i=1;i<=n;++i){
		w[i]=read();
		v[i]=read();
	}

	int res=0;

	for(int i=1;i<=n;++i){
		for(int j=1e5;j>=v[i];--j){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			if(dp[j]<=W) res=max(res,j);
		}
	}

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

    return 0;
}

Measured memory_bytes: 7652
#include <stdio.h>
int main(){
  int i,j,minj,n,work,count=0,a[100];

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

  for(i=0; i<n; i++){
    minj=i;
    
    for(j=i; j<n; j++){
      if(a[j] < a[minj]) minj=j;
    }
      if(i != minj){
	work=a[i];
	a[i]=a[minj];
	a[minj]=work;
	count++;
    }
  }


  if(n==1) printf("%d",a[0]);
  else{
    for(i=0; i<n; i++){
      if(i==n-1) printf("%d", a[i]);
      else printf("%d ",a[i]);
    }
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



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

    vector<int>p(n);
    for (int i = 0; i < n; i++)cin >> p[i];
    sort(p.rbegin(), p.rend());

    long long int t = 0;
    for (int i = m; i < n; i++) {
        t += p[i];
    }
    cout << t << endl;
    return 0;

}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                a[i][j] = scan.nextInt();
            }
        }
        int n = scan.nextInt();
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            b[i] = scan.nextInt();
        }
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                for(int x = 0; x < n; x++){
                    if(a[i][j] == b[x]){
                        a[i][j] = 1;
                    }
                }
            }
        }
        if(a[0][0] == 1 && a[0][1] == 1 && a[0][2] == 1){
            System.out.println("Yes");
        }else if(a[0][0] == 1 && a[1][0] == 1 && a[2][0] == 1){
            System.out.println("Yes");
        }else if(a[0][0] == 1 && a[1][1] == 1 && a[2][2] == 1){
            System.out.println("Yes");
        }else if(a[1][0] == 1 && a[1][1] == 1 && a[1][2] == 1){
            System.out.println("Yes");
        }else if(a[2][0] == 1 && a[2][1] == 1 && a[2][2] == 1){
            System.out.println("Yes");
        }else if(a[0][1] == 1 && a[1][1] == 1 && a[1][2] == 1){
            System.out.println("Yes");
        }else if(a[0][2] == 1 && a[1][2] == 1 && a[2][2] == 1){
            System.out.println("Yes");
        }else if(a[0][2] == 1 && a[1][1] == 1 && a[2][0] == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int ct = 0;
        for (int i = 0; i < N; i++) {
            ct += (sc.nextInt() >= K)? 1: 0;
        }

        System.out.println(ct);
    }
}

Measured memory_bytes: 48116
n,x,y = map(int,input().split())

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])

Measured memory_bytes: 3444
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;
int n = 0, m = 0;
int a[MAXN];
int b[MAXN];



int main() {
	int a = 0, b = 0;
	string s;
	cin >> a >> b;
	cin >> s;
	if(s.length() != a + b + 1){
		cout << "No" << endl;
		return 0;
	}
	if(s[a] != '-'){
		cout << "No" << endl;
		return 0;
	}
	s.erase(s.begin()+a);
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == '-'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	

    return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define int ll
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int a,b; cin>>a>>b;
    int ans=0;
    if(b>=a){
        if((a>=0&&b>=0)||(a<=0&&b<=0)){ans=abs(a-b);}
        else{
            ans=abs(-1*a-b)+1;
        }
    }else{
        if(a>=0&&b>=0){ans=(abs(-1*a+b))+2;if(b==0)ans--;}
        else if(a<0&&b<0){ans=abs(-1*b - (-1)*a); ans+=2;}
        else{
            ans=max(abs(a),abs(b))-min(abs(a),abs(b))+1;
            
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);
    	int count = sc.nextInt();

    	int[] ans = new int[100000];

    	for (int i = 0; i < count; i++) {
    		final int element = Integer.parseInt(sc.next());

    		ans[element] = ans[element] + 1;

    		if (element < 99999)
    			ans[element + 1] = ans[element + 1] + 1;


    		if(element > 0)
    			ans[element - 1] = ans[element - 1] + 1;
    	}

    	int ansInt = IntStream.of(ans).parallel().max().getAsInt();
    	System.out.println(ansInt);
    }

}

Measured memory_bytes: 50448