akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int MOD = 1e9 + 7;

inline int add(int x, int y){
	int res = x + y;	
	while(res >= MOD)res-=MOD;
	return res;
}

inline int mul(int x,int y){
	return (1LL * x * y) % MOD;
}

int modpow(int x,int p){
	int res = 1;
	while(p){
		if(p&1)gmul(res,x);
		gmul(x,x);
		p/=2;
	}
	return res;
}

inline int invert(int x){
	return modpow(x,MOD - 2);
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,K;
	cin >> n >> K;
	int ans = 0;
	int inf = modpow(10,100);
	int lo=0, hi=0;
	rep(i,0,K-1)gadd(lo, add(inf,i));
	rep(i,0,K-1)gadd(hi, add(inf,n-i));
	rep(k,K,n+2){
		gadd(lo, add(inf,k-1));
		gadd(hi, add(inf,n-(k-1)));
		gadd(ans, add(hi, MOD - lo));
		gadd(ans, 1); 
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    double pi=3.1415926;
    int n;
    cin>>n;
    cout<<pi*2*n;
    return 0;
}

Measured memory_bytes: 3796
n = gets.to_i
a = gets.split.map(&:to_i)
flag = 0
cnt = 0

while flag < n
  (flag..n-1).reverse_each do |i|
    if i == flag then
      break
    end
    v = a[i]
    if v < a[i-1] then
      a[i] = a[i-1]
      a[i-1] = v
      cnt += 1
    end
  end
  flag += 1
end

puts a.join(' ')
puts cnt



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

using namespace std;

#define MAX 10000
#define INFTY 99999999

#define WHITE 0
#define GRAY 1
#define BLACK 2


struct Node {
	vector<int> ch;
	vector<int> co;
};



Node G[MAX];


int n;
int d[MAX];
int p[MAX];
int color[MAX];




void dijkstra(int s)
{
	int u;

	for (int i = 0; i < n; i++) {
		p[i] = -1;
		d[i] = INFTY;
	}

	d[s] = 0;

	while (true) {

		int mincost = INFTY;

		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}

		if (mincost == INFTY) {
			break;
		}

		color[u] = BLACK;

		for (int i = 0; i < G[u].ch.size(); i++) {
			int co = G[u].co[i];
			int ch = G[u].ch[i];

			if (color[ch] != BLACK) {
				if (d[u] + co < d[ch]) {
					d[ch] = d[u] + co;
					p[ch] = d[u];
					color[ch] = GRAY;
				}
			}
		}
	}

}

int main(void)
{
	int u;
	int k;
	int v;
	int c;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			G[u].ch.push_back(v);
			G[u].co.push_back(c);
		}
	}

	dijkstra(0);

	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}

}

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

const int Maxn = 111111;
struct Edge {
	int v;
	Edge *nxt;
} pool[Maxn*2], *tree[Maxn], *tail = pool;
inline void addedge(const int &u, const int &v) {
	tail->v = v;
	tail->nxt = tree[u], tree[u] = tail++;
}

int n, k, a[Maxn];
bool visited[Maxn];
priority_queue<pair<int, int>> heap;

void solve() {
	for (int u; !heap.empty(); ) {
		u = heap.top().second, heap.pop();
		for (Edge *p = tree[u]; p; p = p->nxt) {
			if (!visited[p->v]) {
				a[p->v] = a[u]-1;
				visited[p->v] = true;
				heap.push({a[p->v], p->v});
			} else {
				if (abs(a[p->v]-a[u]) != 1) {
					puts("No");
					return;
				}
			}
		}
	}
	puts("Yes");
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", a[i]);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		addedge(x, y), addedge(y, x);
	}
	scanf("%d", &k);
	for (int x, y; k--; ) {
		scanf("%d%d", &x, &y);
		a[x] = y;
		visited[x] = true;
		heap.push({y, x});
	}
	solve();
	return 0;
}

Measured memory_bytes: 6260
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

sum = 0
even = 0
odd = 0
n.times do |i|
  sum += a[i]
  even += a[i] if i.even?
  odd += a[i] if i.odd?
end
odd += a[0]

ans = []
ans[0] = even*2 - sum
ans[1] = odd*2 - sum

(2..(n-1)).each do |i|
  if i.even?
    even = even - a[i-2] + a[i-1]
    ans[i] = even*2 - sum
  else
    odd = odd - a[i-2] + a[i-1]
    ans[i] = odd*2 - sum
  end
end

puts(ans.join(" "))

Measured memory_bytes: 15116
#include <vector>
#include <stdio.h>
#include <set>


using namespace std;

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

  set<int> s;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    s.insert(a);
  }
  if (s.size() % 2 == 0) {
    printf("%lu\n", s.size() - 1);
  } else {
    printf("%lu\n", s.size());
  }
  return 0;
}



Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 10000000000007 
#define maxn 200005
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;

long long power(int x,int y){
if(y==0)return 1;
long long t=power(x,y/2);
if(y%2==1)return (x*t*t)%Mod;
return (t*t)%Mod;

}
long long gcd(int x,int y){
    // if(y>x)swap(x,y);
    if(y==0)return x;
    return gcd(y,x%y);
}
void solve(){
int n;
  cin>>n;
  if(n==1)cout<<0<<endl;
  else cout<<1<<endl;

}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
  
// test(t)  
 solve();


  


}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    ll p = 0;
    rep(i,n){
        cin >> a[i];
        p ^=a[i];
    }
    rep(j,60){
        if((p>>j)&1){
            rep(i,n){
                if((a[i]>>j)&1){
                    a[i] ^= (1LL<<j);
                }
            }
        }
    }
    rep(i,min(60,n)){
        sort(a.begin(),a.end(),greater<ll>());
        ll c = -1;
        rep(j,60){
            if((a[i]>>j)&1){
                c = j;
            }
        }
        if(c==-1)break;
        rep(j,n){
            if(i!=j){
                if((a[j]>>c)&1){
                    a[j]^=a[i];
                }
            }
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
        
    int m = min(n,60);
    cerr << bitset<60>(p) << endl;
    rep(i,n){
        cerr << bitset<60>(a[i]) << endl;
    }
    ll q = 0;
    rep(i,m){
        q ^=a[i];
    }
    cout << q + (p^q) << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;








public class Main{

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	   int n =fs.nextInt();
	   int a[] = fs.readArray(n);
	   int count=0;
	   for(int i=0;i<n;i+=2) {
		   if(a[i]%2!=0) count++;
	   }
	     System.out.println(count);
	    	
	     
	    	 }

	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32604
#include <iostream>
#include <cctype>

using namespace std;

string Strength[8] = {"000000","0000ff","00ff00","00ffff",
		      "ff0000","ff00ff","ffff00","ffffff"};

string Color[8] = {"black","blue","lime","aqua",
		   "red","fuchsia","yellow","white"};

int x_t(char c){
  if(islower(c)) return 10 + (c - 'a');
  return c - '0';
}

int change(string s){
  return x_t(s[0])*16 + x_t(s[1]);
}

string solve(string R,string G,string B){
  int pos,Min = (1<<29),d;
  int r = change(R),g = change(G),b = change(B);
  string rr,gg,bb;

  for(int i = 0 ; i < 8 ; i++){
    rr = Strength[i].substr(0,2);
    gg = Strength[i].substr(2,2);
    bb = Strength[i].substr(4,2);
 
    int rk = change(rr) ,gk = change(gg) ,bk = change(bb);    
    d = (r-rk)*(r-rk) + (g-gk)*(g-gk) + (b-bk)*(b-bk);

    if(d < Min){
      Min = d;
      pos = i;
    }
  }

  return Color[pos];
}

int main(){
  string str;

  while(cin >> str ,str != "0"){
    string R,G,B;

    R = str.substr(1,2);
    G = str.substr(3,2);
    B = str.substr(5,2);

    cout << solve(R,G,B) << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

const int n = 100000;
const int MOD = 1000000007;
const ll MOD2 = 1000000014000000049LL;

class ModFact {
    int inv[n+1];
    int fact[n+1];
public:
    constexpr ModFact() : fact(), inv() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i <= n; i++) {
            f = f*(i+1)%MOD;
            fact[i+1] = f;
        }
        f = power(f, MOD-2);
        for (int i = n; i >= 0; i--) {
            inv[i] = fact[i] * f % MOD;
            f = f * (i+1) % MOD;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%MOD;
            a = (a*a)%MOD;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}

	int getfact(int n) {
		return fact[n];
	}
    
} fact;

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a += fact[i];
        a = a > MOD ? a - MOD : a;
        ans += a * d;
    }
    printf("%lld\n", ((ans%MOD)*fact.getfact(N-1))%MOD);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,x,i,d=0,c=1;
    scanf("%d%d",&n,&x);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        d=d+a[i];
        if(x>=d){
            c++;
        }
    }
    printf("%d\n",c);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
	char num[] = "ABCDEF";

	char aa;
	char bb;
	scanf("%c %c",&aa,&bb);

	int a = 0;
	int b = 0;
	for(int i = 0; i < 6; i++){
		if(aa == num[i]){
			a = i;
		}
		if(bb == num[i]){
			b = i;
		}
	}
	if(a > b){
		printf(">\n");
	}else if(a == b){
		printf("=\n");
	}else{
		printf("<\n");
	}


	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    ll n,x,q;
    cin>>n>>x>>q;
    map<ll,ll>m,m2;
    vector<string>v;
    for(int i=0;i<q;i++)
    {
        ll d;
        cin>>d;
        m2[d]++;
    }
    for(int i=1;i<=n;i++)
    {
        ll f=m2[i];
        ll ans=x-q+f;
        if(ans>0)
        {
            v.pb("Yes");
        }
        else
        {
            v.pb("No");
        }
        //cout<<f<<endl;
    }
    for(auto x:v)
    {
        cout<<x<<endl;
    }
}


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

int main(void) {
  int a, b;
  char s[11];

  scanf("%d %d", &a, &b);
  scanf("%s", s);

  int count = 0;
  int flag = 1;
  for (int i=0; i<strlen(s); i++) {
    //printf("%c",s[i]);
    if (s[i] == '-') {
      //printf("\n%d == %d\n", count, a);
      if (count != a) {
        flag = 0;
        break;
      }
      count = -1;
    }
    count++;
  }

  if (flag == 1 && count != b) {
    flag = 0;
  }

  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=5e3+100;
int mark[sz];

int main()
{
    Go_
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

    cin>>x;
    if(x==0) cout<<1<<endl;
    else cout<<0<<endl;
    

}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

// ================================================= //


/*
 update : k に xを加算
 query : [s,t) の総和を出力
 */
const ll INIT = 0;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
    }
    
    void update(int k, ll val) {
        k += N - 1;
        node[k] += val;
        while (k) {
            k = (k - 1) / 2;
            //node[k] = node[2 * k + 1] + node[2 * k + 2];
            node[k] += val;
        }
    }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return node[k];
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
    ll rsq(int a, int b) { return query(a, b, 0, 0, N); }
};



int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    SegTree ST(n);
    while(q--){
        int com,x,y; cin >> com >> x >> y;
        if(com == 0){
            ST.update(x-1,y);
        }else{
            cout << ST.rsq(x-1,y) << endl;
        }
    }
    return 0;
}



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

int n, m;
int tmp[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int ok[10] = {};

vector<pair<int, int> > vec;

int ans[1000010];

int keta;

int ma(int ii, int no){
    if(ii >= keta){
        return no;
    }

    for(int i = 9;i >= 0;i--){
        if(ok[i] == 1){
            int c = tmp[i-1]-vec[vec.size()-1].first;
            if(c <= no){
                ans[ii] = i;
                return ma(ii+1, no-c);
            }
        }
    }

    return no;
}

int memo[10] ={};

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

    int a;

    for(int i = 0;i < m;i++){
        cin >> a;
        ok[a] = 1;
        memo[tmp[a-1]] = max(memo[tmp[a-1]], a);
    }

    for(int i = 0;i < 10;i++){
        if(memo[i] != 0){
            vec.push_back(make_pair(i, memo[i]));
        }
    }


    sort(vec.begin(), vec.end(), greater<pair<int, int> >() );

    keta = n / vec[vec.size()-1].first;
    int nkr = n % vec[vec.size()-1].first;


    while(1){
        for(int i = 0;i < keta;i++){
            ans[i] = vec[vec.size()-1].second;
        }

        nkr = ma(0, nkr);
        for(int i = keta-1;i >= 0;i--){
            if(nkr == 0){
                break;
            }

            for(int j = 0;j < vec.size();j++){
                if(vec[j].first-tmp[ans[i]-1] <= nkr){
                    nkr -= vec[j].first-tmp[ans[i]-1];
                    ans[i] = vec[j].second;
                    break;
                }
            }
        }
        if(nkr == 0){
            break;
        }else{
            keta--;
            nkr = n-vec[vec.size()-1].first*keta;
        }
    }


    for(int i = 0;i < keta;i++){
        cout << ans[i];
    }

    cout << endl;

    return 0;
}


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

int max_rainy(const string &s) {
    if (s.empty()) return 0;
    const int sz = s.size();

    int curr = s[0] == 'R' ? 1 : 0;
    int ans = curr;

    for (int i = 1; i < sz; ++i) {
        if (s[i] == 'R') {
            if (s[i - 1] == 'R') {
                ++curr;
            } else {
                curr = 1;
            }
        } else {
            ans = max(curr, ans);
            curr = 0;
        }
    }

    ans = max(ans, curr);

    return ans;
}

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

    string s;
    cin >> s;

    cout << max_rainy(s) << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;
int a[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	cout << max({ max(a * 10 + b,a + b * 10) + c,max(a * 10 + c,a + 10 * c) + b,max(b + c * 10,b * 10 + c) + a }) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Xor Sum 4
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            long[] c = new long[60];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < 60; j++) {
                    c[j] += ((A[i] >> j) & 1);
                }
            }

            long ans = 0;

            for (int j = 0; j < 60; j++) {
                ans = (ans + ((1L << j) % 1000000007) * ((N - c[j]) * c[j] % 1000000007)) % 1000000007;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 101596
#include<iostream>
using namespace std;
int n;
int data[100];
void inp(){
  cin>>n;
  for(int i=0;i<n;++i)cin>>data[i];
}
void proc(int i){
  int key=data[i];
  int j=i-1;
  while(j>=0&&data[j]>key){
    data[j+1]=data[j];
    --j;
  }
  data[j+1]=key;
}
void out(){cout<<data[0];for(int i=1;i<n;++i)cout<<" "<<data[i];cout<<endl;}
int main(){
  inp();
  out();
  for(int i=1;i<n;++i){
    proc(i);
    out();
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <bits/stdc++.h>
 
#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;
 
typedef long long ll;
const ll mod=1e9+7;
 
using pear = pair<int,int>;
 
int main(){
    int n; cin >> n;
    vector <int> b(n-1);
    ll ans = 0;
    rep(i,n-1){
        cin >>b[i];
        if(i == 0) ans += b[i];
        else ans += min(b[i],b[i-1]); 

        if(i == n-2) ans += b[i];
    }
    cout << ans << endl;
}

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

const int INF = 1 << 30;
int N, P, dp[6150];
vector<pair<int, int>> snack;

signed main() {

    for (int i = 0; i < 6150; ++i) dp[i] = -INF;
    dp[0] = 0;

    cin >> N >> P;
    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        snack.emplace_back(A, B);
    }
    sort(snack.begin(), snack.end());

    int res = 0;
    for (auto& s: snack) {
        int A, B;   tie(A, B) = s;
        for (int i = 3049; i >= 0; --i) {
            dp[i + A] = max(dp[i + A], dp[i] + B);
            if (i < P) res = max(res, dp[i] + B);
        }
    }
    cout << res << endl;

}


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


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

    vector<int> R(4010, 0), G(4010, 0), B(4010, 0);
    if(S[0] == 'R') R[0]++;
    if(S[0] == 'G') G[0]++;
    if(S[0] == 'B') B[0]++;
    for(int i=1; i<S.size(); i++){
        R[i] = R[i-1]; if(S[i] == 'R') R[i]++;
        G[i] = G[i-1]; if(S[i] == 'G') G[i]++;
        B[i] = B[i-1]; if(S[i] == 'B') B[i]++;
    }

    Int ans = 0;
    rep(i,N){
        for(int j=i+1; j<N; j++){
            if(S[i] == S[j]) continue;

            if((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')){
                ans += B[N-1] - B[j];
                if(2*j-i < N && S[2*j-i] == 'B') ans--;
            }

            if((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')){
                ans += G[N-1] - G[j];
                if(2*j-i < N && S[j + (j-i)] == 'G') ans--;
            } 
            if((S[i] == 'B' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'B')){
                ans += R[N-1] - R[j];
                if(2*j-i < N && S[j + (j-i)] == 'R') ans--;
            } 
        }
    }
    
    cout << ans << endl;
}

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

int main() {
  int num; cin >> num;
  vector<double> elements(num);
  
  for(int i = 0; i < num; i++) {
    cin >> elements.at(i);
  }
  stable_sort(elements.begin(), elements.end());
  
  double ans = elements.at(0);
  for(int i = 1; i < num; i++) {
   ans = (ans + elements.at(i)) / 2;
  }
  
  cout << ans << endl;
    
  return 0; 
}

Measured memory_bytes: 3712
n,p = map(int,input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i]%=2

a1 = a.count(1)
a0 = a.count(0)

if a1>0:
    print(2**a0*2**(a1-1))
else:
    if p == 1:
        print(0)
    else:
        print(2**a0)




Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    for(int i=0;i<a;i++){
        if(s[i]=='-'){
            cout << "No";
            return 0;
        }
    }
    if(s[a]!='-'){
        cout << "No";
        return 0;
    }
    for(int i=0;i<b;i++){
        if(s[a+1+i]=='-'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";        
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

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

		String A = sc.nextLine();
		String B = sc.nextLine();

		int res = 0;

		if(A.length() != B.length()){
			res = A.length() - B.length();
		}else{
			for(int i = 0;i < A.length();i++){
				int A_num = A.charAt(i) - '0';
				int B_num = B.charAt(i) - '0';

				if(A_num == B_num)continue;
				res = A_num - B_num;
				break;
			}

		}

		if(res > 0){
			System.out.println("GREATER");
		}else if(res < 0){
			System.out.println("LESS");
		}else{
			System.out.println("EQUAL");
		}


		sc.close();

	}

}


Measured memory_bytes: 21716
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k,cnt=0,p=0,r; cin>>n>>k;
    vector<ll> a(n,0);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    map<ll,ll> m;
    rep(i,2*n){
        cnt++;
        if(cnt==k) break;
        if(m.count(a[p])){
            r=cnt-m[a[p]];
            break;
        }
        else m[a[p]]=cnt;
        p=a[p];
    }
    if(cnt!=k) cnt=(k-cnt)/r*r+cnt;
    while(cnt!=k){
        p=a[p];
        cnt++;
    }
    cout<<a[p]+1<<endl;
}

Measured memory_bytes: 14764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  ll n, m, k; cin >> n >> m >> k;
  ll ans = 0;
  rep(i, n) {
    if(i==0) continue;
    (ans += i*m*m%mod*(n-i)%mod) %= mod;
  }
  rep(i, m) {
    if(i==0) continue;
    (ans += i*n*n%mod*(m-i)%mod) %= mod;
  }
  cout << ans * comb(n*m-2, k-2) % mod << endk;
  return 0;
}


Measured memory_bytes: 50416
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define int         long long
    #define pb          push_back
    #define vi          vector<int>
    #define pii         pair<int,int>
    #define all(a)      (a).begin(),(a).end()
    #define ff           first
    #define ss           second
    #define INF         1e10
    const int N = 2000 + 5, K = 21, mod = 1000000007, MOD = 1000000007;  
    
    void solve(){
        string s;
        cin>>s;
        int t = 0, ans = 0;
        for(int i=0; i<3; i++){
            if(s[i]=='R')
                t++;
            else{
                ans = max(ans, t);
                t = 0;
            }
        }
        ans = max(ans, t);
        if(s == "RRR") ans = 3;
        cout<<ans<<endl;
    }      

    int32_t main()
    {
        IOS;
        int TESTS=1;
        // cin>>TESTS;
        while(TESTS--)
        {       
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3652
-- SPDX-License-Identifier: X11
-- 2020-08-23
-- Takoyaki

module Main where

solve :: [Int] -> Int
solve [n,x,t] = (if n `mod` x == 0
                   then n `div` x
                   else n `div` x + 1) * t
solve _ = error "Failure parsing inputs"

parse :: String -> [Int]
parse = map (read :: String -> Int) . words

main :: IO ()
main = getContents >>= \x -> print . solve . parse $ x


Measured memory_bytes: 3888
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w;
    cin >> h >> w;
    vector<int> ct(26, 0);
    int i, j;
    char ch;
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> ch;
            ct[ch - 'a']++;
        }
    }
    int val[5] = {0};
    for(i = 0; i < 26; i++) {
        val[4] += ct[i] / 4;
        val[ct[i] % 4]++;
    }
    val[1] += val[3];
    val[2] += val[3];
    int p, q;
    bool err = false;
    if(h % 2 == 1 && w % 2 == 1) {
        p = h / 2;
        q = w / 2;
        for(i = 0; i < p; i++) {
            if(val[2] > 0) {
                val[2]--;
            }
            else if(val[4] > 0) {
                val[2]++;
                val[4]--;
            }
            else {
                err = true;
            }
        }
        for(i = 0; i < q; i++) {
            if(val[2] > 0) {
                val[2]--;
            }
            else if(val[4] > 0) {
                val[2]++;
                val[4]--;
            }
            else {
                err = true;
            }
        }
        if(val[1] > 0) {
            val[1]--;
        }
        else {
            err = true;
        }
        h--;
        w--;

    }
    else if(h % 2 == 1) {
        q = w / 2;
        for(i = 0; i < q; i++) {
            if(val[2] > 0) {
                val[2]--;
            }
            else if(val[4] > 0) {
                val[2]++;
                val[4]--;
            }
            else {
                err = true;
            }
        }
        h--;
    }
    else if(w % 2 == 1) {
        p = h / 2;
        for(i = 0; i < p; i++) {
            if(val[2] > 0) {
                val[2]--;
            }
            else if(val[4] > 0) {
                val[2]++;
                val[4]--;
            }
            else {
                err = true;
            }
        }
        w--;
    }
    if(h * w != val[4] * 4) {
        err = true;
    }
    if(!err) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int maxn=1e5;
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b==c)||(a!=b&&b!=c&&a!=c)) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		if(h + w >= 10) {
			System.out.println("error");
		} else {
			System.out.println(h + w);
		}
	}

}


Measured memory_bytes: 21844
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		/*Keep summing 1+2+3+4+..., then add leftovers if possible and minimize jumps
		 * 5 can be done in 3... (1: stay, 2: jump, 3: jump)
		 * Find first even N such that 1+2+3..+N is >= X*/
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int X = I.nextInt();
		int ans = 0;
		int sum = 0;
		int add = 1;
		while (sum<X) {
			sum+=add;
			add++;
			ans++;
		}
		O.pln(ans);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25520
// https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/0583
// 最大公約数、約数
// 公約数は最大公約数の約数

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

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

vector<int> divisor(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

void Main()
{
    int n; cin >> n;
    int a[4];
    rep(i, n) cin >> a[i];
    int gcdnum = gcd(a[0], a[1]);
    if (n == 3) {
        gcdnum = gcd(gcdnum, a[2]);
    }
    vector<int> res = divisor(gcdnum);
    sort(res.begin(), res.end());
    rep(i, res.size()) cout << res[i] << endl;
}

int main()
{
	Main();
}



Measured memory_bytes: 3168
function main(input) {
  const formatted_input = input.split('\n');
  const W =  parseInt(formatted_input[0].split(' ')[0]);
  const H =  parseInt(formatted_input[0].split(' ')[1]);
  const w =  parseInt(formatted_input[1].split(' ')[0]);
  const h =  parseInt(formatted_input[1].split(' ')[1]);

  console.log( W*H - (h*W + (H-h)*w) );

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;

int main () {
  cin >> N;

  int i = 1;
  while((i+1)*(i+1) <= N) i++;

  cout << i*i << endl;
  return 0;
}


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

using namespace std;


int main() {
    int n, w, h; cin >> n >> w >> h;
    vector<int> row_vector(w+1, 0), col_vector(h+1, 0);
    for(int i = 0; i < n; ++i) {
        int p_w, p_h, r; cin >> p_w >> p_h >> r;
        int left, right;
        left = max(p_w - r, 0), right = min(p_w+r, w);
        row_vector[left]++;
        row_vector[right]--;
        left = max(p_h - r, 0), right = min(p_h+r, h);
        col_vector[left]++;
        col_vector[right]--;
    }
    int row_flag = 1, col_flag = 1;
    int sum;
    sum = 0;
    for(int i = 0; i < w; ++i) {
        sum += row_vector[i];
        row_vector[i] = sum;
        if(sum <= 0) {
            row_flag = 0;
            break;
        }
    }
    sum = 0;
    for(int i = 0; i < h; ++i) {
        sum += col_vector[i];
        col_vector[i] = sum;
        if(sum <= 0) {
            col_flag = 0;
            break;
        }
    }
    cout << ((row_flag + col_flag)? "Yes" : "No") << endl;
    return 0;
}

// [Problem] Koto Distance
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2600&lang=jp
// 
// imos法
// 区間の重複の数を高速に調べるためのアルゴリズム
// [0, 3]と[2, 5]が与えられたときに,
// [0, 2)は重複1, [2, 3]は重複2, (3, 5]は重複1, それ以外は0
// と答えたいというような問題に使える.
// 簡単の為に各区間が[l, r)の形であるものだけを考えよう. 一見そうでなくてもこの形で表現する方法はあるものはたくさん.
// 
// 位置lの得点を1だけ増やし（＋１し), 位置rの得点を1だけ減らす(-1する).
// この処理を各区間に対して行っておき, 最後に左から順に累積和を取っていけば良い
// そうすると区間に入ると+1, 出ると-1になるから, 累積和として今「入っている」区間の総数が得られる.
// これはまさに区間の重複の数に他ならない.
//
// 本問題では, 行・列それぞれについて芋すほうを適用してみよう
// (行・列を別々に考えるところまではわかったんだけど...)




Measured memory_bytes: 3636
s = list(input())

if s[0] == s[1]:
    print(1,2)
elif len(s) == 2:
    print(-1,-1)
else:
    x, y = s[0], s[1]
    UNBALANCE = False
    for i in range(2, len(s)):
        if x == s[i]:
            print(i-1, i+1)
            UNBALANCE = True
            break
        elif y == s[i]:
            print(i, i+1)
            UNBALANCE = True
            break
        else:
            x, y = y, s[i]
    if not UNBALANCE:
        print(-1,-1)

Measured memory_bytes: 3956
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,i=inpl()
print(N-i+1)


Measured memory_bytes: 4468
D = int(input())

C = list(map(int, input().split()))#下がりやすさ
S = [list(map(int, input().split())) for _ in range(D)]#増加分
#T = [int(input()) for _ in range(D)]#コンテストの開催
Last = [-1] * 26

ans = 0

for i in range(D):
    T = max(S[i])
    t = S[i].index(T)
    #ans += S[i][t]
    #Last[t-1] = i 
    #for k in range(26):
    #    ans -= C[k] * (i - Last[k])
    print(t+1)

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

int n, m, k;
string grid[10];

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    cin >> grid[i];
  int res = 0;
  int la = (1<<n), lb = (1<<m);
  for (int r = 0; r < la; r++) {
    for (int c = 0; c < lb; c++) {
      int tot = 0;
      for (int i = 0; i < n; i++) {
        if ((r>>i) & 1) continue;
        for (int j = 0; j < m; j++) {
          if ((c>>j) & 1) continue;
          if (grid[i][j] == '#') tot++;
        }
      }
      if (tot == k) res++;
    }
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 3604
import sys,math
input=sys.stdin.readline
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(100):
    x=math.cos(2*math.pi*i/100)
    y=math.sin(2*math.pi*i/100)
    ax,ay=0,0
    for dx,dy in xy:
        if x*dx+y*dy>=0:
            ax+=dx
            ay+=dy
    ans=max(ans,(ax**2+ay**2)**0.5)
print(ans)


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

using namespace std;

typedef long long ll;

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

        int n;
        cin>>n;
        int last=-1;
        for(int i=1;i<=n;i++)
        {
                int x;
                cin>>x;
                if(last<=x-1)
                        x--;
                if(last>x)
                {
                        cout<<"No\n";
                        return 0;
                }
                last=x;
        }
        cout<<"Yes\n";

        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	ll k;
	cin >> n >> k;
	map<ll, ll> a;
	ll t, u;
	rep(i, n) {
		cin >> t>>u;
		a[t] += u;
	}

	int ans = 0;
	auto itr = a.begin();
	while (k > 0) {
		k -= itr->second;
		ans = itr->first;
		itr++;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 4224
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())

s=[0]
tot=0
for i in map(int,input().split()):
    tot+=i
    s.append(tot)

d={}
for i in s:
    if i in d:
        d[i]+=1
    else:
        d[i]=1

ans=0
for i,j in d.items():
    ans+=j*(j-1)
print(ans//2)

Measured memory_bytes: 33600
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long LL;

const int mn=1e6+7;
int p[mn],a[20];

void get_prime()
{
	for(int i=2;i<mn;++i) {
		if(!p[i]) p[++p[0]]=i;
		for(int j=1;j<=p[0]&&i*p[j]<mn;++j) {
			p[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}

int main()
{
	LL n,ans=0;
	get_prime();
	scanf("%lld",&n);
	for(int i=1;i<15;++i) a[i]=a[i-1]+i;
	int c=1;
	while(n!=1&&c<=p[0]) {
		if(n%p[c]==0) {
			int cnt=0;
			while(n%p[c]==0) cnt++,n/=p[c];
			for(int i=1;i<15;++i) if(a[i]>cnt) {ans+=i-1;break;}
		}
		c++;
	}
	if(n!=1) ans++;
	cout<<ans;
}

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

const ll INF = 1LL<<60;

int main(){

    ll X; cin >> X;

    ll ans = 0;
    ll money = 100;
    while (true){
        money += money/100;
        ans += 1;
        if (money >= X){
            break;
        }
    }

    cout << ans << endl;
}

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

#define ll long long

const ll MOD = 1e9 + 7;

ll fpow(ll a, ll b) {
    ll ret = 1;
    a %= MOD;
    while (b) {
        if (b & 1) {
            ret = (ret * a) % MOD;
        }
        b /= 2;
        a = (a * a) % MOD;
    }
    return ret;
}

void flip(ll &a, ll &b) {
    swap(a, b);
    b *= -1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    map<pair<ll, ll>, pair<int, int>> cnt;
    ll zr = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && !a[i]) {
            zr++;
            continue;
        }
        ll gc = __gcd(a[i], b[i]);
        a[i] /= gc;
        b[i] /= gc;
        if (b[i] == 0) {
            a[i] = abs(a[i]);
        }       
        if (a[i] < 0 && b[i] < 0) {
            a[i] *= -1;
            b[i] *= -1;
        }
        if (b[i] < 0 && a[i] > 0) {
            a[i] *= -1;
            b[i] *= -1;
        }
        if (a[i] > 0) {
            cnt[make_pair(a[i], b[i])].first++;
        } else {
            flip(a[i], b[i]);
            cnt[make_pair(a[i], b[i])].second++;
        }
    }
    ll ans = 1;
    for (pair<pair<ll, ll>, pair<int, int>> it: cnt) {
        ll pos = fpow(2, it.second.first) - 1;
        ll neg = fpow(2, it.second.second) - 1;
        ans = (ans * ((pos + neg + 1) % MOD)) % MOD;
    }
    ans = (ans + zr) % MOD;
    ans--;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 18668
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

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

      int id = 1, a;
      while (cin >> a)
      {
            if (a == 0) return cout << id, 0;
            id++;
      }
      return 0;
}

Measured memory_bytes: 3660
'''
Created on 2020/09/09

@author: harurun
'''
def main():
  import heapq
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(lambda x: -x ,A))
  heapq.heapify(B)
  for i in range(M):
    t=heapq.heappop(B)
    s=-((-t)//2)
    heapq.heappush(B,s)
  ans=0
  for j in range(N):
    q=heapq.heappop(B)
    ans+=(-q)
  print(ans)
  return
main()

Measured memory_bytes: 20356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int sq = ceil(sqrt(N));

    int min = INT_MAX;
    for (ll i=1; i<=sq; i++) {
        if (N % i == 0) {
            ll w = N / i;
            int s = to_string(w).size();
            min = s < min ? s : min;
        }
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
import heapq
n = int(input())
v = list(map(int, input().split()))
v_heap = []
for i in v:
    heapq.heappush(v_heap, i)
for _ in range(n-1):
    heapq.heappush(v_heap, (heapq.heappop(v_heap)+heapq.heappop(v_heap))/2)
print(heapq.heappop(v_heap))

Measured memory_bytes: 38384