akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const int maxn = 2e5 + 10;

vector<int> g[maxn];
int mt[maxn];
int used[maxn];
int cn = 1;
vector<ll> prm = { 0, 1 };
ll dsu[maxn * 2], sz[maxn * 2];
pair<ll, ll> c3[maxn * 2];

ll find(int v) {
	if (dsu[v] == v) return v;
	else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
	u = find(u);
	v = find(v);

	if (sz[u] > sz[v]) swap(u, v);
	if (u != v) {
		dsu[u] = v;
		sz[v] += sz[u];
		c3[v].first += c3[u].first;
		c3[v].second += c3[u].second;
	}
}

bool dfs(int v) {
	if (used[v] == cn) return false;

	used[v] = cn;

	ll rnd = rand() % 2;
	if (rnd == 1) {
		for (int i = 0; i < g[v].size(); i++) {
			int u = g[v][i];
			if (mt[u] == -1 || dfs(mt[u])) {
				mt[u] = v;
				return true;
			}
		}
	}
	else {
		for (int i = 0; i < g[v].size(); i++) {
			int u = g[v][1 - i];
			if (mt[u] == -1 || dfs(mt[u])) {
				mt[u] = v;
				return true;
			}
		}
	}


	return false;
}

int main()
{
	fastInp;

	ll n, h, w;
	cin >> n >> h >> w;

	ll vals = 0, ans = 0;
	vector<tuple<ll, ll, ll>> vec;
	for (int i = 0; i < n; i++) {
		dsu[i] = i;
		c3[i] = { 1, 0 };
		sz[i] = 1;
	}

	for (int i = n; i < n + h; i++) {
		dsu[i] = i;
		c3[i] = { 0, 1 };
		sz[i] = 1;
	}
	for (int i = n + h; i < n + h + w; i++) {
		dsu[i] = i;
		c3[i] = { 0, 1 };
		sz[i] = 1;
	}

	for (int i = 0; i < n; i++) {
		ll r, c, a;
		cin >> r >> c >> a;
		r--; c--;
		vec.push_back({ a, r, c });
	}

	sort(vec.rbegin(), vec.rend());

	ll cnt = 0;
	ll hw = h + w;
	for (int i = 0; i < n; i++) {
		ll r = get<1>(vec[i]), c = get<2>(vec[i]), a = get<0>(vec[i]);
		r += n;
		c += h + n;
		r = find(r);
		c = find(c);
		if (c == r) {
			if (min(c3[c].first + 1ll, c3[c].second) > min(c3[c].first, c3[c].second)) {
				ans += a;
				uni(c, i);
			}
		}
		else {
			if (min(c3[c].first, c3[c].second) + min(c3[r].first, c3[r].second) < min(c3[c].first + c3[r].first + 1ll, c3[c].second + c3[r].second)) {
				ans += a;
				uni(c, i);
				c = find(c);
				uni(c, r);
			}
		}
		/*if (mt[r] == -1 || mt[c + h + 1] == -1) {
			vals++;
			cnt++;
			g[i].push_back(r);
			g[i].push_back(c + h + 1);
			if (mt[r] == -1) {
				mt[r] = i;
			}
			else {
				mt[c + h + 1] = i;
			}
			ans += a;
			continue;
		}
		cn++;
		vals++;

		g[i].push_back(r);
		g[i].push_back(c + h + 1);
		cnt += dfs(i);

		if (cnt >= vals) {
			ans += a;
			continue;
		}
		else {
			vals--;
		}*/
	}

	cout << ans;

	return 0;
}

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

int binary_search(vector<int>& a,int key) {
    int left = -1;
    int right = (int)a.size(); 
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (a[mid] >= key) right = mid;
        else left = mid;
    }
    if(a[right]==key) return right;
    else return -1;
}


int main()
{
    // input
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    int q;
    cin >> q;
    vector<int> t(q);
    rep(i,q) cin >> t[i];

    // solve
    vector<int> ans(0);
    sort(ALL(s));
    sort(ALL(t));
    rep(i,t.size()){
        int l=0;
        int r=s.size();
        while(r-l>1){
            int m=(l+r)/2;
            if(t[i]<s[m])r=m;
            if(t[i]>s[m])l=m;
            if(s[m]==t[i]){ans.emplace_back(t[i]); break;}
        }
    }

    cout << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 3324
n,m=map(int,input().split())
a=[]
k=[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  k.append(sum(2**(int(i)-1)for i in input().split()))
inf=float('inf')
dp=2**n*[inf]
dp[0]=0
for i in range(2**n):
  for j in range(m):
    dp[i|k[j]]=min(dp[i|k[j]],dp[i]+a[j])
print(dp[-1]if inf!=dp[-1]else-1)


Measured memory_bytes: 45272
#include<bits/stdc++.h>
using namespace std;
const int N=100009;
int n,a[N],ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);

    for(int i=1;i<=n;i++)
        if(i+1>a[i+1])
        {     for(int j=i+1;a[j]==i;j++)       ans^=1;
            ans|=(a[i]-i)&1;
            puts(ans? "First":"Second");
            return 0;
        }

    return 0;
} 

Measured memory_bytes: 640
#include<cstdio>

using namespace std;

int main(void){
	int ku[11],i,ans=0;
	float v1,v2,zen=0,hit;

	while((scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%f,%f",&ku[1],&ku[2],&ku[3],&ku[4],&ku[5],&ku[6],&ku[7],&ku[8],&ku[9],&ku[10],&v1,&v2))!=EOF){
			for(i=1;i<=10;i++)	zen+=ku[i];
			hit=zen/(v1+v2)*v1;
			for(i=1;i<=10;i++){
				ans+=ku[i];
				if(ans>=hit){
					printf("%d\n",i);
					break;
				}
			}
			zen=0;
			ans=0;
	}

	return 0;
}

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


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for( int i = 0; i < N; ++i ) cin >> h[i];


    vector<int> dp(N, 1e+9);  // dp[i]: minimum cost to reach i
    dp[0] = 0;
    dp[1] = abs( h[1] - h[0] );
    for( int i = 2; i <= K; ++i ){
        for( int j = 1; j <= i; ++j ){
            dp[i] = min( dp[i], abs(h[i] - h[i-j]) + dp[i-j] );
        }
    }
    for( int i = K+1; i < N; ++i ){
        for( int j = 1; j <= K; ++j ){
            dp[i] = min( dp[i], abs(h[i] - h[i-j]) + dp[i-j] );
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int x;

int main () {


    cin >> x;
    for (int n = 1 ; ; ++ n) {
        if (n * x % 360 == 0) {
            printf("%d\n", n);
            break;
        }
    }

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    VLL C(N-1),S(N-1),F(N-1);
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    VLL ans(N);
    rep(i,N){
        int t=0;
        rept(j,i,N-1){
            if(t<S[j]) t=S[j];
            else if(t%F[j]==0);
            else t=t+F[j]-t%F[j];
            t+=C[j];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

void solv()
{
	int Q; scanf("%d", &Q);

	long long int mid = 0, sumb = 0, sumleft = 0, sumright = 0;
	multiset<int> leftset, rightset;

	int p, a, b; scanf("%d%d%d", &p, &a, &b);
	mid = a; sumb += b;
	for (int i = 1; i < Q; i++){
		int p; scanf("%d", &p);
		if (1 == p){
			int a, b; scanf("%d%d", &a, &b);
			sumb += b;
			if (a < mid){
				leftset.insert(a);
				sumleft += mid - a;
			}
			else{
				rightset.insert(a);
				sumright += a - mid;
			}
			if (leftset.size() > rightset.size()){
				multiset<int>::iterator itr = leftset.end(); itr--;

				rightset.insert(mid);
				sumright += (mid - *itr)*rightset.size();
				sumleft -= (mid - *itr)*leftset.size();

				mid = *itr;
				leftset.erase(itr);
			}
			else if (rightset.size() > leftset.size()+1){
				multiset<int>::iterator itr = rightset.begin();

				leftset.insert(mid);
				sumleft += (*itr - mid)*leftset.size();
				sumright -= (*itr - mid)*rightset.size();

				mid = *itr;
				rightset.erase(itr);
			}
		}
		else{
			printf("%lld %lld\n", mid, sumleft + sumright + sumb);
		}
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 9600
N = int(input())
a = list(map(int,input().split()))
x = a[0]
y = sum(a[1:])
ans = abs(x-y)

for i in range(1,N-1):
    x += a[i]
    y -= a[i]
    temp = abs(x-y)
    if temp < ans:ans = temp
print(ans)

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

int const N = 200000;
int p[N];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		p[t - 1] = i;
	}
	int an = 0, bf = n, c = 0;
	f(i, 0, n){
		if (p[i] > bf)++c;
		else c = 1;
		bf = p[i];
		an = max(an, c);
	}
	printf("%d\n", n - an);
}

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

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

  int n; cin >> n;
  ordered_set<ii> S;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    if (S.empty())
      S.insert(ii(x, i));
    else {
      int p = S.order_of_key(ii(x,-1));
      if (p == 0) {
        S.insert(ii(x,i));
      } else {
        S.erase(S.find_by_order(p - 1));
        S.insert(ii(x,i));
      }
    }
  }

  cout << S.size() << ende;
  return 0;
}


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


int main() {
     int n;
     cin >> n;
     long long ans = 0;
     for(int i = 1;i <= n;i++){
         long long y = n/i;
         ans += i * y * (y + 1) / 2;
     }
     cout << ans;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int A[3];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(A[0],A[1],A[2]);
  if(A[0]&1||A[1]&1||A[2]&1) return puts("0"),0;
  if(A[0]==A[1]&&A[1]==A[2]) return printf("%d\n",-1),0;
  int res=31;
  for(int i=0;i<3;++i) {
    int t=0;
    while(A[i]%2==0) A[i]/=2,++t;
    A[i]=t; res=min(res,A[i]);
  }
  if(A[0]==A[1]&&A[1]==A[2]) ++res;
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    double a,b,h,m; cin >> a >> b >> h >> m;
    double th1,th2,th;
    th1 = M_PI * h / 6 + M_PI * m / 360;
    th2 = M_PI * m / 30;
    th = max(th1,th2) - min(th1,th2);
    if (th >= M_PI) th =  2 * M_PI - th;
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(th));
    cout << fixed << setprecision(16) << ans << "\n";
}   
 

Measured memory_bytes: 4228
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>

using namespace std; 

#define MP make_pair
typedef unsigned long long ULL;

//dp[i+1][j]...i番目まで使って重さj以下になるように選んだ時の最大価値
//dp[0][j]=0
long dp[101][10001];

int main(){

	int N,W;
	cin>>N>>W;

	vector<int> v(N),w(N);
	for(int i=0;i<N;i++) cin>>v[i]>>w[i];

	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]) dp[i+1][j]=dp[i][j];
			else       dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
		}
	}

	cout<<dp[N][W]<<endl;

	return 0;
}

Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
ll dp[N],a[N];
int main(){
	fast;
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[1]=0;dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++){
		dp[i]=1e17;
		for(int j=max(i-k,1);j<=i-1;j++){
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}cout<<dp[n]<<endl;return 0;
}/*『你强归你强，Siyuan比你强』*/

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli s,w;
    cin>>s>>w;
    if(w>=s)
    cout<<"unsafe";
    else
    cout<<"safe";
    return 0;
}


Measured memory_bytes: 3640
def f(n,k):
    lim = int((n + 0.1) ** 0.5) + 1
    ws = []
    s = 0
    for i in range(1, lim):
        w = n // i - n // (i + 1)
        ws.append(w)
        s += w
    ws += [1] * (n - s)
    m = len(ws)
    dp0 = ws[::-1]
    dp1 = [0] * m
    for _ in range(k - 1):
        s = 0
        for j in range(m):
            s += dp0[j]
            dp1[m - j - 1] = (s * ws[j]) % md
        dp0 = dp1[:]
    print(sum(dp0) % md)
md=10**9+7
n,k=map(int,input().split())
f(n,k)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    vec ans(N);
    REP(i, N) ans[A[i] - 1] = i + 1;
    REP(i, N) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
using namespace std;
#define PorLLM(x) (x >= 0 ? x : 10'000'000'000)

int main()
{
    long long x, y;
    cin >> x >> y;
    cout << min({PorLLM(y-x), PorLLM(y+x)+1, PorLLM(-y-x)+1, PorLLM(-y+x)+2}) << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
#define fa(i,a,n) for(long long  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>s;
   a=0;
   b=0;
   for(auto c:s){
     if(c=='R') a++;
     else{
       b=max(a,b);
       a=0;
     }
    }
    b=max(a,b);
    cout<<b<<endl;
   
   return 0;
}
    

Measured memory_bytes: 3648
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    cin >> a >> b;
    if (1 > a || a > 9 || 1 > b || b > 9)
        cout << -1;
    else
        cout << a * b;

    return 0;
}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,a,b,k,c=0;
	cin>>a>>b>>k;
	if (a>b) swap(a,b);
	for (j=a;j>=1;j--)
	{
		if (a%j==0&&b%j==0)
		{
			c++;
			if (c==k) 
			{
				cout<<j;
				break;
			}
		}
	}
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(v.begin(), v.end());
    priority_queue<int> pq;
    int ans = 0, j = 0;
    for (int i = 1; i <= M; i++) {
        while (j < N && v[j].first <= i) {
            pq.push(v[j].second);
            j++;
        }
        if (pq.empty()) continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
import sys
INFTY=sys.maxsize

def readinput():
    n,m=list(map(int,input().split()))
    a=[]
    for _ in range(m):
        a.append(int(input()))
    return n,m,a

def main(n,m,a):
    MOD=10**9+7
    dp=[0]*(n+3)
    dp[0]=1
    ia=0
    for i in range(n+1):
        if ia<m and i==a[ia]:
            ia+=1
            #print(ia)
            continue
        dp[i+1]=(dp[i+1]+dp[i])%MOD
        dp[i+2]=(dp[i+2]+dp[i])%MOD
        #print(dp)
    return dp[n]

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)



Measured memory_bytes: 14380
import scala.util.control.Breaks

object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val n = array(0)
  val m = array(1)
  var lrArr = Vector.empty[(Int, Int)]
  var result = (0, 0)
  for(i<-1 to m) {
    val readLR = scala.io.StdIn.readLine()
    val arrayLR =  readLR.split(" ").map(_.toInt).toVector
    lrArr :+= (arrayLR(0), arrayLR(1))
  }
  val b = new Breaks

  b.breakable{
    lrArr.zipWithIndex.foreach { case (lr, i) =>
      if(i == 0) {
        result = lr
      } else {
        var min = 0
        var max = 0
        if (result._1 >= lr._1) {
          min = result._1
        } else {
          min = lr._1
        }
        if (result._2 >= lr._2) {
          max = lr._2
        } else {
          max = result._2
        }
        if(min > max) {
          result = (0, 0)
          b.break()
        } else {
          result = (min, max)
        }
      }
    }
  }
  if (result._1 == 0 && result._2 == 0) {
    print(0)
  } else {
    print(result._2 - result._1 + 1)
  }

}

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

using namespace std;

#define MAX 100000

int main(){
  int N, K, in;

  while(scanf("%d%d" ,&N ,&K), (N | K)){
    bool found = false, used[MAX+2];
    vector<int> vec;
    int start = MAX;

    memset(used,false,sizeof(used));

    for(int i = 0 ; i < K ; i++){
      scanf("%d" ,&in);
     
      if(in){
        start = min(start, in);
        used[in] = true;
        vec.push_back(in);
      }else{
        found = true;
      }
    }

    int res = 1;
    if(found){
      start--;
      int cnt = 0, pos, p = 0;
      for(int i = start ; i <= N+1 ; i++){
        if(used[i]){
          cnt++;
        }else{
          p++;
          if(p == 1){
            pos = i + 1;
            if(i != 0 || i != N+1){
              cnt++;
            }
          }
          if(i == 0) continue;
          if(p == 2){
            res = max(res,cnt);
            p = 1;
            cnt = i - pos + 1;
            pos = i + 1;
          }
        }

      }
    }else{
      sort(vec.begin(),vec.end());
      int cnt = 0;
      for(int i = 1 ; i < K ; i++){
        if(vec[i] - vec[i-1] == 1){
          cnt++;
          res = max(res,cnt);
        }else{
          cnt = 1;
        }
      }
    }

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

  return 0;
}

Measured memory_bytes: 1808
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [input() for i in range(h)]
q = []
dist = [[False] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            q.append((i, j))
            dist[i][j] = True
test = [(0, 1), (0, -1), (1, 0), (-1, 0)]
cnt = -1
while q:
    cnt += 1
    qq = []
    for y, x in q:
        for dy, dx in test:
            yy, xx = y + dy, x + dx
            if xx < 0 or yy < 0 or xx > w - 1 or yy > h - 1 or dist[yy][xx]:
                continue
            else:
                dist[yy][xx] = True
                qq.append((yy, xx))
    q = qq
print(cnt)


Measured memory_bytes: 110896
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  	string a, b, c; cin >> a >> b >> c;
  	string ans = "";
  	ans += toupper(a[0]);
    ans += toupper(b[0]);
    ans += toupper(c[0]);
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val a, b, c = sc.nextInt
    if (a != 0 && b != 0 && c != 0) {
      var X = Array.fill[Int](a + b + c)(2)
      val A = Array.fill[Array[Int]](sc.nextInt)(Array.fill[Int](4)(sc.nextInt - 1))
      for (now <- A) {
        if (now(3) == 0) {
          X(now(0)) = 1
          X(now(1)) = 1
          X(now(2)) = 1
        }
      }
      for (now <- A) {
        if (now(3) == -1) {
          if (X(now(0)) == 1 && X(now(1)) == 1) X(now(2)) = 0
          if (X(now(0)) == 1 && X(now(2)) == 1) X(now(1)) = 0
          if (X(now(2)) == 1 && X(now(1)) == 1) X(now(0)) = 0
        }
      }
      println(X.mkString("\n"))
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n ;
	int a[n];
	rep(i,n){
		cin >> a[i];
	}
	int ans = 0;
	vector<int> num(0);
	for(int i = n -1 ; i >= 0 ; i -- ){
		//いれたとき、そいつの約数のカウンタに＋1する
		if(a[i] % 2 == 1) {
			ans ++ ;
			int now = i + 1;
			num.push_back(now);
			//now の約数となるものの値をkとして、a[k-1]を++
			for(int j = 1 ;j * j <= now ; j ++){
				if(now % j == 0){
					if(a[j-1] == 0) a[j-1] = 1;
					else a[j-1] = 0 ;
					if(j*j!=now){
						int yakusuu = j;
						yakusuu = now / j; 
						if(a[yakusuu-1] == 0) a[yakusuu-1] = 1;
						else a[yakusuu-1] = 0 ;
					}
				}
			} 
		}
	}
	cout << ans << endl;
	rSORT(num);
	for(int i = 0 ; i < ans ; i++){
		cout << num[i];
		if(i == ans - 1) cout << endl;
		else cout << " " ;
	}
}


Measured memory_bytes: 2424
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define EPS 1e-8
#define mp make_pair
#define equals(a,b) fabs((a) - (b)) < EPS

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

int main() {
	int n, k, l;
	double t, u, v;
	cin >> n >> k >> t >> u >> v >> l;

	bool d[100005];
	memset(d, 0, sizeof(d));

	rep(i, n) {
		int x;
		cin >> x;
		d[x] = true;
	}

	double ans = 0;
	double time = 0.0;
	int cnt = 0;

	rep(i, l) {
		if(d[i]) {
			if(cnt == k) time = t;
			else cnt++;
		}

		if(equals(time, 0.0)) {
			if(cnt > 0) {
				time = t;
				cnt--;
			}
		}

		if(time > EPS) {
			ans += 1.0 / v;
			time -= 1.0 / v;
		} else {
			ans += 1.0 / u;
		}
	}

	cout << fixed;
	cout.precision(20);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
int n;
cin>>n;
int i;
for(i=n; ; i++){
    if(i%111==0) break;
}
    cout<<i<<endl;
}

Measured memory_bytes: 256
/*  ex4_1
    pptenshi  */

#include<stdio.h>
#include<math.h>

int main(void) {
    int num_apple, distance;
    int ans;

    // input
    scanf("%d%d", &num_apple, &distance);

    // calculate answer
    ans = (int)ceil((double)num_apple / (distance * 2 + 1));

    //output
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int l=0,r=n-1;
  int ans = 0;
  while(l<r){
    while(l<r&&s[l]=='R') ++l;
    while(l<r&&s[r]=='W') --r;
    if(l<r){
      ++l;
      --r;
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
#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 Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll D, T, S; cin >> D >> T >> S;
    ll sum = S * T;
    string ans = "Yes";
    if(sum < D) ans = "No";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n;
	cin >> n;
	string s; int l;
	for (int i = 0; i < n; i++) {
		int a, b,memo;
		a = 0; b = 0;
		cin >> s;
		l = s.length();
		memo = 1;
		for (int j = 0; j < l; j++) {
			if (0 <= s[j] - '0'&&s[j] - '0' <= 9) {
				memo = s[j] - '0';
			}
			else if (s[j] == 'm') {
				a += memo * 1000; memo = 1;
			}
			else if (s[j] == 'c') {
				a += memo * 100; memo = 1;
			}
			else if (s[j] == 'x') {
				a += memo * 10; memo = 1;
			}
			else if(s[j]=='i'){
				a += memo;
			}
		}
		cin >> s;
		l = s.length();
		memo = 1;
		for (int j = 0; j < l; j++) {
			if (0 <= s[j] - '0'&&s[j] - '0' <= 9) {
				memo = s[j] - '0';
			}
			else if (s[j] == 'm') {
				b += memo * 1000; memo = 1;
			}
			else if (s[j] == 'c') {
				b += memo * 100; memo = 1;
			}
			else if (s[j] == 'x') {
				b += memo * 10; memo = 1;
			}
			else if (s[j] == 'i') {
				b += memo;
			}
		}
		int x = a + b;
		if (x / 1000 >= 2)cout << x / 1000;
		if (x / 1000 >= 1)cout << "m";
		x %= 1000;
		if (x / 100 >= 2)cout << x / 100;
		if (x / 100 >= 1)cout << "c";
		x %= 100;
		if (x / 10 >= 2)cout << x / 10;
		if (x / 10 >= 1)cout << "x";
		x %= 10;
		if (x >= 2)cout << x;
		if (x >= 1)cout << "i";
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 2984
//package ABC147A;
import java.util.*;

public class Main{
	public static void main(String[] args){
		
		long startTime = System.currentTimeMillis();
		
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		
		long div=(long)Math.pow(10, 9)+7;
		long[] A=new long[n];
		
		long ans=0;
		
		for(int i=0;i<n;i++){
			A[i]=sc.nextLong();
		}
		
		for(int i=0;i<60;i++){
			long a=0;
			long count1=0;

			for(int j=0;j<n;j++){
				if((A[j]>>i&1)==1)count1++;
				//System.out.println("j:"+j+" l:"+l+" res: "+l/(long)(Math.pow(2,j)));
			}
			a=a+count1*(n-count1);
			
			for(int j=0;j<i;j++){
				a=(a<<1)%div;
			}
			ans+=a;
			ans%=div;
		}

		
		System.out.println(ans);
		long endTime = System.currentTimeMillis();
		//System.out.println("処理時間：" + (endTime - startTime) + " ms");
	}
}


Measured memory_bytes: 98944
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#define endl '\n'
using namespace std;
typedef long long ll;
int main(){

    int n; cin >> n;
    string s; cin >> s;
    if(n%2==1)cout<<"No";
    else{
    int m = n/2;
    bool flag = true;
    for(int i=0; i<m; i++)
    {
        if(s[i]!=s[m+i]){
            flag = false;
            break;
        }
    }
    if(flag)cout << "Yes";
    else cout << "No";
    }
    return 0;

}


Measured memory_bytes: 3604
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
int a=ir.nextInt();
int b=ir.nextInt();
int c=ir.nextInt();
out.println(a<b&&b<c?"Yes":"No");
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24412
#include <iostream>

using namespace std;

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

int main()
{
    _097a();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

ll a,b,c;
double EPS=0.000001;
int main(){
  cin>>a>>b>>c;
  ll tmp=a+b-c;
  if(tmp>0){
    cout<<"No"<<endl;
    return 0;
  }
  if(tmp*tmp>4*a*b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1==0)
	{
		cout<<"1";
	}else if(x2==0)
	{
		cout<<"2";
	}else if(x3==0)
	{
		cout<<"3";
	}else if(x4==0)
	{
		cout<<"4";
	}else{
		cout<<"5";
	}
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3564
import itertools
S=list(input())
l=['','+']
L=list(itertools.product(l,repeat=len(S)-1))
ans=0
for i in range(2**(len(S)-1)):
    a = S[0]
    for j in range(len(S)-1):
        a+=L[i][j]+S[j+1]
    ans+=eval(a)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans = 0;
	ll temp = k;
	ll f= 0;
	ll te;
	k = max(f,k-a);
	if(k!=0)
	ans += a;
	else if(k==0)
	ans += temp;

	k = max(f,k-b);
	te = k;
	
	if(k!=0)
	k = max(f,k-c);

	if(k!=0)
	ans += c*(-1);
	else
	ans += te*(-1);

	cout<<ans<<endl;
	return 0;

}

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

int main() {
    int n;
    cin >> n;
    int a[3 * n];
    for (int i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    long long result = 0;
    for (int j = 0, k = 3 * n - 2; j < n; j++, k -= 2) {
        result += a[k];
    }
    cout << result;
    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  map<long long,int> mp;
  mp[0]=1;
  long long ans=0;
  long long sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);
    ans+=mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
		
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;

	vector<int> ans(n, 0);

	vector<int> d1(n, 0); //from x to anywhere else
	vector<int> d2(n, 0); //from y to anywhere else

	d1[x] = 0;
	d1[y] = 1;

	d2[y] = 0;
	d2[x] = 1;

	for(int i = 0; i < n; i++) if(i != x && i != y) { 
		d1[i] = abs(x - i);	
		d2[i] = abs(y - i); 
		d1[i] = min(d1[i], d2[i] + 1);
		d2[i] = min(d2[i], d1[i] + 1);
	}


	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int d = j - i;
			if(i == x) {
				d = min(d, d1[j]);		
			} else if(i == y) {
				d = min(d, d2[j]);
			}
			d = min(d, d1[i] + d1[j]);
			d = min(d, d2[i] + d2[j]);
			ans[d]++;
		}
	}

	for(int i = 1; i < n; i++) {
		cout << ans[i] << '\n';	
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
int main() {
	int n;
	int a, b;
	std::vector<int> k,t;
	while (true)
	{
		std::cin >> n;
		if (n == 0)
			break;
		int g = 0;
		int s = 0;
		for (int i = 0; i < n; ++i) {
			if (i == 0)
				g -= g,
				s -= s;
			std::cin >> a >> b;
			if (a == b)g += a, s += b;
			if (a > b) g += a + b;
			if (a < b) s += b + a;
		}
		k.push_back(g);
		t.push_back(s);
	}
	for (int i = 0; i < k.size(); ++i) {
		std::cout << k[i] << " " << t[i] << std::endl;
	}
	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;
  double t,a;
  cin>>n>>t>>a;
  int ans=-1;
  double min=INF;
  for(int i=0;i<n;i++){
    double h;cin>>h;
    if(min>abs(a-(t-h*0.006))){
      ans=i+1;
      min=abs(a-(t-h*0.006));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
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();
        if(Math.abs(n-m) > 1){
            System.out.println(0);
            return;
        }
        long answer = 0;
        if(n == m){
            answer = solve(n,m);
            answer += solve(n,m);
        }
        else if(n > m){
            answer = solve(n,m);
        }
        else if(m > n){
            answer = solve(m,n);
        }
        answer %= 1000000007;
        System.out.println(answer);
    }
    public static long solve(int max,int x){
        long answer = 1;
        while(max != 1){
            //System.out.println("max = "+ max);
            answer *= max;
            answer %= 1000000007;
            answer *= x;
            answer %= 1000000007;
            max--;
            x--;
        }
        return answer;
    }
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<string> num(10,"");
  vector<string> res(1000);
  vector<bool> open(1000, false);
  rep(i, 10){
    char a = i + '0';
    num[i] = a;
  }
  int index = 0;
  rep(i, 10){
    rep(j,10){
      rep(k,10){
        res[index] = num[i] + num[j] + num[k];
        index++;
      }
    }
  }
  rep(i, 1000){
    char one = res[i][0];
    char two = res[i][1];
    char three = res[i][2];
    string tmp = "";
    rep(j, n){
      if(tmp.size() == 0){
        if(s[j] == one){
          tmp += s[j];
          continue;
        }
      }else if(tmp.size() == 1){
        if(s[j] == two){
          tmp += s[j];
          continue;
        }
      }else if(tmp.size() == 2){
        if(s[j] == three){
          tmp += s[j];
          continue;
        }
      }
    }
    if(tmp.size() == 3){
      int ind = 0;
      ind += 100 * (tmp[0] - '0');
      ind += 10 * (tmp[1] - '0');
      ind += (tmp[2] - '0');
      open[ind] = true;
    }
  }
  int ans = 0;
  rep(i,1000){
    if(open[i])ans++;
  }
  cout << ans << endl;
}

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

bool has3(int x) {
    while(x) {
        if( x % 10 == 3) return true;
        x /= 10;
    }
    return false;
}

void call(int n) {
    for(int x = 1; x <= n; x++){
        if(x % 3 == 0 || has3(x) ) {
            cout << " " << x;
        }
    }
    cout << endl;
}

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

    return 0;
}


Measured memory_bytes: 3088