akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);


// ===

fn main() {
    let (n, m): (usize, usize) = read();
    let mut q: Vec<(usize, usize)> = vec![];
    for i in 0..m {
        let (u, v): (usize, usize) = read();
        q.push((v, u));
    }
    q.sort();

    let mut max = 0;
    let mut cnt = 0;
    for qi in q {
        if max <= qi.1 {
            cnt += 1;
            max = qi.0;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 6396
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

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

	cout << (x < a ? 0 : 10) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double n, m; cin >> n >> m;
    vector<double> a(n);
    double sum = 0;
    rep(i,n) cin >> a[i], sum += a[i];
    int cnt = 0;
    sum /= 4*m;
    rep(i,n) {
        if (sum <= a[i]) cnt++;
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
    int n, d;
    std::cin >> n >> d;
    std::vector<std::vector<int>> a(n, std::vector<int>(d));
    for (int i = 0; i < n; i++) for (int j = 0; j < d; j++) std::cin >> a[i][j];
    int ret = 0;
    for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
        int dist = 0;
        for (int k = 0; k < d; k++) {
            auto t = a[i][k] - a[j][k];
            dist += t * t;
        }
        int l = 0, r = 10000;
        while (r - l > 1) {
            auto k = (l + r) / 2;
            if (k * k <= dist) l = k;
            else r = k;
        }
        if (l * l == dist) ret++;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
/*                                  /   \                                 */      
/*                                 /*****\                               */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K             */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x%MOD;else return (x*n)%MOD;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
long long power(long long x, 
                         ll y, ll p) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
long long modInverse(long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
long long nCrModPFermat(long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    long long fac[n + 1]; 
    fac[0] = 1; 
    for (ll i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;


//	   cin>>t;
	      while(t--)
{
ll n,m,j,k,l,i;
cin>>n;
if(n==1)
cout<<0;
else if(n==2)
cout<<2;
else{
	ll ans=0;
	ans=(((pow1(10,n)%MOD)+(pow1(8,n)%MOD)%MOD)-(2*(pow1(9,n)%MOD))%MOD+MOD)%MOD;
	cout<<ans;
	ee;
//	cout<<"JSM";
}
		
}
return 0;
}









Measured memory_bytes: 3624
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>m;
ll x=(1<<n)-1;
set<int> s[m+1];
int count[m+1];
for(int i=1;i<=m;i++)
{
   cin>>k;
   while(k--)
   {
      cin>>temp;
      s[i].insert(temp);
   }
}
for(int i=1;i<=m;i++)
{
   cin>>count[i];
}
ll ans=0;
for(int i=0;i<=x;i++)
{
int tempcount[m+1]={0};
  for(int j=0;j<n;j++)
  {
     if((1<<j)&i)
     {
        for(int y=1;y<=m;y++)
        {
           if(s[y].find(j+1)!=s[y].end())
           {
              tempcount[y]++;
           }
        }
     }
  }
  bool flag=1;
  for(int j=1;j<=m;j++)
  {
     if(tempcount[j]%2!=count[j]%2)
     {flag=0;break;}
  }
  if(flag)
  ans++;
}
cout<<ans;







return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
     
     
ll func( ll N ) {
  ll cnt = 0;
  while( N > 2 ) {
    N --;
    N -= (N+1)/2;
    cnt++;
  }
     
  return cnt;
}
     
int main()
{
  ll X;
  cin >> X;
     
  ll l = 0, r = 1e18;
  while( r - l  > 1 ) {
    ll mid = (r + l) / 2;
    ll x = func( mid );
    if( x <= X ) {
      l = mid;
    } else {
      r = mid;
    } 
  }
     
  if( func( l ) == X && func( r ) == X ) {
    cout << r << endl;
  } else cout << l << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int a = 0;
  bool b = false;
  double x, y = 0;
  for(int i = 0; i < 20000; i++) {
    x = floor(i*0.08);
    y = floor(i*0.1);
    if(x <= A && A < x + 1) {
      if(y <= B && B < y + 1) {  
        a = i;
        b = true;
        break;
      }
    }
  }
  if(b == true) {
    cout << a << endl;
  }
  else {
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}




int main()
{
    weewoo;
    int a,b;
    cin >> a >> b;
    for(int i=1;i<4;i++){
        if(i!=a&&i!=b)
            return cout << i << endl,0;
    }
    return 0;
}


Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W,L;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};
char cc[1000000] = {};

int main() {


	cin >>N;
	a = 0;
	b = 0;
	c = 0;
	d = 0;
	e = 0;
	
	for (int i = 0; i < N; i++) {
		cin >> S;
		if (S[0] == 'M') {
			a++;
		}
		if (S[0] == 'A') {
			b++;
		}
		if (S[0] == 'R') {
			c++;
		}
		if (S[0] == 'C') {
			d++;
		}
		if (S[0] == 'H') {
			e++;
		}
	}

	A[0] = a * b * c  +a * b * d + a * b * e + a * c * d + a * c * e + a * d * e + b * c * d +b * c * e + b * d * e + c * d * e;
	
	

	cout << A[0] << endl;
	
	return 0;

}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
	int a[100][100],b[100],c[100],n,m,i,j;

	scanf("%d %d", &n,&m);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	for (j = 0; j < m; j++)
	{
		scanf("%d", &b[j]);
	}

	for (i = 0; i < n; i++)
	{
		c[i] = 0;
		for (j = 0; j < m; j++)
		{
			c[i] += a[i][j] * b[j];
		}
	}

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

	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	if (a[0] == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for (ll i = 0; i < n; i++) {
		if (ans > (long double)1e18 / a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3996
k = int(input())
a, b = map(int, input().split())

ans = 0
if a == b:
    if a%k == 0:
        ans += 1
    else:
        ans += 0
else:
    for i in range(a,b + 1):
        if i%k == 0:
            ans += 1
        else:
            ans += 0
if ans >= 1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct Parser{
    typedef string::const_iterator itr;
    itr begin;
    vector<bool> TF;
    T ans;
    Parser(const string &s,const vector<bool> &TF):TF(TF){
        begin=s.begin();
        ans=expr(begin);
    }
    T expr(itr &begin){
        if(*begin=='-'){
            consume(begin,'-');
            return !expr(begin);
        }
        else if(*begin=='('){
            consume(begin,'(');
            T ret=expr(begin);
            if(*begin=='*'){
                consume(begin,'*');
                ret&=expr(begin);
            }
            if(*begin=='+'){
                consume(begin,'+');
                ret|=expr(begin);
            }
            if(*begin=='-'&&*(begin+1)=='>'){
                consume(begin,'-');
                consume(begin,'>');
                ret=(!ret|expr(begin));
            }
            consume(begin,')');
            return ret;
        }else{
            if(*begin=='T'){
                consume(begin,'T');
                return true;
            }
            if(*begin=='F'){
                consume(begin,'F');
                return false;
            }
            char tmp=*begin;
            begin++;
            return TF[tmp-'a'];
        }
    }
    void consume(itr &begin,char expected){
        if(*begin==expected){
            begin++;
        }else{
            fprintf(stderr,"Expected: '%c' Got: '%c'\n",expected,*begin);
            fprintf(stderr,"Rest string is ");
            while(*begin){
                fprintf(stderr,"%c",*begin++);
            }
        }
    }
};

int main(){
    string s;
    while(cin>>s&&s!="#"){
        string s1,s2;
        for(int i=0;;i++){
            if(s[i]=='='){
                s1=s.substr(0,i);
                s2=s.substr(i+1);
                break;
            }
        }
        bool flg=1;
        for(int i=0;i<(1<<11);i++){
            vector<bool> TF(11);
            for(int j=0;j<11;j++){
                TF[j]=(i>>j&1);
            }
            Parser<bool> p1(s1,TF);
            Parser<bool> p2(s2,TF);
            if(p1.ans!=p2.ans){
                cout<<"NO"<<endl;
                flg=0;
                break;
            }
        }
        if(flg) cout<<"YES"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

while(1){
  
  int H,W;
  
  scanf("%d %d",&H,&W);
  
  if(H==0){break;}
  
  for(int i=1; i<=H; i++){
  for(int j=1; j<=W; j++){
    if(i%2==0){
      if(j%2==0){printf("%c",'#');}
      else{printf("%c",'.');}
      }
    else{
      if(j%2==0){printf("%c",'.');}
      else{printf("%c",'#');}
      }
   
    }
    printf("\n");
    }
    
    printf("\n");
   
}
   

}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 998244353
#define ll_MAX 19223372036859
#define endl "\n"
inline ll absdiff(ll a,ll b){ return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    fast
    ll q;q = 1;
    // cin>>q;
    for (ll t = 0; t < q; ++t)
    {
        ll a,b,ans;cin>>a>>b;
        ans=(a*b)/gcd(a,b);
        cout<<ans;
    }
    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 100002
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
vector<bool>Isprime(MAX+1,true);
vector<int>Prime(MAX+1,0); //Primearra
int Primecounter =0;
//Primearray counter;
void p(){
    for(int i = 2; i<MAX+1;i++){
        if(Isprime[i]){
            for(int j = 2;i*j<MAX;j++)
                Isprime[i*j] = false;//素数ならPrimearrayに格納してその倍数を全てfalseに
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
}
signed main(){
    p();
    Isprime[1]=false;
    vector<int>d(100002,0);
    for(int i=0;i<d.size();i++){
        if(Isprime[i]&&Isprime[(i+1)/2])
            d[i]++;
    if(i)d[i]+=d[i-1];
    }
    int Q; cin>>Q;
    rep(i,Q){
        int a,b;cin>>a>>b;
        cout<<d[b]-d[a-1]<<endl;
    }
}


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
long long A, B, C, D;
cin >> A >> B >> C >> D;

long long L = C * D / euclidean_gcd(C, D);

long long sum = (B / C) + (B / D);

//cout << sum << endl; 

long long sum2 = ((A - 1) / C) + ((A - 1)/ D);
  
long long lc = (B / L) - ((A - 1) / L); 


//cout << sum2 << endl; 

long long ans = (B - A + 1) -((sum - sum2) - lc);
  
 
cout << ans << endl; 
}


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

typedef long long int ll;
ll a, b, c, k;

int main() {
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    ll cnt = 0;
    while(cnt < k && b <= a) {
        b *= 2;
        cnt++;
    }

    while(cnt < k && c <= b) {
        c *= 2;
        cnt++;
    }

    if(a < b && b < c) printf("Yes\n");
    else printf("No\n");

    return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, x ;
  cin >> a >> b >> x ;
  
  if(a<=x && x<=a+b){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

int main(){
    ll N; cin >> N;
    map<ll,ll> mp;
    rep(i,N){
        ll x; cin >> x;
        mp[x] ++;
    }
    ll ans = 0;
    for(auto it : mp){
        ll x = it.first;
        ll y = it.second;
        if(x <= y) ans += y - x;
        else ans += y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<(a+b-1)/b<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m=0,a=0,r=0,c=0,h=0;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(s[i][0]=='M'){
      m++;
    }
    if(s[i][0]=='A'){
      a++;
    }
    if(s[i][0]=='R'){
      r++;
    }
    if(s[i][0]=='C'){
      c++;
    }
    if(s[i][0]=='H'){
      h++;
    }
  }
  cout << m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define el_cucuy ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, k, a[mxn], b[mxn], c[mxn], dp[3][mxn];

int main(){
    el_cucuy
    cin >> n;
    for (int i = 1; i <= n; i ++){
        cin >> a[i] >> b[i] >> c[i];
    }for (int i = 1; i <= n; i ++){
        dp[0][i] = max(dp[1][i - 1] + a[i], dp[2][i - 1] + a[i]);
        dp[1][i] = max(dp[0][i - 1] + b[i], dp[2][i - 1] + b[i]);
        dp[2][i] = max(dp[0][i - 1] + c[i], dp[1][i - 1] + c[i]);
    }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n]));
    return 0;
}


Measured memory_bytes: 15360
// Teleporter

func main() {
    let nk = readLine()!.split(separator: " ").map{Int($0)!}
    let a = [0] + readLine()!.split(separator: " ").map{Int($0)!}
    let (_, k) = (nk[0], nk[1])

    // key番の町にvalue回目に到達した記録
    var dic: [Int: Int] = [:]

    var position = 1
    for i in 1...k {
        position = a[position]
        if let pre = dic[position] {
            let cycle = i - pre
            // あまり分をループして調整
            // 逆向きのdictionaryで一発で出すこともできるはず
            let rest = (k - i) % cycle
            if rest == 0 {
                break
            }
            for _ in 1...rest {
                position = a[position]
            }
            break
        } else { 
            dic[position] = i
        }
    }

    print(position)
}

main()

Measured memory_bytes: 19260
def solve(N, A, B, C):
  count = 0
  for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]
    if a == b:
      if a != c: count = count + 1
    else:
      if a == c: count = count + 1
      elif b == c: count = count + 1
      else: count = count + 2
  return count

N = int(input())
A = input()
B = input()
C = input()

print(solve(N, A, B, C))

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,v) VL v(n);rep(i,n)cin>>v[i]
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define LINE puts("------------------")
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<class T>T center(T a,T b,T c){
  if( (a<=b&&b<=c)||(a>=b&&b>=c) )return b;
  if( (b>=a&&a>=c)||(b<=a&&a<=c) )return a;
  return c;
}
void print(){}
template<class Head,class... Tail>
void print(Head&& head, Tail&&... tail){
  cout<<head<<endl;
  print(forward<Tail>(tail)...);
}
void input(){}
template<class Head,class... Tail>
void input(Head&& head, Tail&&... tail){
  cin>>head;
  input(forward<Tail>(tail)...);
}
template<typename T>
ostream &operator<<(ostream&out,const vector<T>&v){
  if(!v.empty()){
    copy(v.begin(),v.end(),ostream_iterator<T>(out,", "));
    out<<"\b\b";
  }
  return out;
}
template<typename T1, typename T2>
ostream &operator<<(ostream&out,const pair<T1,T2>&p){
  out<<p.first<<", "<<p.second;
  return out;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  cinv(n,a);
  a.pb(0);
  ll res=0,tmp=0;
  rep(i,n+1){
    if(a[i]==0){
      res+=tmp/2;
      tmp=0;
    }
    else{
      tmp+=a[i];
    }
  }
  out(res);


  return 0;
}


Measured memory_bytes: 1792
n = input()
last = n[-1]
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]
if int(last) in hon:
    print('hon')
elif int(last) in pon:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9172
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	d = Dict{String,Int}()
	for i in 1:n
		s = readline() |> chomp
		if haskey(d,s)
			d[s] += 1
		else
			d[s] = 1
		end
	end
	m = maximum(values(d))
	a = String[]
	for i in keys(d)
		if d[i]==m
			push!(a,i)
		end
	end
	a = sort(a)
	for i in a
		println(i)
	end
end

main()

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> S;

}

void solve(){
    input();
    int x = S.size();
    string ans;
    REP(i,x) ans+="x";
    cout << ans << endl;
    
}

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


Measured memory_bytes: 256
k, x = map(int, input().split())
btm = -1000000
top = 1000000

if (x - k + 1) >= btm:
  btm = x - k + 1
if (x + k - 1) <= top:
  top = x + k - 1
[print("%d " % i, end="") for i in range(btm, top + 1)]

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

using namespace std;
using int64 = long long;

int main() {
    int n;
    int64 sum = 0;
    cin >> n;

    for (int i=1; i<=n; i++) {
        if (i%3 && i%5)
            sum += i;
    }

    cout << sum << endl;
}


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

int main() {
    int n, count = 0;
    string str;
    cin >> n >> str;
    rep(i, n - 2) {
        if(str.at(i) == 'A' && str.at(i + 1) == 'B' && str.at(i + 2) == 'C') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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





int main() {

	ll A, B;
	cin >> A >> B;
	cout << max(max(2 * A - 1, 2 * B - 1), A + B);

	system("PAUSE");
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<math.h>
#define EPS1 1e-6
#define EPS2 1e-9
#define EPS3 1e-15
#define fi first
#define se second
#define ff first.first
#define ss second.second
#define sf second.first
#define fs first.second
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ul;
typedef pair<ld,ld> ldd;
typedef pair<double,double> dd;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef pair<ld,ii> dii;

int main(){
	string a,b;
	cin>>a>>b;
	int ct = 0;
	int la = a.length();
	for(int i = 0;i<la;i++){
		if(a[i] == b[i]){
			ct++;
		}
	}
	cout<<ct<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  vector<int> v(N);
  for (int &x:v) {
    cin >> x;
  }

  vector<int> a = v;
  sort(a.begin(), a.end());

  int max = a.back(); a.pop_back();
  int prev = a.back();

  for (int i = 0; i < N; i++) {
    if (v[i] == max) {
      cout << prev << endl;
    } else {
      cout << max << endl;
    }
  }
}

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


Measured memory_bytes: 3200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

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

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<P> a(n);
    vector<vector<int>> g(n,vector<int>(0));
    int x,y;
    rep(i,n-1){
        cin>>x>>y;
        a[i]=P(x-1,y-1);
        g[x-1].emplace_back(y-1);
        g[y-1].emplace_back(x-1);
    }
    int num_col=0;
    int par=-1;
    rep(i,n){
        x=g[i].size();
        if(chmax(num_col,x)) par=i;
    }
    cout<<num_col<<endl;
    map<P,int> col;
    int cnt=0;
    queue<P> que;
    que.emplace(par,0);
    while(cnt<n-1){
        tie(x,y)=que.front();
        que.pop();
        int now=1;
        for(auto z:g[x]){
            if(col.count(P(x,z)) || col.count(P(z,x))) continue;
            if(now==y) now ++;
            col[P(x,z)]=now;
            cnt ++;
            que.emplace(z,now);
            now ++;
        }
    }
    rep(i,n-1){
        tie(x,y)=a[i];
        if(col.count(P(x,y))) cout<<col[P(x,y)]<<endl;
        else cout<<col[P(y,x)]<<endl;
    }
}/*
./problem.exe
*/

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
 int x,y;
 cin>>x>>y;
 bool f=false;
 rep(i,x+1){
    int z=x-i;
    if(i*2+z*4==y) f=true;
 }
 (f)? cout<<"Yes":cout<<"No";
   return 0;
}



Measured memory_bytes: 3632
<?php
while(1){
	$res = fscanf(STDIN, '%d', $n);
	if($res==0) break;
	$cnt=0;
	for($a=0; $a<=9; ++$a){
	for($b=0; $b<=9; ++$b){
	for($c=0; $c<=9; ++$c){
	for($d=0; $d<=9; ++$d){
		$sum = $a+$b+$c+$d;
		if($sum===$n){
			$cnt++;
		}
	}
	}
	}
	}
	echo $cnt.PHP_EOL;
}

Measured memory_bytes: 6576
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int h,a;
   scanf("%d%d",&h,&a);
   if(h%a==0)
       printf("%d",h/a);
   
   else
      printf("%d",h/a + 1);
 
	return 0;
}

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

int main()
{
  int s;
  scanf("%d", &s);
  
  int cnt=0;
  while (s != 0)
  {
    div_t dt = div(s, 10);
    
    if (dt.rem == 1)
    {
      ++cnt;
    }
    s = dt.quot;
  }
  
  printf("%d", cnt);
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a<=9&&b<=9){
    cout<<a*b<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int A[200000];
long long dp[3][200000+1];
int main(){
  int i, k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(k=(0);k<(3);k++){
    int i;
    for(i=(0);i<(N+1);i++){
      dp[k][i] = -4611686016279904256LL;
    }
  }
  for(i=(0);i<(N);i++){
    for(k=(1);k<(3);k++){
      chmax(dp[k][i+1], dp[k-1][i]);
    }
    for(k=(0);k<(3);k++){
      if(i>0){
        chmax(dp[k][i+1], dp[k][i-1]+ A[i]);
      }
      else{
        chmax(dp[k][i+1], -4611686016279904256LL+ A[i]);
      }
    }
    if(i==0){
      chmax(dp[0][i+1], A[i]);
    }
    if(i==1){
      chmax(dp[1][i+1], A[i]);
    }
    if(i==2){
      chmax(dp[2][i+1], A[i]);
    }
  }
  if(N%2==0){
    wt_L(dp[1][N]);
    wt_L('\n');
  }
  else{
    wt_L(dp[2][N]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200412-1

// --- original code ---
// int N, A[2d5];
// 
// ll dp[3][2d5+1];
// {
//   rd(N,A(N));
//   rep(k,3) rep(i,N+1) dp[k][i] = -ll_inf;
//   rep(i,N){
//     rep(k,1,3) dp[k][i+1] >?= dp[k-1][i];
//     rep(k,3) dp[k][i+1] >?= if[i>0, dp[k][i-1], -ll_inf] + A[i];
//     if(i==0) dp[0][i+1] >?= A[i];
//     if(i==1) dp[1][i+1] >?= A[i];
//     if(i==2) dp[2][i+1] >?= A[i];
//   }
// //  rep(i,N+1) wt(i, dp[0][i], dp[1][i], dp[2][i]);
//   wt(if[N%2==0, dp[1][N], dp[2][N]]);
// }


Measured memory_bytes: 10136
def check(str):
    str2 = str[::-1]
    return str == str2



def main():
    s = input()
    n = len(s)
    first = s[:(n-1)//2]
    end = s[((n+3)//2)-1:]
    if all((check(s), check(first), check(end))):
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 9064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int mod = 1e9+7;
struct Mint {
  int val;
  Mint inv() const {
    int tmp, a = val, b = mod, x = 1, y = 0;
    while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
    return Mint(x);
  }
public:
  Mint() :val(0) {}
  Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
  int mtoi() { return this->val; }
  Mint pow(ll t) { Mint res = 1,b = *this; while(t){if(t&1)res *= b;b *= b;t >>= 1;}return res; }
  Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
  Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
  Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
  Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
  bool operator==(const Mint& x) const { return val == x.val; }
  bool operator!=(const Mint& x) const { return val != x.val; }
  bool operator<(const Mint& x) const { return val < x.val; }
  bool operator<=(const Mint& x) const { return val <= x.val; }
  bool operator>(const Mint& x) const { return val > x.val; }
  bool operator>=(const Mint& x) const { return val >= x.val; }
  Mint operator+(const Mint& x) const { return Mint(*this) += x; }
  Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
  Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
  Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
  vector<Mint> Fact, Finv;
public:
  factorial(int maxx) {
    Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
    Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
  }
  Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
  Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
  Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main(){
  int n; scanf("%d",&n);
  vector<int> a(2*n);
  rep(i,0,2*n)scanf("%d",&a[i]);
  sort(ALL(a));
  ll ans=0;
  rep(i,0,2*n){
    ans+=a[i]; i++;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 100010;
LL sta[Maxn], tp, n, m;
LL s[Maxn], t[Maxn];
LL bs(LL r, LL x) {
	LL l = 1, ret = 0;
	while(l <= r){
		LL mid = l+r>>1;
		if(sta[mid] <= x){ ret = mid; l = mid+1; }
		else r = mid-1;
	}
	return ret;
}
int main() {
	LL i, j, k;
	scanf("%lld%lld", &n, &m);
	sta[tp=1] = n;
	for(i = 1; i <= m; i++){
		LL x;
		scanf("%lld", &x);
		while(tp && sta[tp] >= x) tp--;
		sta[++tp] = x;
	}
	t[tp] = 1;
	for(i = tp; i >= 1; i--){
		k = sta[i]; LL x = bs(i-1, k);
		while(x){
			t[x] += k/sta[x]*t[i];
			k %= sta[x];
			x = bs(x-1, k);
		}
		s[1] += t[i]; s[k+1] -= t[i];
	}
	for(i = 1; i <= n; i++) printf("%lld\n", s[i] += s[i-1]);
	return 0;
}

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

int d[100], a[100];
map<vector<int>, int>id;
vector<int>re[5040];
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v{ 0,1,2,3,4,5,6 };
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0, t = 0;
		for (int i : v) {
			rep(j, 7) {
				if ((t >> j & 1) && abs(j - i) <= d[j])cnt += a[j];
			}
			t |= 1 << i;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040)rep(k, 8) {
		auto t = re[j].begin();
		int cnt = 0, p = 0, o = 0;
		vector<int>q(7);
		rep(l, 8) {
			if (k == l) {
				rep(y, 8) {
					if ((p >> y & 1) && y + d[i - 1 + y] >= 7)
						cnt += a[i - 1 + y];
				}
				p |= 1 << 7; q[o++] = 6;
			}
			else {
				if ((p >> 7 & 1) && 7 - d[i + 6] <= *t)cnt += a[i + 6];
				p |= 1 << *t;
				if (*t)q[o++] = *t - 1;
				t++;
			}
		}
		int v = id[q];
		dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
		ans = max(ans, dp[i][v]);
	}
	printf("%d\n", ans);
}

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

int main() {
	int n,k;
	cin >> n >> k;
	string ans = "NO";
	if((n / 2) + (n % 2) >= k)
	{
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  double w,h,x,y;
  scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  
  double tarea=0;
  double sarea=w*h;
  
  int index=0;
  
  if(x==w/2 && y==h/2){
    tarea=sarea/2;
    index=1;
  }else{
    tarea=sarea/2;
  }
  
  printf("%lf %d",tarea,index);
  
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	int ans=0;
	cin>>a[0];
	bool flg_up=false,flg_down=false;
	for(int i=1;i<n;i++){
	    cin>>a[i];
	    if((!flg_up)&&(!flg_down)){
	        if(a[i]>a[i-1]) flg_up=true;
	        else if(a[i]<a[i-1]) flg_down=true;
	    }
	    else if(flg_up&&a[i]<a[i-1]){
	        ans++;
	        flg_up=false;
	    }
	    else if(flg_down&&a[i]>a[i-1]){
	        ans++;
	        flg_down=false;
	    }
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 640