akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll H, W;
  cin >> H >> W;

  ll ans = INFLL;
  FOR(h,1,H) {
    ll sa = h*W;
    { int h2 = (H-h)/2;
      ll sb = h2*W;
      ll sc = (H-h-h2)*W;
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      ans = min(ans,smax-smin);
    }
    { int w = W/2;
      ll sb = (H-h)*w;
      ll sc = (H-h)*(W-w);
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      ans = min(ans,smax-smin);
    }
  }
  FOR(w,1,W) {
    ll sa = w*H;
    { int w2 = (W-w)/2;
      ll sb = w2*H;
      ll sc = (W-w-w2)*H;
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      ans = min(ans,smax-smin);
    }
    { int h = H/2;
      ll sb = (W-w)*h;
      ll sc = (W-w)*(H-h);
      ll smax, smin;
      smax = max({sa,sb,sc});
      smin = min({sa,sb,sc});
      ans = min(ans,smax-smin);
    }
  }

  cout << ans << endl;
}

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

int main() {
  int X;
  scanf("%d", &X);

  int answer;
  answer = X / 500 * 1000;
  X = X - X / 500 * 500;
  answer += X / 5 * 5;

  printf("%d", answer);

  return 0;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let (n, m, l) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };
    let mut dist = vec![vec![0; n]; n];
    for _ in 0..m {
        let (a, b, c) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1, i[2])
        };
        dist[a][b] = c;
        dist[b][a] = c;
    }

    let mut dp = vec![vec![100_000_000_000; n]; n];
    for i in 0..n { for j in 0..n {
        if dist[i][j] > 0 { dp[i][j] = dist[i][j]; }
    }}

    for k in 0..n { for i in 0..n { for j in 0..n {
        if dp[i][k] + dp[k][j] < dp[i][j] {
            dp[i][j] = dp[i][k] + dp[k][j];
        }
    }}}

    for i in 0..n { for j in 0..n {
        dp[i][j] = if dp[i][j] <= l { 1 }
        else { 100_000_000_000 };
    }}

    for k in 0..n { for i in 0..n { for j in 0..n {
        if dp[i][k] + dp[k][j] < dp[i][j] {
            dp[i][j] = dp[i][k] + dp[k][j];
        }
    }}}

    let q = read_one::<usize>();
    for _ in 0..q {
        let (s, t) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        let ans: isize = if dp[s][t] > 100_000_000 { -1 }
        else { (dp[s][t] - 1) as isize };
        println!("{}", ans);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

#define C_MAX 20000
#define R_MAX 20

bitset<C_MAX> senbei[R_MAX];
int R, C;

int count_col(int i) {
    int count = 0; // 0の数
    for (int p = 0; p < R; p++) {
        if (!senbei[p][i]) count++;
    }
    return (count > R - count ? count : R - count);
}

int count_all_cols() {
    int count = 0;
    for (int p = 0; p < C; p++) {
        count += count_col(p);
    }
    return count;
}

int solve(int r) {
    if (r > R) return count_all_cols();
    int turned, not_turned;
    not_turned = solve(r+1);
    senbei[r].flip();
    turned = solve(r+1);
    return (not_turned > turned ? not_turned : turned);
}

int main() {
    while (cin >> R >> C) {
        if (R == 0 && C == 0) break;
        for (int i = 0; i < R; i++) {
            senbei[i].reset();
            for (int j = 0; j < C; j++) {
                int tmp; cin >> tmp;
                if (tmp) {
                    senbei[i].set(j);
                }
            }
        }
        cout << solve(0) << endl;
    }
    return 0;
}

Measured memory_bytes: 916
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

ll n;
ll a,b,c,aa,bb,cc;

ll tradeBy2(ll n,ll a,ll b){
//	cout<<n<<" "<<a<<" "<<b<<endl;
	if(a<b){
		return n/a*b+n%a;
	}else{
		return n/b*a+n%b;
	}
}

ll _(ll n,ll b,ll bb,ll c,ll cc){
//	cout<<n<<endl;
	ll ans=0;
	for(int i=0;i<=n;i++){
		ll val=i/bb*b+i%bb+(n-i)/cc*c+(n-i)%cc;
		ans=max(ans,val); 
	}
	return ans;
}

int main(int argc,char* argv[]){
	cin>>n>>a>>b>>c>>aa>>bb>>cc;
	
	bool fa=(a<aa);
	bool fb=(b<bb);
	bool fc=(c<cc);
	
	int cnt=fa+fb+fc;
	
//	cout<<cnt<<endl;
	
	if(cnt==3 || cnt==0){
		ll aaa=0;
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n-i;j++){
	//			int val=tradeBy3(i,j,n-i-j,(a<aa),(b<bb),(c<cc));
				
				ll val=tradeBy2(i,a,aa)+tradeBy2(j,b,bb)+tradeBy2(n-i-j,c,cc);
				aaa=max(aaa,val);
			}
		}
		
		cout<<aaa<<endl;
		return 0;
	}
	
	if(cnt==2){
		ll ans=0;
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n-i;j++){
				ll val=0;
				if(fa && fb){
					val=tradeBy2(i,a,aa)+tradeBy2(j,b,bb)+n-i-j;
					ans=max(ans,max(val,val/cc*c+val%cc));
				}
				if(fb && fc){
					val=tradeBy2(i,b,bb)+tradeBy2(j,c,cc)+n-i-j;
					ans=max(ans,max(val,val/aa*a+val%aa));
				}
				if(fa && fc){
					val=tradeBy2(i,a,aa)+tradeBy2(j,c,cc)+n-i-j;
					ans=max(ans,max(val,val/bb*b+val%bb));
				}
			}
		}
		
		cout<<ans<<endl;
		return 0;
	}
	
	if(cnt==1){
//		return 1; 
		ll ans=0;
		if(fa){
			n=n/a*aa+n%a;
			ans=_(n,b,bb,c,cc);
			
		}
		if(fb){
			n=n/b*bb+n%b;
			ans=_(n,a,aa,c,cc);
		}
		if(fc){
			n=n/c*cc+n%c;
			ans=_(n,a,aa,b,bb);
		}
		
		cout<<ans<<endl;
		return 0;
	}
}



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

using namespace std;

typedef long long ll;

const int M=2e5+44;

int la,lb;
ll lc,gcd,la2,lb2;
char sa[M],sb[M];

void init()
{
	gcd=__gcd(la,lb);
	lc=1ll*la*lb/gcd;
	la2=la/gcd; lb2=lb/gcd;
}

bool solve()
{
	for(int i=0;i*la2<la;i++)
		if((sa[la2*i]!=sb[lb2*i]))
			return false;
	return true;
}

int main()
{
	scanf("%d%d",&la,&lb);
	scanf("%s%s",sa,sb);
	init();
	if(solve()) printf("%lld\n",lc);
	else puts("-1");
	return 0;
}


/*

a b
a=p*h*g
b=q*h*g
a*k1=b*k2=T
x*k1+1=y*k2+1 :no.x,no.y(0<=x<a,0<=y<b)
x*k1=y*k2
x*b=y*a
x/p=y/q

3 6
abc
adbdcd
x:0 1 2
y:0 1 2 3 4 5
p=1 q=2
0-0
1-2
2-4

*/



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vi as(n);
	trav(x, as) cin >> x, --x;

	vector<ll> c0(m+1), c1(m+1);
	auto add = [&](int a0, int a1, int fr, int to){
		c0[fr] += a0;
		c1[fr] += a1;
		c0[to] -= a0;
		c1[to] -= a1;
	};
	rep(i,1,n){
		int x = as[i-1], y = as[i];
		if(x < y){
			add(y-x, 0, 0, m);
			add(x-y, 0, x+1, y+1);
			add(y+1, -1, x+1, y+1);
		} else if(x > y){
			int d = y-x+m;
			add(d, 0, y+1, x+1);
			add(y+m+1, -1, x+1, m);
			add(y+1, -1, 0, y+1);
		}
	}
	ll ans = 1e16;
	ll a0 = 0, a1 = 0;
	rep(i,0,m){
		a0 += c0[i], a1 += c1[i];
		ans = min(ans, a0+a1*i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
program task1016;
var
    a,b,c : ansistring;
    x,y,i,t : int64;
    sum : int64;
begin
    read(a);
    sum := 0;
    b := a;
    c := a;
    delete(b,pos(' ',a),length(a)-pos(' ',a)+1);
    val(b,x,i);
    //writeln(b);
    delete(a,1,pos(' ',a)+2);
    val(a,y,t);
    //writeln(a);
    if c[pos(' ',c) + 1] = '+' then
        sum := x + y
    else 
        sum := x - y;
    writeln(sum);
end.

Measured memory_bytes: 1284
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    string s;cin>>s;
    vector<ll>ir(n+1,0),ig(n+1,0),ib(n+1,0);
    for(int i=0;i<n;++i){
        ++(s[i]=='R'?ir:s[i]=='G'?ig:ib)[i+1];
    }
    for(int i=1;i<=n;++i){
        ir[i]+=ir[i-1];
        ig[i]+=ig[i-1];
        ib[i]+=ib[i-1];
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        for(int k=0;k<n;++k){
            if(s[i]==s[k])continue;
            char foo=(int)('R')+(int)('G')+(int)('B')-(int)(s[i])-(int)(s[k]);
            auto&v=foo=='R'?ir:foo=='G'?ig:ib;
            if(ll cnt=v[k]-v[i+1];cnt>0){
                if((k-i)%2==0&&s[i+(k-i)/2]==foo)--cnt;
                ans+=cnt;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3684
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


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

    map<int,int> cnts;
    long long sum = 0;
    for (auto x : A) {
        cnts[x] += 1;
        sum += x;
    }

    int q;
    cin >> q;

    while (q-- > 0) {
        int x, y;
        cin >> x >> y;

        if (x != y) {
            auto it = cnts.find(x);
            if (it != cnts.end()) {
                int cnt = it->second;
                cnts.erase(x);
                sum -= x * 1LL * cnt;
                cnts[y] += cnt;
                sum += y * 1LL * cnt;
            }
        }

        cout << sum << '\n';
    }


    return 0;
}

Measured memory_bytes: 6896
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
int N,X;
cin >> N >> X;

int L[N+1];

for (int n=1;n<N+1;n=n+1) {
cin >> L[n];
}



int D;
int c;

D=0;

for (int i=1;D<=X;i=i+1) {
        //cout << "跳ねるのは" << D << endl;
    D=D+L[i];

    c=i;
}

cout << c << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int op;
    while(cin>>op)
    {
        if(op==1)
        {
            cout<<"Hello World"<<endl;
        }
        else
        {
            int a,b;
            cin>>a>>b;
            cout<<a+b<<endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n ,mi;
	cin >> n >> mi;
	
	int m = n/2;
	int pos = 1;
	REP(i, 0, mi){
		if(i % 2 == 0){
			cout << m-pos+1 << " " << m+pos<< endl;
		}
		else{
			cout << pos << " " << n-pos << endl;
			++pos;
		}
	}

}


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

sum_all = sum(A)
sum_tmp1 = 0
ans = float('inf')
for i in range(N):
  sum_tmp1 += A[i]
  sum_tmp2 = sum_all - sum_tmp1
  ans = min(ans,abs(sum_tmp1-sum_tmp2))
print(ans)

Measured memory_bytes: 26764
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int a,b,c;cin>>a>>b>>c;
  if(a<b&&b<c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    cin>>N;
    vector<int64> d(N);
    for(int64 i=0;i<N;i++){
        cin>>d[i];
    }

    sort(d.begin(),d.end());
    if(d[N/2]-d[N/2-1]){
        cout<<d[N/2]-d[N/2-1]<<endl;
    }else{
        cout<<0<<endl;
    }
    
    return 0;
}

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

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

  vector<string> res;
  res.emplace_back("a");
  auto dfs = [&](auto& f, int d)->void {
    if (d == n) return ;
    int m = sz(res);
    vector<string> nres;
    for (int i = 0; i < m; i++) {
      int k = 0;
      for (int j = 0; j < d; j++) {
        k = max(k, res[i][j] - 'a');
      }
      for (int j = 0; j <= k + 1; j++) {
        nres.emplace_back(res[i] + (char)('a' + j));
      }
    }
    swap(res, nres);
    f(f, d + 1);
  };
  dfs(dfs, 1);
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  for (auto e : res) cout << e << endl;
  return 0;
}

Measured memory_bytes: 11212
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n ;
    cin >> n ;
    ll m = n / 100 ;
    ll k = n % 100 ;
    ll g = (k + 4) / 5 ;
    if (g <= m) cout << 1 ;
    else cout << 0 ;
    
    return (0) ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	LL n, d, a;
	cin >> n >> d >> a;
	vector<pair<LL, LL>> v(n);
	inc(i, n) { cin >> v[i].FI >> v[i].SE; }
	
	sort(ALL(v));
	
	vector<LL> s(n + 1);
	LL ans = 0;
	inc(i, n) {
		if(i != 0) { s[i] += s[i - 1]; }
		v[i].SE += s[i];
		if(v[i].SE <= 0) { continue; }
		LL c = ce(v[i].SE, a);
		pair<LL, LL> q = { v[i].FI + 2 * d, 2'000'000'000 };
		LL p = UB(v, q);
		s[i] -= a * c;
		s[p] += a * c;
		ans += c;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using ll = int_fast64_t;
const ll MOD = 1e9+7;

ll fact[100000], finv[100000], inv[100000];

void combinit(){
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(ll i=2; i<100000; i++){
                fact[i] = fact[i-1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i-1] * inv[i] % MOD;
        }
}

ll comb(ll n, ll k){
        if(n<k or n<0 or k<0) return 0;
        return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
        ll n, k;
        scanf("%ld %ld", &n, &k);

        combinit();
        ll r = n-k;
        for(ll b=1; b<=k; b++){
                printf("%ld\n", comb(r+1, b) * comb(k-1, k-b) % MOD);
        }
        return 0;
}


Measured memory_bytes: 2560
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
vector< ll > tree[N];

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
     ll k,n;
     cin>>k>>n;
     ll arr[n];
     for(int i=0;i<n;i++)
      cin>>arr[i];
    ll ans=0;
    for(int i=1;i<n;i++)
      ans=max(ans,arr[i]-arr[i-1]);
    ans=max(ans,k-(arr[n-1]-arr[0]));
    cout<<k-ans<<'\n';
}

Measured memory_bytes: 25344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

ll dp[3009][3009];
ll a[3009];
ll f(ll i,ll j){
    ll &ref = dp[i][j];
    if(ref!=-1)
        return ref;
    ref = 0;
    if(i>j)
        return ref=0;
    
    return ref = max(a[i]-f(i+1,j),a[j]-f(i,j-1));
}
int main(){
    fast;
    ll n;cin>>n;
    
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<max(a[0]-f(1,n-1),a[n-1]-f(0,n-2));
    return 0;
}

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

int main(){
	int u,v;
	int a[102] = {0};
	
	while( cin >> u >> v ){
		if( u == 0 && v == 0 ){
			bool flag = true;
			if( a[1]%2 == 0 || a[2]%2 == 0 ){
				flag = false;
			}
			for(int i=3 ; i <= 101 ; i++ ){
				if( a[i]%2 == 1 ){
					flag = false;
					break;
				}
			}
			cout << ((flag)? "OK" : "NG" ) << endl;
			for(int i=0 ; i <= 101 ; i++ )
				a[i] = 0;
		}else{
			a[u]++;
			a[v]++;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
ll MOD=1000*1000*1000+7, n, m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n, ans=0;
	cin>>n;
	map<pair<int,int>, int>A;
	for(int i=1; i<=n; i++){
		ll a, b, x=i;
		b=x%10;
		while(x){
			a=x%10;
			x/=10;
		}
		A[mp(a, b)]++;
	}
	for(auto x:A){
		auto y=x.first;
		auto z=x.second;
		ans+=A[mp(y.second, y.first)]*z;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 500000

typedef struct{
  int key, left, right;
}Node;

Node tree[N+1];
int size;

void insert(int x){
  int p = 0;
  while(1){
    if(x < tree[p].key){
      if(tree[p].left == -1){
        tree[p].left = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].left;
    }else{
      if(tree[p].right == -1){
        tree[p].right = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].right;
    }
  }
}

void inorder(int p){
  if(tree[p].left != -1) inorder(tree[p].left);
  printf(" %d", tree[p].key);
  if(tree[p].right != -1) inorder(tree[p].right);
}

void preorder(int p){
  printf(" %d", tree[p].key);
  if(tree[p].left != -1) preorder(tree[p].left);
  if(tree[p].right != -1) preorder(tree[p].right);
}

int find(int p, int x){
  if(tree[p].key == x) return 1;
  if(x < tree[p].key && tree[p].left != -1) if(find(tree[p].left, x)) return 1;
  if(tree[p].key < x && tree[p].right != -1) if(find(tree[p].right, x)) return 1;
  return 0;
}

int main(){
  int n, i, first;
  first = 1;
  scanf("%d", &n);

  for(i=0;i<=n;i++){
    if(i<=n)break;
  }
  
  for(i=0;i<=n;i++) tree[i].key = tree[i].left = tree[i].right = -1;
  size = 0;
  while(n--){
    char str[100];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(first){
        tree[size++].key = in;
        first = 0;
      }
      else insert(in);
    }else if(!strcmp(str, "find")){
      int in;
      scanf("%d", &in);
      printf("%s\n", (find(0, in) ? "yes" : "no"));
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 7596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N,M;
    cin >> N >> M;
    vector<vector<int>> S(M,vector<int>(N,0));
    vector<int> P(M);
    REP(m,M){
        int K;
        int s;
        cin >> K;
        REP(k,K){
            cin >> s;
            s--;
            S[m][s] = 1;
        }
    }
    cin >> P;
    int ans = 0;
    for(int bit=0; bit<(1<<N); bit++){
        int p_cnt = 0;
        REP(m,M){
            int cnt = 0;
            for(int i=0;i<N;i++){
                if((bit&(1<<i)) && (1 == S[m][i])){
                    cnt++;
                }
            }
            if(P[m] == cnt%2){
                p_cnt++;
            }
        }
        if(M == p_cnt)ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

class DisjointSet {
 private:
  class Node {
    friend DisjointSet;

    std::size_t parent;
    std::size_t size;

    Node(const std::size_t parent, const std::size_t size) : parent(parent), size(size) {}
  };

  std::vector<Node> nodes;

 public:
  explicit DisjointSet(const std::size_t n) : nodes(n, Node(n, 1)) {}

  std::size_t size() const { return nodes.size(); }

  std::size_t size(const std::size_t x) { return nodes[root(x)].size; }

  std::size_t root(const std::size_t x) {
    if (nodes[x].parent == size()) return x;
    return nodes[x].parent = root(nodes[x].parent);
  }

  bool is_same(const std::size_t x, const std::size_t y) { return root(x) == root(y); }

  bool unite(const std::size_t x, const std::size_t y) {
    std::size_t rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (nodes[rx].size < nodes[ry].size) std::swap(rx, ry);
    nodes[rx].size += nodes[ry].size;
    nodes[ry].parent = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  DisjointSet ds(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    ds.unite(a, b);
  }
  set<int> st;
  for (int i = 0; i < N; i++) {
    st.insert(ds.root(i));
  }
  cout << (int)st.size() - 1 << '\n';
  return 0;
}


Measured memory_bytes: 8424
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main()
        {
            string[] inp = Console.ReadLine().Split();
            int[] nums = new int[3];
            nums[0] = Int32.Parse(inp[0]);
            nums[1] = Int32.Parse(inp[1]);
            nums[2] = Int32.Parse(inp[2]);
            Array.Sort(nums);
            Console.WriteLine("{0} {1} {2}", nums[0], nums[1], nums[2]);
        }
    }
}



Measured memory_bytes: 9356
import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int[] num = new int['z' - 'a' + 1];
        while (scan.hasNext()) {
            char[] chars = scan.next().toLowerCase().toCharArray();
            for (char ch : chars) {
                if (Character.isLetter(ch)) {
                    num[ch - 'a']++;
                }
            }
        }
        for (int i = 0; i < num.length; i++) {
            System.out.printf("%c : %d\n", (char)('a' + i), num[i]);
        }
    }
}

Measured memory_bytes: 26068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define ll long long

int main(void){
    int a, b;
    cin >> a >> b;

    int c = 1;
    int ans = 0;
    while(c < b){
        c += a-1;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
sh,sm,fh,fm,k = map(int,input().split())
h = 0
m = 0
ans = 0

if sm > fm:
    h = 60*(fh-sh)
    m = sm -fm
    ans = h - m - k
else:
    h = 60*(fh-sh)
    m = fm -sm
    ans = h + m - k  

print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

vecl res(1000001);

int main() {
    ll N; cin >> N;
    for(ll i = 1; i <= 1e6; i++) {
        for(ll j = i; j <= 1e6; j += i) {
            res[j]++;
        }
    }
    ll ans = 0;
    for(ll c = 1; c <= N; c++) {
        ll rest = N-c;
        ans += res[rest];
    }
    cout << ans << endl;
}

Measured memory_bytes: 10988
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

	vector<int> a(n), b(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i] - (i + 1);
	}
	sort(b.begin(), b.end());

	long long c;
	if (n % 2 == 1) {
		c = b[n / 2];

		long long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += abs(a[i] - (c + i + 1));
		}
		cout << ans << endl;
	} else {
		c = (b[n / 2 - 1] + b[n / 2]) / 2;
		long long ans1 = 0, ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans1 += abs(a[i] - (c + i + 1));
		}
		c++;
		for (int i = 0; i < n; i++) {
			ans2 += abs(a[i] - (c + i + 1));
		}
		cout << min(ans1, ans2) << endl;
	}


	return 0;
}

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

int C[3][3],a[3],b[3];

int main(void){
    rep(i,3)rep(j,3)cin >> C[i][j];
    rep(i,3)b[i] = C[i][0];
    rep(i,3)a[i] = C[0][i] - b[0];
    rep(i,3)rep(j,3)if(b[i]+a[j] != C[i][j]){cout << "No" << endl;return 0;}
    cout << "Yes" << endl;
    return 0;
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> choco(H, vector<char>(W, '0'));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            choco[i][j] = c;
        }
    }

    vector<vector<int>> acc_sum(H + 1, vector<int>(W + 1, 0));
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            acc_sum[i][j] = acc_sum[i][j - 1] + acc_sum[i - 1][j] - acc_sum[i - 1][j - 1] + (choco[i - 1][j - 1] == '1' ? 1 : 0);
        }
    }

    // for (int i = 0; i <= H; ++i) {
    //     for (int j = 0; j <= W; ++j) {
    //         cout << acc_sum[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    const function<int(int, int, int, int)> f = [&](int y2, int x2, int y1, int x1) {
        return acc_sum[y2][x2] - acc_sum[y1][x2] - acc_sum[y2][x1] + acc_sum[y1][x1];
    }; 

    const function<int(int, const vector<int>&)> search = [&](int left, const vector<int>& bs) {
        for (int right = left + 1; right <= W; ++right) {
            debug(right);
            int cnt = 0;
            for (int i = 1; i < bs.size(); ++i) {
                cnt = max(cnt, f(bs[i], right, bs[i - 1], left));
            }
            if (cnt > K) {
                return right - 1;
            }
        }
        return W;
    };

    const function<int(const vector<int>&)> check = [&](const vector<int>& bs) {
        int cnt = 0;
        for (int left = 0; left < W;) {
            int res = search(left, bs);
            debug(left);
            debug(res);
            if (res == left) { return -1; }
            else {
                left = res;
                cnt++;
            }
        }
        debug(cnt);
        return cnt - 1;
    };

    int res = 1000000;
    for (uint32_t b = 0; b < 1u << (H - 1); ++b) {
        vector<int> bs({0});
        for (int i = 0; i < H - 1; i++) { if ((b >> i) & 1) { bs.push_back(i + 1); } }
        bs.push_back(H);
        // for (const auto& b : bs) { cout << b << ", "; } cout << endl;
        int r = check(bs);
        if (r == -1) { continue; }
        else { res = min(r + (int)bs.size() - 2, res); }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int n,i;

scanf("%d",&n);

char s[n];

scanf("%s",&s);

if(n%2==1){
printf("No");
}else{
for(i=0;i<n/2;i++){
if(s[i]!=s[n/2+i]){break;}
}

if(i==n/2){printf("Yes");}
else{printf("No");}

}

return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <string.h>

using namespace std;

bool  func (char *str, int len);

int main(void)
{
	char str[100];
	char str2[50];
    bool ret;
	int len;
	
	cin >> str;

	len = strlen( str );
	
	if ( func ( str, len) && func ( str, len / 2) ) {	
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

bool func ( char* str, int len )
{
	bool retBool = false;
	int i, j;
	
	i = 0;
	j = len - 1;
	
	while ( i <= (len/2) ) {
		 if (str[i] != str[j]) {
		 	break;
		 }
		 i++;
		 j--;
	}
	
	if (i >= j) {
		retBool = true;
	}
	
	return retBool;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, ll> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<P> v;
vector<int> used;
int c[100100];
bool f[100100];

bool comp(P a, P b){
	return (a.second>b.second);
}

int main(void){
	int n,i,t,p;
	ll d,ans=0ll,k,m=0ll,l,g;
	fill(f,f+100100,false);
	fill(c,c+100100,0ll);
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> t >> d;
		--t;
		v.push_back(P(t,d));
	}
	sort(v.begin(),v.end(),comp);
	for(i=0; i<n; ++i){
		t = v[i].first;
		d = v[i].second;
		if(!c[t]){
			++c[t];
			f[i] = true;
			--k;
			++m;
			ans += d;
			used.push_back(i);
		}
		if(!k){
			break;
		}
	}
	ans += (m*m);
	p = used.l_ength()-1;
	for(i=0; i<n; ++i){
		t = v[i].first;
		d = v[i].second;
		if(f[i]){
			continue;
		}
		if(k){
			--k;
			++c[t];
			ans += d;
			continue;
		}
		if(p<0){
			continue;
		}
		if(v[used[p]].first == t){
			continue;
		}
		if(c[v[used[p]].first]==1 && c[t]==0){
			l = v[used[p]].second;
			g = d;
		}else if(c[v[used[p]].first]==1){
			l = v[used[p]].second+(m*m-(m-1)*(m-1));
			g = d;
		}else if(!c[t]){
			l = v[used[p]].second;
			g = d+((m+1)*(m+1)-m*m);
		}
		if(g>l){
			--c[v[used[p]].first];
			if(!c[v[used[p]].first]){
				--m;
			}
			++c[t];
			if(c[t]==1){
				++m;
			}
			ans += (g-l);
			--p;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2932
d = 998244353

num = int(input())

l = list(map(int, input().split()))


flag = True

if l[0] != 0:
  flag = False

ll = set(l)

for i in range(max(ll)):
  if i + 1 not in ll:
    flag = False

a = [0 for i in range(max(ll))]

for x in l[1:]:
  if x == 0:
    flag = False
    break
  a[x-1] += 1


ans = 1

for i in range(len(a)-1):
  ans *= a[i] ** a[i+1]


if flag:
  print(ans % d)
else:
  print(0)

Measured memory_bytes: 15484
import java.io.*
import java.util.*

fun solve(N: Long, a: LongArray){
    println(a.sum() - N)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val a = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        a[i] = sc.next().toLong()
    }
    solve(N, a)
}



Measured memory_bytes: 35300
import sys

count = int(raw_input())
#print count                                                                                                                                                                                                                                   
while 0 < count:
    count -=1
    #print count                                                                                                                                                                                                                               
    a = map(int,raw_input().split())
    #print a[0],a[1],a[2]                                                                                                                                                                                                                      

    if a[1]< a[2]:
        tmp = a[1]
        a[1] = a[2]
        a[2] = tmp

    if a[0] < a[1]:
        tmp = a[0]
        a[0] = a[1]
        a[1] = tmp

    n = a[1]*a[1] + a[2]*a[2]
    if a[0]*a[0] == n:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
using namespace std;

template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

int n,a[2005];
bitset<4000005>bit;
signed main() {
	cin>>n;
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	bit.set(0);
	rep(i,n){
		bit|=bit<<a[i];
	}
	for(int i=(sum+1)/2;;i++){
		if(bit[i]){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1664
def compare(a, b): # a also b are both string
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')
	return a_ > b_

def divide(num, den): # den is integer
	quo = ''; resi = 0
	digit = len(num) if int(num[0]) >= den else len(num)-1
	for i in range(len(num)):
		temp = (int(num[i])+resi*10)//den
#		print('dtemp', temp)
		resi = (int(num[i])+resi*10)%den
#		print('dresi', resi)
		quo += str(temp)
	return quo

def multi(a, n):
	s = ''; resi = 0
	for i in range(len(a))[::-1]:
		temp = (int(a[i])*n + resi)%10
#		print('mltemp', temp)
		resi = (int(a[i])*n + resi)//10
#		print('mlresi', resi)
		s = str(temp) + s
	return s


def plus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; resi = 0
	for i in range(l)[::-1]:
		temp = (int(a_[i]) + int(b_[i]) + resi)%10
#		print('ptemp', temp)
		resi = (int(a_[i]) + int(b_[i]) + resi)//10
#		print('presi', resi)
		s = str(temp) + s
	return s

# a is higher than b
def minus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; bollow = 0
	for i in range(l)[::-1]:
		temp = int(a_[i]) - int(b_[i]) - bollow
#		print('mitemp', temp)
		bollow = 0
		if temp >= 0:
			s = str(temp) + s
		else:
			bollow = 1
			s = str(temp + 10) + s
	return s


s, c = input().split()
if compare(s, divide(c, 2)) or s == c:
	print(int(divide(c, 2)))
else:
	print(int(plus(s, divide(minus(c, multi(s, 2)), 4))))


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

int main(){
	string s;
	cin>>s;
	if(s[2]==s[3]){
		if(s[4]==s[5]){
			cout<<"Yes"<<flush;
			return 0;
		}
	}
	cout<<"No"<<flush;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

// ユーグリッド互除法
ll GCD(ll a, ll b)
{
  if(b == 0) return a;
  else return GCD(b, a % b);
}

// 最小公倍数
ll LCM(ll a, ll b)
{
  ll g = GCD(a,b);
  return a*(b/g);
}

// 3個以上の場合の最小公倍数
ll LCM_multi(vector<ll> a)
{
  ll l = a[0];
  FOR(i,1,a.size()){
    l = LCM(a[i], l);
  }
  return l;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n, m;
	cin >> n >> m;
	set<int> st2;
	vector<ll> al(n);
	REP(i,n){
		ll a;
		cin >> a;		
		int cnt2 = 0;
		ll a_cp = a/2;
		al[i] = a_cp;
		while(a_cp%2==0){
			cnt2++;
			a_cp /= 2;
		}
		st2.insert(cnt2);
		if(st2.size()>1){
			cout << 0 << '\n';
			return 0;
		}
		
	}
	al.push_back(1);
	ll to = LCM_multi(al);
	ll to2 = to;
	int cnt = 0;
	/*
	while(to2<=m){
		cnt++;
		to2 = to * (ll)(2*cnt + 1);
	}
	cout << cnt << '\n';
	*/
	cout << (to>m ? 0 : (m/to+1)/2) << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        a.push_back(temp);
    }
    int ans=0;
    for(int i=1;i<n-1;i++){
        if(a[i]>a[i-1] and a[i]<a[i+1]){
            ans++;
        }
        if(a[i-1]>a[i] and a[i]>a[i+1]){
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m,d = LI()
    a,b = LI()
    if a != m:
        print(1)
    else:
        print(0)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
#include<stdio.h>

int main(void){
	int m,k=0,g=0,i,n;
	scanf("%d",&n);
	for(i = 1;i <= n;i++){scanf("%d",&m);if(m%2 == 0){g++;}else{k++;}}
	if(k%2 == 0){printf("YES\n");}else{printf("NO\n");}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int linSearch(int[], int, int);
int main(void){
    int i, n, q, C = 0, S[10000], T[500];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }
    for(i = 0; i < q; i++){
        if(linSearch(S, n, T[i]) != -1) C++;
    }
    printf("%d\n", C);
    

    return 0;
}
int linSearch(int src[], int n, int dst){
    int i;
    for(i = 0; i < n; i++){
        if(src[i] == dst) return i;
    }
    return -1;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int N;
ll b[110];

int main() {
    cin >> N;
    rep(i, N-1) cin >> b[i+1];
    b[0] = INF; b[N] = INF;

    ll a[110];

    for (int i = 1; i <= N; i++) {
        a[i-1] = min(b[i-1], b[i]);
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors
                
def main():
    n = int(input())
    n1 = sorted(make_divisors(n))

    mn = 10 ** 10
    for i in n1:
        mn = min(mn, max(len(str(n // i)), len(str(i))))
    print(mn)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void) {
 
  int n,x,t,i;

  scanf("%d %d %d", &n,&x,&t);

  for(i=0;n>0;i++){
    n-=x;
  }

  printf("%d",i*t);

  return 0;
}

Measured memory_bytes: 2152
n = int(input())
h = list(map(int, input().split()))
p = h[-1]
flag = 0
for i in h[::-1]:
  if i <= p:
    p = i
    continue
  elif (i - p) == 1:
    p = i - 1
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 14396
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
let sp = input.split("\n");
for( let i = 0; sp[i] !== "0 0"; i++ ) {
  let hw = sp[i].split(" ").map(Number);
  let h = hw[0]; w = hw[1];
  for( let hh = 0; hh < h; hh++ ) {
    let row = "";
    for( let ww = 0; ww < w; ww++ ) {
      if( hh === 0 || hh === h - 1 || ww === 0 || ww === w - 1 ) {
        row += "#";
      } else {
        row += ".";
      }
    }
    console.log(row);
  }
  console.log();
}

Measured memory_bytes: 18804
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    int n, m = 0, sum = 0;
    cin >> n;
    vector<int> l(n);
    repi(i, n, 0)
    {
        cin >> l[i];
        m = max(l[i], m);
        sum += l[i];
    }
    if (2 * m < sum)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    println(line.sorted.mkString(" "))
    println(sSort(List(), line, 0))
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={
    if(unsorted.length == 0) n
    else if(unsorted.sorted == unsorted) n
    else if(unsorted.indexWhere(_ == unsorted.min) == 0) sSort(sorted :+ unsorted.min, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 45212
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 100005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int a,k,ans=0;
int div1(int n)
{
	if(n<k) return 0;
	if(!(n%k)) return n/k;
	return div1(n-n/k-1);
}
int div2(int n)
{
	if(n<k) return 0;
	if(!(n%k)) return n/k;
	int now=n/k,lst=n-now*k,tim=lst/(now+1);
	if(tim*(now+1)==lst) return now;
	return div2(n-(tim+1)*(now+1));
}
int main()
{
	int T=read();
	while(T--)
	{
		a=read();k=read();
		if(sqrt(a)>=k) ans^=div1(a);
		else ans^=div2(a);
	}
	puts(ans?"Takahashi":"Aoki");
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> row;
typedef vector<row> matrix;

const ll MOD = 1e9 + 7;

ll N, K;
matrix a;

matrix identity() {
    matrix I(N, row(N));
    for (int i = 0; i < N; i++)
        I[i][i] = 1;
    return I;
}

matrix operator*(const matrix& A, const matrix& B) {
    matrix C(N, row(N));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            for (int k = 0; k < N; k++)
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
    return C;
}

matrix pow(matrix A, ll b) {
    matrix P = identity();
    for (; b > 0; b /= 2) {
        if (b % 2)
            P = P * A;
        A = A * A;
    }
    return P;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    a.assign(N, row(N));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> a[i][j];
    matrix p = pow(a, K);
    ll result = 0;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            result = (result + p[i][j]) % MOD;
    cout << result << endl;
}


Measured memory_bytes: 512