akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.function.Function;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGoHome solver = new CGoHome();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGoHome {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();

            long answer = BinarySearch.binarySearchLong(n -> ((n * (n + 1)) / 2) >= x);

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class BinarySearch {
        public static long binarySearchLong(Function<Long, Boolean> bigEnough) {
            long tooSmall = 0, tooBig;
            if (bigEnough.apply(tooSmall)) {
                return tooSmall;
            }

            for (tooBig = 1; !bigEnough.apply(tooBig); tooBig *= 2)
                ;

            if (!bigEnough.apply(tooBig - 1)) {
                return tooBig;
            }

            while (tooBig - tooSmall > 1) {
                long center = (tooBig + tooSmall) / 2;
                if (!bigEnough.apply(center)) {
                    tooSmall = center;
                } else {
                    tooBig = center;
                }
            }

            return tooBig;
        }

    }
}



Measured memory_bytes: 26708
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
	string S, T;
	cin >> S >> T;

	for(int i = 0; i < T.size(); i++) {
		bool flag = true;
		for(int j = 0; j < S.size(); j++) {
			if(S[j] != T[(i + j) % S.size()]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
char s[N];int n,x,m;
int main(){
	scanf("%d",&x),n=x/500,m=x%500/5;
	printf("%d\n",n*1000+m*5);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>
#include <set>
#include <map>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}



int main() {
	Get(int, x,a);

	co << (x<a?0:10) << en;
}




Measured memory_bytes: 256
def solve(h,m):
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    dm = m / 60.0 * 360.0
    x = abs(dh-dm)
    if x > 180:
        x = 360 - x
    if 0 <= x < 30.0:
        return("alert")
    elif 90.0 <= x <= 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1])) 

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

using namespace std;

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

    int n;
    cin >> n;

    int a[n][3];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];

    int dp[n][3];
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (i == 0)
                dp[i][j] = a[i][j];
            else
                dp[i][j] = a[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
        }
    }

    int answer = 0;
    for (int j = 0; j < 3; j++)
        answer = max(answer, dp[n - 1][j]);

    cout << answer << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

bool check(pair<ll, ll> a, int lim){
	return abs(a.first) + abs(a.second) <= lim;
}

int main(){
	int n;
	cin >> n;
	vector<pair<int, int> > a(n);
	int parity = -1;
	for(int i = 0; i < n; ++ i){
		int x, y;
		cin >> x >> y;
		if(parity == -1) parity = abs(x + y) % 2;
		else {
			if(parity != abs(x + y) % 2) return cout << "-1\n", 0;
		}
		a[i] = {x, y};
	}
	int m = 31;
	vector<int> d(m);
	d[0] = 1;
	for(int i = 1; i < m; ++ i) d[i] = 2 * d[i - 1];
	if(parity == 0) d.push_back(1), sort(d.begin(), d.end()), m++;
	reverse(d.begin(), d.end());
	cout << m << '\n';
	for(int i = 0; i < m; ++ i) cout << d[i] << " ";
	cout << '\n';
	for(int i = 0; i < n; ++ i){
		for(int j = 0; j < m; ++ j){
			int lim = d[j] - parity;
			if(check(make_pair(a[i].first - d[j], a[i].second), lim)) cout << "R", a[i].first -= d[j];
			else if(check(make_pair(a[i].first + d[j], a[i].second), lim)) cout << "L", a[i].first += d[j];
			else if(check(make_pair(a[i].first, a[i].second - d[j]), lim)) cout << "U", a[i].second -= d[j];
			else if(check(make_pair(a[i].first, a[i].second + d[j]), lim)) cout << "D", a[i].second += d[j];
			else cout << "?";
		}
		cout << '\n';
	}
}
			
	
	


Measured memory_bytes: 256
n,m = gets.strip.split.map(&:to_i)
rec = Array.new(n){Array.new(n,0)}
m.times do
  a,b = gets.strip.split.map(&:to_i)
  rec[a-1][b-1] += 1
  rec[b-1][a-1] += 1
end
for i in 0..n-1
  puts rec[i].sum
end

Measured memory_bytes: 14344
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  var m = o.a();

  var arr = [];
  for (var i = 0; i < m; i++) {
    arr[i] = [];
    var k = o.a();
    for (var j = 0; j < k; j++) {
      arr[i].push(o.a());
    }
  }
  var p =  o.l();

  var count = 0;
  for (var i = 0; i < Math.pow(2, n); i++) {
    var str = i.toString(2);
    while(str.length < n) str = "0"+str;
    // console.log({str});
    var flag = true;
    for (var j = 0; j < m; j++) {
      var lightCount = 0;
      arr[j].forEach(x => {
        if (str[x - 1] === "1") {
          lightCount += 1;
        }
      });

      // console.log({lightCount, pj: p[j]});
      if (lightCount % 2 !== p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      count += 1;
    }
  }

  console.log(count);
}


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


Measured memory_bytes: 9660
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int H, W, M;
    cin >> H >> W >> M;
    VI h(H,0),w(W,0);
    map<PII,int> mp;
    REP (i, M) {
        int tmph,tmpw;
        cin >> tmph;
        tmph--;
        h[tmph]++;
        cin >> tmpw;
        tmpw--;
        w[tmpw]++;
        mp[{tmph,tmpw}]++;
    }
    int maxh = *max_element(ALL(h));
    VI maxhv;
    REP(i,H) if (h[i] == maxh) maxhv.push_back(i);
    ans += *max_element(ALL(h));
    int maxw = *max_element(ALL(w));
    VI maxwv;
    REP(i,W) if (w[i] == maxw) maxwv.push_back(i);
    ans += *max_element(ALL(w));
    ans--;
    for (auto i : maxhv) {
        for (auto j : maxwv) {
            if (mp[{i,j}] == 0) {
                ans++;
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_e && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_e && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_e && sh shellscripts/submit_cpp.sh
*/


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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> t,x,y;

    for(int i = 0; i< n; i++){
        int a,b,c; cin >> a >> b >> c;
        t.push_back(a);
        x.push_back(b);
        y.push_back(c);
    }

    for(int i = 0; i < n; i++){
        if(t[i] < x[i] + y[i]){
            cout << "No" << endl;
            return 0;
        }
        else{
            if((x[i] + y[i]) % 2 == 0){
                if(t[i] % 2 != 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
            else{
                if(t[i] % 2 == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
void YesNo(bool x) {
    if (x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    string N; cin >> N;
    int ans = 0;
    rep(i, N.length()) ans += (int)(N[i] - '0');
    YesNo(ans%9==0);
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(abs(a-c) <= d){
    cout << "Yes";
    return 0;
  }

  if(abs(a-b) <= d && abs(b-c) <= d){
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

}


Measured memory_bytes: 3580
dance = list(input())
kekka = 0

for i in range(len(dance)):
    if i%2 == 0:
        if dance[i] == "R" or dance[i] == "U" or dance[i] == "D":
            kekka = kekka + 1
    if i%2 == 1:
        if dance[i] == "L" or dance[i] == "U" or dance[i] == "D":
            kekka = kekka + 1

if kekka == len(dance):
    print("Yes")
else:
    print("No")

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


int N;
// A C G T, 0 1 2 3

long long mod = 1e9 + 7, dp[101][4][4][4];

bool suffix_ok(int a, int b, int c, int d){
    if(
       (b == 0 && c == 2 && d == 1) || //*agc
       (a == 0 && c == 2 && d == 1) || //a*gc
       (a == 0 && b == 2 && d == 1) || //ag*c
       (b == 2 && c == 0 && d == 1) || //*gac
       (b == 0 && c == 1 && d == 2)    //*acg
       ){
        return false;
    }else{
        return true;
    }
}


int main(){
    cin >> N;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                dp[3][i][j][k] = 1;
            }
        }
    }
    dp[3][0][2][1] = dp[3][2][0][1] = dp[3][0][1][2] = 0;
    for(int p = 3; p + 1 <= N; p++){
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                for(int k = 0; k < 4; k++){
                    for(int l = 0; l < 4; l++){
                        if(suffix_ok(i, j, k, l)){
                                dp[p + 1][j][k][l] += dp[p][i][j][k];
                                dp[p + 1][j][k][l] %= mod;
                        }
                    }
                }
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                    ans += dp[N][i][j][k];
                    ans %= mod;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef double Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define it vector<int>::iterator
bool next_combination(it first1,it last1,it first2,it last2){
	if((first1==last1)||(first2==last2))return false;
	it m1=last1,m2=last2;
	m2--;
	while(--m1!=first1&&!(*m1<*m2));
	bool result=(m1==first1)&&!(*first1<*m2);
	if(!result){
		while(first2!=m2&&!(*m1<*first2))first2++;
		first1=m1;
		iter_swap(first1,first2);
		first1++;first2++;
	}
	if((first1!=last1)&&(first2!=last2)){
		m1=last1;m2=first2;
		while((m1!=first1)&&(m2!=last2))iter_swap(--m1,m2++);
		reverse(first1,m1);
		reverse(first1,last1);
		reverse(m2,last2);
		reverse(first2,last2);
	}
	return !result;
}
bool next_combination(it first,it middle,it last){
  return next_combination (first , middle , middle , last );
}
/*
n=5,r=3;
a=0 1 1 2 3
011 012 013 023 112 113 123
*/
//combination (begin,begin+r,end)
int main(){
	int n,m;
	cin>>n>>m;
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	vector<int>dp(n);
	rep(i,n)dp[i]=i;
	double out=0;
	do{
		double sum=0;
		rep(i,m)loop(j,i+1,m)rep(k,3)sum+=pow(in[dp[i]][k]-in[dp[j]][k],2);
		out=max(out,sum);
	}while(next_combination(dp.begin(),dp.begin()+m,dp.end()));
	cout<<shosu(7)<<out<<endl;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
int main(){
  ll N;
  cin>>N;
  vector<ll> x(N);
  vector<ll> xcopy(N);
  for(ll i=0;i<N;i++){
    cin>>x.at(i);
    xcopy.at(i)=x.at(i);
  }
  sort(x.begin(),x.end());
  ll midium=x.at(N/2-1);
  for(ll i=0;i<N;i++){
    if(xcopy.at(i)<=midium){cout<<x.at(N/2)<<endl;}
    else if(xcopy.at(i)>midium){cout<<x.at(N/2-1)<<endl;}
  }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
const int MAXV = 1e5 + 5;
void marmot0814() {
    int n; cin >> n;
    vector<double> dp(n + 1, 0); dp[0] = 1;
    for (int i = 0 ; i < n ; i++) {
        double v; cin >> v;
        for (int j = n ; j >= 1 ; j--)
            dp[j] = dp[j] * (1 - v) + dp[j - 1] * v;
        dp[0] *= (1 - v);
    }
    double sum = 0;
    for (int i = 0 ; i <= n ; i++) {
        if (i * 2 > n)
            sum += dp[i];
    }
    cout << fixed << setprecision(10) << sum << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3872
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vector< pint > kukanl;
	vector< pint > kukanr;
	int L[100001],R[100001];
	int used[100001]={0};
	int leftside=0,rightside=0;
	scan(N);
	rep(i,N){
		scan(L[i]);scan(R[i]);
		kukanl.push_back(mp(L[i],i));
		kukanr.push_back(mp(R[i],i));
		if(L[i]>0) rightside++;
		if(R[i]<0) leftside++;
	}
	sort(kukanl.begin(),kukanl.end());
	sort(kukanr.rbegin(),kukanr.rend());
	ll kyori=0;
	int nowx=0;
	int usednum=0;
	int houkou;
	if(rightside>=leftside){
		houkou=1;
	}
	else{
		houkou=0;
	}
		rep(i,N){
			int selecti,selectl,selectr;
			if(houkou==1){
				selectl=kukanl.back().first;
				if(selectl<=nowx){
					kyori+=abs(nowx);
					break;
				}
				selecti=kukanl.back().second;
				if(used[selecti]==1){
					kukanl.pop_back();
					i--;
					continue;
				}
				kukanl.pop_back();
				used[selecti]=1;
				usednum++;
				kyori+=abs(nowx-selectl);
				nowx=selectl;
				houkou=0;
			}
			else{
				selectr=kukanr.back().first;
				if(selectr>=nowx){
					kyori+=abs(nowx);
					break;
				}
				selecti=kukanr.back().second;
				if(used[selecti]==1){
					kukanr.pop_back();
					i--;
					continue;
				}
				kukanr.pop_back();
				used[selecti]=1;
				usednum++;
				kyori+=abs(nowx-selectr);
				nowx=selectr;
				houkou=1;
			}
			if(i==N-1||kukanl.size()==0||kukanr.size()==0||usednum==N){
				kyori+=abs(nowx);
				break;
			}
		}
		prin(kyori);
	return 0;
}


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

class Program
{
    static bool IsPrime(int a)
    {
        if (a == 2)
        {
            return true;
        }
        if (a < 2 || a % 2 == 0)
        {
            return false;
        }
        for (int i = 3; i <= Math.Sqrt(a); i += 2)
        {
            if (a % i == 0)
            {
                return false;
            }
        }
        return true;
    }

    static IEnumerable<int> Input()
    {
        string s;
        while ((s = Console.ReadLine()) != null) 
        {
            yield return int.Parse(s);
        }
    }

    static void Main()
    {
        var ans = Input().Where(x => IsPrime(x)).Count();
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 9448
n = int(input())
res = False
doubles = 0

for _ in range(n):
  (a, b) = map(int, input().split())
  if a == b:
    doubles += 1
  else:
    doubles = 0
  if doubles > 2:
    res = True
    break
    
print('Yes' if res else 'No')

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

struct Edge{
	int to;
	int weight;
};
vector<Edge> g[100010];
vector<Edge> ch[100010];


void buildTree(int x,int p=-1){
	struct HOGE{
		int sid;
		pair<int,int> argv;
	};
	stack<HOGE> S;
	S.push({0,{x,p}});
	while( S.size() ){
		HOGE s = S.top(); S.pop();
		tie(x,p) = s.argv;
		for( auto e : g[x] ){
			if( e.to != p ){
				S.push({0,{e.to,x}});
				ch[x].push_back(e);
			}
		}
	}
}

struct Info{
	int chid;
	int len;
};
bool operator < (const Info &a,const Info &b){
	if( a.len == b.len ) return a.chid < b.chid;
	return a.len < b.len;
}


vector<Info> seq[100010];
int diameter[100010]; 
int maxPath[100010];

void calcDiameter(int x){
	struct HOGE{
		int sid;
		int argv;
	};
	stack<HOGE> S;
	S.push({0,x});

	while( S.size() ){
		HOGE s = S.top(); S.pop();
		x = s.argv;
		if( s.sid == 0 ){
			S.push({1,x});
			for( auto e : ch[x] ){	
				S.push({0,e.to});
			}
		}else if( s.sid == 1 ){
			vector<Info> s;
			for( auto e : ch[x] ){
				diameter[x] = max(diameter[x],diameter[e.to]);
				s.push_back({e.to,maxPath[e.to]+e.weight});
			}
			
			sort(s.rbegin(),s.rend());
			if( s.size() == 1 ){
				diameter[x] = max(diameter[x],s[0].len);
			}else if( s.size() >= 2 ){
				diameter[x] = max(diameter[x],s[0].len+s[1].len);
			}
			seq[x] = s;
			maxPath[x] = s.size() >= 1 ? s[0].len : 0;
		}
	}
}


struct ImportantInfo{
	int pathMax;
	int diameterMax;
};

vector<Info> getMaxTwo(const vector<Info> &s,int cid){
	vector<Info> own;
	for(int i = 0 ; i < s.size() ; i++){
		if( cid != s[i].chid ) own.push_back(s[i]);
		if( own.size() >= 2 ) break;
	}
	return own;
}

int ans = 0;
void dfs(int x,ImportantInfo info){
	struct HOGE{
		int sid;
		pair<int,ImportantInfo> argv;
	};
	stack<HOGE> S;
	S.push({0,{x,info}});

	while( S.size() ){
		HOGE s = S.top(); S.pop();
		tie(x,info) = s.argv;
		for( auto e : ch[x] ){
			vector<Info> goodPaths = getMaxTwo(seq[x],e.to);
			goodPaths.push_back({-1,info.pathMax});
			goodPaths.push_back({-1,0});
			sort(goodPaths.rbegin(),goodPaths.rend());
			ImportantInfo nextInfo = info;
			nextInfo.pathMax = max(nextInfo.pathMax,goodPaths[0].len) + e.weight;
			nextInfo.diameterMax = max(nextInfo.diameterMax,goodPaths[0].len+goodPaths[1].len);
			ans = max(ans,max(diameter[e.to],nextInfo.diameterMax) + e.weight);
			S.push({0,{e.to,nextInfo}});
		}
	}


}

int main(){
	int N;
	cin >> N;
	for(int i = 1 ; i < N ; i++){
		int p,w;
		cin >> p >> w;
		g[p].push_back({i,w});
		g[i].push_back({p,w});
	}
	int root = 0;
	buildTree(root);
	calcDiameter(root);
	dfs(root,{0,0});
	/*for(int i = 0 ; i < N ; i++){
		cout << i << ": " << diameter[i] << "|";
		for(auto j : seq[i] ) cout << j.len << " ";
		cout << endl;
	}*/
	cout << ans << endl;

}

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

#define pb push_back

using ll = long long;
using pii = pair<int, int>;

template<typename T>
using heap = priority_queue<T, vector<T>, greater<T> >;

const int N = 1e5 + 10, inf = 1e9;
int nxt[N], dp[N];

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m; cin >> n >> m;
    string s; cin >> s;
    fill(nxt, nxt + n + 1, -1);
    fill(dp, dp + n + 1, inf);
    dp[n] = 0;
    heap<pii> pq;
    pq.push({0, n});
    for (int i = n - 1; i >= 0; --i) {
    	if (s[i] == '1')
    		continue;
    	while (!pq.empty() && pq.top().second > i + m)
    		pq.pop();
    	if (!pq.empty()) {
    		dp[i] = pq.top().first + 1;
    		nxt[i] = pq.top().second - i;
    	}
    	pq.push({dp[i], i});
    }
    if (dp[0] >= inf) {
    	cout << -1 << "\n";
    	return 0;
    }
    int c = 0;
    while (c < n) {
    	cout << nxt[c] << " ";
    	c += nxt[c];
    }
    cout << "\n";
}

Measured memory_bytes: 2168
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String o = stdIn.next();
		String e = stdIn.next();
		
		if(o.length()==e.length()) {
			for(int i = 0; i < o.length(); i++) {
				System.out.print(o.charAt(i));
				System.out.print(e.charAt(i));
			}
		}else {
			for(int i = 0; i < e.length(); i++) {
				System.out.print(o.charAt(i));
				System.out.print(e.charAt(i));

			}
			System.out.print(o.charAt(o.length()-1));
		}
		
		
		
	}

}


Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        int K = sc.nextInt();
        var cnt = new int[N];
        for (int i = 1; i <= N; i++) {
            int sum = i;
            int count = 0;
            while (sum < K) {
                sum *= 2;
                count++;
            }
            cnt[i-1] = count;
        }

        var per = new decimal[18];
        per[0] = 1m;
        for (int i = 1; i < 18; i++) {
            per[i] = per[i-1] * 0.5m;
        }

        decimal tmp = 1m / (decimal)N;
        decimal ans = 0m;
        for (int i = 0; i < N; i++) {
            ans += tmp * per[cnt[i]];
        }
        WriteLine(ans.ToString("F9"));
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <deque>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 2e5 + 10;
int n;
ll A[SZ],B[SZ];

int main()
{
	/*
	int T;
	scanf("%d",&T);
	while(T --)
	{
		
	}
	*/
	//system("pause");
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++) scanf("%lld%lld",&A[i],&B[i]);
	sort(A + 1,A + n + 1);
	sort(B + 1,B + n + 1);
	if(n % 2 == 1) printf("%lld\n",B[n / 2 + 1] - A[n / 2 + 1] + 1);
	else printf("%lld\n",B[n / 2] + B[n / 2 + 1] - A[n / 2] - A[n / 2 + 1] + 1);
	return 0;
} 

Measured memory_bytes: 6352
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int v = sc.nextInt();
    int b = sc.nextInt();
    int w = sc.nextInt();
    int t = sc.nextInt();
    if(Math.abs(b-a) <= (long)t*(v-w))
      System.out.println("YES");
    else
      System.out.println("NO");
  }
}


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

using namespace std;

vector<int> ans(100000, -1);
vector<vector<int>> to(100000);
vector<vector<int>> cost(100000);

void dfs(int v)
{
    for (int i = 0; i < to[v].size(); i++)
    {
        int u = to[v][i];
        if (ans[u] != -1)
            continue;
        ans[u] = (ans[v] + cost[v][i]) % 2;
        dfs(u);
    }
}

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

    for (int i = 0; i < n - 1; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(c);
        cost[b].push_back(c);
    }

    dfs(0);

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

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;

int main(){
    int N,K;
    cin>>N>>K;
    vector<LL>V(N);
    REP(i,N){
        cin>>V[i];
    }
    LL res=0;
    
    for(int r=0;r<=K;r++)for(int l=0;l<=K-r;l++)if(r+l<=N){
        //cout<<r<<" "<<l<<endl;
        LL tmp=0;
        priority_queue<LL,vector<LL>,greater<LL>>pq;
        REP(i,r){
            tmp+=V[i];
            pq.push(V[i]);
        }
        REP(i,l){
            tmp+=V[N-i-1];
            pq.push(V[N-i-1]);
        }
        //cout<<tmp<<endl;
        int cnt=0;
        while(!pq.empty()&&pq.top()<0&&r+l+cnt<K){
            tmp-=pq.top();pq.pop();cnt++;
        }
        
        res=max(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
a = input()
num = a.split(" ")

sq = ( float(num[0])-float(num[2]) )*( float(num[0])-float(num[2]) ) + ( float(num[1])-float(num[3]) )*( float(num[1])-float(num[3]) )
print (round(sq**0.5,8))


Measured memory_bytes: 5616
N,A,B = [ int(it) for it in input().split() ]
li = [ int(input()) for i in range(N) ]

def isOK(p):
  lic = sum([ (max(0,it-p*(B))+(A-B-1))//(A-B) for it in li ])
  if lic <= p:
    return True
  else:
    return False

low = 0
high = 10000000000
for i in range(1000000000):
  key = (low+high)//2
  flag = isOK(key)
  if ( flag ):
    high = key
  else:
    low = key
  if ( low + 1 >= high ):
    break
print ( high )

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

using namespace std;

int main()
{
	//
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	int n;
	cin>>n;

	vector<vector<int>> inp(n, vector<int>(3));  

	for(int i=0; i<n; i++)
		cin>>inp[i][0]>>inp[i][1]>>inp[i][2];

	vector<vector<int>> dp(n, vector<int>(3));

	dp[0][0] = inp[0][0];
	dp[0][1] = inp[0][1];
	dp[0][2] = inp[0][2];

	for(int i=1; i<n; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + inp[i][0];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + inp[i][1];
		dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + inp[i][2];
	}

	int m = max(dp[n-1][0], dp[n-1][1]);

	m = max(m, dp[n-1][2]);
	cout<<m<<endl;
	
    return 0;
}

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

typedef long long ll;

class Point {
public:
  ll x, y;
  
  Point () {}
  Point ( ll x = 0, ll y = 0 ) : x(x), y(y) {}
  
  Point operator - ( const Point &p ) const { return Point(x - p.x, y - p.y); }
};
  
typedef Point Vector;
  
typedef vector<Point> Polygon;
  
ll dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
ll cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; }

/*
  contain: 2
  on segment: 1
  the other case: 0
*/
int
pointInPolygon(Polygon G, Point p) {
  
  int n = G.size();
  bool x = false;
  
  for(int i=0; i<n; i++) {
    Vector V1 = G[i] - p, V2 = G[(i+1)%n] - p;
    
    if( V1.y > V2.y ) swap(V1, V2);
    if( V1.y <= 0 && 0 < V2.y && cross(V1, V2) > 0 ) x = !x;
    if( cross(V1, V2) == 0 && dot(V1, V2) <= 0 ) return 1;
  }
  return (x?2:0);
}
  
int
main() {
  int n, q;
  ll x, y;
    
  Polygon G;
  cin >> n;
    
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    G.push_back(Point(x, y));
  }
    
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> x >> y;
    cout << pointInPolygon(G, Point(x, y)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int max_number = 0;
			int max_value = 0;
			for(int i=0;i<n;i++){
				int number = stdIn.nextInt();
				int value = stdIn.nextInt()+stdIn.nextInt();
				if(max_value<value){
					max_number = number;
					max_value = value;
				}
			}
			System.out.println(max_number+" "+max_value);
		}
	}
}

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

vector<vector<int>> g;
vector<int> o;
map<int, int> ad;
vector<ll> c;

int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.size();
	vector<string> a(0);
	vector<string> b(1);
	rep(i, s.size()){
		int l = min(n-i+1, 6);
		for(int j=1; j<l; j++){
			a.push_back(s.substr(i, j));
	//		cout << i << ' ' << j << ' ' << s.substr(i, j) << endl;
		}
	}
	sort(a.begin(), a.end());/*
	rep(i, a.size()) cout << a.at(i) << ' ';
	cout << endl;*/
	b.at(0) = a.at(0);
	rep(i, a.size()-1) if(a.at(i) != a.at(i+1)) b.push_back(a.at(i+1));
	cout << b.at(k-1) << endl;
	return 0;
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(string, s);

  int cnto = 0, cntx = 0;
  for (auto e : s) {
    if (e == 'o')
      cnto++;
    else
      cntx++;
  }
  cnto += 15 - sz(s);

  cout << (cnto >= 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int A,B,C,D;
    cin>>A>>B;
    cin>>C>>D;
    if(A<=B and B<=C and C<=D)
        cout<<0;
    else
    if(A<=C and C<=B and B<=D)
        cout<<B-C;
    else
    if(A<=C and C<=D and D<=B)
        cout<<D-C;
    else
    if(C<=A and A<=B and B<=D)
        cout<<B-A;
    else
    if(C<=A and A<=D and D<=B)
        cout<<D-A;
    else
    if(C<=D and D<=A and A<=B)
        cout<<0;
	return 0;
}

Measured memory_bytes: 256
s = input()
s = list(map(int,[s[0:2],s[2:4]]))
if s[0] <= 12 and 0 < s[0] and s[1] <= 12 and 0 < s[1]:
        print("AMBIGUOUS")
elif s[0] <= 12 and 0 < s[0]:
        print("MMYY")
elif s[1] <= 12 and 0 < s[1]:
        print("YYMM")
else:
        print("NA")

Measured memory_bytes: 3064
// https://beta.atcoder.jp/contests/abc080
// status: [review]

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

// 時間を引き伸ばす
// 各時刻で必要な録画機の数をカウントしたいが、時刻S - 0.5はそのままインデックスにはできないので2倍に引き伸ばす
template <typename T>
constexpr size_t extend_time(T time) { return static_cast<size_t>(2 * time); }
const int MAX_N = 100000;

int s[MAX_N], t[MAX_N], c[MAX_N];
// tt[time] timeで使用している録画機の台数
int tt[extend_time(MAX_N + 1)];
int sum[extend_time(MAX_N + 1)];
int N, C;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3
)");
    stringstream stream(program_input);
#endif
    stream >> N >> C;
    for (int i = 0; i < N; ++i) stream >> s[i] >> t[i] >> c[i];

    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= C; ++i) {
        memset(tt, 0, sizeof(tt));

        for (int j = 0; j < N; ++j) {
            if (c[j] == i) {
                tt[extend_time(s[j] - 0.5)]++;
                tt[extend_time(t[j])]--;
            }
        }

        for (int j = 1; j < extend_time(MAX_N + 1) ; ++j) tt[j] += tt[j - 1];
        for (int j = 0; j < extend_time(MAX_N + 1); ++j) if (0 < tt[j]) sum[j]++;
    }

    auto ans = *max_element(sum, sum + (MAX_N + 1) * 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n),b(n),v;
    map<int,ll> mp;
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
        mp[a[i]] += b[i];
    }
   
    ll ans = 0;
    for(auto i : mp){
        ans += i.second;
        if(ans>=k){
            cout << i.first<<endl;
            return 0;
        }
    }     
}      
            
            

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
const ll MOD=1e9+7;

ll tim(ll a, ll b){
	return (a*b)%MOD;
}


int main(){
	int N;
	cin>>N;
	priority_queue<P> q;
	rep(i,N){
		int a;
      	cin>>a;
		q.push(make_pair(a,1));
	}
	rep(i,N){
		int a;
      	cin>>a;
		q.push(make_pair(a,-1));
	}
	
	ll dif=0;
	ll ans=1;
	while(!q.empty()){
		P p=q.top();
		q.pop();
		ll f=(ll)p.second;
		if(dif==0)dif+=f;
		else if(dif>0){
			if(f==1)dif++;
			else{
				ans=tim(ans, dif);
				dif--;
			}
		}
		else{
			if(f==-1)dif--;
			else{
				ans=tim(ans, -dif);
				dif++;
			}
		}
	}
	cout<<ans<<endl;
	
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
import math
A, B, H, M = list(map(int, input().split()))
angleS = (H * 60 + M) * 0.5
angleL = M * 6
C = abs(angleS - angleL)
answer = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(C)))
print(answer)

Measured memory_bytes: 62408
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)

int main()
{
  string s;
  int maxv = 0;
  int m[3] = {'J','O','I'};

  cin >> s;
  int i = 0;
  while(i < s.size()) {
    if(m[0] == s[i]) {
      int count[3] = {0};
      Rep(j,3)for(; m[j] == s[i]; i++, count[j]++);
      if(min(count[0],count[2]) < count[1])continue;
      maxv = max(maxv,count[1]);
    } else i++;
  }
  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 3960
def answer(x,y):
    if(x==0):
        return y
    elif y==0:
        return x
    if(x>=y):
        return answer(y,x%y)
    else:
        return answer(x,y%x)
xy= list(map(int,input().split(" ")))
x,y=xy[0],xy[1]
print(answer(x,y))



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

int chars[50][27]={0};
int mins[27]={0};

int main(){
    int n;
    scanf("%d",&n);
    vector<string> strs;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        strs.push_back(s);
    }

    for(int i=0;i<n;++i){
        for(int j=0;j<strs[i].size();++j){
                ++chars[i][strs[i][j]-'a'];
        }
    }

    for(int i=0;i<26;++i){
        int minimum=chars[0][i];
        for(int j=1;j<n;++j){
            if(chars[j][i] < minimum)minimum = chars[j][i];
        }
        mins[i] = minimum;
    }
    for(int i=0;i<26;++i){
        while(mins[i] > 0){
            printf("%c",'a'+i);
            --mins[i];
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,tot,a[111];
int calc(){
	for(int i=0; i<n; i++){
		tot -= a[i];
		if(tot < 0)return i;
	}
	if(tot > 0)return n-1;
	return n;
}
int main(){
	scanf("%d%d",&n,&tot);
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	printf("%d\n",calc());
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll    long long
#define pb          push_back
#define F first
#define S second
#define    endl        '\n'
#define all(v) (v).begin(), (v).end()
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os   << '(' << p.first << ", " << p.second << ')';
}
void dbg_out()
{
    cerr << endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
const int N = 3e5 + 5;
std::vector<ll> p(N, -1),sz(N,1);
ll root(ll x)
{
    if(p[x] == -1) return x;
    return p[x] = root(p[x]);
}
void unite(ll x, ll y)
{
    x = root(x);
    y = root(y);
    if(x != y) p[x] = y,sz[y]+=sz[x];
}
void solve()
{
    ll n, m,x,y;
    cin >> n >> m;
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        unite(x,y);
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
        if(p[i]==-1)
            ans=max(ans,sz[i]);
    cout<<ans;
}
int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    ll TESTS = 1;
    // cin >> TESTS;
    for(int t = 1; t <= TESTS; t++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 7824
#include<stdio.h>

int main(void){
    int num;
    char ini;
    int count = 1;

    scanf("%d",&num);
    char slime[num];

    for(int i = 0; i < num+1; i++){
        scanf("%c",&slime[i]);
        if(i >= 1 && slime[i-1]!=slime[i]){
            count++;
        }
    }
    count--;
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 256
k = int(input())
lunlun = list(range(1, 10))
 
for i in range(k-1):
    a = lunlun[i]
    b = a * 10 +  a % 10 
    if a % 10 != 0:
        lunlun.append(b - 1)
    lunlun.append(b)
    if a % 10 != 9:
        lunlun.append(b + 1)
 
print(lunlun[k-1])

Measured memory_bytes: 15768
# AOJ DSL_2_A "Range Minimum Query"
# SegmantTreeの実装
import sys
input = sys.stdin.readline

# 初期化最大値
INF = 0

class SegmentTree:
    def __init__(self, N):
        self.N = 2**(N-1).bit_length()
        self.data = [-INF for _ in range(2*self.N-1)]
    
    # O(N)で初期化
    def compose(self, A):
        for k, a in enumerate(A):
            self.data[k+self.N-1] = a
        first = self.N - 1
        while first > 0:
            first = (first-1)//2
            for k in range(first, 2*first+1):
                if self.data[2*k+1] > self.data[2*k+2]:
                    self.data[k] = self.data[2*k+1]
                else:
                    self.data[k] = self.data[2*k+2]

    # k番目の値(0-indexed)をaに変更
    def update(self, k, a):
        self.data[k+self.N-1] = a
        k += self.N - 1
        while k > 0:
            k = (k-1)//2
            if self.data[2*k+1] > self.data[2*k+2]:
                self.data[k] = self.data[2*k+1]
            else:
                self.data[k] = self.data[2*k+2]

    # [l, r)
    # kがNodeの番号、対応する区間が[a, b)
    def query_max(self, l, r):
        if l+1 == r:
            return self.data[l+self.N-1]
        L = l + self.N
        R = r + self.N
        s = -INF
        while L < R:
            if R & 1:
                R -= 1
                if s < self.data[R-1]:
                    s = self.data[R-1]
            if L & 1:
                if s < self.data[L-1]:
                    s = self.data[L-1]
                L += 1
            L >>= 1; R >>= 1
        return s


def main():
    MAX = 3*10**5+5

    import sys
    input = sys.stdin.buffer.readline

    N, K = map(int, input().split())
    A = [int(input()) for _ in range(N)]

    ST = SegmentTree(MAX)
    # dp = [0]*(N+1)
    ans = 0
    for i, a in enumerate(A):
        maxscore = ST.query_max(max(a-K, 0), min(a+K+1, MAX))
        # dp[i+1] = dp[max(maxind, 0)] + 1
        ans = max(maxscore+1, ans)
        ST.update(a, maxscore+1)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 151552
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3])
    cout << "Bad" << en;
  else
    cout << "Good" << en;

  return 0;
}

Measured memory_bytes: 256