akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

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

    vector<int> cnt;
    for(int i=0; i<n; i++){
        int num=1;
        while(i + 1 < n && s[i] == s[i+1]){
            num++;
            i++;
        }

        cnt.eb(num);
    }

    bool czero;
    if(s[0] == '0') czero = true;
    else czero = false;

    vector<int> sum(n+10, 0);
    for(int i=0; i<cnt.size(); i++){
        sum[i+1] = sum[i] + cnt[i];
    }

    int ans=0;
    for(int i=1; i<=cnt.size(); i++){
        if(czero){
            int ub = sum[min(i+k*2-1, (int)cnt.size())];
            int lb = sum[max(i-2, 0)];

            chmax(ans, ub - lb);

            czero = false;
        }
        else{
            czero = true;
            chmax(ans, sum[i] - sum[i-1]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		Map<Integer, List<Integer>> edges = getEdges(in, n - 1, false);
		long r = solve(n, edges);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n, Map<Integer, List<Integer>> edges) {
		long[][] dp = new long[n + 1][2];
		dfs(edges, dp, 0, 1);
		return add(dp[1][0], dp[1][1]);
	}

	private static void dfs(Map<Integer, List<Integer>> edges, long[][] dp, int par, int cur) {
		List<Integer> children = edges.get(cur);
		if (children == null) {
			dp[cur][0] = 1;
			dp[cur][1] = 1;
		} else {
			for (int i : children) {
				if (i != par) {
					dfs(edges, dp, cur, i);
				}
			}
			dp[cur][0] = 1;
			dp[cur][1] = 1;
			for (int i : children) {
				if (i != par) {
					dp[cur][0] = mul(dp[cur][0], add(dp[i][0], dp[i][1]));
					dp[cur][1] = mul(dp[cur][1], dp[i][0]);
				}
			}
		}
	}

	static long mod = 1000000007;

	static long add(long a, long b) {
		long r = a + b;
		if (r < 0) {
			r += mod;
		}
		return r % mod;
	}

	static long mul(long a, long b) {
		return (a * b) % mod;
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 128824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll cnt = 0;
    rep(i, N - 1){
        ll mi = min_element(A.begin() + i, A.end()) - A.begin();
        if(mi!=i){
            cnt++;
            swap(A[i], A[mi]);
        }
    }

    rep(i, N) cout << A[i] << (i == N - 1 ? '\n' : ' ');
    cout << cnt << endl;
}


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

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

  vector<long long> vec(87);

  vec.at(0) = 2;
  vec.at(1) = 1;

  for(int i = 2;i <= 86; i++){
    vec.at(i) = vec.at(i-1) + vec.at(i-2);
  }

  long long res = vec.at(N);

  // for(int i = 0; i <=86; i++){
  //   cout << vec.at(i) << endl;
  // }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i, ty - sy) cout << 'U';
  rep(i, tx - sx) cout << 'R';
  rep(i, ty - sy) cout << 'D';
  rep(i, tx - sx + 1) cout << 'L';
  rep(i, ty - sy + 1) cout << 'U';
  rep(i, tx - sx + 1) cout << 'R';
  cout << "DR";
  rep(i, ty - sy + 1) cout << 'D';
  rep(i, tx - sx + 1) cout << 'L';
  cout << 'U' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int n,z=0;
vector<P> v[100000];
int y[100000],vz[100000];
bool used[100000];
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
void mutu(int x){
	used[x]=true;
	int zz=1;
	f(i,v[x].size()){
		if(!used[v[x][i].F]){
			if(zz==vz[x])zz++;
			y[v[x][i].S]=zz;
			z=max(z,zz);
			vz[v[x][i].F]=zz;
			mutu(v[x][i].F);
			zz++;
		}
	}
}
signed main(){
	cin>>n;
	f(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back({b,i});
		v[b].push_back({a,i});
	}
	mutu(0);
	cout<<z<<endl;
	f(i,n-1){
		cout<<y[i]<<endl;
	}
	return 0;
}


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

int main() 
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
  ll n,mm=0;cin>>n;
  vector<string>v(n);
  map<string,ll>f;
  for(ll i=0;i<n;i++)
  { cin>>v[i];f[v[i]]++;mm=max(mm,f[v[i]]);}
  sort(v.begin(),v.end());
  for(ll i=0;i<n;i++)
  {
  if(f[v[i]]==mm){cout<<v[i]<<"\n";i=f[v[i]]+i-1;}
  }
 return 0;
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  if (n % 2 == 1) {
    cout<<(n - 1) * (n - 1) / 2 <<endl;
    for (int i=1; i<=n; i++) {
      for (int j=i+1; j<=n; j++) {
        if (i + j == n) {
          continue;
        }
        cout<<i<<" "<<j<<endl;
      }
    }

  } else {
    cout<<n * (n - 2) / 2 <<endl;
    for (int i=1; i<=n; i++) {
      for (int j=i+1; j<=n; j++) {
        if (i + j == n + 1) {
          continue;
        }
        cout<<i<<" "<<j<<endl;
      }
    }
  }

}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N,M,a[100005],m,sum1,sum2;
    string s;
    cin>>N>>M;
    memset(a,0,sizeof(a));
    sum1=sum2=0;
    for(int i=0; i<M; i++)
    {
        cin>>m>>s;
        if(s=="WA"&&a[m]!=-1)
            a[m]++;
        else if(s=="AC"&&a[m]!=-1)
        {
            sum1++;
            sum2+=a[m];
            a[m]=-1;
        }
    }
    cout<<sum1<<' '<<sum2<<endl;
    return 0;
}


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

int main() {
    string s; cin >> s;
    int n = s.size();

    vector<vector<int>> dp(n + 1, vector<int> (3, -1e9));

    dp[0][0] = 0;
    int ans = 0;

    for(int i = 0; i < n; i += 1) {
        for(int j = 0; j <= 2; j += 1) {
            if(dp[i][j] < 0)
                continue;
            for(int k = 1; k <= 2 and i + k <= n; k += 1) {
                if(s.substr(i - j, j) != s.substr(i, k))
                    dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
            }
        }
    }
    
    for(int i = 0; i <= 3; i += 1)
        ans = max(ans, dp[n][i]);

    cout << ans << "\n";
}

Measured memory_bytes: 13444
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]

T.sort()

ans = 1
bus = T[0]
l = 1
for i in range(1,N):
    if T[i]-bus <= K and l <= C-1:
        l += 1
    else:
        bus = T[i]
        l = 1
        ans += 1
print(ans)


Measured memory_bytes: 7384
using AtCoderBeginnerContest141.Questions;
using AtCoderBeginnerContest141.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest141.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                var count = i + 1;
                var c = s[i];
                if (count % 2 == 1 && c == 'L')
                {
                    yield return "No";
                    yield break;
                }
                if (count % 2 == 0 && c == 'R')
                {
                    yield return "No";
                    yield break;
                }
            }

            yield return "Yes";
        }
    }
}


namespace AtCoderBeginnerContest141
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest141.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest141.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

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

		int sq = (a+b)*h/2;
		System.out.println(sq);
		scanner.close();
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long num[50];

int main()
{
    long long k;
    cin >> k;
    long long t = k / 50;
    for(int i = 0;i < 50;i ++) num[i] = k / 50;
    k %= 50;
    for(int i = 0;i < 50;i ++)
    {
        if(i != (50 - k)) num[i] += i;
        else num[i] += 50;
    }
       printf("50\n");
    for(int i = 0;i < 49;i ++) printf("%lld ",num[i]);
    printf("%lld\n",num[49]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
  
int main(void)
{
    char num[1000];
    int count,sum;
    while(1){
        scanf("%s", num);
        if(num[0]=='0') break;
        count=0;
        sum=0;
        while(1){
            if(num[count]=='\0') break;
            sum+=(int)num[count++]-48;
        }
        printf("%d\n",sum);
    }
    return 0;   
}   

Measured memory_bytes: 536
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

ll n;
Vi a;
graph g;
Vi as;
Vi dp;

void dfs(ll idn,ll prev){
    ll tmp = lower_bound(all(dp),a[idn]) - dp.begin();
    ll mem = dp[tmp];
    chmin(dp[tmp],a[idn]);
    as[idn] = lower_bound(all(dp),INF)-dp.begin();
    rep(i,g[idn].size()){
        edge e = g[idn][i];
        if(e.to != prev){
            dfs(e.to,idn);
        }
    }
    dp[tmp] = mem;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    g.resize(n);
    a.resize(n);
    as.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        ll in,inp;
        cin>>in>>inp;
        in--;
        inp--;
        g[in].pb(edge(inp));
        g[inp].pb(edge(in));
    }
    dp.resize(n,INF);
    dfs(0,-1);
    rep(i,as.size()){
        print(as[i]);
    }
    return 0;
}

Measured memory_bytes: 33196
s = input().rstrip()

if s[0] != 'A':
    print('WA')
    exit(0)

f = False
for i in range(1, len(s)):
    if s[i] == 'C':
        if i < 2 or i >= len(s) - 1:
            print('WA')
            exit(0)
        if f:
            print('WA')
            exit(0)
        f = True
    elif not str.islower(s[i]):
        print('WA')
        exit(0)

if f:
    print('AC')
else:
    print("WA")


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

int main(){
	int n,fib[45] = {1,1};
	cin >> n;
	for(int i = 2; i <= n; i++)
		fib[i] = fib[i - 1] + fib[i - 2];
	cout << fib[n];
	cout << endl;
}

Measured memory_bytes: 1164
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin >> a >> b;
    if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
p = 10 ** 9 + 7
x, y = map(int, input().split())

diff = abs(x - y)
large = max(x, y)
small = min(x, y)

if (small * 2 < large):
    print(0)
    exit()


# ans = diff
large -= diff * 2
small -= diff

if (small % 3 != 0):
    print(0)
    exit()


num = int(small / 3)
nn = int(num * 2 + diff)
# rr = num

factorial = [0] * (nn + 1)
factorial[0] = 1
for i in range(nn):
    factorial[i + 1] = factorial[i] * (i + 1) % p


def cmb(n, k):
    # if (n == 1 or k == 1):
    if (n == 0 or k == 0):
        return 1
    if (n < 0 or k < 0):
        return 0

    return factorial[n] * pow(factorial[n - k], p - 2, p) * pow(factorial[k], p - 2, p) % p


ans = cmb(int(nn), int(num))
print(int(ans))


Measured memory_bytes: 29300
n=int(input())
h=list(map(int,input().split()))
result=0
H=max(h)
for j in range(0,H):
    tmp=0
    cur=0
    #print(h,result)
    for i in range(1,n):
        if h[i]<=0 and h[i-1]>0:
            tmp+=1
            cur=1
            #print(j,i,1)
    if h[n-1]>0 and cur!=0:
        tmp+=1
        #print(j,i,2)
    for i in range(0,n):
        h[i]-=1
    #sprint(tmp)
    result+=max(tmp,1)
print(result)
            

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

int main() {
	long long int a[100][21];
	for(int i=0;i<100;i++){
		for(int j=0;j<21;j++){
			a[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int y;
	cin>>y;
	a[0][y]=1;
	for(int i=1;i<n-1;i++){
		int p;
		cin>>p;
		for(int j=0;j<21;j++){
			if(j+p<=20){a[i][j+p]+=a[i-1][j];}
			if(j-p>=0){a[i][j-p]+=a[i-1][j];}
		}
	}
	int ans;
	cin>>ans;
	cout<<a[n-2][ans]<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

int main()
{
    MOAE;
    int n, sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int o = 1; o <= n; o++)
            {
                //cout << i << " " << j << " " << o << endl;
                sum += __gcd(i, __gcd(j, o));
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3660
#include<stdio.h>

#define MAX 10000

int main() {
    int hako[MAX];
    int i=0, j;
    
    while(1) {
        scanf("%d", &hako[i]);
        if (hako[i] == 0) {
            break;
        }
        i++; //カウント
    }
    
    
    for (j=1; j<=i; j++) {
        printf("Case %d: %d\n", j, hako[j-1]);
    }
    
    return 0;
}



Measured memory_bytes: 2040
#include<stdio.h>
#include<string.h>
#define L 10000000

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[L];
int head,tail,n;

void enqueue(P x){
	Q[tail]=x;
	tail=(tail+1)%L;
}

P dequeue(){
	P x=Q[head];
	head=(head+1)%L;
	
	return x;
}

int min(int a, int b){
	return a<b ? a:b;
}

int main(void){
	int elaps=0,c;
	int i,q;
	P u;
	scanf("%d %d",&n,&q);
	
	for(i=1; i<=n; i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head=1;
	tail=n+1;
	
	while(head !=tail){
		u=dequeue();
		c=min(q,u.t);
		u.t-=c;
		elaps+=c;
		if(u.t>0){
			enqueue(u);
		}else{
			printf("%s %d\n",u.name,elaps);
		}
	}
}


Measured memory_bytes: 20924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
 
using namespace std;
 
typedef long long ll;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/

int main() { 
    ll n = 0, k = 0;
    cin >> n >> k;
    ll a = n%k;
    ll ans = min(a,k-a);
    cout << ans << endl;
  
    return 0; 
} 


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

int main(){
	string s,s2,s3;
	cin >> s >> s2 >> s3;
	char c;
	int a=s[0]-'a';
	while(1){
		if(a==0&& s.size()==0) break;
		else if(a==1 &&s2.size()==0) break;
		else if(a==2 &&s3.size()==0) break;
		
		if(a==0){
			c=s[0];
			a=s[0]-'a';
			s.erase(s.begin());
		}
		else if(a==1){
			c=s2[0];
			a=s2[0]-'a';
			s2.erase(s2.begin());
		}
		else if(a==2){
			c=s3[0];
			a=s3[0]-'a';
			s3.erase(s3.begin());
		}
		
		
	}
	
	cout << char(a+'A') << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort()
s_ls = [i for i in accumulate(a_ls)]
cnt = 1
for i in range(n-2, -1, -1):
    if s_ls[i] * 2 >= a_ls[i+1]:
        cnt += 1
    else:
        break
print(cnt)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
struct S {
  int w, v;
};

void solve() {
  int n;
  cin >> n;
  dump(n);
  // vvl dp(n + 1, vl(100005));
  vvl dp(1025, vl(100005));
  vi vv(n + 1);
  vi vw(n + 1);
  rep(i, n) {
    int v, w;
    cin >> v >> w;
    vv[i + 1] = v;
    vw[i + 1] = w;
    dump(i, v, w);
    int c = i + 1;
    int p = c / 2;
    if (1024 < c) continue;
    rep(j, 100001) {
      dp[c][j] = dp[p][j];
      if (0 <= j - w) {
        maxs(dp[c][j], dp[p][j - w] + v);
      }
    }
  }
  int q;
  cin >> q;
  rep(i, q) {
    int v, l;
    cin >> v >> l;
    vector<S> s;
    s.push_back({ 0, 0 });
    while (1024 < v) {
      int ns = s.size();
      rep(j, ns) {
        if (s[j].w + vw[v] <= l) {
          s.push_back({ s[j].w + vw[v], s[j].v + vv[v] });
        }
      }
      v = v / 2;
    }
    ll ans = 0;
    for (auto c : s) {
      maxs(ans, dp[v][l - c.w] + c.v);
    }
    cout << ans << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main(){
	int c,mx ;
	mx = 0 ;
	int ans = 0 ;
	for(int i=0;i<5;i++){
		cin >> c ;
		ans += (c+9)/10 ;
		if(mx<10-c%10&&c%10!=0) mx = 10-c%10 ;
	}
	cout << ans*10-mx << endl ;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC2019_29
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            while (true)
            {
                int n = ReadInt();
                if (n == 0) break;
                string[] strs = new string[n];
                for(int i = 0; i < n; i++)
                {
                    string s = Read();
                    string tmp = "";
                    tmp += s[0];
                    for (int j = 0; j < s.Length - 1; j++)
                    {
                        if (s[j] == 'a' || s[j] == 'i' || s[j] == 'u'
                            || s[j] == 'e' || s[j] == 'o')
                        {
                            tmp += s[j + 1];
                        }
                    }
                    strs[i] = tmp;
                }
                bool done = false;
                for(int i = 1; i <= 50; i++)
                {
                    var hashSet = new HashSet<string>();
                    bool can = true;
                    for (int j = 0; j < n; j++)
                    {
                        string tmp = "";
                        for(int k = 0; k < Min(i, strs[j].Length); k++)
                        {
                            tmp += strs[j][k];
                        }
                        if (hashSet.Contains(tmp))
                        {
                            can = false;
                            break;
                        }
                        hashSet.Add(tmp);
                    }
                    if (can)
                    {
                        WriteLine(i);
                        done = true;
                        break;
                    }
                }
                if(!done)                WriteLine(-1);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

typedef long long ll;

const int N = 200005;
int vet[N], vet2[N];

int main(){
	int n;
	ll k;
	scanf("%d %lld", &n, &k);
	for (int i=0; i<n; i++){
		scanf("%d", &vet[i]);
	}
	for (int i=0; i<n; i++){
		scanf("%d", &vet2[i]);
	}
	sort(vet2, vet2+n, greater < int >());
	sort(vet, vet+n);
	ll lo = 0, hi = 1000000000000000, ans = -1;
	while (lo <= hi){
		ll mid = (lo + hi) >> 1;
		long long auxK = k;
		bool flag = true;
		for (int i=0; i<n; i++){
			ll num = mid/(ll)vet2[i];
			if((ll)vet[i]-num > auxK){
				flag = false;
				break;
			}
			else auxK -= (max(0LL, (ll)vet[i]-num));
		}
		if(flag) {
			hi = mid-1;
			ans = mid;
		}
		else lo = mid+1;
	}
	printf("%lld\n", ans);
}


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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)scanf("%ld%ld", &i.first, &i.second);
        sort(p.begin(), p.end());
        iota(perm.begin(), perm.end(), 0UL);
        sort(perm.begin(), perm.end(), [&p](auto i, auto j){return p[i].second < p[j].second;});
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    binary[0] = 1;
    for(unsigned long i = 0; i < N; ++i)binary[i + 1] = binary[i] * 2 - (binary[i] > 499122176) * MOD;

    vector<unsigned long> fenwick_tree(N);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long r = i;
        unsigned long ret{fenwick_tree[i]};
        while(i &= i + 1)ret += fenwick_tree[--i];
        i = r;
        while(i < N){
            ++fenwick_tree[i];
            i |= i + 1;
        }
        return ret;
    };

    vector<unsigned long> coef(N + 1);
    for(unsigned long i = 0; i < N; ++i){
        auto q = que(perm[i]);
        ++coef[q];
        ++coef[i - q];
        ++coef[perm[i] - q];
        ++coef[N - i - perm[i] + q - 1];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), (N + MOD - 4) * (binary[N] - 1)) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6488
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  // ここでストリームに obj を書き込みます。
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << "\n";
  }
  return os;
}


int operator<(vector<int> v1,vector<int> v2){
  rep(i,v1.size())
    if(v1[i]>v2[i]) return 0;
  return 1;
}


string key="keyence";

int main(){
  string s; cin >>s;
  vector<int> v(3,0);
  rep(i,s.size()){
    v[s[i]-'a']++;
  }
  sort(v.begin(),v.end());
  print(((v[2]-v[0]<=1)?"YES":"NO"));
}





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

int main(void){
    int h,w;
    cin >> h >> w;
    vector<string> vec(h);
    for(int i=0;i<h;i++) cin >> vec.at(i);

    vector<int> dx = {1,0,-1,0};
    vector<int> dy = {0,1,0,-1};

    bool ok = true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(vec.at(i).at(j)=='.') continue;

            bool good=false;
            for(int k=0;k<4;k++){
                int ni = i+dy.at(k);
                int nj = j+dx.at(k);
                if(ni<0 || ni>=h) continue;
                if(nj<0 || nj>=w) continue;
                if(vec.at(ni).at(nj)=='#') good=true;
            }
            if(!good) ok = false;
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int sum_vector(vector<int> d){
  int rel = 0;
  int N = d.size();
  for(int i =0;i<N;i++)rel+=d.at(i);
  return rel;
}

int main(){
  int N;
  cin >> N;
  vector<int> b(N-1);
  vector<int> a(N);
  for(int i =0;i<N-1;i++)cin >> b.at(i);
  for(int i =0;i<N-2;i++){
    a.at(i+1) = min(b.at(i),b.at(i+1));
  }
  a.at(0) = b.at(0);
  a.at(N-1) = b.at(N-2);
  // for(int i =0;i<N;i++)cout << a.at(i) << endl;
  cout << sum_vector(a) << endl;
}


Measured memory_bytes: 256
fn main() {
    let k = read::<usize>();
    let s = read::<String>();

    if k >= s.len() {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k]);
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 2152
import copy
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = copy.copy(A)
for i in range(N):
    if B[i] <= A[i]:
        A[i] -= B[i]
    elif B[i] <= A[i] + A[i + 1]:
        A[i + 1] -= B[i] - A[i]
        A[i] = 0
    else:
        A[i], A[i + 1] = 0, 0
C = [C[i] - A[i] for i in range(N + 1)]
print(sum(C))

Measured memory_bytes: 25356
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14 
#define MAX_V (110)

struct edge{int to, cap, rev; };

vector <edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t)return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

signed main(){
    int v, e;
    cin >> v >> e;
    rep(i, e){
        int a, b, c;
        cin >> a >> b >> c;
        add_edge(a, b, c);
    }
    cout << max_flow(0, v - 1) << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vi sa(n + 1), sb(n + 1), ta(m + 1), tb(m + 1);
	sa[0] = 0; sb[0] = 0, ta[0] = 0, tb[0] = 0;
	REP(i, n) {
		if (s[i] == 'A') {
			sa[i + 1] = 1; sb[i + 1] = 0;
		}
		else {
			sa[i + 1] = 0; sb[i + 1] = 1;
		}
	}
	REP(i, n) {
		sa[i + 1] += sa[i];
		sb[i + 1] += sb[i];
	}
	REP(i, m) {
		if (t[i] == 'A') {
			ta[i + 1] = 1; tb[i + 1] = 0;
		}
		else {
			ta[i + 1] = 0; tb[i + 1] = 1;
		}
	}
	REP(i, m) {
		ta[i + 1] += ta[i];
		tb[i + 1] += tb[i];
	}
	int q;
	cin >> q;
	REP(i, q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int x = (sa[b] - sa[a - 1]) % 3, y = (sb[b] - sb[a - 1]) % 3, z = (ta[d] - ta[c - 1]) % 3, w = (tb[d] - tb[c - 1]) % 3;

		if ((x == z&&y == w) || (x + w) % 3 == (y + z) % 3)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 2512
import sys

sys.setrecursionlimit(1000000)

mod = 1000000007


def fac(n):
    v = 1
    for i in range(n):
        v = int(((i+1) * v) % mod)
    return v


n, m = map(int, input().split())
if abs(m-n) > 1:
    print(0)
    exit()
n = int(fac(n) % (mod))
m = int(fac(m) % (mod))
ans = int((n*m) % (mod))
if abs(n-m) == 0:
    ans = int((ans*2) % mod)
print(ans)


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

using ll = long long;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll m, k;
  cin >> m >> k;
  ll x = 1;
  for (int i = 0; i < m; i++) x *= 2;
  if (!k) {
    for (int i = 0; i < x; i++)
      cout << i << " " << i << " \n"[i == x - 1];
    return 0;
  }
  if (k >= x) {
    cout << "-1\n";
    return 0;
  }
  ll y = 0;
  for (int i = 0; i < x; i++)
    if (i != k)
      y ^= i;
  if (y != k) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < x; i++)
    if (i != k)
      cout << i << " ";
  cout << k << " ";
  for (int i = x - 1; i >= 0; i--)
    if (i != k)
      cout << i << " ";
  cout << k << "\n";
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
int main() {
    quick
int n,x,last,cur=0,ans=0; cin>>n;
for(int i=0;i<n;i++){
    cin>>x;
    if(i){
        if(last>=x){cur++,last=x;}
        else{cur=0; last=x;}
    }
    else{last=x;}
    ans=max(ans,cur);
}
cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N;
    cin >> N;
    vector<ll> ans(N+1, 0);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                ll f = x*x+y*y+z*z+x*y+y*z+z*x;
                if (f <= N) ans[f]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3500
X, Y = map(int, input().split())
# X * (2**(n-1)) <= Y


from math import log2
eps = 10**(-9)



# X * 2 ** start <= x < X * 2 ** end
def ans(start, end):
#    print(start, end)
    if start + 1 == end:
        return start
    mid = (start + end)//2
    if X * 2**mid  <= Y:
        return ans(mid, end)
    else:
        return ans(start, mid)

print(ans(0, 60)+1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isodd(int n)
{
        int dig = 0;
        while(n)
        {
                n = n/10;
                dig+=1;
        }
        return dig%2==1;
}
int main()
{       
        int n;
        cin>>n;
        int count = 0;
        for(int i = 1 ; i<= n ; i++)
        {
                if(isodd(i)) count+=1;
        }
        cout<<count<<endl;
        return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, L) = readLine()!!.split(" ").map(String::toInt)

    val a = (1..N).map { it + L - 1 }.toMutableList()
    val b = a.mapIndexed { i, e -> Pair(i, Math.abs(e)) }.sortedBy { it.second }.first()
    a.removeAt(b.first)
    a.sum().let(::println)

}

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

using namespace std;

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

const int oo = 0x3f3f3f3f;
const double pi = acos(-1);
const double eps = 1e-9;

#define endl '\n'

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

	int n;
	cin >> n;

	vi V(n);
	for (int i = 0; i < n; ++i)
		cin >> V[i];

	vi ans(n);
	for (int i = 0; i < n; ++i){
		ans[V[i] - 1] = i + 1;
	}

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

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;

string t;

int solve(string s) {
	if(s == t) return 0;
	rep(i, s.length()) {
		if(s[i] != t[i]) {
			int diff = t[i] - s[i];
			int res = 100;
			for(int j=i; j<s.length(); j++) {
				s[j] = ((s[j]-'0'+diff+10) % 10) + '0';
				res = min(res, solve(s)+1);
			}
			return res;
		}
	}
	return 0;
}

int main() {
	int k;
	while(cin >> k, k) {
		string s;
		cin >> s >> t;
		cout << solve(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include<algorithm>
#include<cstring>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define inf (int)1e9
ll dp[101][100001];
ll knapsack(ll n, ll w, ll weight[], ll value[])
{
	if (n == 0 || w <= 0)
		return 0;
	ll a = 0, b = 0;
	if (dp[n][w] != -1)
		return dp[n][w];
	if (weight[n - 1] <= w)
		a = value[n - 1] + knapsack(n - 1, w - weight[n - 1], weight, value);
	b = knapsack(n - 1, w, weight, value);
	dp[n][w] = max(a, b);
	return dp[n][w];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		memset(dp, -1, sizeof(dp));
		ll n, w;
		cin >> n >> w;
		ll weight[n], value[n];
		for (ll i = 0; i < n; i++)
		{
			cin >> weight[i] >> value[i];
		}
		cout << knapsack(n, w, weight, value) << endl;
	}
	return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef 	long long 							ll;
#define		mod									1000000007
#define 	ppi 								pair<ll,ll>
#define 	all(v) 								v.begin(),v.end()
#define 	prq									priority_queue
#define 	vi 									vector<ll>
#define     vip									vector<ppi>
#define 	forn(i,a,b)  						for(i=a;i<b;i++)
#define 	ford(i,a,b)   						for(i=a;i>b;i--)
#define 	endl 								"\n";
#define 	p_b 								push_back
#define 	m_p 								make_pair
#define     umap								unordered_map<ll,ll>
#define     uset                                unordered_set<ll>
#define     Stack								stack<ll>
#define     Queue								queue<ll>
#define     F									first
#define     S 									second				
void print1D(vector<ll> &v)
{
	cout<<"Debug Array:  ";
	for(ll i=0;i<v.size();i++)
 	   cout<<v[i]<<" ";
	cout<<"-----------------------------\n"; 
}

void print2D(vector<vector<ll>> &v)
{
	cout<<"Debug2d: ";
	ll n = v.size(),m=v[0].size();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			cout<<v[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<"--------------------------------------\n";
}

void printS(string &s)
{
	ll l=s.length(),i;
	cout<<"String: ";
	for(i=0;i<l;i++)
	{
		cout<<s[i];
	}
	cout<<"\n---------------------------------------\n";
}

void vectorInput(vector<ll> &v)
{
	ll n=v.size();
	for(ll i=0;i<n;i++){
	   cin>>v[i];
   }
}

void pairInput(vector<ll> &vp)
{
	ll n = vp.size(),i,j,k;
	for(i=0;i<n;i++)
	{
		cin>>vp[i];
	}
}

void swap(ll &a,ll &b)
{
	ll t=a;
	a=b;
	b=t;
}

void sol()
{
	
	ll i,j,k,n,m;
	cin>>n;
	if(n>=30)
	   cout<<"Yes\n";
	else
		cout<<"No";   		 
//	vi v(n);
	//vectorInput(v);
}

/*<----------------------------------------------------------------------------------------------------------------------------------------------->*/

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
	ll test=1;
//	cin>>test;
	while(test--)
	{
		sol();
		
	}
}

Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
    long long int gcd,lsd,a,b,t,mul;
    scanf("%lld%lld",&a,&b);
    mul=a*b;
    if(a==0)gcd=b;
    else if(b==0)gcd=a;
    else{
        while(b!=0){
            t=a%b;
            a=b;
            b=t;
            if(t==0)break;
        }
        gcd=a;

    }
    lsd=mul/gcd;

    printf("%lld",lsd);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define int long long
signed main()
{
   int n,k,c;
   string s;
   cin>>n>>k>>c>>s;
   int a[n],b[n];
   for(int i=0,x=0;i<n;i++){
       if(s[i]=='o'){
           a[x++]=i;
           i+=c;
       }
   }
   for(int i=n-1,x=k-1;i>=0&&x>=0;i--){
       if(s[i]=='o'){
           b[x--]=i;
           i-=c;
       }
   }
   for(int i=0;i<k;i++)if(a[i]==b[i])cout<<a[i]+1<<endl;
   return 0;
}


Measured memory_bytes: 4996