akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define vd vector<double>
#define mi map<int,int>
#define mc map<char,int>
//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int k,x;
	cin>>k >>x;
	v A;
	for(int i=k-1;i>=0;i--){
		A.push_back(x-i);
		}
		for(int i=k-1;i>0;i--){
			A.push_back(x+i);
			}
			sort(A.begin(),A.end());
			for(auto e:A)cout<<e <<" ";
			cout<<"\n";
			
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,Y; cin >> N >> X >> Y; --X,--Y;
    vector<vector<int>> dist(N,vector<int>(N));
    for (int i=0;i<N;++i)
        for (int j=0;j<N;++j)
            dist[i][j]=abs(i-j);
    for (int i=0;i<N;++i){
        for (int j=0;j<N;++j){
            dist[i][j]=min(dist[i][j],dist[i][X]+1+dist[Y][j]);
            dist[i][j]=min(dist[i][j],dist[i][Y]+1+dist[X][j]);
        }
    }
    vector<int> cnt(N,0);
    for (int i=0;i<N;++i)
        for (int j=i+1;j<N;++j)
            ++cnt[dist[i][j]];
    for (int i=1;i<N;++i) cout << cnt[i] << '\n';
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
vector<int> g[100005];
bool vis[100005];
int dp[100005];
void dfs(int node){
    vis[node] = 1;
    for(auto child:g[node]){
        if(!vis[child])
            dfs(child);
        dp[node] = max(dp[node],1 + dp[child]);
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,m; 
        cin >> n >> m;
        memset(vis,0,sizeof(vis));
        memset(vis,0,sizeof(vis));
        FOR(i,0,m){
            int x,y; cin >> x >> y;
            g[x].pb(y); // directed Graph
        }
        FOR(i,1,n+1){
            if(!vis[i])
                dfs(i);
        }
        int ans = 0;
        FOR(i,1,n+1)
            ans = max(ans,dp[i]);
        cout << ans;
    }   
}

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

#define int long long

void reverseStr(string& s) {
        int n = s.size();
        for(int i = 0; i < n / 2; i++) {
                swap(s[i], s[n - i - 1]);
        }
}

signed main() {
        string s;
        cin >> s;
        int q;
        cin >> q;
        bool isRev = false;
        for(int i = 0; i < q; i++) {
                int n = s.size();
                int t;
                cin >> t;
                if(t == 1) {
                        if(isRev) isRev = false;
                        else isRev = true;
                }
                else {
                        int f;
                        cin >> f;
                        string c;
                        cin >> c;
                        if(isRev && f == 1) s.insert(n, c);
                        else if(isRev && f == 2) s.insert(0, c);
                        else if(f == 1) s.insert(0, c);
                        else s.insert(n, c);
                }
        }
        
        if(isRev) reverseStr(s);

        cout << s << endl;
        return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N; cin>>N;
  vector<int> a(N),b(N-1);
  for(int i=0;i<N-1;i++){
    cin>>b[i];
  }
  a[0]=b[0];
  a[N-1]=b[N-2];
  for(int i=1;i<N-1;i++){
    a[i]=min(b[i-1],b[i]);
  }
  cout<<accumulate(a.begin(),a.end(),0)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                      
#include <vector>                                                        
using namespace std;                                                     
                                                                         
int main() {                                                             
  vector<int> Case;                                                      
  while (true) {                                                         
    int x;                                                               
    cin >> x;                                                            
    if (x==0) {                                                          
      break;                                                             
    }                                                                    
    Case.push_back(x);                                                   
  }                                                                      
  for (int i=0; i<Case.size(); i++) {                                    
    cout << "Case" << " " << i+1 << ":" << " " << Case[i] << endl;       
  }                                                                      
  return 0;                                                              
}                           

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "NO" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    map<ll,ll> mp;
    rep(i,N){
        ll a; cin>>a;
        if(mp[a]!=0) dame;
        ++mp[a];
    }
    cout<< "YES"<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int mypow(int a,int b){
	if(b==0) return 1;
	if(b%2) return mypow(a,b-1)*a%mod;
	int z=mypow(a,b/2);
	return z*z%mod;
}
int x[100000];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n){
		cin>>x[i];
	}
	f(i,n){
		if(x[x[i]-1]==i+1) ans++;
	}
	cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 1024
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"
#define dcml(n) fixed<<setprecision(n)

ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){num/=10;digit++;}
    return digit;
}
using namespace std;
//-------------------------------------------
int main(){
  ll N,M;cin>>N>>M;
  
  ll n;string S; ll ans1=0,ans2=0;
  bool isAC[N];ll p[N];REP(i,N){isAC[i]=false;p[i]=0;}
  REP(i,M){
    cin>>n>>S;n--;
    if(isAC[n])continue;
    if(S=="AC"){
      if(!isAC[n]){
        ans1++;
        ans2+=p[n];
        isAC[n]=true;
      }
    }
    else if(S=="WA"){
      if(!isAC[n])p[n]++;
    }
  }
  cout<<ans1<<" "<<ans2;
}


Measured memory_bytes: 1152
N = int(input())
a = list(map(int, input().split()))

ans1 = 0
s = 0
flg = 1
for ai in a:
    s += ai
    if s * flg <= 0:
        ans1 += abs(s) + 1
        s = flg
    flg *= -1

ans2 = 0
s = 0
flg = -1
for ai in a:
    s += ai
    if s * flg <= 0:
        ans2 += abs(s) + 1
        s = flg
    flg *= -1

print(min(ans1, ans2))


Measured memory_bytes: 63088
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    cin >> x[0] >> y[0];
    int odd = ((x[0] + y[0]) % 2 + 2) % 2;
    if (!odd) {
        x[0]--;
    }
    for (int i = 1; i < n; i++) {
        cin >> x[i] >> y[i];
        if (((x[i] + y[i]) % 2 + 2) % 2 != odd) {
            odd = -1;
            break;
        }
        if (!odd) {
            x[i]--;
        }
    }

    if (odd == -1) {
        cout << -1 << endl;
        return 0;
    }

    int m = 31 + (!odd);
    cout << m << endl;
    int d[m];
    for (int i = 0; i <= 30; i++) {
        d[i] = 1 << (30 - i);
    }
    if (!odd) {
        d[31] = 1;
    }
    for (int i = 0; i < m; i++) {
        cout << d[i] << (i == m - 1 ? '\n' : ' ');
    }

    for (int i = 0; i < n; i++) {
        int a = x[i], b = y[i];
        int as = a >= 0 ? 1 : -1, bs = b >= 0 ? 1 : -1;
        a *= as, b *= bs;

        for (int j = 0; j <= 30; j++) {
            char c;
            if (a >= b) {
                c = as == 1 ? 'R' : 'L';
                if (a >= d[j]) {
                    a -= d[j];
                } else {
                    a = d[j] - a;
                    as = -as;
                }
            } else {
                c = bs == 1 ? 'U' : 'D';
                if (b >= d[j]) {
                    b -= d[j];
                } else {
                    b = d[j] - b;
                    bs = -bs;
                }
            }

            cout << c;      
        }

        if (!odd) {
            cout << "R";
        }
        cout << endl;
    }

    return 0;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b, k;
  cin >> a >> b >> k;

  // 解答
  for (int i = a; i <= b; i++) {
    if (a + k > i || i > b - k) {
      cout << i << endl;
    }
  }

  return 0;
}


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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll n; cin >> n;
    ll ans = 987654321;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            string a = to_string(i);
            string b = to_string(n / i);
            ans = min(ans, (ll)max(a.length(), b.length()));
        }
    }

    cout << ans << '\n';

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  int64_t a[n+1];
  int64_t b[n+1];
  int64_t c[n];
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  for(int i = 1; i <= n; i++){
    cin >> b[i];
  }
  for(int i = 1; i <= n-1; i++){
    cin >> c[i];
  }
  
  int64_t ans = b[a[1]];
  int64_t tmp = a[1];
  for(int i = 2; i <= n; i++){
    ans += b[a[i]];
    if((tmp + 1) == a[i] /*&& a[i] != n*/){
      ans += c[tmp];
    }
    tmp = a[i];
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3628
# ACだけど汚すぎるので少しきれいにする
import math
from collections import defaultdict
p = 10 ** 9 + 7

n = int(input())
dict = defaultdict(int)
for i in range(n):
    a, b = [int(x) for x in input().split()]
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = -1
    else:
        d = (a // abs(a)) * math.gcd(a, b)
        a = a // d
        b = b // d
    dict[(a, b)] += 1

bad = []    # 直交するベクトル
others = []  # 直交するベクトルが無いベクトル
zeros = 0  # (0, 0)の数
for (a, b) in dict:
    if dict[(a, b)] == 0: continue
    if a == 0 and b == 0:
        zeros += dict[(a, b)]
        dict[(a, b)] = 0
    elif (b, -a) in dict:
        bad.append((dict[(a, b)], dict[(b, -a)]))
    elif (-b, a) in dict:
        pass    # 重複を避ける
    else:
        others.append(dict[(a, b)])

ans = 1
for (x, y) in bad:
    ans = ans * (pow(2, x, p) + pow(2, y, p) - 1) % p
for z in others:
    ans = ans * pow(2, z, p) % p
ans = (ans + zeros - 1) % p
print(ans)

Measured memory_bytes: 46804
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

sat = 0
A.each do |a|
  sat += B[a-1]
end

A.each_cons(2) do |a,b|
  if a + 1 == b
    sat += C[a-1]
  end
end

puts sat


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n;
    cin >> n;
    string s = to_string(n);
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='9'){cout << "1";}
        else{cout << "9";}
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}
 
using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
// Problem Specific Parameter:
 
vector<int> ans;
 
int k, n;
 
void opr(){
	if(ans.back()==1){
		ans.pop_back();
	}else{
		ans.back()--;
		while(int(ans.size())<n){
			ans.push_back(k);
		}
	}

	return;
}
 
void output() {
	bool first = true;
	for (auto &elem : ans) {
		if (elem == 0) break;
 
		if (first) {
			first = false;
		} else {
			cout << " ";
		}
		cout << elem;
	}
	cout << endl;
}
 
int main(void) {
	cin >> k >> n;
 
	if (k % 2 == 0) {
		const int half = k / 2;
		ans.push_back(half);
		rep(loop, n - 1) ans.push_back(k);
	} else {
		const int half = (k + 1) / 2;
		rep(loop, n) ans.push_back(half);
		rep(loop, n / 2) opr();
	}
 
	output();
 
 
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll>b(n+1);
    rep(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    ll cnt=0;
    rep(i,n+1){
        if(b[i]>=2){
            cnt+=b[i]*(b[i]-1)/2;
        }
    }
    rep(i,n){
        if(b[a[i]]>=2){
            cout<<cnt-b[a[i]]+1<<endl;
        }else{
            cout<<cnt<<endl;
        }
    }
}

Measured memory_bytes: 5760
import itertools
n=int(input())
tl=[[-1]*n for _ in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        tl[i][x-1]=y
ans=0
ll=list(itertools.product(range(2),repeat=n))
for l in ll:
    for i in range(n):
        if l[i]==0:
            continue
        for j in range(n):
            if tl[i][j]<0:
                continue
            if tl[i][j]!=l[j]:
                break
        else:
            continue
        break
    else:
        ans=max(ans,sum(l))
print(ans)

Measured memory_bytes: 48496
import sys
sys.setrecursionlimit(100000)

def dfs(v, tm):
    dts[v] = est[v] = tm + 1
    child = 0

    for i in adj[v]:
        if est[i] == float('inf'):
            child += 1
            parents[i] = v
            dfs(i, tm + 1)
            est[v] = min(est[v], est[i])

            if parents[v] is None and child > 1: aps[v] = True
            if parents[v] is not None and est[i] >= dts[v]: aps[v] = True

        elif parents[v] != i:
            est[v] = min(est[v], dts[i])

nv, ne = map(int, input().split(' '))
adj = [[] for _ in range(nv)]
est = [float('inf')] * nv
parents = [None] * nv
aps = [False] * nv
dts = [0] * nv

for _ in range(ne):
    s, t = map(int, input().split(' '))
    adj[s].append(t)
    adj[t].append(s)

dfs(0, 0)

for i in range(nv):
    if aps[i]:
        print(i)

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

int mod = 1e9+7;
int INF = 1e9+7;


int main(){

  int H, W, x, y;
  cin >> W >> H >> x >> y;

  double area = (double)W*H/2;

  if(W%2==0 && H%2==0 && x==W/2 && y==H/2){
    printf("%.15f 1\n", area);
  }else{
    printf("%.15f 0\n", area);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000 + 10;
int n;
char s[maxn];
int z1[maxn], c1[maxn], z2[maxn], c2[maxn];
void calc(int * z, int * c)
{
	for(int i = 2, l = 1, r = 1; i <= n; ++i)
	{
		if(i <= r) z[i] = min(r - i + 1, z[i - l + 1]);
		while(i + z[i] <= n && s[z[i] + 1] == s[i + z[i]]) ++z[i];
		if(i > r) l = i, r = i + z[i] - 1;
	}
	for(int i = 1; i <= n; ++i) c[i] = i;
	for(int i = 2; i <= n; ++i) 
		for(int j = i - 1; j <= i + z[i] - 1; j += i - 1)
			c[j] = min(c[j], i - 1);
}
int main()
{
	scanf("%s", s + 1); 
	n = strlen(s + 1);
	calc(z1, c1);
	if(c1[n] == 1) 
	{
		printf("%d\n%d\n", n, 1);
		return 0;
	}
	else if(c1[n] == n)
	{
		printf("%d\n%d\n", 1, 1);
		return 0;
	} 
	reverse(s + 1, s + n + 1);
	calc(z2, c2);
	printf("%d\n", 2);
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		if(c1[i] == i && c2[n - i] == n - i)
			++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 12132
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 3668
N, M = map(int, input().split())
A = [0] * N
B = [0] * N
T = 1
ans = 0
for i in range(M):
  s_i , c_i = map(int, input().split())
  if B[s_i - 1] == 0:
    A[s_i - 1] = c_i
    B[s_i - 1] = 1
  else:
    if A[s_i - 1] != c_i:
      T = 0
if B[0] == 0 and N != 1:
  A[0] = 1
for i in range(N):
  y = A[N - i - 1]
  y = int(y)
  ans = ans + y * 10 ** i
if T == 0:
  ans = -1
elif A[0] == 0 and N !=1 :
  ans = -1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
  int _a, b, _c, d;
  cin >> _a, cin >> b, cin >> _c, cin >> d;

  int a = min(_a, _c);
  int c = max(_a, _c);

  if (d >= abs(a - c))
  {
    cout << "Yes" << endl;
    return 0;
  }

  // if ((b >= c) && (b <= a))
  // {
  //   cout << "No" << endl;
  //   return 0;
  // }

  if ((d >= abs(a - b) && (d >= abs(b - c))))
  {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        List<int[]> list = new List<int[]>();

        int w = int.Parse(Console.ReadLine());
        List<int> wn = new List<int>();
        for (int i = 0; i <= w; i++) {
            wn.Add(i);
        }

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++) {
            string v = Console.ReadLine();
            string[] vs = v.Split(',');

            list.Add(new int[] { int.Parse(vs[0]), int.Parse(vs[1]) });
        }

        SortedDictionary<int, int> toWn = new SortedDictionary<int, int>();
        for (int i = 1; i < wn.Count; i++) {
            toWn.Add(ToTate(wn[i], list), i);
        }

        foreach (int key in toWn.Keys) {
            Console.WriteLine(toWn[key]);
        }
        return 0;
    }

    static int ToTate(int value, List<int[]> list) {
        int toValue = value;

        for (int i = 0; i < list.Count; i++) {
            if (list[i][0] == toValue) {
                toValue = list[i][1];
                continue;
            }
            if (list[i][1] == toValue) {
                toValue = list[i][0];
                continue;
            }
        }
        return toValue;
    }
}



Measured memory_bytes: 10684
n, a, b, c, d = map(int, input().split())
s = str(input())

if ('##' in s[a-1:max(c,d)]) == True: # そもそも行けるか
    print("No")
else:
    if d < c: # aがbを追い抜く必要があるとき
        # 抜かせるかどうか
        oinuki= s[b-2:d+1]
        if ("..." in oinuki) == True: # 3個以上の連続があれば抜かせる
            print("Yes")
        else: # 抜かせないとき
            print("No")
    else: # 追い抜く必要なし
        print("Yes")

Measured memory_bytes: 3572
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
    fast_io();

    int n;
    cin >> n;

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

    int left = -1;
    int counts = -1;
    int maxCounts = 0;
    for (int i = 0; i < n; ++i) {
        if (left == -1 || v[i] <= left) {
            counts++;
        } else {
            counts = 0;
        }
        left = v[i];
        maxCounts = max(maxCounts, counts);
    }

    cout << maxCounts <<endl;
}


Measured memory_bytes: 888
#include <iostream>
//#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int A, B;
    cin >> A >> B;
    
    cout << (A >= 13 ? B : (A >= 6 ? B /2 : 0)) << endl;
    
    return 0;
}

Measured memory_bytes: 380
def main():
    S = input()
    n = N= len(S)
    def pal(s):
        return s == s[::-1]

    return pal(S) and pal(S[:(n - 1) // 2]) and pal(S[(N + 3) // 2 - 1:])

print('Yes' if main() else 'No')


Measured memory_bytes: 2940
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   Ans : Integer;
begin
   Get (A);
   Ans := A+A*A+A*A*A;
   Put_Line (Integer'Image (Ans));
end Solve;

Measured memory_bytes: 3632
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, K, an = 0, max = 0, j = 1;
	int a[200010], count[200010] = { 0 }, kind = 0;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		count[a[i]]++;
		if (a[i] > max) {
			max = a[i];
		}
	}
	for (int i = 1; i <= max; i++) {
		if (count[i] != 0) {
			kind++;
		}
	}
	sort(count, count + N,greater<int>());
	for (int i = 0; i < K; i++) {
		an += count[i];
	}
	printf("%d", N - an);
}

Measured memory_bytes: 1664
#include <stdio.h>

int main() {
  int W, H;
  int w, h;
  scanf("%d %d", &H, &W);
  while(W != 0 || H != 0) {
    for(h = 0; h < H; h++) {
      for(w = 0; w < W; w++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n<=2)
        cout<<0;
    else
    {
        if(n%2==0)
            cout<<n/2-1;
        else
            cout<<n/2;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1), B(N);
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;

  rep(i, N) {
    int l = min(A[i], B[i]);
    int r = min(A[i+1], B[i] - l);
    A[i+1] -= r;
    ans += l + r;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int Mod=200003,G=2,MAXN=6e5+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int n,K[MAXN],o[MAXN],a[MAXN];ll ans[MAXN];
namespace Solve{
	const double pie=acos(-1);
	struct cp{double x,y;cp(){}cp(double x,double y):x(x),y(y){}inline cp conj(){return cp(x,-y);}}w[2][MAXN],aa[MAXN],bb[MAXN],cc[MAXN],dd[MAXN];
	inline cp operator+(cp a,cp b){return cp(a.x+b.x,a.y+b.y);}
	inline cp operator-(cp a,cp b){return cp(a.x-b.x,a.y-b.y);}
	inline cp operator*(cp a,cp b){return cp(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}
	int r[MAXN],N,inv[MAXN],cnt;
	inline int Trans(int n){
		int N,c;
		for(N=1,c=0;N<=n;N<<=1,c++);
		for(int i=0;i<N;i++)r[i]=(r[i>>1]>>1)|((i&1)<<(c-1));
		for(int i=0;i<N;i++)w[0][i]=cp(cos(2*pie*i/N),sin(2*pie*i/N)),w[1][i]=cp(cos(2*pie*i/N),-sin(2*pie*i/N));
		return N;
	}
	inline void FFT(cp*F,int len,int opt){
		for(int i=0;i<len;i++)if(i<r[i])swap(F[i],F[r[i]]);
		for(int i=1,x=len>>1;i<len;i<<=1,x>>=1)
			for(int j=0;j<len;j+=i<<1)
				for(int k=0;k<i;k++){
					cp tt=w[opt][k*x]*F[i+j+k];
					F[i+j+k]=F[j+k]-tt,F[j+k]=F[j+k]+tt;
				}
		if(opt)for(int i=0;i<len;i++)F[i].x/=len,F[i].y/=len;
	}
	inline void MTT(int n,int*A,int*B,ll*C){
		int N=Trans(n);
		for(int i=0;i<N>>1;i++)aa[i]=cp(A[i]>>15,A[i]&0x7fff),bb[i]=cp(B[i]>>15,B[i]&0x7fff),aa[i+(N>>1)]=bb[i+(N>>1)]=cp(0,0);
		FFT(aa,N,0),FFT(bb,N,0);
		for(int i=0,j;i<N;i++){j=(N-i)&(N-1);
			cp a=(aa[i]+aa[j].conj())*cp(0.5,0),b=(aa[i]-aa[j].conj())*cp(0,-0.5),c=(bb[i]+bb[j].conj())*cp(0.5,0),d=(bb[i]-bb[j].conj())*cp(0,-0.5);
			cc[i]=a*c+a*d*cp(0,1),dd[i]=b*c+b*d*cp(0,1);
		}
		FFT(cc,N,1),FFT(dd,N,1);
		for(int i=0;i<N;i++){
			ll a=(ll)(cc[i].x+0.5),b=(ll)(cc[i].y+0.5),c=(ll)(dd[i].x+0.5),d=(ll)(dd[i].y+0.5);
			C[i]=(((ll)a<<30)+((ll)(b+c)<<15)+d);
		}
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();int tmp=1;
	Rep(i,0,Mod-2)o[tmp]=i,tmp=1ll*tmp*G%Mod;
	Rep(i,1,n){
		int x=read();a[i]=x;
		if(!x)continue;
		K[o[x]]++;
	}
	Solve::MTT(Mod*2,K,K,ans);tmp=1;ll Ans=0;
	Rep(i,0,2*Mod)Ans+=1ll*ans[i]*tmp,tmp=1ll*tmp*G%Mod;
	Rep(i,1,n)Ans-=1ll*a[i]*a[i]%Mod;Ans/=2;
	cout<<Ans<<"\n"; 
//	Rep(i,0,2*Mod)cout<<ans[i]<<"\n";
	return 0;
}



Measured memory_bytes: 61588
function Main(input) {
  input = input.split("\n");
  var sx = parseInt(input[0].split(" ")[0]);
  var sy = parseInt(input[0].split(" ")[1]);
  var tx = parseInt(input[0].split(" ")[2]);
  var ty = parseInt(input[0].split(" ")[3]);
  var ans = "";
  for(i=0;i<tx-sx;i++){
    ans+="R";
  }
  for(i=0;i<ty-sy;i++){
    ans+="U";
  }
  for(i=0;i<tx-sx;i++){
    ans+="L";
  }
  for(i=0;i<ty-sy;i++){
    ans+="D";
  }
  ans+="D";
  for(i=0;i<=tx-sx;i++){
    ans+="R";
  }
  for(i=0;i<=ty-sy;i++){
    ans+="U";
  }
  ans+="LU";
  for(i=0;i<=tx-sx;i++){
    ans+="L";
  }
  for(i=0;i<=ty-sy;i++){
    ans+="D";
  }
  ans+="R";
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int MSIZE=1000010;

const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
long long sq(long long a){return a*a%mod;}
long long pw(long long a,long long n)
{
  return n==0?1ll:sq(pw(a,n/2))*(n%2==1?a:1ll)%mod;
}
long long iv(long long a){return pw(a,mod-2);}
long long inv[MSIZE],F[MSIZE],iF[MSIZE];

void prev(int N)
{
  inv[0]=0;
  inv[1]=1;
  for(int i=2;i<N;i++){
    inv[i]=(mod-mod/i)*inv[mod%i]%mod;
  }
  F[0]=iF[0]=1;
  for(int i=1;i<N;i++){
    F[i]=F[i-1]*i%mod;
    iF[i]=iF[i-1]*inv[i]%mod;
  }
}

long long Ch(int i,int j)
{
  return F[i]*iF[j]%mod*iF[i-j]%mod;
}

int main()
{
  int n;
  scanf("%d",&n);
  prev(n+1);
  long long ans=0ll;
  for(int i=0;i<n-1;i++){
    ad(ans,F[n-1]+(i-1<n-1-i?0:mod-Ch(i-1,n-1-i)*F[i]%mod*F[n-1-i]%mod));
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 23680
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}


int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  else return b;
}
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  vector<int> B(n+1);
  B[0] = 0;
  for(int i = 1; n >= i; i++){
    B[i] = B[i-1]+A[i-1];
  }
  int ans = B[n];
  for(int i = 0; n >= i; i++){
    ans = min(ans,abs(B[i]-(B[n]-B[i])));
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    string s;
    cin >> s;

    if(s.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    
    bool ok = true;
    rep(i, s.size()-1){
        if(s[i] == 'h' && s[i+1] == 'i') i++;
        else ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int i, count0, count1, ans, dst;
  char S[100000];
  scanf("%s",S);

  count0 = count1 = ans = 0;
  dst = strlen(S);
  for(i = 0; i < dst; ++i){
    if(S[i] == '0'){
      count0++;
    } else {
      count1++;
    }
  }
  
  ans = (count0 >= count1) ? count1: count0;
  printf("%d\n", 2 * ans);
  return 0;
}

Measured memory_bytes: 256
import kotlin.comparisons.compareBy
data class XY(var x: Int, var y: Int) {
    constructor(xy: List<Int>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val R = Array(N) { XY(listOfInt()) }.sortedWith(compareBy({ -it.y }, { it.x }))
    val B = Array(N) { XY(listOfInt()) }.sortedWith(compareBy({  it.x }, { it.y }))
    var ans = 0
    for (b in 0 until N) {
        var rr = -1
        var maxY = -1
        for (r in 0 until N) {
            if (R[r].x == -1) continue
            if (R[r].x < B[b].x && R[r].y < B[b].y) {
                if (maxY < R[r].y) {
                    rr = r
                    maxY = R[r].y
                }
            }
        }
        if (rr != -1) {
            R[rr].x = -1
            ans += 1
        }
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }




Measured memory_bytes: 37868
N, L = gets.split.map(&:to_i)

tasts = N.times.map { |i| L + i }
sum = tasts.inject(:+)

ans = Float::INFINITY
min_aji = Float::INFINITY

tasts.each do |t|
  v = sum - t
  aji = (sum - v).abs

  if min_aji > aji
    min_aji = aji
    ans = v
  end
end

puts ans


Measured memory_bytes: 1788
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  ll T;
  while (cin >> N >> T) {
    ll X = 0;
    ll L = 0, R = T;
    for (int i = 0; i < N; i++) {
      ll t;
      cin >> t;
      if (t <= R) {
        R = t + T;
      } else {
        X += R - L;
        L = t;
        R = t + T;
      }
    }
    X += R - L;
    cout << X << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int i=0,j=a.size()-1;
    int c = 0;
    while(i<=j)
    {
        if(a[i]!=a[j])
        {
            c++;
        }
        i++;
        j--;
    }
    cout<<c;

}


Measured memory_bytes: 256
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = n-r-g 

rgb = 0
for j in range(1,n//2+1):
  for i in range(n-2):
    try:
      arr = sorted([s[i],s[i+j],s[i+j*2]])
      if arr == ["B","G","R"]:
        rgb +=1
    except:
      continue

ans = r*g*b - rgb # 全部の可能性から同じ距離のものを引く
print(ans)

Measured memory_bytes: 74708
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main();
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    _main();
}
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
//---------------------------------------------------------------------------------------------------
struct BellmanFordMax {
    BellmanFordMax() {}
    BellmanFordMax(int n) { init(n); }
    vector<vector<pair<int, int>>> E;
    int N;
    void init(int n) {
        N = n;
        E.resize(0);
        E.clear();
        E.resize(n);
    }
    void add(int a, int b, int c) { E[a].push_back({b, c}); }
    vector<ll> solve(int s) {
        vector<ll> res(N, -infl);
        res[s] = 0;

        rep(i, 0, N - 1) {
            rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
                res[p.first] = max(res[p.first], res[cu] + p.second);
            }
        }

        vector<bool> pos(N);
        rep(i, 0, N) {
            rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
                if (res[p.first] < res[cu] + p.second) {
                    res[p.first] = res[cu] + p.second;
                    pos[p.first] = true;
                }
                if (pos[cu])
                    pos[p.first] = true;
            }
        }

        rep(cu, 0, N) if (pos[cu]) res[cu] = infl;

        return res;
    }
};

int N, M, P;
vector<pair<int, int>> E[2500];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> P;

    BellmanFordMax bf(N);

    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bf.add(a, b, c - P);
    }

    ll ans = bf.solve(0)[N - 1];

    if (ans == infl)
        ans = -1;
    else if (ans < 0)
        ans = 0;

    cout << ans << endl;
}


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

int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<endl;
		return 0;
	}
	if(a+b>=k){
		cout<<a<<endl;
		return 0;
	}
	cout<<a-(k-(a+b))<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int H, W;
    cin >> H >> W;
    pint s;
    cin >> s.first >> s.second;
    pint t;
    cin >> t.first >> t.second;
    --s.first, --s.second, --t.first, --t.second;
    vector<string> S(H);
    for (int i = 0; i < H; ++i) cin >> S[i];
    constexpr int inf = 1e9;
    Graph dist(H, vector<int>(W, inf));
    dist[s.first][s.second] = 0;
    deque<pint> q;
    q.emplace_back(s);
    while (!q.empty()) {
        auto yx = q.front();
        auto d = dist[yx.first][yx.second];
        q.pop_front();
        // if (dist[yx.first][yx.second] != d) continue;
        for (int v = 0; v < 4; ++v) {
            int ny = yx.first + dy[v];
            int nx = yx.second + dx[v];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if (dist[ny][nx] <= d) continue;
            if (S[ny][nx] == '#') continue;
            dist[ny][nx] = d;
            q.emplace_front(ny, nx);
        }
        for (int ey = -2; ey <= 2; ++ey) {
            for (int ex = -2; ex <= 2; ++ex) {
                int ny = yx.first + ey;
                int nx = yx.second + ex;
                if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
                if (dist[ny][nx] <= d + 1) continue;
                if (S[ny][nx] == '#') continue;
                dist[ny][nx] = d + 1;
                q.emplace_back(ny, nx);
            }
        }
    }
    int res = dist[t.first][t.second];
    if (res == inf) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int power(int x,int p)
{
   int res=1;
   while(p)
   {
      if(p&1)res=(res*x)%mod;
      p=p>>1;
      x=(x*x)%mod;
   }
   return res;
}
vector<int>f(2e5+5),inv(2e5+5);
int ncr(int n,int r)
{
   return ((f[n]*inv[n-r])%mod*inv[r])%mod;
}


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

   
int n,k;
cin>>n>>k;

inv[0]=inv[1]=f[0]=f[1]=1;

for(int i=2;i<=f.size()-1;i++)
{
   f[i]=(f[i-1]*i)%mod;
   inv[i]=power(f[i],mod-2);
}
int ans=0;




for(int i=0;i<=min(n-1,k);i++)
{
    ans=(ans+(ncr(n,i)*ncr(n-1,i))%mod )%mod;
}
cout<<ans<<"\n";




}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N; vector<ll> L(N); rep(i, N){cin >> L.at(i);}
    sort(L.begin(), L.end(), greater<ll>());
    ll sum = 0;
    rep(i, N - 1){sum += L.at(i + 1);}
    if (sum > L.at(0)){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.util.Collections;

public class Main{
    public static void main(String[] args){
 
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      
        if(a+b+c >= 22){
          System.out.println("bust");
        
        } else {
          System.out.println("win");
        } 
      
      
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
  int i;
  int kind, amo;
  int price[4];
  int tmp;

  for (i = 0; i < 4; i++) {
    scanf("%d %d", &kind, &amo);
    switch (kind) {
    case 1: tmp = 6000;  break;
    case 2: tmp = 4000;  break;
    case 3: tmp = 3000;  break;
    case 4: tmp = 2000;  break;
    }
    price[i] = tmp * amo;
  }

  for (i = 0; i < 4; i++) {
    printf("%d\n", price[i]);
  }

  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[10], v[2];
	while (cin >> a[0]) {
		rep(i1, 9) {
			char charsagashiteirunowisyo;
			int i = i1 + 1;
			cin >> charsagashiteirunowisyo >> a[i];
			if (i1 == 8) {
				cin >> charsagashiteirunowisyo >> v[0] >> charsagashiteirunowisyo >> v[1];
				break;
			}
		}
		int a_sum = 0;
		for (int i = 0; i < 10; i++) {
			a_sum += a[i];
		}
		int whatnuum = (int)(a_sum*v[0] / (double)(v[0] + v[1]));
	
		for (int i = 0; i < 10; i++) {
			whatnuum-=a[i];
			
			if (whatnuum <= 0) {
				cout << i+1<<endl;
				break;
			}
		
		}
	}
	return 0;
}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
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 power(ll a,ll b) {ll i,p=1; for(i=0;i<b;i++){p*=a;} return p;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        
        char a,b;
        ll x=0;
        cin>>a;
	x=int(a);
	if(x>=65 && x<=91)
	{
	x=(int)(a-'A');
	b='A';
cout<<b;
} 
else{
x=(int)(a-'a');
b='a';
cout<<b;
}
        }

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string str="";
    while(1){
        cin >> str;
        if(str == "0"){
            break;
        }else{
            int n=0;
            for(int i=0;i<str.length();i++){
                n += str[i] - '0';
            }
            cout << n << endl;
        }
    }
}




Measured memory_bytes: 3220