akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

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

  int n, q;
  cin >> n >> q;

  vector<long> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vector<long> sumAll(n+1);
  vector<long> sumEven(n+1);
  vector<long> sumOdd(n+1);

  per(i, n) {
    sumAll[i] = sumAll[i+1] + a[i];
    if ((n-i+1)%2) {
      sumOdd[i] = sumOdd[i+1] + a[i];
      sumEven[i] = sumEven[i+1];
    } else {
      sumOdd[i] = sumOdd[i+1];
      sumEven[i] = sumEven[i+1] + a[i];
    }
  }

  rep(i, q) {
    long x;
    cin >> x;
    int fst = lbv(a, x);
    if (fst != 0 && x-a[fst-1] <= a[fst]-x) {
      fst--;
    }
    int ub = n+1;
    int lb = 1;
    while(ub - lb > 1) {
      int next = (lb+ub)/2;
      int target = n-next;
      int left = fst-next+1+(target-fst);
      if (target == fst) {
        ub = next;
      } else if (left >= 0 && x-a[left] <= a[target]-x) {
        lb = next;
      } else {
        ub = next;
      }
    }
    // int next = lb;
    // int target = n-next;
    // int left = fst-next+1+(target-fst);
    // cout << target << " " << left << endl;
    // if (left < 0 || x-a[left] <= a[target]-x) {
    //   lb = next;
    // }
    long res = 0;
    res += sumAll[n-lb];
    res += sumEven[0];
    res -= sumEven[max(0, n-lb*2)];

    cout << res << endl;
  }
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define forl(a,b,i) for(int i=a;i<=b;i++)
#define _fast_ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
using namespace std;

vector<int>a,ans,dp;
vector<vector<int>>g;

void dfs(int v,int p=-1){
    dp[v]=a[v];
    for(auto to:g[v]){
        if(to==p)continue;
        dfs(to,v);
        dp[v]+=max(dp[to],(int)0);
    }
}

void dfs2(int v,int p=-1){
    ans[v]=dp[v];
    for(auto to:g[v]){
        if(to==p)continue;
        dp[v]-=max(dp[to],(int)0);
        dp[to]+=max(dp[v],(int)0);
        dfs2(to,v);
        dp[to]-=max(dp[v],(int)0);
        dp[v]+=max(dp[to],(int)0);
    }
}

signed main(){
    _fast_;
    int n,m;
    cin>>n>>m;
    int ans1,ans2;
    if(n<=1&& m<=1){
        cout<<0;
    }
    else{
        if(n<=1){
            ans1=0;
            ans2=m*(m-1)/2;
        }else if(m<=1){
            ans2=0;
            ans1=n*(n-1)/2;
        }else{
            ans1=n*(n-1)/2;
            ans2=m*(m-1)/2;
        }
        cout<<ans1+ans2;
    }
    
    
    return 0;
}



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

using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;

const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    int cnt = INF;

    for(int i = 0; i < N; i++) {
        int x = i;
        for(int j = 0; j < N - i; j++) {
            if(s[i+j] != t[j]) {
                x += (N - (i + j));
                x += N - i;
                break;
            }
            x++;
        }
        x += N - (N - i);
        cnt = min(x, cnt);
    }

    cout << cnt << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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



Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int n, SR[4005], SG[4005], SB[4005];
string s;
ll ans;

int main() {
	INIT
	cin >> n >> s;
	SR[0] = s[0] == 'R' ? 1 : 0;
	SG[0] = s[0] == 'G' ? 1 : 0;
	SB[0] = s[0] == 'B' ? 1 : 0;
	rep (i, 1, n) {
		SR[i] = SR[i - 1];
		SG[i] = SG[i - 1];
		SB[i] = SB[i - 1]; 
		if (s[i] == 'R') {
			SR[i]++;
		} else if (s[i] == 'G') {
			SG[i]++;
		} else {
			SB[i]++;
		}
	}
	/*
	rep (i, 0, n) {
		cout << S[i] << ' ' << i << '\n';
	}
	*/
	for (int i = 1; i < n; ++i) {
		if (s[i] == 'R') continue;
		for (int j = i + 1; j < n; ++j) {
			if (s[j] == 'R' || s[i] == s[j]) continue;
			ans += SR[i - 1];
		//	cout << i << ' ' << S[i - 1]<<'\n';
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'R') --ans;
		}
	}
	//cout << ans << endl;
	for (int i = 1; i < n; ++i) {
		if (s[i] == 'G') continue;
		for (int j = i + 1; j < n; ++j) {
			if (s[j] == 'G' || s[i] == s[j]) continue;
			ans += SG[i - 1];
		//	cout << i << ' ' << S[i - 1]<<'\n';
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'G') --ans;
		}
	}
	//cout << ans << endl;
	for (int i = 1; i < n; ++i) {
		if (s[i] == 'B') continue;
		for (int j = i + 1; j < n; ++j) {
			if (s[j] == 'B' || s[i] == s[j]) continue;
			ans += SB[i - 1];
		//	cout << i << ' ' << S[i - 1]<<'\n';
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'B') --ans;
		}
	}
	cout << ans;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(vector<bool> v) {bool first = true; cerr << "{"; for (int i = 0; i < static_cast<int>(v.size()); i++) {if (!first) {cerr << ", ";} first = false; __print(v[i]);} cerr << "}";}
template <size_t N>
void __print(bitset<N> bs) {string res = "<"; for (size_t i = 0; i < N; i++) {res += static_cast<char>('0' + bs[i]);} res += '>'; cerr << res;}
template<typename T>
void __print(const T &x) {int j = 0; cerr << "{"; for (auto &i: x) cerr << (j++ ? ", " : ""), __print(i); cerr << "}";}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << "("; __print(x.first); cerr << ", "; __print(x.second); cerr << ")";}
template <typename A, typename B, typename C>
void __print(const tuple<A, B, C> t) {cerr << "("; __print(get<0>(t)); cerr << ", "; __print(get<1>(t)); cerr << ", "; __print(get<2>(t)); cerr << ")";}
template <typename A, typename B, typename C, typename D>
void __print(const tuple<A, B, C, D> t) {cerr << "("; __print(get<0>(t)); cerr << ", "; __print(get<1>(t)); cerr << ", "; __print(get<2>(t)); cerr << ", "; __print(get<3>(t)); cerr << ")";}
void _print() {cerr << " ]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define deb(...) cerr << "~ [ " << #__VA_ARGS__ << " ] => [ "; _print(__VA_ARGS__)
#define debn(...) cerr << "~ [ "; _print(__VA_ARGS__)
#else
#define deb(...)
#define debn(...)
#endif

#define ALL(DS) (DS).begin(), (DS).end()
#define PB push_back
#define EB emplace_back
#define SZ(DS) (int)((DS).size())
#define fo(ITER, LO, UP) for (ITER = (LO); ITER < (UP); ++ITER)
#define foi(ITER, LO, UP) for (int ITER = (LO); ITER < (UP); ++ITER)
#define foll(ITER, LO, UP) for (ITER = (ll)(LO); ITER < (ll)(UP); ++ITER)
#define folli(ITER, LO, UP) for (ll ITER = (ll)(LO); ITER < (ll)(UP); ++ITER)
#define iter(ITER, DS) for (auto &ITER: DS)

const int M = 1000000007;
const int INF = 1e9 + 5;

void init() {}

void solve() {
    int x; cin >> x;
    cout << (x == 1 ? 0: 1) << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    init();
    solve();
}



Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 510;
int n, dis[maxn][maxn], od[maxn][maxn];
int p[maxn];
int res;
bool ok[maxn][maxn];
void get_ans(int x, int y) {

	res += dis[x][y];
	queue<pair<int,int>> q;
	int val = dis[x][y];
	ok[x][y] = true;
	q.push({x, y});
	while (!q.empty()) {
		auto [x, y] = q.front();
		q.pop();
		for (int i : {-1, 1}) {
			int val = dis[x][y] + !ok[x][y];
			if (val < dis[x+i][y]) {
				dis[x+i][y] = val;
				q.push({x+i, y});
			}
			if (val < dis[x][y+i]) {
				dis[x][y+i] = val;
				q.push({x, y+i});
			}
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 1;i <= n;++i)
		for (int j = 1;j <= n;++j)
			dis[i][j] = min({i-1, n-i, j-1, n-j});

	for (int i = 1;i <= n * n;++i) {
		cin >> p[i];
		--p[i];
		int r = p[i] / n, c = p[i] % n;
		get_ans(r+1, c+1);
	}
	cout << res << '\n';
}


Measured memory_bytes: 5808
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    String s = "Christmas";
    for(int i =0;i<25-D;i++){s += " Eve";}
    System.out.println(s);
  }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int,int,int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int h,w;//y,x
int d[1000][1000];

bool inside(int y,int x)
{
    return (0<=y && y<h && 0<=x && x<w);
}

int main(){
    int ans=0;
    cin>>h>>w;
    vector<string> a(h);
    for (int i = 0; i < h; i++)
    {
        cin>>a[i];
    }
    for (int y = 0; y < h; y++)
    {
        for (int x = 0; x < w; x++)
        {
            if(a[y][x]=='.') d[y][x]=1e9+7;
            else
            {
                d[y][x]=0;
            }
        }
    }
    queue<tiii> q;//y,x,d
    for (int y = 0; y < h; y++)
    {
        for (int x = 0; x < w; x++)
        {
            if(a[y][x]=='#')
            {
                for (int i = 0; i < 4; i++)
                {
                    int nexty=y+dy4[i];
                    int nextx=x+dx4[i];
                    if(inside(nexty,nextx)==true && d[nexty][nextx]==1e9+7)
                    {
                        q.push(make_tuple(nexty,nextx,1));
                        d[nexty][nextx]=1;
                    }
                }   
            }
        }
    }
    while(q.size()>0)
    {
        tiii nowt = q.front();
        q.pop();
        int y = get<0>(nowt);
        int x = get<1>(nowt);
        int dd = get<2>(nowt);
        ans=max(ans,dd);
        for (int i = 0; i < 4; i++)
        {
            int nexty=y+dy4[i];
            int nextx=x+dx4[i];
            if(inside(nexty,nextx)==true && d[nexty][nextx]>dd+1)
            {
                q.push(make_tuple(nexty,nextx,dd+1));
                d[nexty][nextx]=dd+1;
            }
        }
    }


    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	bool find = false;
	int bot = 0;
	int count = 0;
	for (int i = 0; !find && i < N; ++i) {
		++count;
		bot = a[bot]-1;
		if (bot == 1) {
			find = true;
		}
	}
	if (find) {
		cout << count << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


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

int dp[3005][3005];

string lcs(string s, string t, int m, int n) {
  string r = "";
  for(int i=0; i<=m; i++) {
    for(int j=0; j<=n; j++) {
      if(i==0 || j==0) dp[i][j] = 0;
      else if(s[i-1] == t[j-1]) {
          dp[i][j] = 1 + dp[i-1][j-1];
      }
      else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
  }
  int i=m,j=n;
  while(i>0 && j>0) {
    if(s[i-1] == t[j-1]) {
        r += s[i-1];
        i=i-1;
        j=j-1;
    }
    else {
        if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
  }
  return r;
}

int main() {
  int n,m;
  string s,t;
  cin>>s>>t;
  m = s.size();
  n = t.size();
  string r = lcs(s,t,m,n);
  string rev = string(r.rbegin(),r.rend()); 
  cout<<rev;
}

Measured memory_bytes: 38836
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
        }
        int ans = 0;
        while(true) {
            boolean flg = false;
            for (int i = 0; i < n; i++) {
                if(h[i] != 0) {
                    h[i]--;
                    flg = true;
                } else if(flg){
                    break;
                }
            }
            if(!flg) {
                break;
            }
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35944
N, *A = map(int, open(0))

A.sort()

if N % 2 == 1:
    L, M, R = A[:N // 2], A[N // 2], A[N // 2 + 1:]
    print((sum(R) - sum(L)) * 2 + max(- M + L[-1], M - R[0]))
else:
    L, R = A[:N // 2], A[N // 2:]
    print((sum(R) - sum(L)) * 2 - R[0] + L[-1])

Measured memory_bytes: 7760
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		HashSet<Integer> set=new HashSet<Integer>();
		set.add(a);
		set.add(b);
		set.add(c);
		System.out.println(set.size());
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
import itertools
N=int(input())
L=list(map(int,input().split()))
ans=0
for i,j,k in itertools.combinations(range(N),3):
    if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
        continue
    x=max(L[i],L[j],L[k])
    if L[i]+L[j]+L[k]>2*x:
        ans+=1
print(ans)

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

#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(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i,k) cin >> d[i];

    while(1){
        int num=n;
        bool ans=true;
        while(num>0){
            rep(i,k) if(num%10==d[i]) ans=false;
            num/=10;
        }
        // cout << n << endl;
        if(ans) break;
        n++;
    }

    cout << n << endl;
    
    return 0;
}

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

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

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    vector<ll> dp(n, INF);
    dp[0] = 0;
    reps(i,n-1){
        reps(j,k){
            if(i >= j)chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
from collections import deque

S = deque(input())
queryNum = input()
flip = False
for i in range(int(queryNum)):
	order = input()
	if order == '1':
		if flip:
			flip = False
		else:
			flip = True
	else:
		if order[2] == '1':
			if not flip:
				S.appendleft(order[4])
			elif flip:
				S.append(order[4])
		else:
			if not flip:
				S.append(order[4])
			elif flip:
				S.appendleft(order[4])
S = ''.join(S)
if flip:
	print(S[::-1])
else: 
	print(S)

Measured memory_bytes: 8564
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n,x,y; cin>>n>>x>>y;
    map<int,int>g;
    rep(i,1,n-1)
    {
        rep(j,i+1,n)
        {
            int k=min((j-i),abs(i-x)+1+abs(j-y));
            g[k]++;
        } 
    }
    rep(i,1,n-1)
    cout<<g[i]<<"\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a[200010];
	cin>>n;
	map<ll,ll>b;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	ll ans=0;
	for(auto itr=b.begin();itr!=b.end();itr++){
		ll val=itr->second;
		ans+=val*(val-1)/2;
	}
//	cout <<ans;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		ll sum1=b[now]*(b[now]-1)/2;
		ll sum2=(b[now]-1)*(b[now]-2)/2;
		cout << ans+sum2-sum1<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
  int n,x,ans,s=0;
  cin>>n>>x;
  ans=n;
  vector<int> v(n);
  rep(i,n) cin>>v[i], s+=v[i];
  s=x-s;
  sort(v.begin(),v.end());
  cout<<ans+s/v[0]<<endl;
}


Measured memory_bytes: 256
l = map(int, raw_input().split())

a = l[0]
b = l[1]
c = l[2]
d = l[3]

if abs(a - c) <= d:
    print('Yes')

elif abs(a - b)  <= d and abs (b - c) <= d:
    print('Yes')

else:
    print('No')


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 3616
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{

    string a,b;
    cin >> a >> b;

    int A,B;
    cin >> A >> B;

    string x;
    cin >> x;

    if(x==a)
    {
        cout << A-1 << " " << B << endl;
    }
    else{
        cout << A << " " << B-1 << endl;
    }


    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    long long n;
    cin >> n;

    long long ans = n;
    for (int i = 1; 1ll * i * i <= n; i++) {
        if (n % i == 0) {
            ans = i + n / i - 2;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int main() {
	while (true) {
		bool osenbei[10][10000];
		int cnt[10000] = {};
		int r, c;
		cin >> r >> c;
		if (r == 0 && c == 0) break;

		REP(i, r) {
			REP(j, c) {
				int in;
				scanf("%d", &in);
				osenbei[i][j] = in == 1 ? true : false;
				if (!osenbei[i][j]) cnt[j]++;
			}
		}

		int ncnt[10000], ans = 0, now;
		REP(i, 1 << r) {
			REP(j, c) ncnt[j] = cnt[j];

			REP(j, r) if (i & (1 << j)) {
				REP(k, c) {
					if (!osenbei[j][k]) ncnt[k]--;
					else ncnt[k]++;
				}
			}

			now = 0;
			REP(j, c) {
				if (ncnt[j] > r - ncnt[j]) now += ncnt[j];
				else now += r - ncnt[j];
			}
			ans = max(ans, now);
		}

		cout << ans << endl;
	}

	return 0;
}

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

bool solve(string S) {
  if (S[0] != 'A') return false;
  int N = S.size();
  int con = 0;
  for (int i = 0; i < N; ++i) if (S[i] >= 'A' && S[i] <= 'Z') ++con;
  if (con != 2) return false;
  bool exist = false;
  for (int i = 2; i+1 < N; ++i) if (S[i] == 'C') exist = true;
  if (!exist) return false;
  
  return true;
}

int main() {
  string S;
  cin >> S;
  if (solve(S)) cout << "AC" << endl;
  else cout << "WA" << endl;
}
  
  

Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
        String s[] = a.split("");
        String ans;
        String ans2;
        String check;
        for(int i = 0; i < a.length(); i++){
          for(int j = i; j < a.length(); j++){
            ans = a.substring(0, i);
            ans2 = a.substring(j, a.length());
            check = ans + ans2;           
       	    if(check.equals("keyence")){
          	 System.out.println("YES");
         	 return;
      	 	 }else if(ans.equals("keyence")){
          	 System.out.println("YES");
         	 return;
            }else if(ans2.equals("keyence")){
          	 System.out.println("YES");
         	 return;
            }
          }
        }
        System.out.println("NO");
    }
}

Measured memory_bytes: 40360
xy = list(map(int, input().split()))
x = xy[0]
y = xy[1]

can = False
for i in range(x+1):
    for j in range(x-i+1):
        if 2*i+4*j==y and i+j==x:
            can = True
            break
    else:
        continue
    break

if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62936
#include<stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
    if(A == 1){
    	if(B == 2){
    		printf("%d",3);
		}
		else{
			printf("%d",2);
		}
	}
	else if(A == 2){
		if(B == 1){
			printf("%d",3);
		}
		else{
			printf("%d",1);
		}
	}
	else if(A == 3){
		if(B == 2){
			printf("%d",1);
		}
		else{
			printf("%d",2);
		}
	}
	return 0;
}

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

s=sum(A)
n=int(s**0.5)

#約数のリスト
cd=[]

for i in range(1,n+2):
	if s%i==0:
		cd.append(i)
		cd.append(s/i)

cd.sort(reverse=True)

def check(t):
	if t==1: return True
	A_temp=[]
	for x in A:
		A_temp.append(x%t)

	A_temp.sort()

	#Aの配列をmod tした配列A_tempの累積和
	A_temp_sum=[]

	for i,x in enumerate(A_temp):
		if i==0: A_temp_sum.append(x)
		else: A_temp_sum.append(A_temp_sum[-1]+x)

	#配列の前半は、数字をマイナスしていく
	p1=min(bisect_left(A_temp_sum,K),N-2)
	if A_temp_sum[p1]<=K:
		k1=A_temp_sum[p1]
	else:
		#配列の項数p1の値がKを超えている場合は、p1の1個手前の値をとる
		p1-=1
		k1=A_temp_sum[p1]


	#配列の後半で、数字をどれだけプラスする必要があるか
	k2=t*(N-p1-1)-(A_temp_sum[-1]-A_temp_sum[p1])

	#プラスする量が、マイナスする量より少なければ成立
	if k2<=k1:
		return True
	else:
		return False

for x in cd:
	if check(x):
		print x
		quit()


Measured memory_bytes: 32540
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    while (N) {
        ans++;
        N /= K;
    }

    cout << ans << endl;
}

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

int main(){
int n;cin >>n;
int l[n];for(int i=0;i<n;i++)cin >>l[i];  
sort(l,l+n);
string ans;
  if (accumulate(l,l+n,0)>l[n-1]*2)ans="Yes";
  else ans="No";
  cout <<ans<<endl;
}

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

int main() {
    int S;
    cin >> S;

    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = (S % 3600) % 60;
    cout << h << ':' << m << ':' << s << endl;
}



Measured memory_bytes: 3096
#include "iostream"
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<=n-3;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            count++;
        }
        
    }
    
    cout<<count<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<math.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
	if(a<b)
		swap(a,b);
	return b==0?a:gcd(b,a%b);
}

int main() {
	ll A,B;
	cin>>A>>B;
	ll n = gcd(A,B);
	ll num=0;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)
			num++;
		while(n%i==0)
			n/=i;
	}
	if(n>1)
		num++; 
	cout<<num+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let n = read_i64();
    for i in 0..100 {
        for k in 0..100 {
            if i * 4 + k * 7 == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll> a(N);
	ll ans = 0;
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		ans += a[i]*a[j];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int cnt = 0;
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      if (line.length() == 1) {
        cnt++;
        continue;
      }
      List<String> strc = new ArrayList<String>();
      List<String> strr = new ArrayList<String>();
      for (int ii = 0; ii < line.length(); ii++) {
        strc.add(line.substring(ii, ii + 1));
        strr.add(line.substring(ii, ii + 1));
      }
      Collections.reverse(strr);
      boolean flag = true;
      for (int ii = 0; ii < strc.size(); ii++) {
        if (!strc.get(ii).equals(strr.get(ii))) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int main(){
  cin >> N;
  for (int i=1; i<=N; i++){
    cin >> A[i];
    if(A[i] == 0) continue;
    for (int j=1; j<=A[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;
  for (int n=1; n< 1<<N; n++){
    bool ok = true;
    for (int i=1; i<=N; i++){
      if(!((n>>(i-1))&1)) continue;
      for(int j=1; j<=A[i]; j++){
        if(((n>>(x[i][j]-1))^y[i][j]) & 1){
          ok = false;
          break;
        }
      }
      if(!ok) break;
    }
    if(ok) ans = max(ans, __builtin_popcount(n));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]
dp = []
for n in range(N):
    if n == 0:
        dp.append(0)
    elif n== 1:
        dp.append(abs(H[n] - H[n-1]) + dp[-1])
    else:
        dp.append(
            min(
                abs(H[n] - H[n-1])+dp[-1]
                ,abs(H[n] - H[n-2])+dp[-2]
            )
        )
print(dp[-1])

Measured memory_bytes: 13772
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1] && s[1]==s[2])cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int a[N];

int main(){
  int n,k;
  cin >> n  >> k;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a, a+n);
  int sum = 0;
  for(int i=0;i<k;i++) sum += a[n-1-i];
  printf("%d\n",sum);
}


Measured memory_bytes: 256
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 
    # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 
print(ans)

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int count = 0;
    int i = min(a, b);
    while (true) {
        if ((a % i == 0) && (b % i == 0)) {
            count++;
        }
        if (count == k) break;
        i--;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        switch(sc.next()){
            case "SUN":
                System.out.println(7);
                break;

            case "MON":
                System.out.println(6);
                break;

            case "TUE":
                System.out.println(5);
                break;

            case "WED":
                System.out.println(4);
                break;

            case "THU":
                System.out.println(3);
                break;

            case "FRI":
                System.out.println(2);
                break;

            case "SAT":
                System.out.println(1);
                break;
        }


    }
}


Measured memory_bytes: 35780
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n){
		int num[100];
		for(int i = 0; i < n; i++){
			cin >> num[i];
		}
		for(int j = 1; j <= n; j++){
			if(j < n ) cout << num[n - j] << ' ';
			else if(j == n) cout << num[n - j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

string s;
int main(){
    cin >> s;
    int ans=0;
    for(int i=0,j=sz(s)-1;i<j;){
        if(s[i]==s[j]) ++i,--j;
        else if(s[i]=='x') ++i,ans++;
        else if(s[j]=='x') --j,ans++;
        else {
            ans=-1;break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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




int main() {
int N;
cin>>N;
if(N%10==3){cout<<"bon"<<endl;}
else if(N%10==0||N%10==1||N%10==6||N%10==8){cout<<"pon"<<endl;}
else{cout<<"hon"<<endl;}


}


Measured memory_bytes: 3596
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (int i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (int j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}


vector<long long> comb = vector<long long>(100 * 100, -1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}

inline int count(int b, int N, int K) {
	int res = 0;
}

int main() {
	using pos = pair<int, int>;
	int N; cin >> N;
	auto as = vector<pos>(N);
	auto bs = vector<pos>(N);
	for (size_t i = 0; i < N; i++) cin >> as[i].first >> as[i].second;
	for (size_t i = 0; i < N; i++) cin >> bs[i].first >> bs[i].second;
	sort(as.begin(), as.end(), [](pos a, pos b) {return max(a.first, a.second) > max(b.first, b.second); });
	sort(bs.begin(), bs.end(), [](pos a, pos b) {return min(a.first, a.second) < min(b.first, b.second); });
	int answer = 0;
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < as.size(); j++) {
			if (bs[i].first > as[j].first&&bs[i].second > as[j].second) {
				answer++;
				as.erase(as.begin() + j);
				break;
			}
		}
	}
	cout << answer << endl;
}

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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#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 ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, e;
	vi a, as;
	cin >> n;
	while (cin >> e) {
		a.pb(e);
		as.pb(e);
	}
	sort(rall(as));
	for (auto x : a) {
		int i = 0;
		if (as[i] == x) i++;
		cout << as[i] << ende;
	}
  return 0;
}


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

int main()
{
    int N, H[100000];
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &H[i]);
    }
    int cur = 0, max = 0;
    for (int i = 0; i < N-1; i++)
    {
        if (H[i] >= H[i + 1])
        {
            cur++;
            if (cur > max)
            {
                max = cur;
            }
        }
        else
        {
            cur = 0;
        }
    }
    printf("%d\n",max);
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    map<int, int> A;
    REP(i,n){
        int a;
        cin >> a;
        A[a]++;
    }
    int ans=0;
    for(auto a:A)
        if(a.second%2!=0) ans+=1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	int i = 0;
	while(i <= n)
	{
		int tmp = 0;
		int j = 0;
		while(a[i] == a[i + j])
		{
			j++;
		}
			
		int k = 0;
		while(i+k < n && a[i + k] - a[i] >= 0 && a[i + k] - a[i] <= 2)
		{
			k++;
			tmp++;
		}
		
		if(ans < tmp)
		{
			ans = tmp;
		}
		
		i += j;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int dp[2][1 << 22];

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;

		int b[505][505]={0};
		for(int i=1; i<=n; i++){
			for(int j=0; j<m; j++){
				char c; cin >> c;
				b[i][j] = c - '0';
			}
		}

		int ans = 0;
		if(n <= 22){
			int S = 1 << n;
			for(int i=0; i<S; i++){
				int cnt = 0;
				int ingredient[501]={0};//材料
				for(int j=1; j<=n; j++){
					if((i & (1<<(j-1))) == 0) continue;
					cnt++;
					for(int k=0; k<m; k++) ingredient[k] ^= b[j][k];
				}
				bool flag = true;
				for(int j=0; j<m; j++){
					if(ingredient[j] == 1){
						flag = false;
						break;
					}
				}
				if(flag) ans = max(ans, cnt);
			}
		}else{
			int B[501]={0};
			for(int i=1; i<=n; i++){
				for(int j=0; j<m; j++){
					B[i] |= (b[i][j] << j);
				}
			}

			int S = 1 << m;
			//fill(dp[0], dp[1], INT_MIN);
			for(int i=0; i<S; i++) dp[0][i] = dp[1][i] = INT_MIN;
			dp[0][0] = 0;
			for(int i=0; i<n; i++){
				for(int j=0; j<S; j++){
					dp[(i+1)%2][j^B[i+1]] = max(dp[(i+1)%2][j^B[i+1]], dp[i%2][j] + 1);
					dp[(i+1)%2][j] = max(dp[(i+1)%2][j], dp[i%2][j]);
				}
			}
			ans = dp[n%2][0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 20476
import java.util.Scanner;

// *** at 2018/**/**

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveA081();
	}

	private void solveA081() {
		Scanner sc = new Scanner(System.in);
		char N[] = sc.nextLine().toCharArray();
		int cnt = 0;
		for (char c : N) cnt += c - '0';
		System.out.println(cnt);
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 21844
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {

    double a ;
    cin >> a;
    double c = a / 3.0;
    double ans = c*c*c;
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 0;

int main()
{
//	freopen("input.in", "r", stdin);
    int n;
    cin >> n;

    ll all = 1;
    for (int i = 0; i < n; i++)
        all *= 3;

    ll odd = 1;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a % 2 == 0) odd *= 2;
    }

    cout << all - odd;

	return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

while True:
    try:
        a, b = map(int, input().split())
        print(gcd(a, b), lcm(a, b))
    except EOFError:
        break


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

double getDistance(double xa, double ya, double xb, double yb) {
    return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double dist = getDistance(xa, ya, xb, yb);
        if (dist > ra + rb) cout << 0 << endl;
        else if (abs(ra - rb) <= dist) cout << 1 << endl;
        else if (ra > rb) cout << 2 << endl;
        else cout << -2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=2e5+5;
const int M=1e9+7;
void solve()
{
	int n;
	cin>>n;
	multiset<int> s;
	int a[n];
	int ans=0;
	f(i,0,n-1){
		cin>>a[i];
		if(s.size()==0)
		{
			s.insert(a[i]);
			ans++;
		}
		else
		{
			auto it=s.lower_bound(a[i]);
			if(it==s.begin())
			{
				ans++;
				s.insert(a[i]);
			}
			else
			{
				it--;
				s.erase(it);
				s.insert(a[i]);
			}
		}
	}
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 5760
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if((Y%2)==1){
			System.out.println("No");
			return;
		}
		if(Y<(X*2)){
			System.out.println("No");
			return;
		}
		if(Y>(X*4)){
			System.out.println("No");
			return;
		}
		
		System.out.println("Yes");
		return;
	}
}

Measured memory_bytes: 35784
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll jump = x / d;
	ll ans = 0;
	if (jump < k) {
		ans = x;
		if ((1e15 / jump) < d) {
		//	if (jump >= d) {
				rep(i,jump)ans -= d;
				if ((k - jump) % 2 == 1)ans -= d;
			
		}
		else {
			ans = x - (jump * d);
			if ((k - jump) % 2 == 1)ans -= d;
		}
	}else{
		if ((1e15 / jump) < d) rep(i, d)ans -= jump;
		else ans = (abs(x - (k * d)));
	}
	cout << abs(ans) << endl;
	return 0;
}



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

int main()
{
    int a;
    for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
    a=i*j;
    cout<<i<<'x'<<j<<'='<<a<<'\n';
    }
    }
    return 0;
}
    

Measured memory_bytes: 2896
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    int k;
    int maxn = -1;
    int minn = 1000000;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &k);
      maxn = max(maxn, k);
      minn = min(minn, k);
      sum += k;
    }
    printf("%d\n", (sum - maxn - minn) / (n - 2));
  }
}



Measured memory_bytes: 2580