akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>

using namespace std;

int v[100005];
map<int, int> vmap[2];
vector<pair<int,int>> vocc[2];

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		vmap[i & 1][v[i]]++;
	for (int i = 0; i < 2; i++) {
		for (auto it : vmap[i])
			vocc[i].push_back({ (n / 2) - it.second,it.first });
	}
	int p = -1;
	for (int i = 0; i < 2; i++) {
		while ((int)vocc[i].size()<3)
			vocc[i].push_back({ n / 2,p-- });
		sort(vocc[i].begin(), vocc[i].end());
	}
	int ans = n + 5;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (vocc[0][i].second == vocc[1][j].second)
				continue;
			ans = min(ans, vocc[0][i].first + vocc[1][j].first);
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 6524
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n, d;

void solve() {
	cin >> n >> d;

	int ans = 0;
	while (n--) {
		int x, y;
		cin >> x >> y;

		double dist = sqrt(x * x + y * y);
		if (dist <= d)ans++;
	}

	cout << ans << endl;
}

int32_t main() {
	IOS;



	solve();

	return 0;
}




Measured memory_bytes: 3680
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		for(int i=1; i<10; i++) {
			for(int j=1; j<10; j++) {
				System.out.println(i+"x"+j+"="+i*j);
			}
		}

	}

}

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

class yaml {
public:
    yaml() : name_("invalid")
    {}
    yaml(string const& n) : name_(n)
    {}

    yaml get(string const& key) {
        if(child.count(key) == 0) {
            throw std::runtime_error("no such property");
        }
        return child[key];
    }

    void add(string const& key, yaml y) {
        child[key] = move(y);
    }

    string name() const {
        return name_;
    }

private:
    string name_;
    map<string, yaml> child;
};


yaml create_impl(vector<string> const& v, string name, int& l) {
    const int L = v.size();
    yaml res(name);
    int indent = 0;
    while(v[l][indent] == ' ') {
        indent++;
    }
    while(l < L) {
        int indent2 = 0;
        while(v[l][indent2] == ' ') {
            indent2++;
        }
        if(indent2 < indent) {
            break;
        }
        if(indent2 == indent) {
            int col = v[l].find(':');
            if(col == v[l].size()-1) {
                string key = v[l].substr(indent2);
                key.pop_back();
                res.add(key, create_impl(v, "object", ++l));
            } else {
                string key = v[l].substr(indent2, col-indent2);
                string name = v[l].substr(col+2);
                res.add(key, yaml{name});
                ++l;
            }
        }
    }
    return res;
}

yaml create(vector<string> const& v) {
    int l = 0;
    return create_impl(v, "object", l);
}

string proc(yaml y, string const& query) {
    int p = 1;
    while(p < query.size()) {
        int np = query.find('.', p);
        string key;
        if(np == string::npos) {
            key = query.substr(p);
            p = query.size();
        } else {
            key = query.substr(p, np-p);
            p = np + 1;
        }
        y = y.get(key);
    }
    return y.name();
}

int main() {
    string query;
    getline(cin, query);
    vector<string> v;
    string line;
    while(getline(cin, line)) {
        v.push_back(line);
    }
    yaml y = create(v);
    try {
        string res = proc(y, query);
        if(res == "object") {
            cout << res << endl;
        } else {
            cout << "string \"" << res << "\"" << endl;
        }
    } catch(std::exception& ex) {
        cout << ex.what() << endl;
    }
}


Measured memory_bytes: 3520
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    Xs = list(map(int, input().split()))
    
    mean = sum(Xs) / n

    cmean = ceil(mean)
    fmean = floor(mean)

    ct = 0
    ft = 0

    for i in range(n):
        ct += (Xs[i] - cmean) ** 2
        ft += (Xs[i] - fmean) ** 2
    
    print(min(ct, ft))

    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, ans=0;
    int x[110];
    cin >> n >> k;
    for(int i=0; i<n ;i++){
        cin >> x[i];
    }
    
    for(int i=0; i<n ;i++){
        if(x[i] < k - x[i]){
            ans += x[i]*2;
        }else{
            ans += (k - x[i])*2;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
main(){for(int A,N,i,a,f;std::cin>>A,A|(f=i=0);f?printf("%d\n",a):puts("NO COLOR"))for(std::map<int,int>m;i++<A;++m[N]>A/2&&(f=1)&(a=N))std::cin>>N;}

Measured memory_bytes: 1944
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#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)
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;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

string o, e;

int main(){
  cin >> o;
  cin >> e;
  rep(i, o.size()+e.size()){
    if(i%2) cout << e[i/2];
    else cout << o[i/2];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<int> vi;
const int MOD=1000000007;

int n,a[200005],ans;

bool cek(int x){
	ll sum=0,sum1=0;
	for(int i=1;i<=n;i++){
		sum+=abs(a[i]-(x+i));
	}
	for(int i=1;i<=n;i++){
		sum1+=abs(a[i]-(x-1+i));
	}
	if(sum<sum1){
		return true;
	}
	else{
		return false;
	}
}

void binser(){
	int lo=-1000000000,hi=1000000000,mid;
	while(lo<=hi){
		mid=(lo+hi)/2;
		if(cek(mid)){
			ans=mid;
			lo=mid+1;
		}
		else{
			hi=mid-1;
		}
	}
}

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

	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	binser();
	ll sum=0;
	for(int i=1;i<=n;i++){
		sum+=abs(a[i]-(ans+i));
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	ll N, M;
	cin >> N >> M;
	vector<ll> height(N);
	vector<int> flag(N, 1);
	vector<P> load(M);
	int ans = 0;
	rep (i, N)
	{
		cin >> height[i];
	}
	rep(i, M)
	{
		cin >> load[i].first;
		cin >> load[i].second;
		if (!(height[load[i].first - 1] > height[load[i].second - 1]))
		{
			flag[load[i].first - 1] = 0;
		}
		if (!(height[load[i].second - 1] > height[load[i].first - 1]))
		{
			flag[load[i].second - 1] = 0;
		}

	}
	rep(i, N) if (flag[i] == 1) ans++;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6104
import math
K=int(input())

Sum=0
for x in range(1,K+1):
    for y in range(x+1,K+1):
        for z in range(y+1,K+1):
            a=math.gcd(x,y)
            b=math.gcd(a,z)
            Sum+=b*6
            
for x in range(1,K+1):
    for y in range(x+1,K+1):
        Sum+=math.gcd(x,y)*6

for i in range(1,K+1):
    Sum+=i

print(Sum)

Measured memory_bytes: 67776
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll a[100005],b[100005];
int n;
int main(){
	double T = clock();
	cin >> n;
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++) scanf("%lld",&b[i]);
	ll M = 0,Mval = 0; ll sidelazy = 0;
	vector<pair<ll,ll> >S; ll lazy = 0;
	
	for(int i=0;i<n;i++){
	
		ll newM,newMval;
		if(M<=0){
			if(M != 0){
				S.push_back(mp(M-sidelazy,-lazy)); 
			}
			sidelazy += b[i]-a[i]; M=b[i]-a[i]; lazy--;
		}
		else{
			ll cand = M,MIN = Mval+M,pre = M,val = Mval+M;
			for(int i=S.size();i>=1;i--){
				ll X = S[i-1].fi,Y = S[i-1].sc;
				ll Z = X+sidelazy;
				if(Z>0){
					if(Y+lazy+1<0){
						if(MIN >= val){
							MIN = val;
							cand = pre;
						}
					}
					else{
						if(MIN >= val- (Y+lazy+1) * (pre-Z)){
							MIN = val- (Y+lazy+1) * (pre-Z);
							cand = Z;
						}
					}
					val -= (Y+lazy+1) * (pre-Z);
					pre = Z;
				}
				else{
					if(Y+lazy+1<0){
						if(MIN >= val){
							MIN = val;
							cand = pre;
						}
					}
					else{
						if(MIN >= val- (Y+lazy+1) * pre){
							MIN = val- (Y+lazy+1) * pre;
							cand = 0;
						}
					}
					if(Y+lazy-1<0){
						if(MIN >= val- (Y+lazy+1) * pre){
							MIN = val- (Y+lazy+1) * pre;
							cand = 0ll;
						}
					}
					else{
						if(MIN >= val- (Y+lazy+1) * pre - (Y+lazy-1) * (-Z)){
							MIN = val- (Y+lazy+1) * pre - (Y+lazy-1) * (-Z);
							cand = Z;
						}
					}
					break;
				}
			}
			M = cand;
			Mval = MIN; lazy--; vector<pair<ll,ll> >vec;
			
			while(!S.empty()){
				ll X = S[S.size()-1].fi,Y = S[S.size()-1].sc;
				ll Z = X+sidelazy;
				
				if(Z>0){
					ll a = X, x = Y;
					S.pop_back();
					if(a+sidelazy>=M);
					else{
						vec.pb(mp(a,x+2));
					}
				}
				else{
					ll a = X, x = Y;
					S.pop_back();
					if(a+sidelazy>=M);
					else{
						if(a+sidelazy != 0 && a+sidelazy<M) S.pb(mp(a,x));
						if(0<M) S.push_back(mp(-sidelazy,x+2));
					}
					break;
				}
			}
			sidelazy += b[i]-a[i]; M += b[i]-a[i];
			for(int i=0;i<vec.size();i++){
				S.pb(vec[vec.size()-1-i]);
			}
		
		}
		
	}
	if(M<=0){
		cout << Mval << endl;
	}
	else{
		ll pre = M;
		for(int i=S.size();i>=1;i--){
			ll X = S[i-1].fi,Y = S[i-1].sc;
			ll Z = X+sidelazy;
			if(Z>0){
				Mval -= (Y+lazy) * (pre-Z);
				pre = Z;
			}
			else{
				Mval -= (Y+lazy) * (pre);
				break;
			}
		}
		cout << Mval << endl;
	}
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

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

	map<int, int> mp;
	for (int i = 0; i <= 101; i++) mp[i] = 0;

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

	int minv = INT_MAX;
	int ans = 0;
	for (int i = 0; i <= 101; i++) {
		if (!mp[i]) {
			int tmp = abs(x - i);
			if (tmp < minv) {
				minv = tmp;
				ans = i;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  if(m == 0) {
    cout << n + 1 << endl;
    return 0;
  }
  vector<pair<int, int>> p(m);
  for(int i=0;i<m;++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  vector<pair<int, int>> v;
  int l = p[0].first, r = p[0].second;
  for(int i=1;i<m;++i) {
    if(p[i].first <= r) {
      l = min(l, p[i].first);
      r = max(r, p[i].second);
    } else {
      v.push_back({l, r});
      l = p[i].first, r = p[i].second;
    }
  }
  v.push_back({l, r});
  int ans = n + 1;
  for(int i=0;i<(int)(v.size());++i) {
    ans += 2 * (v[i].second - v[i].first);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cmath>

using namespace std;

#define ll long long

int main(){
    ll N,K;
    ll ans1=0,ans2=0;
    cin >> N >> K;

    if(K %2 == 0){
        ans1 = pow(N / K, 3);
        ans2 = pow((N + K / 2) / K, 3);
    }else{
        ans1 = pow(N / K, 3);
    }
    cout << ans1 + ans2 << endl;
}

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

long gcd(long m, long n){
	long temp;
	while (m % n != 0){
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main(){
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long cd = c * d / gcd(c, d);
    long min_c = (a + (c - 1)) / c;
    long min_d = (a + (d - 1)) / d;
    long min_cd = (a + (cd - 1)) / cd;
    long max_c = b / c;
    long max_d = b / d;
    long max_cd = b / cd;
    cout << 
        (b - a + 1)
        - (max_c != 0 ? (max_c - min_c + 1) : 0)
        - (max_d != 0 ? (max_d - min_d + 1) : 0)
         + (max_cd != 0 ? (max_cd - min_cd + 1) : 0) 
        << endl;
    return 0;
}


Measured memory_bytes: 256
k = int(input())

# a,bの最大公約数
def gcd(a, b):
   while b:
       a, b = b, a % b
   return a


ans = 0
for i in range(1,k+1):
    for j in range(1, k + 1):
        p = gcd(i, j)
        for k in range(1, k + 1):
            ans += gcd(p, k)

print(ans)


Measured memory_bytes: 73768
#include <bits/stdc++.h>
using namespace std;
int n; 
int dp[400000]={};
int main()
{
	cin>>n;
	for(int i=1;i<=300000;i++)
		dp[i]=100000;
	vector <int> hoge;
	hoge.push_back(1);
	for(int i=6;i<=100000;i*=6)
	{
		hoge.push_back(i);
	}
	for(int i=9;i<=100000;i*=9)
		hoge.push_back(i);
	for(int i=0;i<=100000;i++)
	{
		for(int q=0;q<hoge.size();q++)
		{
			int mee=i+hoge[q];
			if(dp[mee]>dp[i]+1)
				dp[mee]=dp[i]+1;
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    string s; cin >> s;
    if(stoi(s.substr(5, 2)) < 4) {
        cout << "Heisei" << '\n';
        return 0;
    }
    if(stoi(s.substr(5, 2)) == 4 && stoi(s.substr(8, 2)) <= 30) {
        cout << "Heisei" << '\n';
        return 0;
    }
    cout << "TBD" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];
  ll sum=0;
  REP(i,n)sum+=a[i];

  ll now=0;
  ll ans;
  REP(i,n){
    if((now+a[i])*2>sum){
      ans = sum-2*now;
      now += a[i];
      ans = min(ans,now-(sum-now));
      break;
    }
    now += a[i];
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 1792
def main():
    n = int(input())
    a = list(map(int, input().split()))


    a.append(0)
    a.insert(0, 0)
    costs = []
    for i in range(n + 1):
        costs.append(abs(a[i + 1] - a[i]))

    s = sum(costs)
    for i in range(n):
        print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

main()

Measured memory_bytes: 13920
n = int(input())
S = [input() for _ in range(n)]
Count = {'AC' : 0,
         'WA' : 0,
         'TLE' : 0,
         'RE' : 0
        }
for s in S:
  Count[s] += 1

for k, v in Count.items():
  print(str(k) + ' x ' + str(v))

Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	string s, t;
	cin >> s >> t;
	int slen = s.size();
	int tlen = t.size();
	vector<vector<int>> dp(slen + 1, vector<int>(tlen + 1, 0));
	for (int i = 0; i < slen; i++) {
		for (int j = 0; j < tlen; j++) {
			if (s[i] != t[j])
				dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
			else
				dp[i+1][j+1] = dp[i][j] + 1;
		}
	}
	int i = slen;
	int j = tlen;
	string lcs = "";
	while (i > 0 && j > 0)
	{
		if (dp[i][j] == dp[i-1][j])
			i--;
		else if (dp[i][j] == dp[i][j-1])
			j--;
		else
		{
			lcs = s[i-1] + lcs;
			i--;
			j--;
		}
	}
	cout << lcs << endl;
}


Measured memory_bytes: 35584
def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 1 not in A:
        print(-1)
        exit()
    next = 1
    for a in A:
        if a == next:
            next += 1
    print(N - next + 1)


if __name__ == '__main__':
    main()


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b == c + d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}



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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int ans = x;
  REP(i, n){
    int ate = (d-1)/a[i] + 1;
    ans += ate;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s;
	cin >> s;
	map<string, int> m = { {"SUN", 7}, {"MON", 6},{"TUE",5},{"WED",4},{"THU",3},
		{"FRI",2},{"SAT",1}};
	cout << m[s] << endl;
	return 0;
}



Measured memory_bytes: 3612
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j=j-1
        A[j+1] = v
    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        if k==N-1:
            print(A[k])


Measured memory_bytes: 5980
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const db EPS = 1e-9;
const int N = 200+100;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int n;
char s[N],t[N],ans[N];

int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	rep(i,1,n) ans[i] = s[i];
	rep(i,1,n+1){
		int jud = 1;
		rep(j,i,i+n-1){
			if(j <= n){
				if(ans[j] != t[j-i+1]) {jud = 0; break;}
			}
			else ans[j] = t[j-i+1];
		}
		if(jud) break;
	}
	printf("%d\n",(int)strlen(ans+1));
	return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){
    while(true){
        int sheet[11][11] = {};
        int size; cin >> size;
        if(size == 0) return 0;
        
        // get
        for(int i=0; i<size; i++){
            int col_sum = 0;
            for(int j=0; j<size; j++){
                cin >> sheet[i][j];
                col_sum += sheet[i][j];
            }
            sheet[i][size] = col_sum;
        }
        
        // show
        for(int i=0; i<size; i++){
            for(int j=0; j<size+1; j++){
                cout << right << setw(5) << sheet[i][j];
            }
            cout << endl;
        }
        // row sum
        for(int i=0; i<size+1; i++){
            int row_sum = 0;
            for(int j=0; j<size; j++){
                row_sum += sheet[j][i];
            }
            cout << right << setw(5) << row_sum;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n, *a = map(int, read().split())
    a = deque(a)
    r = 1
    flag = False
    muki = 0
    n1 = a.popleft()
    while a:
        n2 = a.popleft()
        if flag:
            if n1 < n2 and muki:
                n1 = n2
            elif n1 > n2 and not muki:
                n1 = n2
            elif n1 == n2:
                pass
            else:
                r += 1
                flag = False
                n1 = n2
        else:
            if n1 < n2:
                flag = True
                muki = 1
                n1 = n2
            elif n1 > n2:
                flag = True
                muki = 0
                n1 = n2
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>T&get(){T a;cin>>a;return a;}
template<typename T>T&rev(T&a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>a){sort(all(a));return a;}

typedef long long ll;
typedef vector<int> vi;

const int inf = 1e9;
const ll linf = 3e18;

struct P {
    int x, y;
    P(int x0,int y0){x=x0,y=y0;}
    P(){};
};

bool mp[5001][5001];
P c[3000];

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

    int N;
    while (cin >> N, N) {
        memset(mp, 0, sizeof(mp));

        rep(i, N) {
            cin >> c[i].x >> c[i].y;
            mp[c[i].y][c[i].x] = 1;
        }

        int ma = 0;

        rep(i, N) rep(j, i) {
            P p = c[i], q = c[j];
            P d(q.x - p.x, q.y - p.y);

            P a(p.x + d.y, p.y - d.x);
            if (a.x < 0 || a.x > 5000 || a.y < 0 || a.y > 5000 || !mp[a.y][a.x]) continue;
            P b(a.x + d.x, a.y + d.y);
            if (b.x < 0 || b.x > 5000 || b.y < 0 || b.y > 5000 || !mp[b.y][b.x]) continue;
            chmax(ma, d.x * d.x + d.y * d.y);
        }

        cout << ma << endl;
    }
}

Measured memory_bytes: 25652
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long

//ansはMの約数
int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    vector<int> Myakusu;
    rep(i,(int)sqrt(M)+3){
        if(i==0)continue;
        if(M%i==0){
            Myakusu.push_back(i);
            Myakusu.push_back(M/i);
        }
    }
    sort(Myakusu.begin(),Myakusu.end());
    int Msize=Myakusu.size();
    rep(i,Msize){
    //    printf("no%d\n",Myakusu[Msize-1-i]);
        if(M%Myakusu[Msize-1-i]==0){
            if(M/Myakusu[Msize-1-i]>=N){
                printf("%d\n",Myakusu[Msize-1-i]);return 0;
            }
        }else{
            if(M/Myakusu[Msize-1-i]>N){
                printf("%d\n",Myakusu[Msize-1-i]);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, R: int):
    if N>10:
        print(R)
        return
    else:
        print(R+100*(10-N))
        return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(N, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int dif = b - a;
		dif += 1;
		for(int i = 0; i < dif; i++) {
			if(a % k == 0) {
				System.out.println("OK");
				return;
			}
			a++;
		}
		System.out.println("NG");

	}

}

Measured memory_bytes: 35572
#include<iostream>
#include<string>

using namespace std;

int main() {
  string yohou;
  cin >> yohou;
  const char* yohou_c = yohou.c_str();
  char* yohou_char = (char*)yohou_c;
  string tenki;
  cin >> tenki;
  const char* tenki_c = tenki.c_str();
  char* tenki_char = (char*)tenki_c;
  
  int count = 0;
  
  for (int i=0; i<3; i++) {
    if (*(tenki_char+i) == *(yohou_char+i)) {
      count++;
    }
  }
  
  
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
def II(): return int(sys.stdin.readline())

def get_is_prime_tuple(n):  # including n
    isPrime = [True for _ in range(n+1)]
    isPrime[0] = False
    isPrime[1] = False
    for j in range(4, n+1, 2): isPrime[j] = False  # multiples of 2

    for i in range(3, int(n**0.5)+1):
        if not isPrime[i]: continue
        for j in range(i*i, n+1, i+i):  # j = (i*i, (i+2)*i, ..., m*i <= n)
            isPrime[j] = False
    return tuple(isPrime)

def main(): 
    isPrime = get_is_prime_tuple(55555)
    N = II()
    for i in range(2,55556):
        if isPrime[i] and i%5 == 1:
            print(i, end=' ')
            N -= 1
        if N == 0:
            break
    print('')
    
main()

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

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

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

// Line
class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

// Circle
class C { public: P p; ld r; };

vector<L> tangent_cp(C c, P p) {
  vector<L> ret;
  P v = c.p - p;
  ld d = abs(v);
  ld l = sqrt(norm(v) - c.r * c.r);
  if (isnan(l)) { return ret; }
  P v1 = v * P(l / d,  c.r / d);
  P v2 = v * P(l / d, -c.r / d);
  ret.push_back(L(p, p + v1));
  if (l < eps) return ret;
  ret.push_back(L(p, p + v2));
  return ret;
}

vector<L> tangent_cc(C c1, C c2) {
  vector<L> ret;
  if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
    P center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
    ret = tangent_cp(c1, center);
  }
  if (abs(c1.r - c2.r) > eps) {
    P out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
    vector<L> nret = tangent_cp(c1, out);
    ret.insert(ret.end(), begin(nret),end(nret));
  }
  else {
    P v = c2.p - c1.p;
    v /= abs(v);
    P q1 = c1.p + v * P(0,  1) * c1.r;
    P q2 = c1.p + v * P(0, -1) * c1.r;
    ret.push_back(L(q1, q1 + v));
    ret.push_back(L(q2, q2 + v));
  }
  return ret;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_lp(L l, P p) {
  return abs(p - proj(l, p));
}

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<C> min_d;
    vector<C> max_d;
    vector<L> lines;
    REP(i,n){
      ld x,y,r,m;
      cin>>x>>y>>r>>m;
      C a = {P(x,y), r};
      C b = {P(x,y), r+m};
      min_d.push_back(a);
      max_d.push_back(b);
      lines.push_back({P(x+r,y+r),P(x+r,y-r)});
      lines.push_back({P(x+r+m,y+r+m),P(x+r+m,y-r+m)});
    }
    vector<C> all_c = min_d;
    all_c.insert(end(all_c),begin(max_d),end(max_d));
    for(C a:all_c) for(C b:all_c) {
      auto tans = tangent_cc(a,b);
      lines.insert(end(lines),begin(tans),end(tans));
    }
    int mx = 0;
    for (L l:lines) {
      int num=0;
      REP(i,n) {
        ld dist = dist_lp(l, min_d[i].p);
        if (min_d[i].r <= dist + eps && dist <= max_d[i].r + eps)
          ++num;
      }
      mx=max(mx,num);
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 12092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct Point {
   int x, y;
   bool operator<(const Point& p) const {
      if (x != p.x) return x > p.x;
      return y < p.y;
   }
};

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;

   vector<Point> P(N);
   REP(i, N)
      cin >> P[i].x >> P[i].y;

   sort(P.begin(), P.end());

   llong res = 0;

   llong max_xplusy = P[0].x + P[0].y, max_xminusy = P[0].x - P[0].y;
   for (int i = 1; i < N; ++i) {
      Point p = P[i];
      res = max(res, max_xplusy - p.x - p.y);
      res = max(res, max_xminusy - p.x + p.y);
      max_xplusy = max(max_xplusy, (llong) p.x + p.y);
      max_xminusy = max(max_xminusy, (llong) p.x - p.y);
   }

   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 4764
#include<iostream>
using namespace std;
string s;
bool cek1(){
	int ki = 0,ka = s.length()-1;
	while(ki<=ka){
		if(s[ki]!=s[ka]) return 0;
		ki++,ka--;
	}
	return 1;
}
int cek2(){
	int ki = 0, ka = ((s.length()-1)/2)-1;
	while(ki<=ka){
		if(s[ki]!=s[ka]) return 0;
		ki++,ka--;
	}
	return 1;
}
int cek3(){
	int ki = 0, ka = ((s.length()+3)/2)-1;
	while(ki<=ka){
		if(s[ki]!=s[ka]) return 0;
		ki++,ka--;
	}
	return 1;
}
int main(){
	cin>>s;
	if(cek1() && cek2() && cek3){
		cout<<"Yes\n";
	}else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int N,x,i,j,B=0,C=1,flag=0;

  scanf("%d",&N);

  for(i=0;i<N;i++)
    {
      flag=0;
      B=0;
      C=1;
      for(j=0;j<10;j++)
	{
	  scanf("%d",&x);
	  if(B>C && x>B)B=x;
	  else if(B>C && x<B && x>C)C=x;
	  else if(B<C && x>C)C=x;
	  else if(B<C && x<C && x>B)B=x;
	  else {flag=1; break;}
	  //printf("%d %d\n",B,C);
	}
      if(flag==1)printf("NO\n");
      else printf("YES\n");
}

  return 0;
}

Measured memory_bytes: 0
N=int(input())
L=list(map(int,input().split(" ")))
L.sort()
count=0
for i in range(N-2):
    for j in range(N-i-2):
        for k in range(N-i-j-2):
            x=i+j+1
            y=x+k+1
            if L[i]!=L[x] and L[y]<L[x]+L[i] and L[x]!=L[y]:
                count +=1
print(count)
            

Measured memory_bytes: 9200
import math
import collections
def main():
    n = int(input())
    A=[int(i) for i in input().split()]
    dd = collections.defaultdict(int)

    for i in A:
        dd[i]+=1
    yama = []
    for i in dd.keys():
        yama.append([i,dd[i]])

    yama.sort(key = lambda x:x[0])
    yama_l = len(yama)
    cnt=0
    renozku = False
    for i in range(yama_l-1):
        if(yama[i][1]==2 and yama[i+1][1]==2):
            renzoku = True

        if(yama[i][1]%2==0):
            cnt+=1
    if(yama[-1][1]%2==0):
        cnt+=1
    if(cnt==2 and renzoku):
        print(len(yama)-1)
    elif(cnt%2==1):
        print(len(yama)-1)
    else:
        print(len(yama))
if __name__ == '__main__':
    main()


Measured memory_bytes: 104780
#include <iostream>
#include <iomanip>

int main() {
	int h, m, s;
	int rest;
	
	while( 1) {
		std::cin >> h >> m >> s;
		if(h==-1 && m==-1 && s==-1) break;

		// Calculate Remaining Time
		rest = 7200 - ( h*3600 + m*60 + s);

		std::cout << std::setw(2) << std::setfill('0') << (rest/3600) << ":" <<
			std::setw(2) << std::setfill('0') << ( (rest%3600) / 60 ) << ":" <<
			std::setw(2) << std::setfill('0') << (rest%60) << std::endl;
		
		std::cout << std::setw(2) << std::setfill('0') << ((rest*3)/3600) << ":" <<
			std::setw(2) << std::setfill('0') << ( ((rest*3)%3600) / 60 ) << ":" <<
			std::setw(2) << std::setfill('0') << ((rest*3)%60) << std::endl;
	}
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> A(N),B(N),C(N);
  for ( int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  for ( int i = 0; i < N; i++){
    cin >> B.at(i);
  }
  
  for ( int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  int sati = 0;
  
  for ( int i = 0; i < N; i ++){
    A.at(i)--;
    sati += B.at(A.at(i));
    if ( ( i > 0 ) && ( A.at(i) - 1 == A.at(i - 1))){
      sati +=C.at(A.at(i)-1);
    }
  
  }
  
  cout << sati << endl;

}

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

using namespace std;

typedef long long ll;

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

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

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

	int k;
	cin >> k;

	while(k > 0){
		k--;
		if(a >= b) b *= 2;
		else if(b >= c) c *= 2;
	}

	if(a < b && b < c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
int n,mins;

int get_sum(int a){
    int sum=0;
    while(a) sum+=a%10,a/=10;
    return sum;
}

int main(){
    while(scanf("%d",&n)!=EOF){
        mins=inf;
        for(int i=1;i<=((n+1)>>1);i++){
            int temp=get_sum(i)+get_sum(n-i);
            mins=min(mins,temp);
        }
        printf("%d\n",mins);
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m, q;
H a[1000000];
H p[1000000];
int b[1000][1000];
signed main() {
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		cin >> a[i].x >> a[i].y;
		for (int j = a[i].x; j >= 0; j--) {
			b[j][a[i].y]++;
		}
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			b[i][j] = b[i][j] + b[i][j - 1];
		}
	}
	for (int i = 0; i < q; i++) {
		cin >> p[i].x >> p[i].y;
		cout << b[p[i].x][p[i].y] << endl;
	}
}

Measured memory_bytes: 13184
lis = [i+1 for i in range(int(input()))]
num = lis[0::2]
ans = 0
for i in num:
  c = 0
  for j in range(1,i+1):
    if i % j == 0:
      c += 1
  if c == 8:
    ans +=1

print(ans)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
int u[maxn];
int find(int x){
	if(x == u[x]) return x;
	return u[x] = find(u[x]);
}
long long cost[maxn];
int main(){
	iota(u, u + maxn, 0);
	int n, q; cin >> n >> q;
	for(int i = 0; i < n; i++) cost[i] = 1ll<<60;
	vector<tuple<int,int,int> > ed;
	for(int i = 0; i < q; i++){
		int a, b; long long c; cin >> a >> b >> c;
		cost[a] = min(cost[a], c + 1);
		cost[b] = min(cost[b], c + 2);
		ed.push_back(make_tuple(c, a, b));
	}
	for(int i = 0; i < 2 * n; i++){
		int now = i % n; 
		int prv = now - 1; if(prv < 0) prv += n;
		cost[now] = min(cost[now], cost[prv] + 2);
	}
	for(int i = 0; i < n; i++) ed.push_back(make_tuple(cost[i], i, (i + 1) % n));
	sort(ed.begin(), ed.end());
	long long ans = 0;
	for(auto e : ed){
		int w, x, y; tie(w, x, y) = e;
		if(find(x) != find(y)){
			ans += w;
			u[find(x)] = find(y);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11628
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
    long long a,b,pot=0;
    cin>>a>>b;
    while(a--)
    {
        long long c,d;
        cin>>c>>d;
        if((c*c+d*d)<=b*b)
        {
            pot++;
        }
    }
    cout<<pot<<"\n";
    return 0;
}




Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  string s;
  int k;
  cin >> s >> k;
  REP(i, s.size()) {
    if (s[i] == 'a') continue;
    int tmp = 'z' - s[i] + 1;
    if (tmp <= k) {
      k -= tmp;
      s[i] = 'a';
    }
    if (k == 0) {
      break;
    }
  }
  // if (k == 0) {
  //   cout << s << endl;
  // }
  k %= 26;
  s.back() += k;
  cout << s << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 592
n=int(input())
cost=[]
start=[]
fre=[]

from math import ceil

for _ in range(n-1):
    c,s,f=map(int,input().split())
    cost.append(c)
    start.append(s)
    fre.append(f)


for i in range(n):
    if i==n-1:
        print(0)
        break

    time=start[i]+cost[i]

    for j in range(i+1,n-1):
        if time>=start[j] and time%fre[j]==0:
            time+=cost[j]
        elif time>=start[j] and time%fre[j]!=0:
            time+=fre[j]*ceil(time/fre[j])-time+cost[j]
        else:
            time=start[j]+cost[j]

    print(time)



Measured memory_bytes: 9240
sz;
k;
char x[18],buf[2200000];
A,B,p,T;
long ans;
main()
{
	sz=read(0,buf,2200000);
	sz-=2;
	while(1)
	{
		A=B=0;
		p=1;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			B+=(k-'0')*p;
			p*=10;
		}
		p=1;
		if(sz<0)break;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			A+=(k-'0')*p;
			p*=10;
		}
		T=(-A-ans)%B;
		if(T<0)T+=B;
		ans+=T;
	}
	sz=17;
	do
	{
		x[--sz]=ans%10+'0';
		ans/=10;
	}while(ans);
	write(1,x+sz,17-sz);
}

Measured memory_bytes: 2304