akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define nooo cout<<"NO\n"
#define yess cout<<"Yes\n"
#define no cout<<"No\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
   string s;
   cin>>s;
   string ans=s.substr(0,3);
   cout<<ans;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string result = "No";
 
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++){
   int a, b;
   int doublet = 0;
   cin >> a >> b;
   
   if(a == b){
     doublet = 1;
   }
    
   vec.at(i) = doublet;
   //cout << "index "<< i << " : " << vec.at(i) << endl;
  }
  
  for(int i = 2; i < n; i++){
    if(vec.at(i) == 1 && vec.at(i-1) == 1 && vec.at(i-2) == 1){
    	result = "Yes";   
    }
  }
 
  cout << result << endl;
 
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(){
  int a,b,c,x,i,j,k,cnt=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(i*500+j*100+k*50==x)
          cnt++;
      }
    }
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
n=int(input())
s=list(map(str,input()))
for i in range(len(s)):
    if ord(s[i])+n>=91:
        s[i]=chr(ord(s[i])+n-90+64)
    else:
        s[i]=chr(ord(s[i])+n)
print(''.join(s))

Measured memory_bytes: 3060
//41
#include<iostream>
#include<string>
#include<vector>

using namespace std;

bool cmp(string a,string b){
  for(int i=0;i<a.size();i++){
    if(a[i]!='?'&&b[i]!='?'&&a[i]!=b[i])return false;
  }
  return true;
}

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    string ps[1024],s[1024],d[1024];
    for(int i=0;i<n;i++){
      cin>>ps[i]>>s[i]>>d[i];
    }
    vector<int> v;
    string sa[1024],da[1024],mb[1024];
    for(int i=0;i<m;i++){
      bool p=false;
      cin>>sa[i]>>da[i]>>mb[i];
      for(int j=0;j<n;j++){
	if(cmp(sa[i],s[j])&&cmp(da[i],d[j])){
	  p=ps[j]=="permit";
	}
      }
      if(p){
	v.push_back(i);
      }
    }
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
      cout<<sa[v[i]]<<' '<<da[v[i]]<<' '<<mb[v[i]]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1532
#include<stdio.h>

int main(){

  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if((r<=x) && (x<=(W-r)) && (r<=y) && (y<=(H-r))){
     printf("Yes\n");
}
	    else printf("No\n");

	    return 0;

	    }

Measured memory_bytes: 1812
#include <iostream>
#include <string>
#include <cctype>
#include <vector>

using namespace std;

typedef string::iterator Iterator;
const int LIMIT = 1<<10;

int number(Iterator &it) {
    int val = 0;
    if(!isdigit(*it)) throw "not a number";
    while(isdigit(*it)) {
        val <<= 1;
        val += *it - '0';
        if(val >= LIMIT) throw "limit over";
        ++it;
    }
    return val;
}

int expression(Iterator &it, bool &operated);
int factor(Iterator &it, bool &operated) {
    if(*it == '(') {
        ++it;
        bool opr = false;
        int val = expression(it, opr);
        if(*it == ')' && opr) {
            ++it;
            return val;
        } else {
            throw "Illegal paren";
        }
    } else {
        return number(it);
    }
    throw "error";
}
int term(Iterator &it, bool &operated) {
    int lhs = factor(it, operated);
    while(*it == '*') {
        ++it;
        lhs *= factor(it, operated);
        if(lhs < 0 || lhs >= LIMIT) throw "limit over";
        operated = true;
    }
    return lhs;
}

int expression(Iterator &it, bool &operated) {
    int lhs = term(it, operated);
    while(*it == '+' || *it == '-') {
        char op = *it;
        ++it;
        if(op == '+') {
            lhs += term(it, operated);
        } else if(op == '-') {
            lhs -= term(it, operated);
        }
        operated = true;
        if(lhs < 0 || lhs >= LIMIT) throw "limit over";
    }
    return lhs;
}

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

    string str;
    cin >> str;
    vector<int> dotpos;
    for(int i = 0; i < str.size(); ++i) {
        if(str[i] == '.') dotpos.push_back(i);
    }
    int allpat = 1;
    for(int i = 0; i < dotpos.size(); ++i) {
        allpat *= 7;
    }
    int ans = -1;
    for(int pat = 0; pat < allpat; ++pat) {
        int tmp = pat;
        string expr(str);
        for(int i = 0; i < dotpos.size(); ++i) {
            int n = tmp % 7;
            tmp /= 7;
            expr[dotpos[i]] = "01+-*()"[n];
        }
        try {
            bool dmy;
            Iterator it = expr.begin();
            int val = expression(it, dmy);
            if(val < 0 || val >= LIMIT) throw "limit over";
            if(it != expr.end()) throw "premature end";
            ans = max(ans, val);
        } catch (const char *msg) {
            //cout << expr << ' ' << msg << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	if(s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0])puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,k;
    cin>>n>>k;
    int ans=1;
    rep(i,n){
        if(ans*2<ans+k)ans*=2;
        else ans+=k;
    }
    cout<<ans<<enl;

    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int mod = 1e9+7;

int32_t main(){

    int ans = 1;

    int n   ;cin >> n;

    for(int x=1;x<=n;x++){
        ans = ((ans%mod) * (x% mod)) % mod;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;

#define N 110000

vector<int> vec[N];
int order[N];
int a[N], pa[N];

void init(int n) {
    memset(order, 0, sizeof(order));
    for (int i = 1; i <= n; ++i) {
        pa[i] = i;
        vec[i].clear();
        vec[i].push_back(a[i]);
    }
}

int findset(int x) {
    return x == pa[x] ? pa[x] : pa[x] = findset(pa[x]);
}

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) == 2) {
        for (int i = 1; i <= n; ++i) scanf("%d",&a[i]);
        init(n);
        while (m--) {
            int u, v;
            scanf("%d%d",&u, &v);
            int x = findset(u);
            int y = findset(v);
            if (x != y) {
                if (vec[x].size() > vec[y].size())  swap(x, y);
                pa[x] = y;
                for (int i = 0; i < vec[x].size(); ++i) {
                    vec[y].push_back(vec[x][i]);
                }
            }
        }
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            int x = findset(i);
            if (!order[x]) { sort(vec[x].begin(), vec[x].end()); order[x] = 1; }
            int p = lower_bound(vec[x].begin(), vec[x].end(), i) - vec[x].begin();
            if (vec[x][p] == i) cnt++;
        }
        printf("%d\n",cnt);

    }
    return 0;
}


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

#define ll long long
#define endl "\n"

ll a[1000005], n, dp[1000005];

ll solve(ll i){
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	if(dp[i]!=-1)	return dp[i];
	if(i+2<n)
		return dp[i]=min(abs(a[i]-a[i+1])+solve(i+1), abs(a[i]-a[i+2])+solve(i+2));
	return dp[i]=abs(a[i]-a[i+1])+solve(i+1);	
}

int main(){
	memset(dp,-1,sizeof dp);
	cin >> n;
	for(ll i=0;i<n;i++)		cin >> a[i];
	cout << solve(0) << endl;
	return 0;
}

Measured memory_bytes: 15292
#coding: utf-8
# n,k = int(input())
# list = list(map(int,input().split()))
# strings = list(map(str, [input() for i in range(amount)]))
import math

n = int(input())
nn = int(math.sqrt(n) // 1)
ans = 0

for i in reversed(range(1,nn+1)):
    # print(i)
    if n % i == 0:
        ans = (i-1)+(n//i-1)
        break

print(ans)


Measured memory_bytes: 2940
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k;
    scanf("%d%d",&n,&k);
    printf("%d\n",ceil(n+k,2));
    return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    string s;
    cin>>s;

    int q;
    cin>>q;

    string front;
    string back;

    bool rev = true;

    while (q--)
    {
        int x;
        cin>>x;

        if (x == 1)
        {
            rev = !(rev);
        }
        else
        {
            int y;
            char c;
            cin>>y>>c;
            if (y == 1)
            {
                if (rev)
                    front += c;
                else
                    back += c;
            }
            else
            {
                if (rev)
                    back += c;
                else
                    front += c;
            }
        }
    }
    reverse(front.begin(), front.end());
    string ans = front+s+back;
    if (rev)
    {
        cout<<ans<<endl;
    }
    else
    {
        reverse(ans.begin(), ans.end());
        cout<<ans<<endl;
    }
}


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

int main(){
	int N,K; cin>>N>>K;
	vector<int> ok(N, 0); // ok=1, ng=0
	rep(i, K){
		int d; cin>>d;
		rep(j, d){
			int a; cin>>a;
			ok[a-1] = 1;
		}
	}
	int ans = 0;
	rep(i, N) if(ok[i] == 0) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 3592
#include <cassert>
#include <cmath>
#include <algorithm>
#include <float.h>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Point {
  double x;
  double y;
  char d;

  Point(double x = -1, double y = -1, char d = 'U') {
    this->x = x;
    this->y = y;
    this->d = d;
  }
};

vector<Point> points;
int N;

double f(double t) {
  double max_y = -10000000000;
  double max_x = -10000000000;
  double min_y = 10000000000;
  double min_x = 10000000000;

  for (int i = 0; i < N; ++i) {
    Point p = points[i];

    switch(p.d) {
      case 'U':
        p.y += t;
        break;
      case 'D':
        p.y -= t;
        break;
      case 'L':
        p.x -= t;
        break;
      case 'R':
        p.x += t;
        break;
    }

    min_y = min(min_y, p.y);
    min_x = min(min_x, p.x);
    max_y = max(max_y, p.y);
    max_x = max(max_x, p.x);
  }

  return (max_y - min_y) * (max_x - min_x);
}

int main() {
  cin >> N;

  double x, y;
  char d;

  for (int i = 0; i < N; ++i) {
    cin >> x >> y >> d;
    points.push_back(Point(x, y, d));
  }

  double left = 0.0;
  double right = 100000000;

  for (int i = 0; i < 200; ++i) {
    double t1 = (left * 2 + right) / 3.0;
    double t2 = (left + right * 2) / 3.0;

    if (f(t1) < f(t2)) {
      right = t2;
    } else {
      left = t1;
    }
  }

  double time = (left + right) / 2.0;
  cout << fixed << setprecision(12) << f(time) << endl;

  return 0;
}


Measured memory_bytes: 4724
#include <stdio.h>
#include <vector>

using namespace std;

int h,w;
int sh,sw,th,tw;
bool flag[1010][1010];
bool mapp[1010][1010];

void dfs(int x, int y, vector< pair<int, int> > &vec){
  //printf("%d %d\n",x,y);
  flag[x][y]=0;
  if (flag[x-1][y] && mapp[x-1][y]) dfs(x-1,y,vec);
  if (flag[x+1][y] && mapp[x+1][y]) dfs(x+1,y,vec);
  if (flag[x][y-1] && mapp[x][y-1]) dfs(x,y-1,vec);
  if (flag[x][y+1] && mapp[x][y+1]) dfs(x,y+1,vec);

  for (int i=-2; i<=2; ++i){
    for (int j=-2; j<=2; ++j){
      if (x+i>0 && x+i<=h && y+j>0 && y+j<=w)
        if (flag[x+i][y+j] && mapp[x+i][y+j])
          vec.push_back({x+i,y+j});
    }
  }

}

int main(){
  scanf("%d%d",&h,&w);
  scanf("%d%d%d%d",&sh,&sw,&th,&tw);
  for (int i=0; i<=h+1; ++i){
    for (int j=0; j<=w+1; ++j){
      flag[i][j] = 1;
      mapp[i][j] = 0;
    }
  }

  vector< pair<int,int> > que;
  que.push_back({sh,sw});

  for (int i=1; i<=h; ++i){
    char st[1010];
    scanf("%s",st);
    for (int j=1; j<=w; ++j){
      if (st[j-1]=='.')
        mapp[i][j] = 1;
    }
  }
  int ans = 0;
  while(1){
    vector< pair<int,int> > que_last( que );
    que.clear();
    for(int i=0; i<que_last.size(); ++i) {
      int x = que_last[i].first, y = que_last[i].second;
      if (flag[x][y] && mapp[x][y])
        dfs(x, y, que);
    }
    if(que.empty() || flag[th][tw]==0)
      break;
    ++ans;
    //printf("%d\n",ans);

  }

  if (flag[th][tw])
    printf("-1\n");
  else
    printf("%d\n",ans);

}

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

using namespace std;

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

  int N,M,V,P; cin>>N>>M>>V>>P;
  vector<int> A(N); for (auto& a : A) cin>>a;
  sort(A.rbegin(), A.rend());
  vector<long> ca(N);
  for (int i = P; i < N; i++) {
    ca[i] = ca[i-1] + A[P-1]-A[i];
  }
  auto is_ok = [&](int n) {
    if (A[n-1]+M < A[P-1])
      return false;
    long buf = long((P-1)+(N-n+1))*M + ca[n-2] + long(A[n-1]+M-A[P-1])*(n-P);
    cerr << n << ": " << buf << endl;
    return buf >= (long)M*V;
  };
  int ok = P, ng = N+1;
  while (ng-ok > 1) {
    auto c = (ok+ng)/2;
    if (is_ok(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }
  cout << ok << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    int n, m; cin>>n>>m;
    char slika[n][m];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
         cin>>slika[i][j];   
        }
    }
    
    int mat[n][m];
    mat[0][0]=1;
    for(int i=1; i<n; i++)
    {
        if(slika[i][0]=='#') mat[i][0]=0;
        else mat[i][0]=mat[i-1][0];
    }
    for(int j=1; j<m; j++)
     {
        if(slika[0][j]=='#') mat[0][j]=0;
        else mat[0][j]=mat[0][j-1];
    }
    
    for(int i=1; i<n; i++)
    {
        for(int j=1; j<m; j++)
        {
            if(slika[i][j]=='#') mat[i][j]=0;
            else mat[i][j]= (mat[i-1][j]+ mat[i][j-1])%1000000007;
        }
    }
    
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
       //     cout<<mat[i][j]<<" ";
        }
     //   cout<<endl;
    }
    cout<<mat[n-1][m-1]<<endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi c(n);
  rep(i, n-1) {
    int a; std::cin >> a;
    c[a-1]++;
  }
  rep(i, n) {
    std::cout << c[i] << "\n";
  }
}


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

bool read(int &x)
{ return scanf("%d", &x) != EOF; }

const int N = 2e5 + 10;

int n;
int a[N];
typedef priority_queue<int, vector<int >, greater<int > > PQ;
PQ pp[N];
queue<int > Q;

void mergex(int &x, int &y){
    if (pp[x].size() < pp[y].size()) swap(x, y);
    while (pp[y].size()){
        pp[x].push(pp[y].top());
        pp[y].pop();
    }
}

main(){
    read(n);
    static vector<int > V;
    for (int i = 1; i <= n; i++) {
        read(a[i]);
        V.push_back(a[i]);
    }
    sort(V.begin(), V.end());
    for (int i = 1; i <= n; i++){
        a[i] = lower_bound(V.begin(), V.end(), a[i]) - V.begin() + 1;
        pp[i].push(a[i]);
        Q.push(i);
    }

    long long ans = 0;
    for (int i = 1; i <= n; i++){
        int init = Q.front();
        Q.pop();
        while (1){
            if (pp[init].size() && pp[init].top() == i) {
                ans += pp[init].size() - 1;
                pp[init].pop();
                if (pp[init].size()) Q.push(init);
                break;
            }
            mergex(init, Q.front());
            Q.pop();
        }
    }
    cout << ans << '\n';
}



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

int main()
{
    std::string s;
    std::cin >> s;
    if((s[0] == 'a' || s[1] == 'a' || s[2] == 'a') && (s[0] == 'b' || s[1] == '\
b' || s[2] == 'b') && (s[0] == 'c'|| s[1] == 'c' || s[2] == 'c')){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

S = []
C = []
for i in range(N):
    a, b = map(int, input().split())
    S.append((a,b))
for i in range(M):
    c, d = map(int, input().split())
    C.append((c,d))
# print(S)
# print(C)

for s in S:
    ans = []
    for i,c in enumerate(C):
        d = abs(s[0] - c[0]) + abs(s[1] - c[1])
        ans.append((d,i))
    ans = sorted(ans)
    min_d = ans[0][0]
    ans_last = []
    for j in ans:
        if j[0] == min_d:
            ans_last.append(j[1]+1)
    print(sorted(ans_last)[0])

Measured memory_bytes: 3064
import math
import sys

N = int(input())
H  = list(map(int,input().split()))

H[0] = H[0] -1
for i in range(1,N):
    if H[i-1] > H[i]: 
        print('No')
        exit(0)
    elif H[i-1] < H[i]:
        H[i] = H[i] -1 
print('Yes')


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

int n, p[10], q[10], per[10];
int a, b;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin>>n;
  for (int i=1; i<=n; ++i) cin>>p[i];
  for (int i=1; i<=n; ++i) cin>>q[i];

  for (int i=1; i<=n; ++i) per[i]=i;
  while (true) {
    bool ok=true;
    for (int i=1; i<=n; ++i) {
      if (per[i]!=p[i]) {
        ok=false;
        break;
      }
    }
    if (ok) break;
    else {
      ++a;
      next_permutation(per+1, per+1+n);
    }
  }

  for (int i=1; i<=n; ++i) per[i]=i;
  while (true) {
    bool ok=true;
    for (int i=1; i<=n; ++i) {
      if (per[i]!=q[i]) {
        ok=false;
        break;
      }
    }
    if (ok) break;
    else {
      ++b;
      next_permutation(per+1, per+1+n);
    }
  }

  cout<<abs(a-b);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std ;
using ll = long long ;

int main(){
	ll r=0,b=0,sum=0 ;
	string s ; cin >> s ;
	sum = s.size() ;
	for(int i=0;i<sum;i++){
		r += (s.at(i)=='0') ;
		b += (s.at(i)=='1') ;
	}
	cout << sum-abs(r-b) << endl ;
}


Measured memory_bytes: 512
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split();
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);
            if(b*2>a)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(a - b * 2);
            }
        }
    }
}

Measured memory_bytes: 27392
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define piii pair<int,pii>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N=1e5+5;
int fa[N][25],ans[N],n,Q,dep[N],d[N],cnt[N],sum[N];
vi v[N],col[N],len[N];
vector<piii> q[N];
void DFS(int now,int fat)
{
	fa[now][0]=fat;
	dep[now]=dep[fat]+1;
	for(int i=0;i<v[now].size();i++)
		if(fat!=v[now][i])
			d[v[now][i]]=d[now]+len[now][i],DFS(v[now][i],now);
}
int lca(int x,int y)
{
	if(dep[x]>dep[y])swap(x,y);
	for(int i=0;dep[x]<dep[y];i++)
		if(((dep[y]-dep[x])>>i)&1)
			y=fa[y][i];
	if(x==y)return x;
	for(int i=19;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
void dfs(int now,int fat)
{
	for(int i=0;i<q[now].size();i++)
		if(q[now][i].F>0){
			ans[q[now][i].F]+=d[now]+cnt[q[now][i].S.F]*q[now][i].S.S-sum[q[now][i].S.F];
		}else{
			ans[-q[now][i].F]-=2*(d[now]+cnt[q[now][i].S.F]*q[now][i].S.S-sum[q[now][i].S.F]);
		}
	for(int i=0;i<v[now].size();i++)
	{
		int to=v[now][i];
		if(to==fat)continue;
		cnt[col[now][i]]++;
		sum[col[now][i]]+=len[now][i];
		dfs(to,now);///////
		cnt[col[now][i]]--;
		sum[col[now][i]]-=len[now][i];
	}
}
int main()
{
	cin>>n>>Q;
	for(int i=0;i<n-1;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		v[a].pb(b);
		v[b].pb(a);
		col[a].pb(c);
		col[b].pb(c);
		len[a].pb(d);
		len[b].pb(d);
	}
	DFS(1,0);
	for(int i=1;i<20;i++)
		for(int j=1;j<=n;j++)
			fa[j][i]=fa[fa[j][i-1]][i-1];
	for(int i=1;i<=Q;i++)
	{
		int a,b,x,y;
		cin>>a>>b>>x>>y;
		q[x].pb(mp(i,mp(a,b)));
		q[y].pb(mp(i,mp(a,b)));
		q[lca(x,y)].pb(mp(-i,mp(a,b)));
	}
	dfs(1,0);
	for(int i=1;i<=Q;i++)cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 42552
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vll ans;

void construct(ll a, ll b, ll l, ll r) {
  if (r - l == 1) {
    ans[l] = a, ans[r] = b;
    return;
  }
  ll mid = (l + r) / 2;
  ll x = __builtin_ctz(a^b);
  ll xa = ((a>>(x+1))<<x) + (a & ((1<<x)-1));
  ll xb = ((b>>(x+1))<<x) + (b & ((1<<x)-1));
  construct(xa, xa^1, l, mid);
  construct(xa^1, xb, mid+1, r);
  for (ll i=l; i<=mid; i++) ans[i] = ((ans[i]>>x)<<(x+1)) + (a & (1<<x)) + (ans[i] & ((1<<x)-1));
  for (ll i=mid+1; i<=r; i++) ans[i] = ((ans[i]>>x)<<(x+1)) + (b & (1<<x)) + (ans[i] & ((1<<x)-1));
}

int main() {
  ll n, a, b; cin >> n >> a >> b;
  if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    ans.resize(1LL<<n, 0);
    construct(a, b, 0, ans.size()-1);
    REP(i, ans.size()) {
      cout << ans[i];
      if (i != ans.size()-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2048
S = input().strip()
N = len(S)
MOD = 10**9+7
dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1
mul = 1

for i in range(N):
    x = S[i]
    for j in range(13):
        if x == '?':
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
                dp[i + 1][(j * 10 + k) % 13] %= MOD
        else:
            n = int(x)
            dp[i + 1][(j * 10 + n) % 13] += dp[i][j]
            dp[i + 1][(j * 10 + n) % 13] %= MOD

print(dp[N][5] % MOD)



Measured memory_bytes: 61788
package main

import (
	"fmt"
	"math"
)

var a, b, h int

func main() {
	fmt.Scan(&a, &b, &h)
	fmt.Println((a + b) * h / 2)
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


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

using namespace std;

int main() {
    int n, k, p = 0, value;
    vector<int> f;
    cin>> n;
    cin>> k;

    while (n){
        cin>> value;
        f.push_back(value);
        n--;
    }
    sort(f.begin(), f.end());
    for(int i = 0; i < k; i++)
        p += f[i];
    cout<< p;
    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			int sum = 0;
			
			for(int i=0;i<=n;i++){
				if(i!=0)sum+=a/b;
				a = (a%b)*10;
			}
			System.out.println(sum);
			
		}
	}
}

Measured memory_bytes: 20068
class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[2], dice[1], dice[3], dice[4] ]
    @bottom = dice[5]
  end

  def roll(action)
    b = @bottom
    u = @top
    case action
    when "N"
      @top   = @side[2]
      @bottom  = @side[0]
      @side[2] = b
      @side[0] = u
    when "E"
      @top   = @side[3]
      @bottom  = @side[1]
      @side[3] = b
      @side[1] = u
    when "S"
      @top   = @side[0]
      @bottom  = @side[2]
      @side[0] = b
      @side[2] = u
    when "W"
      @top   = @side[1]
      @bottom  = @side[3]
      @side[1] = b
      @side[3] = u
    end
  end

  def aaaaa(sub)
    i = 0
    while true
      if south == sub.south
        4.times do
          if all_num == sub.all_num
            puts "Yes"
            return
          end
          roll("E")
        end
      end
      if i > 6
        puts "No"
        return
      elsif i == 3
        roll("E")
        roll("N")
      else
        roll("N")
      end
      i += 1
    end
  end

  def top
    @top
  end

  def bottom
    @bottom
  end

  def north
    @side[0]
  end

  def east
    @side[1]
  end

  def south
    @side[2]
  end

  def west
    @side[3]
  end

  def all_num
    [@top, @bottom, @side[2], @side[1], @side[3], @side[4]]
  end
end

d = Dice.new(gets.split.map(&:to_i))
sub = Dice.new(gets.split.map(&:to_i))

d.aaaaa(sub)

Measured memory_bytes: 6128
from collections import Counter

N, *A = map(int, open(0).read().split())

ctr = Counter(A)
c0 = 0
c1 = 0
for v in ctr.values():
    if v % 2 == 0:
        c0 += 1
    else:
        c1 += 1

print(c1 + c0 - c0 % 2)


Measured memory_bytes: 61880
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}

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

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input
int N;
vector<int> d(100050);

//processing



//dpTable
//int dp[100050];

int main(){
    cin >> N;
    rep(i,N){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    cout << d.at(N / 2 - 1) - d.at(N / 2) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b-a-b+1 << endl;
    return 0;
}


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

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

using namespace std;
using ll = long long;

map<ll,ll> prime_factor(ll);

int main()
{
    ll N,ans=0;
    cin>>N;

    map<ll,ll> m = prime_factor(N);
    for(auto p : m){
        int n=1;
        while(p.second >= (n+1)*(n+2)/2){n++;}
        ans+=n;
    }
    cout << ans << endl;

    return 0;
}


map<ll,ll> prime_factor(ll n)
{
    map<ll,ll> res;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n /=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

bool visited[60][60];
char G[60][60];
int shortest[60][60];
int main() {
    int H,W;
    int cnt_white=0;
    cin >> H >> W;

    rep(i,H){
        rep(j,W){
            cin >> G[i][j];
            if(G[i][j]=='.')
                cnt_white++;
        }
    }
    queue<P> q;
    q.push(P(0,0));
    visited[0][0]=true;
    Fill(shortest,0);
    while(!q.empty()){
        int h=q.front().first, w=q.front().second;
        q.pop();
        for(int i=0; i<4; i++){
            int nh=h+dy[i], nw=w+dx[i];
            if(nh>=0 && nh<H && nw>=0 && nw<W
               && !visited[nh][nw] && G[nh][nw]=='.'){
                q.push(P(nh,nw));
                visited[nh][nw]=true;
                shortest[nh][nw]=shortest[h][w]+1;
            }
        }
    }
    
    if(shortest[H-1][W-1]!=0) {
        cout << cnt_white - shortest[H - 1][W - 1] - 1 << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s[3];
	s[0] = "Sunny";
	s[1] = "Cloudy";
	s[2] = "Rainy";
	string inp;
	cin >> inp;
	for(int i = 0 ; i < 3 ; i ++){
		if(s[i] == inp){
			cout << s[(i + 1)%3];
			return 0;
		}
	}
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ_console
{
    class _1_3_C
    {
        static void Main()
        {
            while (true)
            {
                string[] buff = Console.ReadLine().Split(' ');
                if (buff[0] == "0" && buff[1] == "0")break;
                Console.WriteLine(buff.Select(x => int.Parse(x)).OrderBy(x => x).Aggregate("", (ans, x) => ans + x.ToString() + " ").Trim());
            }
        }
    }
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const ll mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while(cin >> n){
        int cont[n+5] = {};
        f1(n){
            cin >> cont[i];
        }
        f1(n){
            if(cont[i]>cont[i-1]){
                cont[i]--;
            }
        }
        fr(i,2,n+1){
            if(cont[i]<cont[i-1]){
                cout<<"No"<<endl;
                exit(0);
            }
        }
        cout << "Yes" << endl;
    }
}

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

using namespace std;

bool comppair(pair<int,int> p1,pair<int,int> p2){
    return p1.second<p2.second;
}

int main(){
    int N,M,a,b,res,amax;
    
    scanf("%d%d",&N,&M);
    vector<pair<int, int> > vp(M);
    
    for(int i=0;i<M;i++){
        scanf("%d%d",&a,&b);
        vp[i]=make_pair(a,b);
    }

    sort(vp.begin(),vp.end(),comppair);
    
    res = 1;
    amax = vp[0].second;
    for(int i=1;i<M;i++){
        if(amax<=vp[i].first){
            res++;
            amax = vp[i].second;
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)

	as := make([]int, n)
	sum := 0

	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
		sum += as[i]
	}

	avg := sum / n
	rem := sum % n
	ans := 0

	if rem == 0 {
		for _, v := range as {
			ans += (v - avg) * (v - avg)
		}
	} else {
		off := 0
		up := 0

		for _, v := range as {
			off += (v - avg) * (v - avg)
			up += (v - (avg + 1)) * (v - (avg + 1))
		}

		if up < off {
			ans = up
		} else {
			ans = off
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N,W,H;

struct Info{
	Info(){
		left = right = top = bottom = Area = 0;
	}
	void set(int arg_left,int arg_right,int arg_top,int arg_bottom,int arg_Area){
		left = arg_left;
		right = arg_right;
		top = arg_top;
		bottom = arg_bottom;
		Area = arg_Area;
	}
	bool operator<(const struct Info &arg) const{
			return Area > arg.Area;
	};

	int left,right,top,bottom,Area;
};

struct Point{
	int row,col;
};

int calcArea(int left,int right,int top,int bottom){
	return (right-left)*(bottom-top);
}

Point calcCutPoint(Info tmp,int num){
	Point point;

	num %= 2*((tmp.right-tmp.left)+(tmp.bottom-tmp.top));

	if(num <= (tmp.right-tmp.left)){
		point.row = tmp.top;
		point.col = tmp.left+num;
	}else if(num <= (tmp.right-tmp.left)+(tmp.bottom-tmp.top)){
		point.row = tmp.top+(num-(tmp.right-tmp.left));
		point.col = tmp.right;
	}else if(num <= 2*(tmp.right-tmp.left)+(tmp.bottom-tmp.top)){
		point.row = tmp.bottom;
		point.col = tmp.right-(num-((tmp.right-tmp.left)+(tmp.bottom-tmp.top)));
	}else{
		point.row = tmp.bottom-(num-(2*(tmp.right-tmp.left)+(tmp.bottom-tmp.top)));
		point.col = tmp.left;
	}

	return point;
}

int main(){

	int id,num;
	Point point;

	priority_queue<Info> Q;

	vector<Info> V;


	while(true){
		scanf("%d %d %d",&N,&W,&H);
		if(N == 0 && W == 0 && H == 0)break;

		V.clear();
		Info first;
		first.set(0,W,0,H,H*W);

		V.push_back(first);

		for(int new_id = 1; new_id <= N; new_id++){
			scanf("%d %d",&id,&num);
			id--;

			point = calcCutPoint(V[id],num);

			Info new_info_1,new_info_2;

			if(point.col == V[id].left || point.col == V[id].right){

				new_info_1.set(V[id].left,V[id].right,V[id].top,point.row,calcArea(V[id].left,V[id].right,V[id].top,point.row));
				new_info_2.set(V[id].left,V[id].right,point.row,V[id].bottom,calcArea(V[id].left,V[id].right,point.row,V[id].bottom));

			}else{

				new_info_1.set(V[id].left,point.col,V[id].top,V[id].bottom,calcArea(V[id].left,point.col,V[id].top,V[id].bottom));
				new_info_2.set(point.col,V[id].right,V[id].top,V[id].bottom,calcArea(point.col,V[id].right,V[id].top,V[id].bottom));

			}

			V.erase(V.begin()+id);

			if(new_info_1.Area <= new_info_2.Area){

				V.push_back(new_info_1);
				V.push_back(new_info_2);
			}else{
				V.push_back(new_info_2);
				V.push_back(new_info_1);
			}
		}

		for(int i = 0; i <= N; i++)Q.push(V[i]);

		printf("%d",Q.top().Area);
		Q.pop();

		while(!Q.empty()){
			printf(" %d",Q.top().Area);
			Q.pop();
		}
		printf("\n");
	}

	return 0;
}

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
//global-----------------------------------------------------------------------------------------------------------------------
int n, m;
int ans;
int now;
int a, b;
bool can_continue = false;
//#define DEBUG
//function-------------------------------------------------------------------------------------------------------------------
int main() {
	scanf( "%d", &n );
	scanf( "%d", &m );
	ans = m;
	now = m;
	rep( i, n ) {
		scanf( "%d %d", &a, &b );
		if ( can_continue ) {
			continue;
		}
		now += a - b;
		ans = max( ans, now );
		if ( now < 0 ) {
			can_continue = true;
			ans = 0;
		}
	}
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 1188