akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    ll M = 1;
    while( N > 0 ){
        if(N / 10 == 0){
            break;
        }
        N /= 10;
        M++;
    }
    return M;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}


// ---------------------------------------------

bool search(ll k){
    if(k == 2){
        return true;
    }
    ll m = (ll)pow(k, 0.5) + 1;
    for(ll i=2;i<=m;++i){
        if(k % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    ll x;
    cin>>x;
    for(ll i=x;i<=1e9;++i){
        if(search(i) == true){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;

const int MOD = 1000000007;

int main(){
    int n;
    cin>>n;
    Vll a(n);
    REP(i,n) cin>>a[i];

    Vll num_one_bit(65,0);
    REP(i,n){
        int b = 0;
        LL tmp = a[i];
        while(tmp>0){
            num_one_bit[b] += tmp%2;
            tmp/=2;
            b++;
        }
    }


    LL total = 0;
    LL two_pow = 1;
    REP(i,60){
        LL xor_sum = (num_one_bit[i] * (n-num_one_bit[i]))%MOD;
        total = (total + (xor_sum*two_pow)%MOD)%MOD;
        two_pow = (two_pow*2)%MOD;
    }

    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 2560
/*author  ADITYA BANSAL
                 //~ MNNIT ALLAHABAD     */
        #include<bits/stdc++.h>
        using namespace std;
        #define ll long long
        #define ull unsigned long long
        ll power(ll,ll);
        ll ncr(ll,ll);
        ll add(ll a,ll b);
        void fact();
        ll mul(ll a,ll b);
        #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
        #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define fi(a,b) for(ll i=a; i<b; i++)
        #define fk(a,b) for(ll k=a; k<b; k++)
        #define fri(a,b) for(ll i=a; i>=b; i--)
        #define fj(a,b) for(ll j=a; j<b; j++)
        #define ffi(a,b) for(ll i=a;i*i<=b;i++)
        #define mp make_pair
        #define ff first 
        #define  tc ll t; cin>>t; while(t--)
        #define all(v) (v).begin(),(v).end()
        #define ss second
        #define pb push_back
        #define mem(v,a) memset((v),a,sizeof(v));
        #define pll pair<ll,ll>
        #define mll map<ll,ll>
        #define sll set<ll>
        #define vll vector<ll>
        #define max3(a,b,c) max(a,max(b,c))
        #define min3(a,b,c) min(a,min(b,c))
        #define nl endl
         int mod=1e9+7;
        const ll  N=100002LL;
        ll fac[N+2];
        ll inv[N+2];
    
        signed main(){  
    	fast
    	
    	 //~ tc
        {
		     ll n;
		     cin>>n;
		  if(n%2==1) cout<<"No\n";
		  else { string s;
			  cin>>s;
			  
			  ll f=0;
			  fi(0,n/2){
				  if(s[i]!=s[n/2+i]) f=1;
				  
			  }
			  if(f) cout<<"No\n";
			  else cout<<"Yes\n";
			  
		  }
		
		
		
		
	     }
            return 0;
        }
         
         
        /******************************************************************************/
         
        ll add(ll a,ll b){
			a+=b+mod;
		   if(a>=mod) a-=mod;
		   
		   return a;
		} 
         
        ll mul(ll a,ll b){
            return ((a)*(b))%mod;
        }
         
        ll power(ll a,ll n){
          ll res=1;
          while(n){
              if(n&1) res= mul(res,a);
             n>>=1; 
             a= mul(a,a);
          }
            return res;
        }
        void fact(){
        	inv[0]=fac[0]=1;
        	fi(1,N){
        	 fac[i]=mul(fac[i-1],i);
        	inv[i]=power(fac[i],mod-2);
        }
        }
         
        ll ncr(ll n,ll r){
        	
        	if(r>n) return 0;
        	ll e=fac[n];
        	e=mul(e,inv[r]);
        	e=mul(e,inv[n-r]);
        	return e;
        }


Measured memory_bytes: 256
import math

N, D = map(int, input().split())

X = []
result = 0

for i in range(N):
	X.append([int(n) for n in list(input().split())])

for i in range(N):
	p1 = X.pop(0)
	for p2 in X:
		diff = 0
		for i in range(D):
			diff += (p1[i] - p2[i])**2
		res = math.sqrt(diff)
		if res.is_integer():
			result += 1

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

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

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int cnt=1;
  while(cnt<=a[n-1])cnt*=2;
  vector<pair<int,int>>as;
  map<int,int>ma;
  rep(i,n)
  {
    ma[a[i]]++;
  }
  as=vector<pair<int,int>>(all(ma));
  int res=0;
  int tcnt=cnt;
  int l=as.size();
  as.push_back({1e9+1,0});
  sort(all(as));
  for(int i=l-1;i>=0;i--)
  {
    if(as[i].second==0)continue;
    while(tcnt>2*as[i].first)tcnt/=2;
    pair<int,int> tp={tcnt-as[i].first,1};
    int  f=lower_bound(all(as),tp)-as.begin();
    if(as[f].first==tcnt-as[i].first)
    {
      if(i==f)
      {
        res+=as[f].second/2;
        as[f].second=as[f].second&1;
      }
      else
      {
        int tmp=min(as[i].second,as[f].second);
        res+=tmp;
        as[i].second-=tmp;
        as[f].second-=tmp;
      }
    }

  }
  cout<<res<<endl;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
int test_case_number = 1;

void print_case(){
    #ifdef LOCAL
    cout << "Case #" << test_case_number++ << ": ";
    #endif
}

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    while(b <= a){
        b *= 2;
        k --;
    }

    while(c <= b){
        c *= 2;
        k --;
    }
    if(k < 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}
 
int main(){
    solve();
}

Measured memory_bytes: 3632
n = int(input())
h = list(map(int, input().split()))

count = 0
while True:
    left = -1
    right = -1
    for i, hh in enumerate(h):
        if hh > 0:
            if left < 0:
                left = i
            right = i
        elif right >= 0:
            break
    if left < 0:
        break
    count += 1
    for i in range(left, right + 1):
        h[i] -= 1
print(count)

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> tree(n);
  vector<vector<int>> cost(n);

  rep(i, n - 1) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    tree.at(a).push_back(b);
    cost.at(a).push_back(w);
    tree.at(b).push_back(a);
    cost.at(b).push_back(w);
  }

  vector<int> ans(n, -1);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    rep(i, tree.at(v).size()) {
      int u = tree.at(v).at(i);
      int w = cost.at(v).at(i);
      if (ans.at(u) != -1) {
        continue;
      } else {
        ans.at(u) = ((ans.at(v) + w) % 2);
        q.push(u);
      }
    }
  }

  rep(i, n) {
    cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 11904
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();
			StringTokenizer st = new StringTokenizer(line," ");
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			if(a < b){
				if(b < c){
					System.out.println("Yes");
				}
				else{
					System.out.println("No");
				}
			}
			else{
				System.out.println("No");
			}
		}
		catch(IOException e){
			System.out.println(e);
		}
	}
}

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

bool isPrime(int X) {
    bool ok = true;
    if (X == 2) {
        return ok;
    }
    else {
        int rootX = pow(X, 0.5) + 1;
        for (int i = 2; i <= rootX; i++) {
            if (X % i == 0) ok = false; 
        }
        return ok;
    }
}

int main() {
    int X;
    cin >> X;
    while (true) {
        if (isPrime(X)) {
            cout << X << endl;
            break;
        }
        X ++;
    }
    return 0;
} 

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

int main() {
  long long N, P;
  std::cin >> N >> P;
  std::string S;
  std::cin >> S;

  std::vector<long long> m(N + 1, -1); // m[i] = S[i, N) % p
  m[N] = 0;
  long long pow = 1;
  for (long long i = N; i > 0; --i) {
    pow = pow * 10 % P;
    m[i - 1] = (m[i] + pow * (S[i - 1] - '0')) % P;
  }

  if (P == 2 || P == 5) {
    long long res = 0;
    for (long long r = 1; r <= N; ++r) {
      if ((S[r - 1] - '0') % P == 0)
        res += r;
    }
    std::cout << res << std::endl;
    return 0;
  }

  std::vector<long long> count(P, 0);
  for (long long i = 0; i < N + 1; ++i)
    count[m[i]] += 1;

  long long res = 0;
  for (long long p = 0; p < P; ++p) {
    if (count[p] < 1)
      continue;
    res += count[p] * (count[p] - 1) / 2;
  }
  std::cout << res << std::endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << string(b, '0'+a);
    }else {
        cout << string(a, '0'+b);
    }
    puts("");
    return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=2*10e5+5;
ll n,m,s,a[MAX_N],cnt[MAX_N];

int main(){
  cin >> n;
  a[0]=-1;
  for(int i=1;i<n;++i){
    cin >> a[i];
    ++cnt[a[i]-1];
  }
  for(int i=0;i<n;++i){
    cout << cnt[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 6700
#include<iostream>
using namespace std;
int main(){
	string s;
	int a[26]={};
	while(getline(cin,s)){
	for(int i=0;i<s.size();i++){
		if(s[i]-'A'<=26){
			s[i]+=32;
		}
		for(int j=0;j<26;j++){
			if(s[i]-'a'==j){
				a[j]++;
			}
		}
	}
}
	for(int i=0;i<26;i++){
		cout<<(char)('a'+i)<<" : "<<a[i]<<endl;
}
	return 0;
}



Measured memory_bytes: 3156
from sys import exit
l,r=map(int,input().split())
res=10000000000000
for i in range(l,r):
	for j in range(i+1,r+1):
		a=(i*j)%2019
		if a==0:
			print("0")
			exit()
		else:
			res=min(res,a)
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 14 , Mod = 998244353 , G = 3 , INF = 0x3f3f3f3f;
double PI = acos(-1);

struct Virt{
    double x , y;
    Virt(double _x = 0.0 , double _y = 0.0):x(_x) , y(_y){}
};

Virt operator + (Virt x , Virt y){return Virt(x.x + y.x , x.y + y.y);}
Virt operator - (Virt x , Virt y){return Virt(x.x - y.x , x.y - y.y);}
Virt operator * (Virt x , Virt y){return Virt(x.x * y.x - x.y * y.y , x.x * y.y + x.y * y.x);}

int read(){
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1 ; ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

int H , W;

int marked[N] , match[N];
char s[N][N]; bool book[N];

bool check(){
	memset(marked , 0 , sizeof(marked));
	for(int i = 1 ; i <= W ; i++){
		if(marked[i]) continue;
		for(int j = 1 ; j <= W ; j++){
			if(marked[j] || (i == j)) continue;
			bool flag = true;
			for(int k = 1 ; k <= H ; k++)
				if(s[k][i] != s[match[k]][j]){
					flag = false;
					break;
				}
			if(flag){
				marked[i] = marked[j] = 1;
				break;
			}
		}
	}
	int pos = 0 , cnt = 0;
	for(int i = 1 ; i <= W ; i++)
		if(!marked[i]) cnt++ , pos = i;
	if(cnt >= 2 || (cnt && (W % 2 == 0))) return false;
	if(cnt == 1)
		for(int i = 1 ; i <= H ; i++)
			if(s[i][pos] != s[match[i]][pos])
				return false;
	return true;
}

bool ans;

void dfs(int cnt , int flag){
	if(cnt == ((H + 1) >> 1) + 1){
		if(check())
			ans = true;
		return;
	}
	if(ans) return;
	for(int i = cnt ; i <= H ; i++){
		if(!match[i]){
			for(int j = i + 1 ; j <= H ; j++)
				if(!match[j]){
					match[i] = j; match[j] = i;
					dfs(cnt + 1 , flag);
					match[i] = match[j] = 0;
				}
			if(flag){
				match[i] = i;
				dfs(cnt + 1 , 0);
				match[i] = 0;
			}
		}
	}
}

int main(){
	H = read() , W = read();
	for(int i = 1 ; i <= H ; i++)
		scanf("%s",s[i] + 1);
	if(H & 1) dfs(1 , 1);
	else dfs(1 , 0);
	if(ans) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let a: String = read();
    if a == "SUN" {
        println!("{}", 7);
    } 
    if a == "MON" {
        println!("{}", 6);
    } 
    if a == "TUE" {
        println!("{}", 5);
    } 
    if a == "WED" {
        println!("{}", 4);
    } 
    if a == "THU" {
        println!("{}", 3);
    } 
    if a == "FRI" {
        println!("{}", 2);
    } 
    if a == "SAT" {
        println!("{}", 1);
    } 

}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    REP(i,1,n+1){
        if(a[i] == a[i-1]){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

signed main() {
	ll n, ans = 0;
	string s;
	cin >> s;
	n = s.size();
	vector<ll> psum(n+10);
	s = s + "#";
	reverse(begin(s), end(s));
	map<ll, ll> mp;
	psum[0] = 0;
	mp[0] = 1;
	for (ll i=1, ten=1; i<=n; i++, (ten *= 10) %= 2019) {
		psum[i] = psum[i-1] + (s[i] - '0') * ten;
		psum[i] %= 2019;
		ans += mp[psum[i]];
		mp[psum[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5388
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,Q=get_i
s=array(A)
kind_s=Hash.new(0)
num=[]
A.times do|i|
    s[i]=gets.to_i
    num<<s[i]
    kind_s[s[i]]=1
end
t=array(B)
kind_t=Hash.new(0)
B.times do|i|
    t[i]=gets.to_i
    num<<t[i]
    kind_t[t[i]]=1
end
x=array(Q)
Q.times do|i|
  x[i]=gets.to_i
  num<<x[i]
end
exc=Hash.new(-1)
to=array(num.size)
num.sort.each_with_index do|v,i|
  exc[v]=i
  to[i]=v
end
n=num.size
info=Array.new(n){[-INF,-INF]}
to.each_with_index do|v,i|
    info[i][0],info[i][1]=info[i-1][0]-1,info[i-1][1]-1 if i.nonzero?
    info[i][0]=0 if kind_s[v]==1
    info[i][1]=0 if kind_t[v]==1
end
(n-2).downto(0) do|i|
    min_i=[0,0]
    min=INF
    if info[i][0]!=-INF and info[i][1]!=-INF
      if info[i][0]>=0 and info[i][1]>=0
          mx=max(info[i][0],info[i][1])+i
          min=to[mx]-to[i]
      elsif info[i][0]<=0 and info[i][1]<=0
          mn=min(info[i][0],info[i][1])+i
          min=to[i]-to[mn]
      else
          mx=max(info[i][0],info[i][1])+i
          mn=min(info[i][0],info[i][1])+i
          min=to[mx]-to[mn]+min((to[i]-to[mx]).abs,(to[i]-to[mn]).abs)
      end
    end
    2.times do|l|
        2.times do|r|
            val=0
            next if l==0 and r==0
            next if info[i+l][0]==-INF or info[i+r][1]==-INF
            if info[i+l][0]+l>=0 and info[i+r][1]+r>=0
                mx=max(info[i+l][0]+l,info[i+r][1]+r)+i
                val=to[mx]-to[i]
            elsif info[i+l][0]+l<=0 and info[i+r][1]+r<=0
                mn=min(info[i+l][0]+l,info[i+r][1]+r)+i
                val=to[i]-to[mn]
            else
                mx=max(info[i+l][0]+l,info[i+r][1]+r)+i
                mn=min(info[i+l][0]+l,info[i+r][1]+r)+i
                val=to[mx]-to[mn]+min((to[i]-to[mx]).abs,(to[i]-to[mn]).abs)
            end
            if val<min
                min=val
                min_i=[l,r]
            end
        end
    end
    info[i][0]=info[i+min_i[0]][0]+min_i[0]
    info[i][1]=info[i+min_i[1]][1]+min_i[1]
end
x.each do|x_|
    i=exc[x_]
    if info[i][0]>=0 and info[i][1]>=0
        mx=max(info[i][0],info[i][1])+i
        puts to[mx]-to[i]
    elsif info[i][0]<=0 and info[i][1]<=0
        mn=min(info[i][0],info[i][1])+i
        puts to[i]-to[mn]
    else
        mx=max(info[i][0],info[i][1])+i
        mn=min(info[i][0],info[i][1])+i
        puts to[mx]-to[mn]+min((to[i]-to[mx]).abs,(to[i]-to[mn]).abs)
    end
end

Measured memory_bytes: 110404
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>

using namespace std;

#pragma GCC oprimize("Ofast")
#define rep(i,a,b) for(__typeof(b)i=a;i<b;++i)

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;

ll n;
ll mem[100010][5];
vl2 l;

ll dp(ll at, ll last)
{
    if(at==n)return 0;
    if(mem[at][last]!=-1)return mem[at][last];
    ll ans = 0;
    if(last!=0)
        ans = max(ans,l[at][0]+dp(at+1,0));
    if(last!=1)
        ans = max(ans,l[at][1]+dp(at+1,1));
    if(last!=2)
        ans = max(ans,l[at][2]+dp(at+1,2));
    return mem[at][last] = ans;
}


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

    memset(mem,-1,sizeof(mem));

	cin >> n;
	l.resize(n,vl(3));
	rep(i,0,n)
	{
		cin >> l[i][0] >> l[i][1] >> l[i][2];
	}
	cout << dp(0,3);
	return 0;
}


Measured memory_bytes: 15872
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
S = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    temp = []
    for _ in range(A):
        temp.append([str(x) for x in input().split()])
        S[i] = temp
ans = 0
for i in range(2 ** N - 1, -1,-1):
    biti = list(bin(i)[2:].zfill(N))
    flag = 0
    for j in range(N):
        if biti[j] == "1":
            for k in S[j]:
                if biti[int(k[0])-1] != k[1]:
                    flag = 1
                    break
        if flag:
            break
    if not flag:    
        biti = np.array(biti)
        ans = max(ans, np.count_nonzero(biti == "1"))
print(ans)

Measured memory_bytes: 12772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int R;
    double ans;
    cin >> R;
    ans = 2 * R * M_PI;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <string>
#include <iostream>
using namespace std;
int N, D; string X, Y;
int main() {
	cin >> N >> X >> D; Y = X;
	for(int i = 0; i < N; i++) {
		if(D == 0) break;
		if(X[i] == '0') {
			Y[i] = '1'; D--;
		}
	}
	for(int i = N - 1; i >= 0; i--) {
		if(D == 0) break;
		if(X[i] == '1') {
			Y[i] = '0'; D--;
		}
	}
	cout << Y << endl;
	return 0;
}

Measured memory_bytes: 3196
import sys
def inpl(): return list(map(int, input().split()))

K, A, B = inpl()
if A+2 >= B or K-A+1 < 2:
    print(1+K)
    sys.exit()
print(A + (K-A+1)//2 * (B-A) + (K-A-1)%2)

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

int main() {
 int N;
 cin >> N;
  vector<string> poll(N);
  for(int i = 0; i < N; i++){
    cin >> poll.at(i);
  }
 sort(poll.begin(), poll.end());
 map<string, int> cnt;
    for (string x : poll) {
    if (cnt.count(x)) {
      cnt.at(x)++;
    } else {
      cnt[x] = 1;
    }
    }
  int max_cnt = 0;
  int count = 0;
  vector<string> max(N);
  for (string x : poll) {
    if (max_cnt < cnt.at(x)) {
      max_cnt = cnt.at(x);
      count = 1;
      max[count-1] = x;
    }
    if (max_cnt == cnt.at(x)) {
      max_cnt = cnt.at(x);
      if(max[count-1] != x){
      count++;
      max[count-1] = x;
      }
    }
  }
  max.resize(count);
  sort(max.begin(), max.end());
  for(int i = 0; i < max.size(); i++){
    cout << max[i] << endl;
  }
}

Measured memory_bytes: 28288
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)%s
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;
int n,k;
ll a[1005];
ll q[1000005];
int main(){
	scanf("%d%d",&n,&k);
	For(i,1,n) scanf("%lld",&a[i]),a[i]+=a[i-1];
	For(i,0,n-1) For(j,i+1,n) q[++*q]=a[j]-a[i];
	ll format=0;
	Rep(i,40,0){
		format+=(1ll<<i);
		int cnt=0;
		For(j,1,*q) if ((q[j]&format)==format) cnt++;
		if (cnt<k) format-=(1ll<<i);
	} 
	printf("%lld\n",format);
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int cnt;

void swap(int i, int j, int *A);

void selectionSort(int *A, int N) {
  int minj, j, i;
  
  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[minj]) {
	minj = j;
      }
    }
    if (i != minj) {
      cnt++;
    }
    swap(i, minj, A);
  }
}

void swap(int i, int j, int *A) {
  int tmp;

  //cnt++;
  tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}

int main() {
  cnt = 0;
  int N, A[100];

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

  selectionSort(A, N);
  
  for (int i = 0; i < N - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[N - 1] << endl;
  cout << cnt << endl;

  return 0;
}
  
  

Measured memory_bytes: 3084
#include<stdio.h>
int min(int a, int b)
{
	return a < b ? a : b;
}
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int N;
	int h[100010];
	int dp[100010] = {0};
	scanf("%d", &N);
	
	for (int i = 1;i <= N;i++)scanf("%d", &h[i]);
	h[0] = h[1];
	for (int i = 2;i <= N;i++)
	{
		/*dp[i-1]から1つジャンプ*/
		int step1 = dp[i - 1] + abs(h[i-1]-h[i]);
		/*dp[i-2]から2つジャンプ*/
		int step2 = dp[i - 2] + abs(h[i - 2] - h[i]);
		dp[i] = min(step1, step2);
	}
	printf("%d", dp[N]);
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n; scanf("%d", &n);
	vi a(n+1);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	vi b(n+1);
	for (int i = n; i > 0; i--) {
		int tmp = 0;
		for (int j = i + i; j <= n; j += i) tmp += b[j];
		if ((tmp & 1) != a[i]) b[i] = 1;
	}

	vi ans;
	for (int i = 1; i <= n; i++)
		if (b[i]) ans.push_back(i);
	printf("%lu\n", ans.size());
	for (int x : ans) printf("%d ", x);
	puts("");
}


Measured memory_bytes: 3064
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

fn solve(sum: i64) -> i64 {
    const MOD: i64 = 1e9 as i64 + 7;
    let mut count = vec![0; sum as usize + 1];
    count[0] = 1;

    for sum in 3..=sum {
        for last_val in 3..=sum {
            count[sum as usize] += count[(sum - last_val) as usize];
            count[sum as usize] %= MOD;
        }
    }
    count[sum as usize]
}

fn main() {
    let mut reader = TokenReader::new();
    let sum = reader.next();

    let res = solve(sum);
    println!("{}", res);
}


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

using namespace std ;

int a , b , k ;

int main ()
{
	scanf("%d%d%d",&a,&b,&k);
	int x=__gcd(a,b);
	int i ;
	for ( i=x ; i>=1 ; i-- )
		if ( x%i==0 ) 
		{
			k--;
			if ( !k ) break;
		}
	printf("%d\n",i);
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

int64 gcd(int64 a, int64 b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

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

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

    cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		//WK変数
		String result = "hon";
		int last = N % 10;

		//演算
		if (last == 3) {
			result = "bon";
		} else if (last == 0 || last == 1 || last == 6 || last == 8) {
			result = "pon";
		}

		//結果出力
		System.out.println(result);
	}
}

Measured memory_bytes: 35704
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	int N;	cin >> N;
	vector<int> X(N), Y(N);
	rep(i, N) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y.begin(), Y.end());
	rep(i, N) {
		if (Y[N / 2] <= X[i]) cout << Y[N / 2 - 1] << endl;
		else cout << Y[N / 2] << endl;
	}
	cout << endl;
}


Measured memory_bytes: 3712
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int main(){
	int a=r,b=r,c=r;
	cout<<b+min(c,a+b+1);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x > i) {
      cout << -1 << endl;
      return 0;
    }
    a.insert(a.begin() + x - 1, x);
  }
  
  for (int i = 0; i < n; i++)
    cout << a[i] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    vector<int> x(3);
    rep(i, 3) cin >> x[i];
    sort(x.begin(), x.end());
    int M = x[2];
    rep(i, 2) {
        M += i;
        if((3*M-x[0]-x[1]-x[2])%2==0) {
            cout << (3*M-x[0]-x[1]-x[2])/2;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import math
from functools import reduce
import itertools
def gcd(*numbers):
    return reduce(math.gcd, numbers)
k = int(input())
a = [i for i in range(1, k+1)]
ans = 0
for v in itertools.combinations_with_replacement(a, 3):
    if len(set(v)) == 1:
        ans += gcd(v[0], v[1], v[2])
    elif len(set(v)) == 2:
        ans += gcd(v[0], v[1], v[2]) * 3
    else:
        ans += gcd(v[0], v[1], v[2]) * 6
print(ans)

Measured memory_bytes: 9584
#include <iostream>
using namespace std;
using ull = unsigned long long;

int main(){
    ull N;
    cin >> N;

    ull temp = N % 11;
    if(temp > 0 && temp <= 6){
        N = N / 11 * 2 + 1;
    }else if(temp == 0){
        N = N / 11 * 2;
    }else{
        N = N / 11 * 2 + 2;
    }

    cout << N << endl;

    return 0;
}


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

int main(){
    int N, Q;
    string S;
    
    cin >> N >> Q;
    cin >> S;

    vector<int> l(Q), r(Q), ac(N+1);

    for(int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
    }

    ac[0]=0;
    for(int i=0; i<N-1; i++){
        if(S[i]=='A' && S[i+1]=='C'){
            ac[i+1] = ac[i]+1;
        }else{
            ac[i+1] = ac[i];
        }
    }
    ac[N]=ac[N-1];

    for(int i=0; i<Q; i++){
        cout << min(ac[r[i]],ac[r[i]-1]) - ac[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,visited[N],p[N];

void solve()
{
    int m;
    cin>>n>>m;

    forn(i,1,m)
    {
    	int a;
    	string s;
    	cin>>a>>s;
    	if(visited[a])continue;
    	else
    	{
    		if(s == "AC")
    		{
    			visited[a] = 1;
    		}
    		else
    		{
    			p[a]++;
    		}
    	}
    }

    int a = 0 , b = 0;

    forn(i,1,n)
    {
    	a+=visited[i];
    	if(visited[i])b+=p[i];
    }
    cout<<a<<" "<<b;

}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

using namespace std;
using ll = long long;

ll solve(int N, vector<int>& as, vector<int>& bs)
{
    ll ans = 0;

    for (int i = 0; i < N; ++i)
    {
        auto k = min(as[i], bs[i]);

        ans += k;
        as[i] -= k;
        bs[i] -= k;

        auto r = min(as[i + 1], bs[i]);

        ans += r;
        as[i + 1] -= r;
        bs[i] -= r;
    }
 
    return ans;
}

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

    int N;
    cin >> N;

    vector<int> as(N + 1), bs(N);

    for (int i = 0; i <= N; ++i)
        cin >> as[i];

    for (int i = 0; i < N; ++i)
        cin >> bs[i];

    auto ans = solve(N, as, bs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4036
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Stack;
 

public class Main{
          
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
                String spl[]=line.split(" ");
                int n=Integer.parseInt(spl[0]),q=Integer.parseInt(spl[1]);
                int[] parent=new int[n];for(int i=0;i<n;i++)parent[i]=i;
                for(int i=0;i<q;i++){
                    line=br.readLine();spl=line.split(" "); int[] ns=new int[3];
                    for(int j=0;j<3;j++) ns[j]=Integer.parseInt(spl[j]);
                    if(ns[0]==0){//UNITE
                        if(parent[ns[1]]!=parent[ns[2]]){int tmp=parent[ns[1]];
                            for(int k=0;k<n;k++){
                                if(parent[k]==tmp)
                                    parent[k]=parent[ns[2]];
                            }
                        }
                       // System.out.println(Arrays.toString(parent));
                    }else{//Print
                        if(parent[ns[1]]==parent[ns[2]])System.out.println("1");
                        else System.out.println("0");
                    }
                }
                
             }
         }catch(Exception e){e.printStackTrace();}         
     }  
     
     
}

Measured memory_bytes: 64436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll tmp;cin>>tmp;tmp--;
    rep(i,n-1){
        ll h;cin>>h;
        if(tmp>h){
            cout<<"No"<<endl;
            return 0;
        }
        if(tmp<=h-1)tmp=h-1;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<sstream>
#include<map>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int maxcnt=30;
int p2[maxn],p5[maxn];
int num2[maxcnt],num5[maxcnt];
map<pair<int,int>,int> num;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s,t;
        cin>>s;
        int p=-1;
        for(int j=0;j<(int)s.length();j++)
            if(s[j]=='.')
            {
                p=j;
                break;
            }
        if(p!=-1)
        {
            t=s.substr(p+1);
            s=s.substr(0,p);
        }
        while((int)t.length()<9) t+='0';
        s+=t;
        stringstream in(s);
        ll cur;
        in>>cur;
        for(;cur%2==0;cur/=2) p2[i]++;
        for(;cur%5==0;cur/=5) p5[i]++;
        num2[p2[i]]++;
        num5[p5[i]]++;
        pair<int,int> now=make_pair(p2[i],p5[i]);
        if(num.find(now)==num.end())
            num[now]=0;
        num[now]++;
    }
    ll ans=0;
    for(int i1=0;i1<18;i1++)
        for(int i2=0;i1+i2<18;i2++)
        {
            if(i1!=i2) ans+=(ll)num2[i1]*num2[i2]+(ll)num5[i1]*num5[i2];
            else ans+=(ll)(num2[i1]-1)*num2[i1]+(ll)(num5[i1]-1)*num5[i1];
        }
    for(int i1=0;i1<18;i1++)
        for(int j1=0;j1<18;j1++)
        {
            pair<int,int> a=make_pair(i1,j1);
            if(num.find(a)==num.end())
                continue;
            for(int i2=0;i1+i2<18;i2++)
                for(int j2=0;j1+j2<18;j2++)
                {
                    pair<int,int> b=make_pair(i2,j2);
                    if(num.find(b)==num.end())
                        continue;
                    if(a!=b) ans-=(ll)num[a]*num[b];
                    else ans-=(ll)(num[a]-1)*num[a];
                }
        }
    ans/=2;
    ans=(ll)n*(n-1)/2-ans;
    cout<<ans<<'\n';
    return 0;
}
/*
5
7.5
2.4
17.000000001
17
16.000000000
 
 
11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001
 */


Measured memory_bytes: 5224
#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;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  unordered_map<int, int> mp;
  REP(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }
  vector<int> v;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    v.push_back(itr->second);
  }
  sort(ALL(v));
  int ans = 0;
  REP(i,(int)v.size() - k){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10312
#include<stdio.h>{
int main(){
int a[100][100],n,i,j,x,y;
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<n+1;i++){
for(j=0;j<n+2;j++){
if(i<n && j>0 && j<n+1){
a[i][j]=0;
}
}
}
x=n/2+1,y=n/2+1;
a[x][y]=1;
x++,y++;
for(i=2;i<=n*n;){
while(1){
if(y==n+1){
y=1;
}
else if(y==0){
y=n;
}
else if(x==n){
x=0;
}
else if(a[x][y]!=0){
x++,y--;
}
else{
a[x][y]=i;
i++;
x++,y++;
break;
}
}
}
for(i=0;i<n;i++){
for(j=1;j<n+1;j++){
if(a[i][j]>99){
printf(" %d",a[i][j]);
}
else if(a[i][j]>9){
printf("  %d",a[i][j]);
}
else{
printf("   %d",a[i][j]);
}
}
printf("\n");
}
}
return 0;
}


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

int main() {
    string s;
    cin>>s;
    string str = "CODEFESTIVAL2016";
    int cnt;
    for (int i = 0; i < str.length(); i++) {
        if (s[i] != str[i]) {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    //std::cout << "Hello, World!" << std::endl;
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)


int main() {
  int N;
  ll a;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) {
    cin >> A[i];
  }

  ll ans=1;
  int cnt=2;
  sort(A.rbegin(),A.rend());
  rep(i,N) {
    if (i==N-1) break;
    if (A[i]==A[i+1]) {
      ans*= A[i];
      cnt--;
      if (cnt==0) {
        cout << ans << endl;
        return 0;
      }
      i++;
      }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(){
		x = y = 0;
	}
	Info(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}
	bool operator<(const struct Info &arg) const{
			return x < arg.x;
	};
	double x,y;
};

int N;

bool compare_y(Info left,Info right){
	return left.y < right.y;
}

Info* info;

double closest_pair(Info* array,int tmp_N){
	if(tmp_N <= 1)return DBL_MAX;

	int mid = tmp_N/2;
	double x = array[mid].x;
	double dist = min(closest_pair(array,mid),closest_pair(array+mid,tmp_N-mid));
	inplace_merge(array,array+mid,array+tmp_N,compare_y);

	vector<Info> V;
	for(int i = 0; i < tmp_N; i++){
		if(fabs(array[i].x-x) >= dist)continue;

		for(int j = 0; j < V.size();j++){
			double dx = array[i].x - V[V.size()-j-1].x;
			double dy = array[i].y - V[V.size()-j-1].y;
			if(dy >= dist)break;
			dist = min(dist,sqrt(dx*dx+dy*dy));
		}
		V.push_back(array[i]);
	}
	return dist;
}

int main(){

	scanf("%d",&N);
	info = (Info*)malloc(sizeof(Info)*N);

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&info[i].x,&info[i].y);
	}

	sort(info,info+N);

	printf("%.7lf\n",closest_pair(info,N));

	return 0;
}



Measured memory_bytes: 7756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int max, min;
		int k[];

		n = sc.nextInt();
		while (n-- != 0) {
			m = sc.nextInt();
			k = new int[m];
			max = Integer.MIN_VALUE;
			min = Integer.MAX_VALUE;
			for (int i = 0; i < m; i++) {
				k[i] = sc.nextInt();
			}
			for (int i = 1; i < m; i++) {
				int t = k[i] - k[i - 1];
				if (0 <= t) {
					max = Math.max(max, k[i] - k[i - 1]);
				} else {
					min = Math.min(min, k[i] - k[i - 1]);
				}
			}

			System.out.print(max == Integer.MIN_VALUE ? 0 : max);
			System.out.print(" ");
			System.out.println(min == Integer.MAX_VALUE ? 0 : -min);
		}
	}
}

Measured memory_bytes: 27400