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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 2e6 + 7;
const ll LINF = (ll) 1e16;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;

int n;
ll pref[N], a[N];

ll get_low(int l, int r) {
	return a[r] * (r - l + 1) - (pref[r] - pref[l - 1]);
}

ll get_high(int l, int r) {
	return pref[r] - pref[l - 1] - a[l] * (r - l + 1);
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    }
    /*
    for (int i = 1; i <= n; i++) {
    	pref[i] = pref[i - 1] + a[i];
	}
    for (int i = 1, l = 1, r = 1; i <= n; i++) {
    	while (l < i && get_low(l, i) + get_high(i, r) > n) {
    		if (a[i] - a[l] > a[r] - a[i]) ++l;
    		else --r;
    	}
		while (r <= n && get_low(l, i) + get_high(i, r) <= n) {
    		++r;
    	}
    	cout << i << ' ' << l << ' ' << r - 1 << endl;
    	ans = max(ans, r - l);
    }
    */
	int ans = 0;
    for (int i = 1, r = 1; i <= n; ) {
    	if (a[i] != i) {
    		i++;
    		continue;
    	}
    	r = i;
    	while (r <= n && a[r] == r) ++r;
    	ans += (r - i + 1) / 2;
    	i = r;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int digits(ll n){
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<P>> v(n);
	rep(i,m){
		int p, y;
		cin >> p >> y;
		p--;
		v[p].emplace_back(y, i);
	}
	vector<string> ans(m);
	rep(i,n){
		sort(v[i].begin(), v[i].end());
		rep(j,v[i].size()){
			string id = "";
			rep(k,6-digits(i+1)){
				id += "0";
			}
			id += to_string(i+1);
			rep(k,6-digits(j+1)){
				id += "0";
			}
			id += to_string(j+1);
			ans[v[i][j].second] = id;
		}
	}
	rep(i,m){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 12416
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(ll i=a;i<b;i++)
#define bFor(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll lpow(ll a,ll b){
  ll res=1;
  rep(i,b){
    res*=a;
  }
  cout<<res;
}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll N,M,x,ans=0;
  cin>>N>>M;
  vec a(N,0);
  priority_queue<ll> que;
  rep(i,N){
    cin>>a[i];
    que.push(a[i]);
  }
  rep(i,M){
    x=que.top();que.pop();
    x=x/2;
    que.push(x);
  }
  rep(i,N){
    x=que.top();que.pop();
    ans+=x;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 1000000007;
const int MX = 200005;
int n;
ll a, b, c, u, aa[MX] = {1}, bb[MX] = {1}, ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MD) if(n%2) (res *= b) %= MD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MD;
	invf[n] =  exp(fact[n] ,MD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MD * invf[b] % MD;}
int main(){
	scanf("%d%lld%lld%lld", &n, &a, &b, &c);
	u = exp(a+b, MD-2);
	a = a * u % MD;
	b = b * u % MD;
	setcomb(n*2);
	rep(i,n){
		aa[i+1] = aa[i] * a % MD;
		bb[i+1] = bb[i] * b % MD;
	}
	for(int i = n; i < n*2; i++){
		ans += comb(i-1, n-1) * (aa[n] * bb[i-n] % MD + bb[n] * aa[i-n] % MD) % MD * 100 % MD * u % MD * i % MD;
	}
	printf("%lld\n", ans % MD);
}


Measured memory_bytes: 4992
// すぬけ君の塗り絵
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long LL;

int N,a,b;
vector<pair<int,int>> p;
LL H,W,ans[10];

int main(){
    cin>>H>>W>>N;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        a--; b--;
        for(int x=a;x>=a-2;x--){
            for(int y=b;y>=b-2;y--){
                if(0<=x&&x+2<H&&0<=y&&y+2<W){
                    p.push_back(make_pair(x,y));
                }
            }
        }
    }
    sort(p.begin(),p.end());
    int num=1;
    LL sum=0,box=(H-2)*(W-2);
    for(int i=1;i<p.size();i++){
        if(p[i-1]==p[i]) num++;
        else{
            ans[num]++;
            num=1;
            sum++;
        }
    }
    if(N){
        ans[num]++;
        sum++;
    }
    ans[0]=box-sum;
    for(int i=0;i<=9;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

const ll mod = 1e9+7;

ll modfact(ll n) {
	if(n == 0) return 1;
	return (n * modfact(n-1)) % mod;
}

int main() {
	int N, M;
	cin >> N >> M;
	ll res;
	if(abs(N-M) == 0) {
		res = (2 * modfact(N) * modfact(M)) % mod;
	}
	else if(abs(N-M) == 1) {
		res = (modfact(N) * modfact(M)) % mod;
	}
	else {
		res = 0;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

long long int digit_sum(long long int n){
    long long int result = 0,tmp=n;
    while(tmp!=0){
        result += tmp % 10;
        tmp /= 10;
    }
    return result;
}



int main(){

    long long int a, n, m;
    scanf("%lld%lld%lld", &a, &n, &m);
    long long int result = 0,tmp;
    FOR(i,1,m+1){
        tmp = (long long int)pow(i + a, n);
        if(tmp>m){
            break;
        }else if(tmp==(long long int)pow(digit_sum(tmp)+a,n)){
            result++;
        }
    }
    printf("%lld\n", result);
    return 0;
}



Measured memory_bytes: 3388
# -*- coding: utf-8 -*-

import sys
import os
import pprint

"""???????????£????????????????????¨??????"""

MAX = 100
d = [[None for i in range(MAX)] for j in range(MAX)]

for i in range(MAX):
    for j in range(MAX):
        if i == j:
            d[i][j] = 0
        else:
            d[i][j] = float('inf')


#fd = os.open('GRL_1_C.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

V, E = list(map(int, input().split()))
for i in range(E):
    start, end, weight = list(map(int, input().split()))
    d[start][end] = weight

# floyd
for k in range(V):
    for i in range(V):
        for j in range(V):
            if d[i][k] == float('inf'):
                continue
            elif d[k][j] == float('inf'):
                continue
            else:
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])


negative = False
for i in range(V):
    if d[i][i] < 0:
        negative = True

if negative:
    print('NEGATIVE CYCLE')
else:
    for i in range(V):
        for j in range(V):

            if d[i][j] == float('inf'):
                print("INF", end="")
            else:
                print(d[i][j], end='')
            if j != V - 1:
                print(' ', end='')
            else:
                print('')

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

vector<int> get_leq(int k, bool eq = true) {
    vector<int> res;
    if (eq) res.emplace_back(k);
    while (k) res.emplace_back(k - 1), k -= k & -k;
    return res;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    long long ans = 0;
    for (int mask: get_leq(k)) {
        long long tmp = 0;
        for (int i = 0; i < n; i++) if ((a[i] | mask) == mask) tmp += b[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	char input[11];
	scanf("%s",input);
	int tanda=0;
	int len=strlen(input);
	char a[11]={'\0'};
	int b=0;
	
	for(int i=0;i<len;i++){
		if(input[i]=='0'){
			a[b]='0';
			b++;
		}
		else if(input[i]=='1'){
			a[b]='1';
			b++;
		}
		else if(input[i]=='B'){
			if(b!=0){
				b--;
				a[b]='\0';
			}
		}
	}
	
	printf("%s", a);
	
	return 0;
}

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

using namespace std;
#define MAX_N 100000


 int  par[MAX_N];
 bool  used[MAX_N];

int root(int x){
    if(par[x]==x){
        return x;
    }
    else{
        return par[x] = root(par[x]);
    }
}

bool same(int x,int y){
    return root(x)==root(y);
}

void unite (int x, int y){
    x=root(x);
    y=root(y);
    if(x==y){
        return;
    }
    par[x]=y;
}

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


    for (int i = 0; i < n; i++)
    {
        par[i]=i;
    }
    
    int x,y,z;
    for (int i = 0; i < m; i++)
    {
        cin>>x>>y>>z;
        unite(x,y);
    }
    for (int i = 0; i < n; i++)
    {
        root(i);
    }
    
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        if(used[par[i]]==false){
            used[par[i]]=true;
            ans++;
        }
    }
    
    cout << ans <<endl;
    return(0);
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define llong long long

using namespace std;


bool hantei(string s,int l){

  int h=l/2;
  
  REP(j,l){
    if(s.at(j)==s.at(h)){
      if(h==l-1)return true;
      h++;
    }

    else
      return false; 
  }

  return false;
}


int main(){

  string s;
  cin>>s;

  int l=s.length()-1;
  int sl=s.length()-1;

  REP(i,sl){
    if(l%2!=0)l--;

    else{
      if(hantei(s,l)){
	 cout<<l<<endl;
	 return 0;
	}
      else l--;
    }
  }
  
  return 0;
}


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

const int INF = 1001001001;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1, l = 0;
    {
      int v = 1;
      while (ord[v] == -1) {
        ord[v] = s.size();
        s.push_back(v);
        v = a[v-1];
      }
      c = s.size() - ord[v];
      l = ord[v];
    }
    if (k < l) cout << s[k] << endl;
    else {
      k -= l;
      k %= c;
      cout << s[l+k] << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll H,W;
string s[400];
ll m[400][400];
ll dh[4] = {0,1,0,-1};
ll dw[4] = {1,0,-1,0};

P dfs(ll h, ll w){
    ll A = 0;
    ll B = 0;
    m[h][w] = 1;
    for(int i=0;i<4;i++){
        ll nh = h + dh[i];
        ll nw = w + dw[i];
        if(nh < 0 || nh >= H) continue;
        if(nw < 0 || nw >= W) continue;
        if(s[h][w] == s[nh][nw]) continue;
        if(m[nh][nw] != 0) continue;
        P p = dfs(nh, nw);
        A += p.first;
        B += p.second;
    }
    if(s[h][w] == '#') A++;
    else B++;
    return {A,B};
}

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> s[i];
    ll ans = 0;
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(m[h][w] == 0){
                P p = dfs(h,w);
                ans += p.first * p.second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16768
#include<iostream>
#include<iomanip>
using namespace std;
int main(void){
    float a,b,c,d,e,f,x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
        x=(e*c-b*f)/(a*e-b*d);
        y=(-d*c+a*f)/(a*e-b*d);
        if(x==0)x=0;
        if(y==0)y=0;
        cout<<fixed<<setprecision(3)<<x<<" "<<fixed<<setprecision(3)<<y<<endl;
        }
        return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,m,a,b,c,d[100005] = {};
string s,t;

int main(){
    
    IN n;

    P(800*n - 200*(n/15));
    
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    string s, t;
    cin >> s >> t;
    int n=s.length(), m=t.length();

    vector<string> v;
    REP(i, n){
        bool f=1;
        REP(j, m){
            if(i+j>=n || (s[i+j]!=t[j] && s[i+j]!='?')){
                f=0;
            }
        }

        if(f){
            string str="";
            REP(j, i){
                if(s[j]!='?'){
                    str+=s[j];
                }
                else{
                    str+='a';
                }
            }
            str+=t;
            int j=0;
            while(i+m+j<n){
                if(s[i+m+j]!='?') str+=s[i+m+j];
                else str+='a';
                j++;
            }
            v.pb(str);
        }
    }

    if(v.size()==0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    SORT(v);
    cout << v[0] << endl;
}

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

int main(){
int A, B, N;
vector<vector<int>> vec_a(3, vector<int>(3));
vector<vector<char>> vec_b(3, vector<char>(3, 'x'));


for(int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
        cin >> vec_a[i][j];
    }
}
cin >> N; 
for (int k = 0; k < N; k++){
    cin >> B;
    for(int i =0; i < 3; i++){
        for(int j =0; j < 3; j++){

            if(B == vec_a[i][j]){
               vec_b[i][j] = 'o'; 
            }
        }
    }
}

if(vec_b[0][0]=='o' && vec_b[0][1]=='o' && vec_b[0][2]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[1][0]=='o' && vec_b[1][1]=='o' && vec_b[1][2]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[2][0]=='o' && vec_b[2][1]=='o' && vec_b[2][2]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[0][0]=='o' && vec_b[1][0]=='o' && vec_b[2][0]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[0][1]=='o' && vec_b[1][1]=='o' && vec_b[2][1]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[0][2]=='o' && vec_b[1][2]=='o' && vec_b[2][2]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[0][0]=='o' && vec_b[1][1]=='o' && vec_b[2][2]=='o'){
    cout << "Yes" <<endl;
}
else if(vec_b[0][2]=='o' && vec_b[1][1]=='o' && vec_b[2][0]=='o'){
    cout << "Yes" <<endl;
}
else{
cout << "No"<< endl;
}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

struct UnionFind{
    
    vector<int> M_par;
    vector<int> M_rank;
    vector<int> M_size;

private:
    void init(int n = 1){
        M_par.resize(n);
        M_rank.resize(n);
        M_size.resize(n);
        for(int i = 0; i < n; i++){
            M_par[i] = i;
            M_rank[i] = 0;
            M_size[i] = 1;
        }
    }

public:

    UnionFind(size_t n = 1){
        init(n);
    }

    size_t find(size_t x){
        if(M_par[x] == x) return x;
        size_t r = find(M_par[x]);
        return M_par[x] = r;
    }
    
    bool same(size_t x, size_t y){
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(M_rank[x] < M_rank[y]) swap(x, y);
        if(M_rank[x] == M_rank[y]) M_rank[x]++;
        M_par[y] = x;
        M_size[x] = M_size[x] + M_size[y];
        return true;
    }

    size_t size(size_t x){
        return M_size[find(x)];
    }

};

int main() {
  
  
  int n, k, l; cin >> n >> k >> l;
  UnionFind ufA(n);
  UnionFind ufB(n);

  for (int i = 0; i < k; i++) {
    int u, v; cin >> u >> v;
    u--;
    v--;
    ufA.unite(u, v);
  }

  for (int i = 0; i < l; i++) {
    int u, v; cin >> u >> v;
    u--;
    v--;
    ufB.unite(u, v);
  }
  
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; i++) {
    mp[make_pair(ufA.find(i), ufB.find(i))]++;
  }
  for (int i = 0; i < n; i++) {
    cout << mp[make_pair(ufA.find(i), ufB.find(i))] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main()
{
  int n;
  scanf("%d",&n);

  int k;
  scanf("%d",&k);
  vector<int>h(n);
  for(int &x:h)
        scanf("%d",&x);


      vector<int>dp(n,INF);
      dp[0]=0;

  for(int i=0;i<n;i++)
  {
      //for(int j:{i+1,i+2})
      for(int j=i+1;j<=i+k;j++)
        if(j<n)
         dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
  }
  cout<<(dp[n-1]);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

int ans[510][510];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M, Q;
    cin >> N >> M >> Q;
    REP(i, M){
        int l, r;
        cin >> l >> r;
        ans[l][r]++;
    }
    REP(l, N+1)REP(r, N) ans[l][r+1] += ans[l][r];
    REP(r, N+1)for(int l=N; l>=0; l--) ans[l][r] += ans[l+1][r];

    REP(i, Q){
        int l, r;
        cin >> l >> r;
        cout << ans[l][r] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
// author : Amit Kumar
#include <bits/stdc++.h>
using namespace std;
#define _ub upper_bound
#define _lb lower_bound
#define bint long long int
#define _in(x) scanf("%lld",&x)
#define _f first
#define _s second
#define _all(x) x.begin(),x.end()
#define _pb push_back
#define _mp make_pair
#define _iv(v) for(auto &i:v){cin>>i;}
#define _ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define _ovn(v) for(auto i:v){cout<<i<<endl;}
#define _euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define _eovn(v) for(auto i:v){cerr<<i<<endl;}
#define _os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define _osn(s) for(auto itr:s){cout<<itr<<endl;}
#define _eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define _eosn(s) for(auto itr:s){cerr<<itr<<endl;}
const long long int INF = 10e9+5;
int main(void){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector<bint>dp(n,INF);
	vector<bint>arr(n);
	_iv(arr);
	dp[0] = 0;
	for(int i=0; i<n; ++i){
		for(int j=i+1; j<=i+k ;++j){
			if(j<n){
				dp[j] = min(dp[j],dp[i]+abs(arr[j]-arr[i]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
    return 0;
}


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

using namespace std;

int n, m, k, x[105][105], ta = -1, tb, tc, ti;
bool v[105][105];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= k; i++) {
		scanf("%d", &tc);
		while (tc--) {
			while (min(ta + dx[ti], tb + dy[ti]) < 0 || ta + dx[ti] >= n || tb + dy[ti] >= m || v[ta + dx[ti]][tb + dy[ti]])
				ti = (ti + 1) % 4;
			ta += dx[ti];
			tb += dy[ti];
			x[ta][tb] = i, v[ta][tb] = 1;
		}
	}
	for (int i = 0; i < n ; i++)
		for (int j = 0; j < m; j++)
			printf("%d%c", x[i][j], j == m - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int i=0; i<= (N / R); i++){
    for (int j=0; j<= (N - i * R) / G; j++){
      int k = N - i * R - j * G;
      if (k % B == 0 && k / B >= 0){
        ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,s;
bool ok(int k){
  int sum=0;
  for(int i=n;i>0;i/=k)sum+=i%k;
  return sum==s;
}
signed main(){
  cin>>n>>s;
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  for(int i=2;i*i<=n;i++)
    if(ok(i)){
      cout<<i<<endl;
      return 0;
    }
  int ans=n+1;
  for(int i=1;i*i<=n-s;i++){
    if((n-s)%i==0){
      if(ok(i+1))ans=min(ans,i+1);
      if(ok((n-s)/i+1))ans=min(ans,(n-s)/i+1);
    }
  }
  cout<<(ans==n+1?-1:ans)<<endl;
}

Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := float64(nextInt())
	b := float64(nextInt())

	//税抜き価格の下限と上限を求めてから一致する値を探す
	costALow := int(math.Ceil(a / 0.08))
	costAUpp := int(math.Ceil((a + 1.0) / 0.08))
	costBLow := int(math.Ceil(b / 0.10))
	costBUpp := int(math.Ceil((b + 1.0) / 0.10))
	ans := -1
	for i := costALow; i < costAUpp; i++ {
		for j := costBLow; j < costBUpp; j++ {
			if i == j {
				ans = i
				goto find
			}
		}
	}
    find:
	fmt.Println(ans)
}

Measured memory_bytes: 640
def div_2(cnt, num):
  if num % 2 != 0:
    return cnt
  else:
    cnt += 1
    return div_2(cnt, int(num / 2))

cnt = 0
n = int(input())
a_lst = input().split()
for elem in a_lst:
  cnt = div_2(cnt, int(elem))

print(cnt)

Measured memory_bytes: 3892
// Some Sums

#include <iostream>
#include <cmath>

using namespace std;

int sum_each_digit(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int total;
    for (int i = 1; i <= n; i++) {
        int n = sum_each_digit(i);
        if (a <= n && n <= b) {
            total += i;
        }
    }

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


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

vector <int> arrival_tak , arrival_aoki , indeg;
vector <bool> vis;
vector <vector <int>> g ;

void dfs(int u, vector <int> &arr)
{
    vis[u] = 1;
    //cout << " at "<<u << endl;

    for(auto v : g[u])
    {

        arr[v] = min(arr[v] , arr[u] + 1);
        //cout << " distance to v = "<<v<< " is "<<arr[v]<<endl;
        if(!vis[v] )
        {
            dfs(v, arr);
        }
    }

}


int main()
{
    int n , u , v;
    cin >> n >> u >> v;
    u-- , v--;

    arrival_aoki = vector <int> (n , INT_MAX);
    arrival_tak = vector <int> (n ,INT_MAX);
    vis =  vector <bool> (n, 0);
    g = vector < vector <int> > (n);



    for(int i = 0 ;i < n- 1; i++)
    {
        int a, b ;
        cin >> a>> b;

        a-- , b--;

        g[a].push_back(b);
        g[b].push_back(a);


    }

    arrival_tak[u] = 0;
    arrival_aoki[v] = 0;
    //cout << " tak "<<u << " and " << v<<endl;
    
    dfs(u,arrival_tak);
    //cout << " aoki "<<endl;
    vis =  vector <bool> (n, 0);
    dfs(v , arrival_aoki);

    int mx_dist = INT_MIN;


    for(int i = 0 ; i < n ; i++)
    {
        //cout << " i = "<<i << " "<<arrival_tak[i] << " and "<<arrival_aoki[i] << endl;
        if(arrival_tak[i] < arrival_aoki[i] && arrival_aoki[i] > mx_dist)
        {
            mx_dist = arrival_aoki[i];
        }
    }

    cout << mx_dist  - 1<< endl;


    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int a, b, t;
  cin >> a >> b >> t;
  int ans = t / a * b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3492
while True:
    ABC=list(map(int,input().split(" ")))
    
    if len(ABC)==3 and ABC[0]<=20 and ABC[1]<=ABC[0]:
        break

a=ABC[0]
b=ABC[1]
c=ABC[2]

empty1=a-b
if c-empty1>0:
    empty2=c-empty1
elif c-empty1<=0:
    empty2=0

print(empty2)

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

int main() {
	int n;
	cin >> n;
	bool p = true; // odd = true, even = false
	list<long long> a;
	long long m;
	for(int i = 0; i < n; i++){
		cin >> m;
		i % 2 ? a.push_back(m) : a.push_front(m);
	}
	if(n % 2) a.reverse();
	
	while(n--){
		cout << a.back() << ' ';
		a.pop_back();
	}
	
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int r[N];

int main(){
    string s;
    cin>>s;
    int n=sz(s),cnt=0;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-2]){
            cout<<-1;
            return 0;
        }
        if(s[i]=='1')cnt++;
    }
    if(s[0]=='0' || s.back()=='1'){
        cout<<-1;
        return 0;
    }
    if(cnt<=1){
        for(int i=2;i<=n;i++){
            cout<<"1 "<<i<<endl;
        }
        return 0;
    }
    vector<pii>ans;
    int l=n-1;
    ans.push_back({1,2});
    for(int i=n-1;i>=0;i--){
        r[i]=l;
        if(s[i]=='1'){
            l=i;
        }
    }
    cout<<1<<" "<<2<<endl;
    for(int i=0;i<n-1;){
        for(int j=i;j<r[i] && j+3<=n;j++){
            cout<<i+2<<" "<<j+3<<endl;
        }
        i=r[i];
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll MAX_W=10000000;
const ll INF=999999999;
ll dp[105][100010];

int main(){
    int N,W;
    cin>>N>>W;
    int w,v;
    cin>>w>>v;
    for(int i=1;i<=W;i++){
        if(w>i){
            dp[0][i]=0;
        }else{
            dp[0][i]=v;
        }
    }
    //cout<<dp[0][W]<<endl;
    for(int i=1;i<N;i++){
        cin>>w>>v;
        for(int j=1;j<=W;j++){
            if(j<w){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=max(dp[i-1][j], dp[i-1][j-w]+v);
            }
        }
    }
    cout<<dp[N-1][W]<<endl;
    return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
int a[37];
int b[37][37];
int num[37];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(int j=1;j<=a[i];j++){
            scanf("%d",&b[i][j]);
            num[b[i][j]]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(num[i]==n)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int e;
int main() {
	
	vector<int> ans;
	while (cin >> e, e) {
		int m=1000000;
		for (int i = 0; i <= e; ++i) {
			if (i*i*i > e) break;
			for (int j = 0; j <= e; ++j) {
				if (i*i*i + j * j > e) break;
				if (e - i * i*i - j * j >= 0) m = min(m, i + j + e - i * i*i - j * j);
			}
		}
		ans.push_back(m);
	}
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}
	


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

int main(){
	int n;
	cin>>n;
	int a[n], b[n+1];
	b[0] = 0;
	int c[n], cost = 0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=0;i<n-1;i++)
		cin>>c[i];
	for(int i=0;i<n;i++){
		cost += b[a[i]];
		//cout<<b[a[i]]<<"\n";
		if(i > 0 and a[i]-a[i-1] == 1){
			cost += c[a[i-1]-1];
			//cout<<c[a[i-1]-1]<<"\n";
		}
	}
	cout<<cost;
	return 0;
}

Measured memory_bytes: 256
s1,s2=map(str,input().split())
d={
  "A":0,
  "B":1,
  "C":2,
  "D":3,
  "E":4,
  "F":5
}
if d[s1]>d[s2]:
  print(">")
elif d[s1]<d[s2]:
  print("<")
else:
  print("=")

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        public class DisjointSet
        {
            int[] p, rank;
            public DisjointSet(int n)
            {
                p = new int[n];
                rank = new int[n];
                for (var i = 0; i < n; ++i)
                {
                    p[i] = i;
                    rank[i] = 0;
                }
            }
            public bool same(int x, int y)
            {
                return findSet(x) == findSet(y);
            }
            public void unite(int x, int y)
            {
                link(findSet(x), findSet(y));
            }
            void link(int x,int y)
            {
                if (rank[y] < rank[x])
                { p[y] = x; }
                else
                {
                    p[x] = y;
                    if (rank[x] == rank[y])
                        ++rank[y];
                }
            }
            int findSet(int x)
            {
                if (x != p[x])
                    p[x] = findSet(p[x]);
                return p[x];
            }
        }
 
        static void Main(string[] args)
        {
            var NQ = Sarray();
            var N = NQ[0];
            var Q = NQ[1];
            var uft = new DisjointSet((int)N);
            for(var i=0;i<Q;++i)
            {
                var com = Sarray();
                if (com[0] == 0)//unite
                { uft.unite((int)com[1], (int)com[2]); }
                else//same
                { WriteLine($"{(uft.same((int)com[1], (int)com[2])?1:0)}"); }
            }
        }
    }
}


Measured memory_bytes: 22512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

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

	sort(a, a + N, greater<int>());
	
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < N; i++)
	{
		if (i % 2 == 0)
		{
			Alice += a[i];
		}
		else
		{
			Bob += a[i];
		}

	}
	cout << Alice - Bob;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a, &b);

    if(a==b)
    {
        printf("Draw");
    }
    else if(a==1)
    {
        printf("Alice");
    }
    else if(b==1)
    {
        printf("Bob");
    }
    else if(a>b)
    {
        printf("Alice");
    }
    else{
        printf("Bob");
    }
    return 0;
}


Measured memory_bytes: 1712
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int key = sc.nextInt();
            if (map.containsKey(key)) {
                map.put(key, map.get(key)+1);
            } else {
                map.put(key, 1);
            }
        }
        int ans = 0;
        for (Integer key : map.keySet()) {
            int value = map.get(key);
            if (value == 0) continue;
            if (value > key) {
                ans += value - key;
            } else if(value < key) {
                ans += value;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 61756
#include<bits/stdc++.h>
using namespace std;
int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

	int n ;
    cin >> n ;
    vector<int> A(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());  
  
    int ans = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int b = 0, a = i-1; 
        while( b < a){ 
            if( A[b] + A[a] > A[i]){ 
  
                ans += a - b ;  
  
               a--;   
            } 
            else 
                b++;   
        } 
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], long long int first, long long int last){
    long long int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main() {
    int n,r;
    scanf("%d %d",&n,&r);
    if (n>=10){
        printf("%d\n",r);
    }else{
        r=r+(100*(10-n));
        printf("%d\n",r);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> d(h+1, vector<ll>(w+1));

    d[0][1] = 1;
    for(int i = 2; i <= w; i++)
    {
        d[0][i] = 0;
    }
    using P = pair<int, int>;
    map<int, int> m;
    m.insert(P(0,1));
    m.insert(P(1,1));
    m.insert(P(2,2));
    m.insert(P(3,3));
    m.insert(P(4,5));
    m.insert(P(5,8));
    m.insert(P(6,13));
    m.insert(P(7,21));
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            // left
            if(j-1 >= 1)
            {
                int l = m[j-2];
                int r = m[w-j];
                int x = l * r;
                d[i][j] = (d[i][j] + d[i-1][j-1] * x) % MOD;
            }
            // rignt
            if(j+1 <= w)
            {
                int l = m[j-1];
                int r = m[w-j-1];
                int x = l * r;
                d[i][j] = (d[i][j] + d[i-1][j+1] * x) % MOD;
            }
            // straight
            int l = m[j-1];
            int r = m[w-j];
            int x = l * r;
            d[i][j] = (d[i][j] + d[i-1][j] * x) % MOD;
        }
    }  
    cout << d[h][k] << endl;
}


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

#define lli unsigned long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long X){

    lli sum=100;
    lli cnt=0;

    while(sum<X){
    	LOG(sum);
        cnt++;
        sum = (double)(sum/100.0)*101;
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long X;
    scanf("%lld",&X);
    func(X);
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
void MI(int &a, int v) {a = min(a,v);}
void MA(int &a, int v) {a = max(a,v);}
const int N=2e5, L=20, PL=1<<L;

int l,n,v,pl;
deque<int> len;

void gen(int x[], int nxt[][N], int reach[]) {
    F(k,l) {
        int cur=0;
        F(i,n+1) {
            if (i == n || (i-1 >= 0 && abs(x[i] - x[i-1]) > len[k])) {
                while (cur < i) {
                    nxt[k][cur] = i;
                    cur++;
                }
            }
        }
    }
    F(mask,pl) {
        reach[mask] = 0;
        F(k,l) if (mask & 1<<k)
            MA(reach[mask], nxt[k][reach[mask-(1<<k)]]);
    }
}

void print(int nxt[][N]) {
    F(k,l) {
        cout<<len[k]<<": ";
        F(i,n) cout<<nxt[k][i]<<" \n"[i==n-1];
    }
}

int x[N], rev[N];
int nxt[L][N], pre[L][N], rLeft[PL], rRight[PL];

signed main() {
    cin>>n>>v;
    F(i,n) cin>>x[i], rev[n-1-i] = x[i];
    len = {v};
    int cur = v;
    while (cur) cur/=2, len.push_front(cur);
    l = len.size();
    pl = 1<<l;
    gen(x, nxt, rLeft);
    gen(rev, pre, rRight);
    //P("nxt:"); print(nxt);
    //P("pre:"); print(pre);
    //F(k,pl) cout<<bitset<3>(k)<<":"<<rLeft[k]<<" \n"[k==pl-1];
    int start = pl/2;
    int offer[n+1]; // if you finish at >= i, we can accept a start <= offer[i]
    F(i,n+1) offer[i] = -1;
    F(mleft,start) {
        int le = rLeft[mleft], ri = n - rRight[start-1-mleft];
        //P(le<<" "<<ri);
        MA(offer[ri], le);
    }
    int best = -1;
    cur = 0;
    while (cur < n) {
        int lim = nxt[l-1][cur];
        for (int i=cur; i<=lim; i++)
            MA(best, offer[i]);
        for (int i=cur; i<lim; i++)
            P((cur <= best ? "Possible" : "Impossible"));
        cur = lim;
    }
}

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


int main() {
  string s;
  cin >> s;
  string t = "";
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
    {
      t += '0';
    } else if (s[i] == '1') {
      t += '1';
    } else if (s[i] == 'B' && t == "") {
      continue;
    } else {
      t.pop_back();
    }
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int w, h, d[12][12], ans;

void solve(int x, int y, int c){
	if(ans <= c) return;
	if(20 < ans && ans < INF) return;
	if(x == w && y == h-1){
		chmin(ans, c);
		return ;
	}
	if(x == w){
		y ++;
		x = 0;
	}
	if(d[y][x] != 1) solve(x+1, y, c);
	if(ans <= c) return;
	if(20 < ans && ans < INF) return;
	if(d[y][x] != 0){
		int r = 1;
		for(;;r++){
			int f = 1;
			REP(i, r)REP(j, r) if(d[y+i][x+j] == 0) f = 0;
			if(!f) break;
		}
		r --;
		
		// check pruning
		int pos[3][2] = {{y-1,x-1},{y-1,x},{y,x-1}};
		REP(k, 3){
			if(pos[k][0] < 0 || pos[k][1] < 0) continue;
			int f = 1;
			REP(i, r+1)REP(j, r+1) if(d[pos[k][0]+i][pos[k][1]+j] == 0) f = 0;
			if(f) return;
		}
		vector<pii> ch;
		REP(i, r)REP(j, r){
			if(d[y+i][x+j] == 1) ch.push_back(pii(y+i, x+j));
			d[y+i][x+j] = -1;
		}
		if(ch.empty()) return ;
		solve(x+1, y, c+1);
		REP(i, ch.size()) d[ch[i].first][ch[i].second] = 1;
	}
	
}
int main(){
	ios::sync_with_stdio(false);
	while(cin >> w >> h, w){
		memset(d, 0, sizeof(d));
		REP(i, h)REP(j, w) cin >> d[i][j];
		ans = INF;
		solve(0, 0, 0);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1220