akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
int INF = 1e9;
int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> c(m);
    for(int i = 0; i < m; i++) std::cin >> c[i];
    int dp[n + 1];
    for(int i = 0; i < n + 1; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n + 1; j++){
            if(j >= c[i]){
                dp[j] = std::min(dp[j], dp[j - c[i]] + 1);
            }
        }
    }
    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 3312
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    ll L;
    cin >> L;
    double a = (double)L / 3;
    printf("%.7lf", a * a * a);
    return;
}

int main()
{
    solve();
    return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int N,K;
    string S;

    cin>>N>>K>>S;

    S[K-1]=tolower(S[K-1]);

    cout<<S<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void chmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void chmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  rep(i, n) {
    a[i] = a[i]-(i+1);
  }
  sort(a.begin(), a.end());
  int b = a[n/2];
  ll ans = 0;
  rep(i, n) {
    ans += abs(a[i]-b);
  }
  cout << ans << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
using PII = pair<int, int>;
using VPII = vector<PII>;
using VB = vector<bool>;

bool compb(PII p1, PII p2) {
  return p1.second < p2.second;
}

int main()
{
  int N, M;
  cin >> N >> M;
  VPII Wars(M);
  int a, b;
  REP(i, M) {
    cin >> a >> b;
    Wars[i] = make_pair(a-1, b-1);
  }
  sort(ALL(Wars), compb);
  
  VB remove(N);
  bool stoppable;
  int total = 0;
  REP(i, M) {
    tie(a, b) = Wars[i];
    stoppable = false;
    FOR(j, a, b) {
      if(remove[j]) {
        stoppable = true;
        break;
      }
    }
    if(!stoppable) {
      remove[b-1] = true;
      total++;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main() {
  char A[110], B[110];
  int Alength, Blength;
  int i;

  scanf("%s %s", A, B);
  Alength = strlen(A);
  Blength = strlen(B);
  if(Alength < Blength) printf("LESS\n");
  else if(Alength > Blength) printf("GREATER\n");
  else {
  	int cmp = strcmp(A, B);
  	if(cmp < 0) printf("LESS\n");
  	else if (cmp > 0) printf("GREATER\n");
  	else printf("EQUAL\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N+1);
    REP(i, N) cin >> H[i+1];
    map<ll, set<ll>> T;
    REP(i, M) {
        ll A, B;
        cin >> A >> B;
        T[A].insert(B);
        T[B].insert(A);
    }

    ll c = 0;
    FOR(i, 1, N+1) {
        if (T[i].size() == 0) {
            c++;
        } else {
            bool can = true;
            for (auto x : T[i]) {
                if (H[i] <= H[x]) can = false;
            }
            if (can) c++;
        }
    }
    cout << c << "\n";
}


Measured memory_bytes: 22648
N, K = map(int, input().split())
S = input()
split_list = [0]
section_list = [0]
for i in range(1, N):
    if S[i-1] != S[i]:
        section_list.append(i - split_list[-1])
        split_list.append(i)
split_list.append(N)
section_list.append(split_list[-1] - split_list[-2])
del split_list[0]
del section_list[0]
answer = 0
if len(section_list) <= 2 * K:
    answer= N
else:
    total = sum(section_list[:2 * K + 1])
    if S[0] == '1':
        answer = total
    for i in range(len(section_list) - 2 * K - 1):
        total = total - section_list[i] + section_list[i+2*K+1]
        if (S[0] == '0') & (i % 2 == 0):
            if total >= answer:
                answer = total
        if (S[0] == '1') & (i % 2 == 1):
            if total >= answer:
                answer = total
    # 0から始まるパターン
    total = sum(section_list[:2 * K])
    if total > answer:
        answer = total
    #0で終わるパターン
    total = sum(section_list[- 2 * K:])
    if total > answer:
        answer = total
print(answer)

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

int main()
{
  int64_t X;
  cin >> X;
  int64_t fty = X / 500;
  int64_t fve = (X % 500) / 5;
  cout << 1000 * fty + 5 * fve << endl;
}

Measured memory_bytes: 256
i,j,k;
long s[444],p[444][444],S,P;
main(a)
{
	scanf("%*d");
	for(;~scanf("%d",&a);)
	{
		i=j++;
		for(s[j]=S+=a;i--;)
		{
			P=9e18;
			for(k=i;++k<j;)
			{
				P=fmin(P,p[i][k]+p[k][j]+S-s[i]);
			}
			p[i][j]=P;
		}
	}
	printf("%ld",P);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n;
	cin >> n;
	map<string, int> mp;
	bool ok = true;
	char tail;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
		if ((i && s.front() != tail) || mp[s] >= 2)
			ok = false;
		tail = s.back();
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	solve();
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (a < b) {
		int aa = a + v * t;
		int bb = b + w * t;
		if (aa >= bb) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		int aa = a - v * t;
		int bb = b - w * t;
		if (aa <= bb) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

//!

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

int ans;
bool f[100001];

void check(int k, int t, int u){
	if((t <= k && k <= u) || ((t + k - 1) / k < u / k)){
		if(!f[k]){
			f[k] = true;
			++ans;
		}
	}
	else if(f[k]){
		f[k] = false;
		--ans;
	}
}

int main(){
	int n, w;
	scanf("%d%d", &n, &w);
	
	for(int i = 1; i <= w; ++i){
		f[i] = true;
	}
	ans = w;
	
	for(int i = 1; i <= n - w + 1; ++i){
		printf("%d%c", ans, i == n - w + 1 ? '\n' : ' ');
		
		for(int j = 1; j * j <= i; ++j){
			if(i % j == 0){
				check(j, i + 1, i + w);
				check(i / j, i + 1, i + w);
			}
		}
		for(int j = 1; j * j <= i + w; ++j){
			if((i + w) % j == 0){
				check(j, i + 1, i + w);
				check((i + w) / j, i + 1, i + w);
			}
		}
	}
}

Measured memory_bytes: 1120
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
   string s, t;
   map<char, char> st, ts;
   cin >> s >> t;
   FOR(i, 0, s.size())
   {

      if (st.find(s[i]) == st.end() && ts.find(t[i]) == ts.end())
      {
         st[s[i]] = t[i];
         ts[t[i]] = s[i];
      }
      else
      {
         if (st[s[i]] != t[i] || ts[t[i]] != s[i])
         {
            cout << "No" << endl;
            return 0;
         }
      }
   }

   cout << "Yes" << endl;

   return 0;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    for(int i = 0; i <= 999; i += 111) {
        if (i <= N && N <= i + 111) {
            cout << i + 111 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def getmaxand(bs, K):
    for k in range(40, -1, -1):
        bit = 1 << k
        avails = [v for v in bs if v & bit]
        if len(avails) < K:
            continue
        filt = ~(-1 << k)
        elims = [v & filt for v in avails]
        return (1 << k) + getmaxand(elims, K)
    return 0


N, K = map(int, input().split())
A = [int(s) for s in input().split()]

bs = []
for l in range(N):
    for r in range(l, N):
        bs.append(sum(A[l:r+1]))

print(getmaxand(bs, K))


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


long long factorial[int(1e6+2)];

int M = 1e9+7;

long long fast_mult(long long a, long long b){
    if(b == 1) return a;
    if(b%2 == 0) return fast_mult(a, b/2)*fast_mult(a, b/2)%M;
    else return fast_mult(a, b-1)*a%M;
}

void fact(int a){
    long long ans = 1;
    factorial[1] = 1;
    factorial[0] = 1;
    for(int i = 2; i <= a; i++){
        ans = ans*i%M;
        factorial[i] = ans;
    }
}

long long C(int a, int b){
    long long tmp = factorial[a];
    long long tmp2 = factorial[a-b]*factorial[b]%M;
    tmp2 = fast_mult(tmp2, M-2);
    return tmp*tmp2%M;
}

void solve(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    fact(1e6);
//    DP[0][0] = 1;
//    for(int j = 0; j < h; j++){
//        for(int i = 0; i < w; i++){
//            if(i == 0 && j == 0) continue;
//            //if(h-j <= a && i <= b) continue;
//            if(i > 0) DP[j][i] = DP[j][i-1];
//            if(j > 0) DP[j][i] +=DP[j-1][i];
//        }
//    }
//    for(int j = 0; j < h; j++){
//        for(int i = 0; i < w; i++){
//            cout << DP[j][i] << "        ";
//        }
//        cout << "\n";
//        }
//    cout << C(h-1+w-1, h-1) << "\n";// - C(b-1+h-1, b-1)*C(a-1+w-1, w-1)%M)+M)%M;
//    cout << C(b-1+h-1, h-1) << "\n";//*C(a-1+w-1, w-1)%M;
//    cout << C(a-1+w-1, w-1) << "\n";
//    cout << b-1+h-1 << "\n";
    long long ans = 0;
    for(int i = b+1; i <= w; i++){
        long long tmp1 = C(i-1+h-a-1, i-1);
        //cout << "tmp1: C(" << i-1+h-a-1 << ", " << i-1 << ") = " << tmp1 << "\n";
        long long tmp2 = C(w-i+a-1, a-1);
        //cout << "tmp1: C(" << w-i+a-1 << ", " << a-1 << ") = " << tmp2 << "\n";
        ans = (ans+tmp1*tmp2)%M;
    }
    cout << ans << "\n";
}

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

    bool multitest = false;
//    multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






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

using namespace std;

int main(){
    long long int N,ans=0;

    cin >> N;

    for(long long int i=2;i*i<=N;i++){
        if(N%i==0){
            long long int other = N/i;

            long long int tmp = N;

            while(tmp%i==0){
                tmp /= i;
            }
            if(tmp%i == 1){
                ans++;
            }

            if(i*i != N){

                tmp = N;
                while(tmp%other==0){
                    tmp /= other;
                }
                if(tmp%other == 1){
                    ans++;
                }
            }
        }
    }

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

    if(N==2){
        cout << 1 << endl;
    }else{
        cout << ans+2 << endl;
    }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a = n / 500;
    int re = n - a * 500;
    int b = re / 5;
    cout << a * 1000 + b * 5 << endl;
    return 0;
}

Measured memory_bytes: 3600
while True:
    N, X = list(map(int, input().split()))
    if N == 0 and X == 0:
        break
    if X < 6:
        print('0')
        continue
    total = 0
    for i in range(1, N+1, 1):
        for j in range(i+1, N+1, 1):
            for k in range(j+1, N+1, 1):
                num = i + j + k
                if num == X and i != j and j != k and k != i:
                    total += 1
    print(f"{total}")


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
#include"ext/pb_ds/assoc_container.hpp"
#include"ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
template<typename T>
using pbds = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

/*
insert(logN)
erase(logN)
find_by_order(logN)//k番目の要素のイテレータを返す
order_of_key(logN)//k以上で最初の数が何番目かを返す
(K未満の個数が何個あるかが分かるらしい）
gp_hash_table<int,int>m//高速なmap
*/
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	int A,B,M;
	cin >> A >> B >> M;
	vector<int>a(A),b(B);
	int ans = 0,mi = INF;
	REP(i,A){
		cin >> a[i];
		CHMIN(mi,a[i]);
	}
	ans += mi;
	mi = INF;
	REP(i,B){
		cin >> b[i];
		CHMIN(mi,b[i]);
	}
	ans += mi;
	REP(i,M){
		int x,y,c;
		cin >> x >> y >> c;
		--x;--y;
		CHMIN(ans,a[x] + b[y] - c);
	}
	out(ans);
}

Measured memory_bytes: 1792
#include<cstdio>
#include<queue>
#include<algorithm>
#define ld long double
#define MN 21000000
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,p,a;
long long mmh[2];
int main(){
	mmh[0]=1;
	n=read();p=read();
	while(n--){
		a=read()&1;
		if (a&1){
			mmh[0]=mmh[1]=mmh[1]+mmh[0];
		}else mmh[0]<<=1,mmh[1]<<=1;
	}
	printf("%lld\n",mmh[p]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(s, n) for (i=s;i<n;i++)
#define MAX 200010

using namespace std;
long long i, n, sum=0, ans, a[MAX], cnt[MAX];

long long c2(long long m) {
    return m*(m-1)/2;
}

int main() {
    scanf(" %lld", &n);
    rep(0, MAX) cnt[i] = 0;
    rep(0, n) {
        scanf(" %lld", &a[i]);
        cnt[a[i]] += 1;
    }
    rep(0, MAX) sum += c2(cnt[i]);
    rep(0, n) {
        if (cnt[a[i]] > 1) printf("%lld\n", sum-cnt[a[i]]+1);
        else printf("%lld\n", sum);
    }
}

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

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

	int a[n];

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

	int ans = 0;

	while(1){

	for(int i=0; i<n; i++){
	
	if(a[i]%2==1){
	cout << ans << endl;
	return 0;
	}

	a[i] /= 2;
	}
	ans++;

	}

}

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

int main(){
  int n;
  cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  int count=0;
  for(int i=0;i<n;i++){
    int a=num[i];
    if(num[a-1]==i+1) count++;
  }
  cout<<count/2<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int k;
    cin >> k;
    int even_num = k / 2;
    int odd_num = (k / 2) + (k % 2);
    cout << even_num * odd_num << endl;
    return 0;
}

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

using namespace std;

int main() {
    int index = 1;
    int x;
    while (true) {
        cin >> x;
        if (x == 0) break;
        printf("Case %d: %d\n", index, x);
        index++;
    }

    return 0;
}


Measured memory_bytes: 3048
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    cnt = 0
    for c in S:
        if c == 'o':
            cnt += 1
    n = len(S)
    if cnt + (15 - n) > 7:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main(void){
    int N,M;
    int L,R;
    cin >> N >> M;
    int l=1,r=N;
    rep(i,M){
        cin >> L >> R;
        if(r < L || R < l){
            cout << 0 << endl;
            return 0;
        }
        else{
            l = max(l,L);
            r = min(r,R);
        }
    } 
    cout << r-l+1<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <set>

// などの必要なインクルードファイルすべて（3章の各標準ライブラリの説明でそれぞれ書いています）
using namespace std;


int main(void){


int z,i,j,r;

int B,C,N;

string yy;

char yui[8];



set<string> S;

S.clear();


scanf("%d",&N); 


for (i = 0; i <= N-1; i++){
  
       scanf("%s",yy.c_str());
	S.insert(yy.c_str());
  
}
//scanf("%s",yy.c_str()); 

//S.insert("aiuddeo");


//yy="aiuejjo";

//yui="aiuejjo";

//string itr =S.begin();

//printf("%s",yy.c_str());

z=S.size();

printf("%d",z);



return 0;

}


Measured memory_bytes: 19320
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func abs(a int, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func chmin(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func chmax(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	heights := nextInts(n)
	dp := make([]int, n)
	for i := range dp {
		dp[i] = math.MaxInt32
	}

	for i := range dp {
		if i == 0 {
			dp[i] = 0
		}

		if i < n-1 {
			dp[i+1] = chmin(dp[i+1], dp[i]+abs(heights[i], heights[i+1]))
		}
		if i < n-2 {
			dp[i+2] = chmin(dp[i+2], dp[i]+abs(heights[i], heights[i+2]))
		}
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
#include <stdio.h>
int main(){
  long long int a, b, x;
  scanf("%lld %lld %lld", &a, &b, &x);
  if(a != 0) printf("%lld\n", (b/x+1) - ((a-1)/x+1));
  else printf("%lld\n", b/x+1);
  return 0;
}


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

using namespace std;

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

  int N;
  cin>>N;
  vector<vector<int>> table(N, vector<int>(N-1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N-1; j++) {
      int t; cin>>t;
      t--;
      table[i][j] = t;
    }
  }
  vector<int> is(N, 0);
  set<int> cands;
  auto check = [&](int x) {
    if (is[x] < N-1) {
      int io = table[x][is[x]];
      if (is[io] < N-1 and table[io][is[io]] == x) {
        cands.insert(x);
        cands.insert(io);
      }
    }
  };
  for (int i = 0; i < N; i++) {
    check(i);
  }
  int d = 0;
  while (not cands.empty()) {
    vector<bool> played(N, false);
    vector<int> ncands;
    for (auto c : cands)
      ncands.push_back(c);
    for (auto i : cands) {
      if (is[i] == N-1)
        continue;
      int o = table[i][is[i]];
      if (not played[i] and not played[o]) {
        played[i] = played[o] = true;
        ++is[i];
        ++is[o];
      }
    }
    cands.clear();
    for (auto c : ncands)
      check(c);
    d++;
  }
  bool suc = true;
  for (int i = 0; i < N; i++) {
    suc &= is[i] == N-1;
  }
  cout << (suc ? d : -1) << endl;

  return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>

int main(void){
	int a, b, ga, gb, ca, cb, i=0, j, r, ri;
	int lcm_num[101], gcd_num[101];
	
	for(ri=0;ri<100;ri++){
		lcm_num[ri] = 0;
		gcd_num[ri] = 0;
	}
	
	while(scanf("%d %d",&a, &b)!=EOF){
		ga = a;
		gb = b;
		ca = a;
		cb = b;
		if(a!=0||b!=0){
			while((r=ga%gb)!=0){
				ga = gb;
				gb = r;
			}
			gcd_num[i] = gb;
			lcm_num[i] = (ca/gcd_num[i])*b;
			i++;
		}
	}
	
	for(j=0;j<i;++j){
		printf("%d %d\n",gcd_num[j],lcm_num[j]);
	}
	
	return 0;
}

Measured memory_bytes: 0
PROGRAM-ID.                      PROGRAM_ID.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 LN           PIC X(13).
    01 N            PIC 9(10).
    01 K            PIC 9(2).
    01 cnt          PIC 9(3).
    01 ans          PIC X(3).
    01 ZS           PIC Z(3)9.
    01 DUMMY        PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT LN.
    UNSTRING LN DELIMITED BY SPACE INTO N K.
    MOVE 0 TO cnt.
    PERFORM UNTIL N <= 0
       COMPUTE N = N / K
       ADD 1 TO cnt
    END-PERFORM.
    MOVE cnt TO ZS.
    PERFORM UNANS.
    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
    ZS DELIMITED BY ALL SPACE
    INTO DUMMY ans.


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;



int main() {
  ll h,n;
  cin >> h >> n;
  vector<int> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  if(h>sum)
  cout << "No" << endl;
  else
  cout << "Yes" << endl;
}


Measured memory_bytes: 3624
import fractions
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

def gcd(*numbers):
  return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
  return reduce(math.gcd, numbers)

print(gcd(*new_lst))


Measured memory_bytes: 16304
#include <iostream>
#include<string>
#include<iomanip>

using namespace std;

int main(void) {
	char n[10];
	int i;

	for (i = 0; i < 10; i++) {
		cin >> n[i];

	}

	
	if ((n[5] == '0') && (n[6] <= '4') && (n[8] <= '3'))
		cout << "Heisei";
	else
		cout << "TBD";
	

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String t = scan.next();
        char a = t.toCharArray()[0];
        t = scan.next();
        char b = t.toCharArray()[0];
        char answer = ' ';
        if (a == 'H') {
            answer = b;
        } else {
            answer = b == 'H' ? 'D' : 'H';
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}


int main()
{
   std::string a,b,d;
   int c;
   std::cin>> c;
   std::cin>> a;
   std::cin>> b;

   std::vector< char > list;

   for( int i = 0; i < a.size(); i++ )
   {
       list.push_back( a[i] );
       list.push_back( b[i] );
   }

   for( int i = 0; i < list.size(); i++ )
   {
       std::cout<< list[i];
   }
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=[int(i) for i in input().split()]

ans=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i+1]-x+a[i]
        a[i+1]=max(0,x-a[i])
print(ans)

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

using namespace std;

#define INF 100010001000
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef pair<int, int> P;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    string S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    rep(i, S.length()) {

    }
    int K;
    cin >> K;
    int c = 0;
    if (K == 32) {
        cout << 51 << endl;
        return 0;
    }
    rep(i, S.length()) {
        if (S[i] == ',') {
            c++;
        }
        if (c == K) {
            if (S[i - 2] == ' ' || c == 1) {
                cout << S[i - 1] << endl;
            } else {
                cout << S[i - 2] << S[i - 1] << endl;
            }
            break;
        }
    }
}


Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N,T;
    cin>>N>>T;
    vector<int>A(N);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    vector<int>filtered_A;
    for(int i=0;i<N;i++){
        if(B[i]<=T){
            filtered_A.push_back(A[i]);
        }
    }
    if(filtered_A.size()==0){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<*min_element(filtered_A.begin(),filtered_A.end())<<endl;
    }

}


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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

int N, W;
int v[100];
int w[100];
int dp[101][10001];

int main()
{
	cin >> N >> W;
	rep(i, N) cin >> v[i] >> w[i];
	reps(i, 1, N+1) {
		rep(j, W+1) {
			if (j < w[i-1]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
		}
	}
	cout << dp[N][W] << endl;
}





Measured memory_bytes: 7016
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(int i = 0;i<(int)n;i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
static const long long INFTY = (1LL << 32);

int getDidigtSum(int i) {
	int sum = 0;
	while (true) {
		sum += i % 10;

		i /= 10;
		if (i == 0)
		{
			break;
		}
	}
	return sum;
}

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int S = 0;
	rep(i, N + 1) {
		int digit_sum = getDidigtSum(i);
		if (A <= digit_sum && digit_sum <= B) {
			S += i;
		}
	}
	cout << S << endl;
	return 0;
}

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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " "<< x <<" "<< y << endl;
    return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    int dp[N + 1][4][4][4];
    for (int i = 0; i <= N; i++) for (int a = 0; a <= 3; a++) for (int b = 0; b <= 3; b++) for (int c = 0; c <= 3; c++) dp[i][a][b][c] = 0;
    dp[0][3][3][3] = 1; // A=0, C=1, G=2, T=3

    for (int i = 0; i < N; i++) {
        for (int a = 0; a <= 3; a++) {
            for (int b = 0; b <= 3; b++) {
                for (int c = 0; c <= 3; c++) {
                    for (int d = 0; d <= 3; d++) {
                        // AGC, ACG, GACをはじく
                        int num = 100 * b + 10 * c + d;
                        if (num == 21 || num == 12 || num == 201) continue;

                        // A?GC, AG?Cをはじく
                        if ((a == 0 && c == 2 && d == 1) || (a == 0 && b == 2 && d == 1)) continue;

                        dp[i+1][b][c][d] += dp[i][a][b][c];
                        dp[i+1][b][c][d] %= MOD;
                    }
                }
            }
        }
    }

    int ret = 0;
    for (int a = 0; a <= 3; a++) {
        for (int b = 0; b <= 3; b++) {
            for (int c = 0; c <= 3; c++) {
                ret += dp[N][a][b][c];
                ret %= MOD;
            }
        }
    }

    cout << ret << endl;

    return 0;
}

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

int main()
{
  int a,b;
  char op;
  int ans;
  cin>>a;
  cin>>op;
  cin>>b;
  if(op=='-')
  {
  
  ans=a-b;
}
  else if(op=='+')
  {
  
  ans=a+b;
}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
  string s;
  getline(cin,s);
   int i=0;
while(s[i]!=0){
{
  if ((s[i] >= 'a') && (s[i] <= 'z')) { 
      s[i]-=0x20;
    
  } else if((s[i]>='A')&&(s[i]<='z')) {
    s[i]+=0x20;
  }
 
}
 cout<<s[i];
 i++;
 
}
cout<<endl;

}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll A[57];

int main() {
    char A[107],B[107];cin >> A >> B;
    rep(i,strlen(A)+strlen(B)){
        if(i%2==0){
            cout << A[i/2];
        }
        else{
            cout << B[i/2];
        }
    }
    cout << endl;
}

Measured memory_bytes: 888
N = int(input())
P = list(map(int,input().split()))

ans = 0
flag = 0
for i in range(N):
    if i+1 == P[i] and flag == 0:
        ans += 1
        if i+1<=N-1 and i+2==P[i+1]:
            flag = 1
    else:
        flag = 0
print(ans)

Measured memory_bytes: 52908
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

void dfs (int x, const vvi &g, vi &depth)
{
    vi sons;
    int curd = 0;

    for (int dest : g[x])
    {
        dfs(dest, g, depth);
        sons.pb(depth[dest]);
    }

    sort(ALL(sons));
    reverse(ALL(sons));
    forn (i, sz(sons))
        curd = max(curd, 1 + sons[i] + i);
    depth[x] = curd;
}

void solve (int n)
{
    vi p(n, -1);
    vvi g(n);
    forn (i, n - 1)
    {
        cin >> p[i + 1];
        --p[i + 1];
        g[p[i + 1]].pb(i + 1);
    }

    vi depth(n);
    dfs(0, g, depth);

    cout << *max_element(ALL(depth)) << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
 
int n;
 
void dfs(std::string s, char alph) {
  if (s.length() == n) {
    std::cout << s << std::endl;
    return;
  }
 
  for (char c = 'a'; c <= alph; c++) {
    dfs(s + c, ((c == alph) ? char(alph + 1) : char(alph)));
  }
}
 
int main() {
  std::cin >> n;
  dfs("", 'a'); 
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  int M;
  cin>>M;
  rep(i,M){
    int T,Y,ans=0;
    cin>>T>>Y;
    vector<int> AM=A;
    AM[T-1]=Y;
    rep(j,N)ans+=AM[j];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin >> S;

    int minNum = 10000;
    int tmpNum = 0;
    for(int i = 2; i <S.size(); i++)
    {
        /* code */
        tmpNum = stoi(S.substr(i-2,3) );
        tmpNum = abs(tmpNum - 753);
        minNum = min(minNum,tmpNum);

    }
    cout << minNum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, m, i, j, n_and, n_xor;
    cin >> n >> m;
    int a[n], b[m], logand[n > m ? n : m], logxor[n + m];
    for(int k = 0; k < n; k++) cin >> a[k];
    for(int k = 0; k < m; k++) cin >> b[k];

    i = j = n_and = n_xor = 0;
    while(i < n && j < m){
        if(a[i] == b[j]){
            logand[n_and++] = a[i++];
            j++;
        } else if(a[i] > b[j]){
            logxor[n_xor++] = b[j++];
        } else {
            logxor[n_xor++] = a[i++];
        }
    }
    for(int k = i; k < n; k++) logxor[n_xor++] = a[k];
    for(int k = j; k < m; k++) logxor[n_xor++] = b[k];

    cout << n_and << " " << n_and + n_xor << endl;
    for(int k = 0; k < n_and; k++) cout << logand[k] << endl;
    i = j = 0;
    while(i < n_and && j < n_xor){
        if(logand[i] < logxor[j]) cout << logand[i++] << endl;
        else cout << logxor[j++] << endl;
    }
    for(int k = i; k < n_and; k++) cout << logand[k] << endl;
    for(int k = j; k < n_xor; k++) cout << logxor[k] << endl;

    return 0;   
}



Measured memory_bytes: 4876
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            if i * 500 + j * 100 + k * 50 == x
              cnt +=1
            end
          
        end
    end
end

puts cnt

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

int main() {
  string Ans;
  vector<int> Num(3);
  REP(i,3) cin>> Num[i];
  sort(Num.begin(),Num.end());
  Ans=Num.at(0)+Num.at(1)==Num.at(2)?"Yes":"No";
  cout << Ans << '\n';
  return 0;
}


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

int main()
{
    int a1,a2,a3,sum=0;
    cin>>a1>>a2>>a3;
    sum=a1+a2+a3;
    if(sum>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int a,b;
  a=n%1000;
  b=n/10;
  if(a==0){cout<<"Yes"<<endl;return 0;}
  if(a%10==0||b%10==0){cout<<"No"<<endl;return 0;}
  if(a/(a%10)==111||b/(b%10)==111)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
maex=0
maey=0
maet=0
flag=0
for i in range(n):
    t,x,y=map(int,input().split())
    kyori=abs(x-maex)+abs(y-maey)
    jikan=t-maet
    if jikan>=kyori and (jikan-kyori)%2==0:
        flag+=0
    else:
        flag=1
    maex=x
    maey=y
    maet=t
print('Yes' if flag==0 else 'No')

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast") 

////////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)

////////////////////////////////////////////////////////////////////////////////

typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si;
typedef map<int,int> mi;

////////////////////////////////////////////////////////////////////////////////






signed main() {
bew;
string str;
cin>>str;
if(str[2]==str[3]&&str[4]==str[5])
cout<<"Yes";
else
cout<<"No";





return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	int N = S.size();
	S = "0" + S;
	bool ok = true;
	for (int i = 0; i <= N; ++i) {
		if (S[i] != S[N - i]) {
			ok = false;
		}
	}
	if (S[1] == '0') ok = false;
	if (!ok) {
		cout << "-1" << endl;
	}
	else {
		vector<int> seq;
		for (int i = 1; i * 2 <= N; ++i) {
			if (S[i] == '1') {
				seq.push_back(i);
			}
		}
		seq.push_back(N);
		for (int i = 1; i < seq.size(); ++i) {
			cout << seq[i - 1] << ' ' << seq[i] << endl;
			for (int j = seq[i - 1] + 1; j < seq[i]; ++j) {
				cout << j << ' ' << seq[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1788
n,k = map(int,input().split())
al = list(map(int,input().split()))

# i番目までの子供でj個の飴を分け合う組み合わせ
dp = [[0 for j in range(k+1)] for i in range(n+1)]


for i in range(n+1):
    dp[i][0] = 1
MOD = 10**9 + 7

for i in range(1,n+1):
    for j in range(1,k+1):
        if j-al[i-1]-1 >= 0:
            dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-al[i-1]-1]
            dp[i][j] %= MOD
        else:
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
            dp[i][j] %= MOD
print(dp[n][k])




Measured memory_bytes: 171144
N, K = map(int, input().split())
A = list(map(int, input().split()))

dictA = {}
for a in A:
    if a in dictA:
        dictA[a] += 1
    else:
        dictA[a] = 1

if len(dictA) <= K:
    print(0)
else:
    dictA = sorted(dictA.items(), key=lambda x:x[1])
    loop = len(dictA) - K
    ans = 0
    for i in range(loop):
        ans += dictA[i][1]
    print(ans)

Measured memory_bytes: 38964
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += a[i]-1;
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int ans = N%1000;
  if(ans == 0){
    ans = 1000;
  }
  cout << 1000 -ans << endl;
}

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

int gcd( int x, int y){
    if( x%y == 0) return y;
    else gcd( y, x%y );
}
int main(){

  int x,y;
  scanf("%d%d\n",&x,&y);
  
  printf("%d\n", gcd(x,y) );
  return 0;

}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    ll n,k;cin>>n>>k;
    vector<VI>next(60,VI(n));
    rep(v,n)cin>>next[0][v],--next[0][v];
    for(int d=0;d+1<60;++d){
        for(int v=0;v<n;++v){
            next[d+1][v]=next[d][next[d][v]];
        }
    }
    int v=0;
    for(int d=0;d<60;++d){
        if(k & (1LL<<d))v=next[d][v];
    }
    cout<<v+1<<endl;
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

int main(){
  char a,b;
  cin >> a >> b;
  if (a == 'H') {
    cout << b << endl;
  } else {
    cout << (b == 'H'?'D' : 'H') << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    cin >> a >> b;
    if(a == 'H')
    {
        cout << b;
    }
    else if(b == 'H')
    {
        cout << 'D';
    }
    else
    {
        cout << "H";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
	int N,M;
	char S[4001],T[4001];
	int dp[4000][4000][2];
int main() {

	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			dp[i][j][1] = -0x7ffffff;
			dp[i][j][0] = 0;
		}
	}
	scanf("%s", S + 1);
	scanf("%s", T + 1);
	int MAX = 0;
	for (int s = 0; s <= N; s++) {
		for (int t = 0; t <= M; t++) {
			if (s < N&&S[s + 1] == 'I') {
				dp[s + 1][t][1] = max(dp[s + 1][t][1], dp[s][t][0] + 1);
				MAX = max(MAX, dp[s+1][t][1]);
			}
			if (t < M&&T[t + 1] == 'I') { 
				dp[s][t + 1][1] = max(dp[s][t + 1][1], dp[s][t][0] + 1); 
				MAX = max(MAX, dp[s][t+1][1]);
			}
			if (s < N&&S[s + 1] == 'O') {
				dp[s + 1][t][0] = max(dp[s + 1][t][0], dp[s][t][1] + 1);
				//MAX = max(MAX, dp[s+1][t][0]);
			}
			if (t < M&&T[t + 1] == 'O') {
				dp[s][t + 1][0] = max(dp[s][t + 1][0], dp[s][t][1] + 1);
				//MAX = max(MAX, dp[s][t+1][0]);
			}
		}
	}
	cout << MAX << endl;
	return 0;
}



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

int main(){
	int N, M; cin >> N >> M;
	priority_queue<int> q;

	while(N--){
		int a; cin >> a;
		q.push(a);
	}

	while(M--){
		int next = q.top() / 2;
		q.pop();
		q.push(next);
	}
	long long sum = 0;
	while(!q.empty()){
		sum += q.top();
		q.pop();
	}

	cout << sum << endl;
}


Measured memory_bytes: 892