akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }

        
  int main(){
      lint n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        --a;--b;--c;--d;
        string s;
        cin>>s;
        if(c<d){
            lint count=0;
            repp(i,b,d){
                if(s[i]=='#')count++;
                else count=0;
                if(count==2){
                    cout<<"No";
                    return 0;
                }
            }
            count=0;
            repp(i,a,c){
                if(s[i]=='#')count++;
                else count=0;
                if(count==2){
                    cout<<"No";
                    return 0;
                }
            }
        }else{
                lint count2=0;
                lint countmax=-INF;
                lint count3=0;
                 repp(i,b-1,d+2){
                if(s[i]=='.')count2++;
                else count2=0;
                countmax=max(countmax,count2);
        }
        if(countmax<3){
            cout<<"No";
            return 0;
        }
        repp(i,a,c){
               if(s[i]=='#')count3++;
                else count3=0;
                if(count3==2){
                    cout<<"No";
                    return 0;
                }
        }
           }
  cout<<"Yes";
  }
  
     
  

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

int main() {
  int target_price,coin_1_num;
  
  cin >> target_price >> coin_1_num;
  
  if (target_price % 500 <= coin_1_num) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int k, x;
    cin >> k >> x;
    for (int i = x - (k - 1); i <= x + (k - 1); ++i) {
        cout << i << " ";
    }
    cout << '\n';
}


Measured memory_bytes: 3588
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

int cnt_digits(llong n)
{
  return (int)(log10(n))+1;
}

void solve()
{
  llong n; cin >> n;
  int ans = cnt_digits(n);

  for (llong i=1; i*i<=n; i++) {
    if (n%i != 0) continue;
    llong b = n/i;
    int cur = max(cnt_digits(i), cnt_digits(b));
    ans = min(ans, cur);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

		int n = sc.nextInt();

		int odd = 0, multiple4 = 0;
		for (int i = 0; i < n; i++)
		{
			int x = sc.nextInt();
			if(x%2 == 1)
				odd++;
			if(x%4 == 0)
				multiple4++;
		}
		if((odd <= multiple4 + 1 && odd+multiple4 == n))
			System.out.println("Yes");
		else
			if(odd > multiple4 )
				System.out.println("No");
			else
				System.out.println("Yes");
	}
	static class Scanner{
		StringTokenizer st;BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException 
		{while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}
}


Measured memory_bytes: 37788
/* ex7_1
   urah   */

#include <stdio.h>

// 頂点を表す構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

// 移動させた頂点を返す関数
point shift_point(point coord, int dx, int dy){
    point new_coord;

    new_coord.x_elem = coord.x_elem - dy;
    new_coord.y_elem = coord.y_elem + dx;
    
    return new_coord;
}


int main(void){
    // coordi(i=1,2,3,4)は(xi,yi)を表す
    point coord1, coord2, coord3, coord4;
    // dx = x2-x1, dy = y2 - y1
    int dx, dy;

    // 入力受け取り
    scanf("%d\t%d\t%d\t%d", &coord1.x_elem, &coord1.y_elem, &coord2.x_elem, &coord2.y_elem);

    dx = coord2.x_elem - coord1.x_elem;
    dy = coord2.y_elem - coord1.y_elem;

    coord3 = shift_point(coord2, dx, dy);
    coord4 = shift_point(coord1, dx, dy);

    // 出力
    printf("%d %d %d %d\n", coord3.x_elem, coord3.y_elem, coord4.x_elem, coord4.y_elem);

    return 0;
}

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

using namespace std;

long long N, A;
const long long INF = 1e13;

long long mul (long long a, long long b)
{
    if (a == 0 || b == 0) return 0;
    if (a > INF / b) return INF;
    return 1LL * a * b;
}

long long f (long long P, int a, int b)
{
    long long ans = 1;
    while (a --)
        ans = mul (ans, P);
    while (b --)
        ans = mul (ans, P + 1);
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%lld %lld", &N, &A);
long long ans = N;
for (int alpha = 0; alpha <= 30; alpha ++)
    for (int beta = 0; beta <= 30; beta ++)
    if (alpha + beta >= 1)
    {
        long long p = 1, u = N, mij, ras;
        while (p <= u)
        {
            mij = (p + u) >> 1;
            if (f (mij, alpha, beta) >= N) ras = mij, u = mij - 1;
            else p = mij + 1;
        }
        long long curr = 1LL * alpha * ras + 1LL * beta * (ras + 1) + 1LL * A * (alpha + beta - 1);
        if (curr < ans)
            ans = curr;
    }
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define mp(a,b) make_pair(a,b)
using namespace std;


int main(){
	int m;
	cin>>m;
	REP(i,0,m){
		set<string> s;
		string str;

		cin>>str;
		REP(j,1,str.size()){
			string left,right,l,r;
			left=str.substr(0,j);
			right=str.substr(j,str.size()-j);
			for(int k=left.size()-1;k>=0;k--){
				l+=left[k];
			}
			for(int k=right.size()-1;k>=0;k--){
				r+=right[k];
			}
			s.insert(left+right);
			s.insert(right+left);
			s.insert(l+right);
			s.insert(right+l);
			s.insert(left+r);
			s.insert(r+left);
			s.insert(l+r);
			s.insert(r+l);
		}
		p(s.size());
	}
	return 0;
}

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;

int da[] = {0, 1, 2}, db[] = {1, 0, 2}, dc[] = {2, 0, 1};

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n, w;
    cin >> n >> w;
    vi W (n), V (n);
    for (i = 0; i < n; ++i)
        cin >> W[i] >> V[i];
    vll dp (w + 1);
    for (i = 0; i < n; ++i)
        for (j = w - W[i]; j >= 0; --j)
            dp[j + W[i]] = max (dp[j + W[i]], dp[j] + V[i]);
    cout << dp[w] << '\n';

    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll L;
	cin >> L;
	vector<bool> sosa;
	while (L > 2) {
		if (L % 2 == 0) {
			L /= 2;
			sosa.push_back(true);
		} else {
			L--;
			sosa.push_back(false);
		}
	}
	reverse(sosa.begin(), sosa.end());
	vector<P> g[21];
	g[1].push_back(P(2, 0));
	g[1].push_back(P(2, 1));
	// dump(sosa.size());
	ll now = 2, v = 2;
	ll l2 = 2;
	for (int i = 0; i < sosa.size(); i++) {
		if (sosa[i]) {
			for (int j = 1; j < now; j++) {
				for (int k = 0; k < g[j].size(); k++) {
					g[j][k].second *= 2;
				}
			}
			l2 *= 2;
			g[now].push_back(P(now + 1, 0));
			g[now].push_back(P(now + 1, 1));
			v += 2;
			now++;
		} else {
			g[1].push_back(P(now, l2));
			v++;
			l2++;
		}
		// dump(l2);
	}
	cout << now << " " << v << endl;
	for (int i = 1; i <= 20; i++) {
		for (int j = 0; j < g[i].size(); j++) {
			cout << i << " " << g[i][j].first << " " << g[i][j].second << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double w=sc.nextInt();
    double h=sc.nextInt();
    int x=sc.nextInt();
    int y=sc.nextInt();
    System.out.print( (w*h/2) );
    if(x*2==w&&y*2==h){
        System.out.println(" 1");
    }else{
        System.out.println(" 0");
    }
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll oo = 0x3f3f3f3f3f3f3f3f;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  vector<int> h(n), dp(n, oo);
  for(auto &x:h) cin >> x;
  
  dp[0] = 0;
  
  for(int i = 1; i < n; ++i)
    for(int j = 1; j <= k; ++j)
      dp[i] = min(dp[i], dp[max(0, i-j)] + abs(h[i] - h[max(0, i-j)]));
  
  cout << dp[n-1] << endl;
  
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define come return
constexpr auto AC = 0;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b)swap(a, b);
	rep(i, a)cout << b;
	cout << endl;
	come AC;
}


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

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

  vector<vector<char>> p(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
          cin >> p.at(i).at(j);
      }
  }
  // top frame
  for (int i = 0; i < W + 2; i++) {
      cout << "#";
  }
  cout << endl;
  // elements
  for (int i = 0; i < H; i++) {
      cout << "#";
      for (int j = 0; j < W; j++) {
          cout << p.at(i).at(j);
      }
      cout << "#" << endl;
  }
  // bottom frame
  for (int i = 0; i < W + 2; i++) {
      cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
set <int> st;

void fx(int digit, int curr){
    if(digit == 1){
        st.insert(curr);
        return ;
    }
    string t = to_string(curr);
    int last = t[t.size()-1] - '0'; 
    fx(digit-1 , curr*10 + last);
    if(last == 9){
        fx(digit-1 , curr*10 + last-1);
    }
    else if(last == 0){
        fx(digit-1 , curr*10 + last+1);
    }
    else{
        fx(digit-1 , curr*10 + last-1);
        fx(digit-1 , curr*10 + last+1);
    }
}

signed main(){
    fast;
    int n; cin >> n;
    int k = 2;
    for(int d = 1 ; d<=11 ; d++){
        for(int i=0; i<=9 ; i++){
            fx(d, i);
        }    
    }
    int t = 0;
    //cout << st.size() << endl;
    for(auto x : st){
        if(t == n){
            cout << x << endl;
            return 0;
        }
        t++;
    }
}


Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k;
    cin>>n;
    m = n/500;
    k = m*1000;
    m = n%500;
    m = m/5;
    m = m*5;
    cout<<m+k<<endl;
}


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

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

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 1e+18
using namespace std;

typedef pair<int,int> P;

signed main(){
	int h,w,d,q;
	P pos[100000];
	vector<int> vec[100000];
	cin >> h >> w >> d;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			int a;
			cin >> a;
			pos[a - 1] = P(i,j);
		}
	}
	for(int i = 0;i < d;i++){
		vec[i].pb(0);
		for(int j = i + d;j < h * w;j += d){
			vec[i].pb(vec[i].back() + abs(pos[j].first - pos[j - d].first) + abs(pos[j].second - pos[j - d].second));
		}
	}
	cin >> q;
	for(int i = 0;i < q;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		cout << vec[b % d][b / d] - vec[a % d][a / d] << endl;
	}
	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


int n;
int num[110000];

int main(){
    n=read();
    memset(num,0,sizeof(num));
    for (int x,i=1;i<=n;i++){
        x=read();
        num[x]++;
        num[x+1]++;
        if (x>0)  num[x-1]++;
    }
    int maxx=0,pos;
    for(int i=0;i<=100000;i++){
        maxx=max(num[i],maxx);
    }
    cout<<maxx<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

string s;
int ans = 0xe869120;
int main() {
	cin >> s;
	for (int i = 0; i != s.size(); ++i)
		s[i] -= '0';
	for (int i = 0; i<= s.size() - 3; ++i) {
		int k = s[i] * 100 + s[i + 1] * 10 + s[i + 2];
		ans = min(ans, abs(753 - k));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  
  int n,k,p[1000];
  int box=0,snap;
  int i,w;
  
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)
    scanf("%d",&p[i]);
  
  for(i=0;i<n;i++){
    for(w=i+1;w<n;w++){
      if(p[i]>p[w]){
        snap=p[w];
        p[w]=p[i];
        p[i]=snap;
      }
    }
  }
  
  for(i=0;i<k;i++)
    box+=p[i];
  
  printf("%d\n",box);
  
  return 0;
}


Measured memory_bytes: 1736
n = int(input())
a =[]
for i in range(1, n+1):
    if i % 3 == 0 or i % 10 == 3 or (i%100)//10 == 3 or (i%1000)//100 == 3 or (i%10000)//1000 == 3:
        a.append(i)
print(' ', end ='')
print(*a)



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

int main()
{
  string S;
  std::cin >> S;
  int buk[3] = {};
  for (char c : S)
  	++buk[c-'a'];
  
  int kyotsu = *min_element(begin(buk), end(buk));
  bool ans = true;
  for (int i = 0; i < 3; ++i)
    ans = ans && ((buk[i] == kyotsu) || (buk[i] == kyotsu + 1));
  
  cout << (ans ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1LL<<31)-1;

template <typename T>
struct RMQ {
    int n;
    vector<T> dat, lazy;
    RMQ(int n_) : n(), dat(n_ * 4, INF), lazy(n_ * 4, INF) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }
 
    /* lazy eval */
    void eval(int k) {
        if (lazy[k] == INF) return;  // 更新するものが無ければ終了
        if (k < n - 1) {             // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = min(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = min(lazy[k * 2 + 2], lazy[k]);
        }
        // 自身を更新
        dat[k] = min(dat[k], lazy[k]);
        lazy[k] = INF;
    }
 
    void update(int a, int b, T x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = min(lazy[k], x);
            eval(k);
        } else if (a < r && l < b) {                     // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, T x) { update(a, b, x, 0, 0, n); }
 
    T query_sub(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return INF;
        } else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        } else {  // 一部区間が被る時
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
 
    /* debug */
    inline T operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < 2 * n - 1; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};

int main(){
    int N,Q; cin >> N >> Q;
    vector<int> S(N),T(N),X(N),D(Q);
    rep(i,N){
        cin >> S[i] >> T[i] >> X[i];
    }
    rep(i,Q){
        cin >> D[i];
    }
    RMQ<int> st(Q);
    rep(i,N){
        int l = S[i]-X[i];
        int r = T[i]-X[i];
        if(r<=0) continue;
        l = max(l,0);
        int a = lower_bound(all(D),l)-D.begin();
        int b = lower_bound(all(D),r)-D.begin();
        st.update(a,b,X[i]);
    }
    rep(i,Q){
        ll res = st.query(i,i+1);
        if(res==INF) res = -1;
        cout << res << endl;
    }
}

Measured memory_bytes: 12748
s = input()

if (s[0] == s[1]):
    if (s[0] != s[2] and s[2] == s[3]):
        print('Yes')
    else:
        print('No')
elif (s[0] == s[2]):
    if (s[0] != s[3] and s[3] == s[1]):
        print('Yes')
    else:
        print('No')
elif (s[0] == s[3]):
    if (s[0] != s[1] and s[1] == s[2]):
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

using namespace std;


int main(int argc, char *argv[]) {
	int N, x;
	cin >> N >> x;

	long ans = 0;
	vector<long> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] > x) {
			ans += a[i] - x;
			a[i] = x;
		}
	}

	for (int i = 1; i < N; i++) {
		if (a[i-1] + a[i] > x) {
			ans += (a[i-1] + a[i]) - x;
			a[i] -= (a[i-1] + a[i]) - x;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		long x[]=new long[11];
		x[0]=sc.nextInt();

		for(int i=1;i<=10;i++){
			x[i]=x[i-1]*r-d;
		System.out.println(x[i]);
		}

	}}

Measured memory_bytes: 21588
import sys


def main():
    n = int(sys.stdin.readline().strip())
    # n = 1000000000000

    dividers = [1]
    for d in range(2, int(n ** 0.5)+1):
        if n % d == 0:
            dividers.append((d))

    divider = dividers[-1]
    ans = (n // divider - 1) + (divider - 1)
    print(ans)


main()


Measured memory_bytes: 38896
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
D=[]
for i in range(M):
    (B,C)=map(int,input().split())
    D.append((C,B))
D.append((0,0))
D.sort(reverse=True)
i=0
j=0
count=0
sum=0
while count<N:
    if A[i]>=D[j][0]:
        sum+=A[i]
        i+=1
        count+=1
    else:
        sum+=D[j][0]*(min(N-count,D[j][1]))
        count+=D[j][1]
        j+=1
print(sum)

Measured memory_bytes: 20992
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int maxn = 100100;


int main(void){
    int n;
    cin >> n;
    ll dp[n];
    REP(i,n+1) dp[i]=INF;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        chmin(dp[i],dp[i-1]+1);
        for(int j=6;j<=i;j*=6){
            chmin(dp[i],dp[i-j]+1);
        }
        for(int j=9;j<=i;j*=9){
            chmin(dp[i],dp[i-j]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4348
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn out(mut head : String, s : String, tail : String, f : bool) {
    head = head.chars().rev().collect();
    let mut ans = head;
    ans.push_str(&s);
    ans.push_str(&tail);

    if f {
        ans = ans.chars().rev().collect();
    }
    println!("{}", ans);
}

fn main() {
    let mut f : bool = false;
    
    let s : String = read();
    let q : usize = read();
    let mut head = String::new();
    let mut tail = String::new();
    
    for _i in 0..q {
        let t : usize = read();
        if t == 1 {
            f = !f;
        }
        else {
            let a : usize = read();
            let b : String = read(); 
            if (a == 2) ^ f {
                tail.push_str(&b);
            }
            else {
                head.push_str(&b);
            }
        }
        //out(head.clone(), s.clone(), tail.clone(), f.clone());
    }
    out(head.clone(), s.clone(), tail.clone(), f.clone());
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    int ans = N;
    vector<bool> data(N, false);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        if (H.at(A - 1) < H.at(B - 1)) {
            if (!data.at(A - 1)) {
                ans--;
                data.at(A - 1) = true;
            }
        }
        else if (H.at(A - 1) > H.at(B - 1)) {
            if (!data.at(B - 1)) {
                ans--;
                data.at(B - 1) = true;
            }
        }
        else if (H.at(A - 1) == H.at(B - 1)) {
            if (!data.at(A - 1)) {
                ans--;
                data.at(A - 1) = true;
            }
            if (!data.at(B - 1)) {
                ans--;
                data.at(B - 1) = true;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
S = list(input())

before_tile = S[0]

ans = 0
for i in range(1, len(S)):
    if S[i] == before_tile:
        ans += 1
        if S[i] == "0":
            S[i] = "1"
        else:
            S[i] = "0"
    before_tile = S[i]

print(ans)


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int A, B, C; cin >> A >> B >> C;
	int D = A + B + C;
	if (D >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long N; cin >> N;
	long A[100009]; for (int i = 1; i <= N + 1; i++) cin >> A[i];
	long B[100009]; for (int i = 1; i <= N; i++) cin >> B[i];
	long res = 0;

	for (int i = 1; i <= N; i++) {
		res += min(A[i], B[i]);
		B[i] -= min(A[i], B[i]);
		res += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
	}

	cout << res << endl;
}

Measured memory_bytes: 1792
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

h,w=nii()
ch,cw=nii()
dh,dw=nii()
s=[list(input()) for i in range(h)]

ch-=1
cw-=1
dh-=1
dw-=1

ans=[[-1 for i in range(w)] for i in range(h)]
ans[ch][cw]=0

que=deque()
que.append((ch,cw))

while que:
  y,x=que.popleft()

  if y==dh and x==dw:
    print(ans[y][x])
    exit()

  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    ny=y+dy
    nx=x+dx
    if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#':
      que.appendleft((ny,nx))
      s[ny][nx]='#'
      ans[ny][nx]=ans[y][x]

    for i in range(-2,3):
      for j in range(-2,3):
        ny=y+i
        nx=x+j
        if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and ans[ny][nx]==-1:
          que.append((ny,nx))
          ans[ny][nx]=ans[y][x]+1

print(-1)

Measured memory_bytes: 136172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(vector<long long> M, vector<long long> D){
	if (D[1] == 1) cout << "1" << endl; else cout << "0" << endl;
}

int main(){	
	vector<long long> M(2-1+1);
	vector<long long> D(2-1+1);
	for(int i = 0 ; i <= 2-1 ; i++){
		scanf("%lld",&M[i]);
		scanf("%lld",&D[i]);
	}
	solve(M, D);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int ans = 0;

	cin >> S;

	rep(i, 6) if (S[i] == '1') ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);
        var c     = long.Parse(spl[2]);

        c = Math.Min(c, a+b+1);

        return c + b;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }

}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        var sum = 0;
        for (int i = 1; i <= N; i++)
        {
            if (i.ToString().Length % 2 == 0)
            {
                i = i * 10 - 1;
                continue;
            }
            sum++;
        }

        Console.WriteLine(sum);
    }
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N, K;
    cin >> N >> K;
    vll Po, Ne;
    for(i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if(a >= 0) {
            Po.push_back(a);
        } else {
            Ne.push_back(a);
        }
    }
    sort(Po.rbegin(), Po.rend());
    sort(Ne.begin(), Ne.end());
    if(Po.size() == 0) {
        ll ans = 1;
        if(K % 2 == 0) {
            for(i = 0; i < K; i++) {
                ans = ans * abs(Ne[i]) % MOD;
            }
        } else {
            for(i = 0; i < K; i++) {
                ans = ans * abs(Ne[Ne.size() - 1 - i]) % MOD;
            }
            ans *= -1;
            ans += MOD;
        }
        cout << ans << endl;
        return 0;
    }
    if(N == K) {
        ll ans = 1;
        for(i = 0; i < Po.size(); i++) {
            ans = ans * Po[i] % MOD;
        }
        for(i = 0; i < Ne.size(); i++) {
            ans = ans * abs(Ne[i]) % MOD;
        }
        if(Ne.size() % 2 == 1) {
            ans *= -1;
            ans += MOD;
        }
        cout << ans << endl;
        return 0;
    }

    vll pselect, nselect;
    ll itp = 0, itn = 0;
    ll ncnt = 0;
    for(i = 0; i < K; i++) {
        if(itp >= Po.size()) {
            nselect.push_back(Ne[itn]);
            itn++;
            ncnt++;
            continue;
        }
        if(itn >= Ne.size()) {
            pselect.push_back(Po[itp]);
            itp++;
            continue;
        }
        if(Po[itp] >= -1 * Ne[itn]) {
            pselect.push_back(Po[itp]);
            itp++;
        } else {
            nselect.push_back(Ne[itn]);
            itn++;
            ncnt++;
        }
    }
    ll psize = Po.size(), nsize = Ne.size();
    if(ncnt % 2 == 1) {
        if(itp >= Po.size()) {
            itp--;
            itn++;
            pselect.pop_back();
            nselect.push_back(Ne[itn]);
        } else if(itn >= Ne.size() || itp == 0) {
            itp++;
            itn--;
            pselect.push_back(Po[itp]);
            nselect.pop_back();
        } else {
            ll prod1 = Po[itp - 1] * Po[itp];
            ll prod2 = Ne[itn - 1] * Ne[itn];
            if(prod1 >= prod2) {
                itp++;
                itn--;
                pselect.push_back(Po[itp]);
                nselect.pop_back();
            } else {
                itp--;
                itn++;
                pselect.pop_back();
                nselect.push_back(Ne[itn]);
            }
        }
    }
    ll ans = 1;
    for(i = 0; i < pselect.size(); i++) {
        ans = ans * Po[i] % MOD;
    }
    for(i = 0; i < nselect.size(); i++) {
        ans = ans * abs(Ne[i]) % MOD;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 2*1e5+10;
const int MAX = 100;
const int MOD = 1e9+7;
const int INF = 1e9 + 5;
int main(){
	int h,w,n; cin >> h >> w >> n;
	if(h > w){	
		int ans = 0, b = 0;
		while(b < n){
			b+=h;
			ans++;
		}
		cout << ans << endl;
	}
	else{
		int ans = 0, b = 0;
		while(b < n){
			b+=w;
			ans++;
		}
		cout << ans << "\n";
	}
 	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    string S;
    cin >> S;
    if ((S[0] >= 'a') && (S[0] <= 'z')) {
        cout << 'a' <<endl;
    }
    else {
        cout << 'A' <<endl;
    }
}


Measured memory_bytes: 3620
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string A;
    cin >> A;
    string ans;
    for(int i = 0; i < 3; i++){
        if(A.at(i) == '9'){
            ans += '1';
        }else if (A.at(i) == '1'){
            ans += '9';
        }else{
            ans += A.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int m = sc.nextInt();
			
			if(m == 0){
				break;
			}
			
			
			int[] numbers = new int[m];
			int[] cards = new int[m];
			
			for(int i = 0; i < m; i++){
				numbers[i] = sc.nextInt();
				cards[i] = sc.nextInt();
			}
			
			
			int[] combs = new int[1001];
			combs[0] = 1;
			
			for(int type = 0; type < m; type++){
				for(int i = 1000; i >= 0; i--){
					if(combs[i] > 0){
						for(int j = 1; j <= cards[type]; j++){
							if((i + j * numbers[type]) <= 1000){
								combs[i + j * numbers[type]] += combs[i];
							}
						}
					}
				}
			}
			
			
			final int n = sc.nextInt();
			
			for(int i = 0; i < n; i++){
				System.out.println(combs[sc.nextInt()]);
			}
		}
		
	}
}

Measured memory_bytes: 12000
let s = stdin.ReadLine()
let k = stdin.ReadLine() |> int64

// 出現回数リストを作る
let f1 (count, before, chunkList) next = 
    match before with 
    | '#' -> 1, next, chunkList // 初期処理
    | x  when x=next -> count+1, next, chunkList
    | _ -> 1, next, (before,count)::chunkList

let appearranceList, (headS, headC), (lastS, lastC) = (s+"#").ToCharArray() |> Seq.fold f1 (0, '#', []) |> fun (_, _, list) -> list |> List.rev, list.Head, list |> List.rev |> List.head

// 端が同じ文字の場合は特殊処理
match appearranceList.Length, headS = lastS with
| 1, _ -> appearranceList |> List.head |> fun (_, i) -> int64 i * k / 2L
| _, false -> appearranceList |> Seq.sumBy (fun (_, i) -> int64 i / 2L) |> (*) k 
| _, true -> 
    appearranceList |> List.tail |> List.rev |> List.tail |> fun x -> (headS, headC + lastC) :: x |> Seq.sumBy (fun (_, i) -> int64 i / 2L) |> (*) (k-1L) //端を除く出現回数
    |>(+) (appearranceList |> Seq.sumBy (fun (_, i) -> int64 i / 2L)) //端の出現回数 
|> stdout.WriteLine

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n, m, a , ans = 0;
	cin >> n >> m;
	priority_queue<ll> que;
	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		que.push(a);
	}
	for(int i = 0; i < m; ++i)
	{
		a = que.top();
		que.pop();
		que.push(a / 2);
	}

	while(!que.empty())
	{
		ans += que.top();
		que.pop();
	}
	cout<< ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 4212
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin >> a >> b >> x;
    
    if(a + x - 1 < b - x + 1){
        for(int i =a;i <= a+x-1;i++){
            cout << i << endl;
        }
        for(int i = b-x+1;i <= b;i++){
                cout << i << endl;
            }
        }
        else{
            for(int i =a;i <= b;i++){
                cout << i << endl;
            }
        }
        return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

ll n,s=100,i;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(n);
    while(1)
    {
    	if (s>=n)
    	{
    		out(i);EL;
    		break;
		}
		else ++i,s+=s/100;
	}
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 3640
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n = int(input())

if is_prime(n):
    print(n -1)
    exit()

ans = n

for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
        temp_1 = n/k
        temp_2 = k
        ans = min(ans,temp_1 + temp_2)

print(int(ans-2))


Measured memory_bytes: 9176
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    ll N = S.size();
    bool isFirst = true;
    if(S[0] == S[N-1]){
        isFirst = N%2==0;
    }
    else{
        isFirst = N%2==1;
    }
    cout << (isFirst ? "First" : "Second") << endstr;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int group[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if(group[x] == group[y])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

int N, Q;
int imos[101010];

int main(){

    cin >> N >> Q;
    char lst = 'S';
    for(int i = 1; i <= N; i++){
        char c;
        cin >> c;
        imos[i] = imos[i - 1];
        if(lst=='A' && c == 'C')imos[i]++;
        lst = c;
    }
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << imos[r] - imos[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
AC = 0
WA = 0
LTE = 0
RE = 0

N = int(input())
for k in range(N):
  i = input()
  if i == "AC":
    AC += 1
  elif i == "WA":
    WA += 1
  elif i == "TLE":
    LTE += 1
  elif i == "RE":
    RE += 1

print("AC x",AC)
print("WA x",WA)
print("TLE x",LTE)
print("RE x",RE)


Measured memory_bytes: 9196
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int n;
vector<vector<int>> g;

int solve(int s = 0, int p = -1) {
	vector<int> v_c;
	for (int c : g[s])
		if (c != p)
			v_c.push_back(solve(c, s));
	sort(v_c.begin(), v_c.end());
	reverse(v_c.begin(), v_c.end());
	int res = 0;
	for (int i = 0; i < v_c.size(); ++i)
		res = max(res, v_c[i] + i + 1);
	return res;
}

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

Measured memory_bytes: 16640