akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

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

    vector<pair<long long, bool> > v(n+m);
    for(int i=0; i<n+m; ++i){
        cin >> v[i].first;
        v[i].second = (i < n);
    }
    v.push_back(make_pair(-INF, false));
    v.push_back(make_pair(INF, false));
    sort(v.begin(), v.end());
    n += m + 2;

    vector<long long> prev(2, -INF);
    vector<long long> cost(n);
    for(int i=0; i<n; ++i){
        int j = (v[i].second ? 0 : 1);
        cost[i] = v[i].first - prev[j^1];
        prev[j] = v[i].first;
    }
    prev.assign(2, INF);
    for(int i=n-1; i>=0; --i){
        int j = (v[i].second ? 0 : 1);
        cost[i] = min(cost[i], prev[j^1] - v[i].first);
        prev[j] = v[i].first;
    }

    while(--q >= 0){
        long long x;
        cin >> x;
        int i = lower_bound(v.begin(), v.end(), make_pair(x, false)) - v.begin();
        long long ans = cost[i] + (v[i].first - x);
        -- i;
        ans = min(ans, cost[i] + (x - v[i].first));
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

// void time() {
//     #ifndef ONLINE_JUDGE
//     cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
//     #endif
// }
 

  int32_t main()
  {        
   
     IOS

     int n;
     cin >> n;
     cout << (n-1)/2;


     

    //time();
    return  0;
     }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,U,W,X,Y,Z;
string S,T;

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

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

int main() {
  int n,d;
  cin >> n >> d;
  if (n % (d*2+1) == 0) cout << n / (d*2+1) << endl;
  else cout << n / (d*2+1) + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,a[maxn],b[maxn],c[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<n;i++)
        scanf("%d",&c[i]);
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=b[i];
        if(i>1 && a[i]==a[i-1]+1){
            sum+= c[a[i]-1];
        }
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		while ((n > 0) && (k > 0)){
			int[] s = new int[k];
			for (int i = 0; i < k; i++){
				s[i] = sc.nextInt();
			}
			int[][] b = new int[n][k];
			for (int i = 0; i < n; i++){
				for (int j = 0; j < k; j++){
					b[i][j] = sc.nextInt();
				}
			}
			int i = 0, j, flag = 1;
			while (i < n){
				j = 0;
				while (j < k){
					s[j] -= b[i][j];
					if (s[j] < 0){
						System.out.println("No");
						flag = 0;
						i = n;
						j = k;
					}
					j++;
				}
				i++;
			}
			if (flag > 0){
				System.out.println("Yes");
			}
			n = sc.nextInt();
			k = sc.nextInt();
		}
	}

}



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

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 2; i < n; i++){
        if (s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long k = scanner.nextInt();

        final List<Long> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextLong())
                .collect(Collectors.toList());

        final int all = n * (n + 1) / 2;
        final List<Long> sums = new ArrayList<>(all / 2);
        for (int i = 0; i < n; i++) {
            long sum = list.get(i);
            sums.add(sum);
            for (int j = i + 1; j < n; j++) {
                sum += list.get(j);
                sums.add(sum);
            }
        }
        Collections.sort(sums);
        Collections.reverse(sums);

        final int tableLength = Long.toBinaryString(sums.get(0)).length();
        final boolean[][] table = new boolean[all][tableLength];
        for (int i = 0; i < all; i++) {
            final long tmp = sums.get(i);
            final String s = Long.toBinaryString(tmp);
            for (int j = s.length() - 1; j >= 0; j--) {
                final char c = s.charAt(j);
                table[i][s.length() - j - 1] = c == '1';
            }
        }

        final Set<Integer> exceptIndices = new HashSet<>();
        final List<Integer> digits = new ArrayList<>();
        for (int i = tableLength - 1; i >= 0; i--) {
            if (exceptIndices.size() > all - k) {
                break;
            }
            final Set<Integer> trues = new HashSet<>();
            final Set<Integer> falsies = new HashSet<>();
            for (int j = 0; j < all; j++) {
                if (exceptIndices.contains(j)) {
                    continue;
                }
                if (table[j][i]) {
                    trues.add(j);
                } else {
                    falsies.add(j);
                }
            }
            if (trues.size() >= k) {
                digits.add(i);
                exceptIndices.addAll(falsies);
            }
        }

        long sum = 0;
        for (final int value : digits) {
            sum += Math.pow(2, value);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 273728
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	short int n;
	while (cin >> n) {
		for(int i=1; n>0; i*=2,n/=2){
			if (n % 2 == 1) {
				cout << i;
				if (n > 1)
					cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3056
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

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

const int MAXN = 1e5+5;
int N, d[MAXN];

void dijk(){
    ms(d,0x3f);
    priority_queue<ii> pq;
    FOR(i,1,10){
        pq.push({-i,i%N});
        mnze(d[i%N], i);
    }
    while(!pq.empty()){
        int v=pq.top().snd, dd=-pq.top().fst; pq.pop();
        if(dd!=d[v]) continue;
        FOR(i,0,10){
            int u=(v*10+i)%N;
            if(d[u] > d[v]+i){
                d[u] = d[v]+i;
                pq.push({-d[u], u});
            }
        }
    }
}

int main(){
    scan(N);
    dijk();
    int ans = d[0];
    printf("%d\n",ans);
}


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

int main() {
	string a, b;
	cin >> a >> b;
	int alen, blen;
	alen = a.length();
	blen = b.length();
	
	if(alen>blen){ cout << "GREATER" ;}
	else if (alen<blen){ cout << "LESS" ;}
	else {
	
		for(int i=0;a[i]!=0;i++){
			//int ai = atoi(a[i]);
			//int bi = atoi(b[i]);
			if(a[i]>b[i]){
				cout << "GREATER" ;
				break;
			}
			else if(a[i]<b[i]){
				cout << "LESS" ;
				break;
			}
			else if (i==alen-1){ cout << "EQUAL" ;}
		} 
	}


	return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	operator int() const { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	inline modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline modulo& operator *= (const modulo &b) { w = (num) w * b.w % mod; return *this; }
	inline modulo& operator /= (const modulo &b) { w = (num) w * b.inv() % mod; return *this; }
	inline modulo  operator +  (const modulo &b) const { modulo r = *this; r += b; return r; }
	inline modulo  operator -  (const modulo &b) const { modulo r = *this; r -= b; return r; }
	inline modulo  operator *  (const modulo &b) const { modulo r = *this; r *= b; return r; }
	inline modulo  operator /  (const modulo &b) const { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9 + 7);
typedef modulo<mod> rem;

const int nsz = int(5e3);
int n, k, a[nsz + 5];
rem dp[nsz + 5], ans;
vector<int> r;

struct union_find {
	int pr[nsz + 5], siz[nsz + 5];
	
	union_find() {
		cont (u, nsz) pr[u] = u, siz[u] = 1;
	}
	
	int inline operator [] (int id) { return qry(id); }
	
	int qry(int u) { return pr[u] == u ? u : pr[u] = qry(pr[u]); }
	
	bool inline link(int u, int v) {
		int pu = qry(u), pv = qry(v);
		if (pu == pv) return 0;
		pr[pv] = pu;
		siz[pu] += siz[pv];
		return 1;
	}
};
union_find uf;

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
		if (a[i] != -1) uf.link(a[i], i);
		if (a[i] == -1) r.push_back(i);
	}
	k = int(r.size());
	
	cont (u, n) {
		if (uf[u] != u || a[u] == -1) continue;
		ans += rem(n - 1).pow(k);
	}
	
	dp[0] = 1;
	loop (i, k) {
		int sz = uf.siz[r[i]];
		for (int j = i; j >= 0; --j) {
			dp[j + 1] += dp[j] * (j ? rem(j) : rem(1)) * rem(sz);
		}
	}
	
	cont (j, k) {
		ans += dp[j] * rem(n - 1).pow(k - j);
	}
	cont (u, n) {
		if (uf[u] != u || a[u] != -1) continue;
		ans -= rem(n - 1).pow(k - 1);
	}
	
	ans = rem(n) * rem(n - 1).pow(k) - ans;
	printf("%d\n", ans);
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;




int main(){
    ofstream out("output.txt");
    
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i =0;i<n;i++) cin>>b[i];
    for(int i=0;i<n-1;i++) cin>>c[i];

    int anterior = -10;
    int res = 0;
    for(int i = 0;i<n;i++){
        res += b[a[i]-1];
        if(a[i] == a[i-1]+1){
            res+=c[a[i]-2];
        }
        anterior = a[i];
        
        //cout<<res<<" "<<anterior<<" "<<i<<endl;
    }
    cout<<res<<endl;
    return 0;
}

 
 







Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int i = sc.nextInt();
    int qt;
    qt = i / (60 * 60);
    System.out.print(qt + ":");
    i -= qt * (60 * 60);
    qt = i / 60;
    System.out.print(qt + ":");
    i -= qt * 60;
    System.out.println(i);
    sc.close();
  }
}



Measured memory_bytes: 26344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

long long gcd(long long a, long long b){
	return b == 0 ? a : gcd(b, a%b);
}


int main(){
	int t;
	long long a, b, c, d;
	scanf("%d", &t);
	while(t--){
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		if(a < b)	printf("No\n");
		else if(b > d) printf("No\n");
		else if(c >= b)	printf("Yes\n");
		else{
			long long temp, temp1;
			temp = gcd(b ,d);
			temp1 = b - temp + a % temp;
			if(temp1 > c)
				printf("No\n");
			else
				printf("Yes\n");
		}
	}
return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
H = list(map(int,input().split()))
flag = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if H[a] > H[b]:
        flag[b] = 0
    elif H[a] < H[b]:
        flag[a] = 0
    else:
        flag[a] = 0
        flag[b] = 0
print(sum(flag))


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

void lcs( string s, string t, int m, int n ){ 
int L[m+1][n+1]; 


for (int i=0; i<=m; i++){ 
	for (int j=0; j<=n; j++){ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (s[i-1] == t[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

/*for (int i=0; i<=m; i++){ 
	for (int j=0; j<=n; j++){ 
		printf("%d ", L[i][j]);
	} 
	printf("\n");
} */

int indice = L[m][n]; 

char lcs[indice+1] = {'\0'}; 

int i = m, j = n; 

//printf("--- %d %d\n", i, j);
while (i > 0 && j > 0){ 
	
	if (s[i-1] == t[j-1])	{ 
		lcs[indice-1] = s[i-1]; 
		i--; j--; indice--;	 
	} 

	else if (L[i-1][j] > L[i][j-1]){ 
		//printf("-----------%d %d -  %d %d\n", i, j, L[i-1][j], L[i][j-1]);
		i--;
	} 
	else{
		//printf("+++++%d %d - %d %d\n", i, j, L[i-1][j], L[i][j-1]);
		j--; 
	}
} 

	cout<< lcs << endl; 
} 

int main(){ 

	string s, t;
	getline(cin, s);
	getline(cin, t);
	int sz = s.size(); 
	int tz = t.size(); 
	lcs(s, t, sz, tz);

	return 0; 
	
} 


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int maximum=*max_element(a.begin(),a.end());
  int minimum=*min_element(a.begin(),a.end());
  
  cout << maximum-minimum << endl;
  
  
}

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

int main(){
    using namespace std;
    unsigned long N, K, S;
    cin >> N >> K >> S;
    for(unsigned long i{0}; i < K; ++i)cout << S << " ";
    if(S == 1000000000)for(unsigned long i{K}; i < N; ++i)cout << S - 1 << " ";
    else for(unsigned long i{K}; i < N; ++i)cout << S + 1 << " ";
    return 0;
}

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

int main(){
  
  int A, B;
  cin >> A >> B;
  
  if(A > 12){
    cout << B << endl;
    return 0;
  }
  if(A > 5){
    cout << B/2 << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}

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

int main(void){
    int a,b,q;
    cin >> a >> b >> q;
    set<ll> setA = {-INF, +INF}, setB = {-INF, +INF};
    rep(i,a){
        ll s;
        cin >> s;
        setA.insert(s);
    }
    rep(i,b){
        ll t;
        cin >> t;
        setB.insert(t);
    }
    rep(i,q){
        ll x;
        cin >> x;
        ll a1 = *(--setA.lower_bound(x));
        ll a2 = *(setA.lower_bound(x));
        ll b1 = *(--setB.lower_bound(x));
        ll b2 = *(setB.lower_bound(x));
        cout << min({
            max(a2,b2)-x,
            x-min(a1,b1),
            (b2-x)*2 + (x-a1),
            (a2-x)*2 + (x-b1),
            (x-a1)*2 + (b2-x),
            (x-b1)*2 + (a2-x)
        }) << endl;
    }
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  double ans = 0;
  while(n--){
    double x; string s;
    cin >> x >> s;
    if(s == "JPY") ans += x;
    else ans += x * 380000;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

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

const double PI = 3.141592653589793;

int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	int A, B, H, M;
	scanf("%d%d%d%d", &A, &B, &H, &M);

	double a = (((double)H / 12 + (double)M / 720) - int((double)H / 12 + (double)M / 720)) * 2 * PI;
	double b = (((double)H + (double)M / 60) - int((double)H + (double)M / 60)) * 2 * PI;

	double C = A * A + B * B - 2 * A*B*cos(fabs(a - b));
	printf("%.10f", sqrt(C));
	return 0;
}




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

int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	double h = 2 * M_PI * (H + M / 60.0) / 12.0;
	double m = 2 * M_PI * M / 60.0;
	double d = sqrt(A * A + B * B - 2 * A * B * cos(h - m));
	cout << fixed << setprecision(15) << d << endl;
	return 0;
}


Measured memory_bytes: 4192
s = input()
sg = s.replace('BC', 'G')
sg = sg + 'E'

ans = 0
anstmp = 0
acount = 0
for i in sg:
    if i == 'A':
        acount += 1
    elif i == 'G':
        anstmp += acount
    else:
        ans += anstmp
        acount = 0
        anstmp = 0

print(ans)

Measured memory_bytes: 3500
A,B = map(int, input().split())

fa = 0
if A%2 == 0 and A%4 == 0:
    fa = 0
elif A%2 == 0 and A%4 != 0:
    fa = 1
elif A%2 != 0 and (A-1)%4 == 0:
    fa = ((A-1) ^ 0)
elif A%2 != 0 and (A-1)%4 != 0:
    fa = (A-1) ^ 1

fb = 0
if (B+1)%2 == 0 and (B+1)%4 == 0:
    fb = 0
elif (B+1)%2 == 0 and (B+1)%4 != 0:
    fb = 1
elif (B+1)%2 != 0 and B%4 == 0:
    fb = (B ^ 0)
elif (B+1)%2 != 0 and B%4 != 0:
    fb = (B ^ 1)

print(fa ^ fb)

Measured memory_bytes: 3064
# coding:utf-8

S = input()
K = int(input())

days = 5000000000000000
strNum = 0
calcEnd = False
for i in S:
    i_int = int(i)
    iNum = 1
    # iNum = i_int ** days
    if i_int == 1:
        iNum == 1
        if strNum + iNum >= K:
            ans = i
            calcEnd = True
            break

    else:
        for j in range(days):
            iNum *= i_int

            if strNum + iNum >= K:
                ans = i
                calcEnd = True
                break

    strNum += iNum

    if calcEnd == True:
        break

print(ans)

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

int main(){
    list<int> l;

    int n;
    cin >> n;

    //n回入力されるのでそれをさばく
    for(int i=0;i<n;i++){
        char s[20];
        cin >> s;

        //insertのとき
        if(s[0]=='i'){
            int x;
            cin >> x;

            l.push_front(x);
        }else if(s[6]=='F'){
            //deleteFirstのとき
            l.pop_front();
        }else if(s[6]=='L'){
            //deleteLastのとき
            l.pop_back();
        }else{
            //deleteのとき
            int x;
            cin >> x;

            for(list<int>::iterator it=l.begin();it!=l.end();it++){
                if(*it==x){
                    l.erase(it);
                    break;
                }
            }
        }
    }

    //出力
    for(list<int>::iterator it=l.begin();it!=l.end();it++){    
        if(it!=l.begin()){
            cout << ' ';
        }
        cout << *it;
    }
    cout << endl;
}


Measured memory_bytes: 34248
import java.util.Scanner;

public class Main {

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

        int n;
        n = in.nextInt();

        long[] array = new long[n];

        boolean flg = true;

        for(int i = 0;i<n; i++)
        {
            array[i] = in.nextLong();
            if(array[i]%2 == 0)
            {
                if((array[i]%3)*(array[i]%5) != 0)
                {
                    flg = false;
                }
            }
        }

        if(flg)
        {
            System.out.println("APPROVED");
        }
        else{
            System.out.println("DENIED");
        }



    }

}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int l; cin >> l;
    vector<int> a(l+1);
    for(int i = 1; i <= l; ++i) cin >> a[i];

    vector<vector<int>> dp(l+1, vector<int>(5, 0));

    for(int i = 1; i <= l; ++i) {
        int ai = a[i];
        dp[i][0] = dp[i-1][0] + ai;
        int e = ai%2 + (ai==0)*2;
        dp[i][1] = e + min(dp[i-1][0], dp[i-1][1]);
        int f = (ai+1)%2;
        dp[i][2] = f + min(dp[i-1][0], min(dp[i-1][1], dp[i-1][2]));
        dp[i][3] = e + min(dp[i-1][0], min(dp[i-1][1], min(dp[i-1][2], dp[i-1][3])));
        dp[i][4] = ai + min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3], dp[i-1][4]});
    }

    cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << endl;
    
    return 0;
}


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

int main() {
  int64_t N,K;
  cin>>N>>K;
  
  map<int64_t,int64_t> dic;
  for(int i=0;i<N;i++){
    int64_t a,b;
    cin>>a>>b;
    dic[a]+=b;
  }
  int64_t sum=0;
  for(auto & x:dic){
    sum+=x.second;
    if(sum>=K){
      cout<<x.first<<endl;
      return 0;
    }
  }
    
    
}

Measured memory_bytes: 7556
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<12, mod = 998244353 , lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vi a(n), b;
	ll ans = 0, t = 0;
	for(auto &i : a) cin >> i, t ^= i;
	ans += t;
	t = (1ll<<60) - 1 - t;
	for(auto &i : a) {
		i&=t;
		for(auto j : b) i = min(i, i^j);
		if(i) b.pb(i);
	}
	t = 0;
	for(auto &i : b) t = max(t, t^i);
	ans += t<<1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

struct guide{
    string city;
    int point;
    
    guide(string s, int p){
        city = s;
        point = p;
    }
    bool operator<(const guide &another) const
    {
        return city==another.city ? point<another.point : city>another.city;
    };
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<string,int>> v;
    REP(i,n){
        string s;
        int p;
        cin>>s>>p;
        v.push_back({s,p});
    }
    vector<int> idx(v.size());
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),
         [=](int x, int y){return v[x].first == v[y].first ? v[x].second > v[y].second : v[x].first < v[y].first ;}
         );

    for(auto i:idx){
        cout<<i+1<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  set<int> ans;
  for(int i=0;i<3;i++)
  {
	if(s[i]=='R')
      ans.insert(i);
  }
  if(ans.size()!=2)
    cout<<ans.size();
  else 
  {
	if(s[0]=='R' && s[1]=='R')
      cout<<2;
    else if(s[2]=='R' && s[1]=='R')
      cout<<2;
    else
      cout<<1;
  }
  return 0;
}
    


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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(i == 0 || i == (H - 1) || j == 0 || j == (W - 1)) {
                    cout << "#" << flush;
                } else {
                    cout << "." << flush;
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>

int main(void)
{
	int num1 = 0;
	int num2 = 0;
	
	for (num1 = 1; num1 <= 9; num1++) {
		for (num2 = 1; num2 <= 9; num2++) {
			printf ("%dx%d=%d\n", num1, num2, num1 * num2);
		}
	}	

	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
 int main(void)
 {
     long A[10000];
     int N,M,i;
     scanf("%d%d",&N,&M);
     for(i=0;i<M;i++)
       scanf("%ld",&A[i]);
   
     for(i=0;i<M;i++)
       N=N-A[i];
     
     if(N>=0) printf("%d\n",N);
     else     printf("-1\n");
   return 0;
 }

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int ans = n;
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, n - (i + 1)));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const double PI=3.14159265358979323846;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint x(n);
  vint cp(n);
  rep(i,n){
    cin>>x[i];
    cp[i]=x[i];
  }
  sort(all(cp));
  rep(i,n){
    if(x[i]<=cp[n/2-1]){
      cout<<cp[n/2]<<'\n';
    }
    else{
      cout<<cp[n/2-1]<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 3840
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
num = 0
for i in range(2**N): 
  B = [0 for _ in range(M)] 
  for j in range(N):
    if ((i>>j)&1):
      for k in range(M):
        if j+1 in List[k][1:]:
          B[k] += 1
  for l in range(M):
    if B[l] % 2 != p[l]:
      break
  else:
    num += 1
print(num)

Measured memory_bytes: 74444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void Libra() {
	int A, B, C, D;
	cin >> A >> B >> C >>D;
	int ab = A + B;
	int cd = C + D;
	if (ab < cd) cout << "Right" << endl;
	else if (ab == cd) cout << "Balanced" << endl;
	else cout << "Left" << endl;
}
int main() {
	Libra();
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val balls_num  = scala.io.StdIn.readInt
    val robotB_x   = scala.io.StdIn.readInt
    val balls_x    = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var total_move = 0

    balls_x.foreach { i =>
      val robotB_dis = Math.abs( i - robotB_x ).toInt
      if( robotB_dis < i ) total_move += robotB_dis else total_move += i
    }

    println( total_move*2 )
  }
}

Measured memory_bytes: 54560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  double p=0;
  for(int i=1;i<=n;i++){
    double pi=1.0/n;
    int x=i;
    while(x<k){
      pi/=2;
      x*=2;
    }
    p+=pi;
  }
  cout<<fixed<<setprecision(16)<<p<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> H >> W >> N;
	set<pair<int, int>>st;
	map<int, int>xp;
	map<int, int>yp;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		xp[L]++;
		yp[R]++;
		st.insert({ L, R });
	}
	int xnum = 0, ynum = 0;
	vector<int>xbox;
	vector<int>ybox;
	for (auto i : xp) {
		xnum = max(xnum, i.second);
	}
	for (auto i : xp) {
		if (i.second == xnum)xbox.push_back(i.first);
	}
	for (auto i : yp) {
		ynum = max(ynum, i.second);
	}
	for (auto i : yp) {
		if (i.second == ynum)ybox.push_back(i.first);
	}
	int ans = xnum + ynum - 1;
	for (auto i : xbox) {
		for (auto j : ybox) {
			if (st.find({ i,j }) == st.end()) {
				cout << ans + 1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 49604
def main():
	# a,b,k = map(int,input().split())
	n,k = map(int,input().split())
	# s = int(input())
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)

	if n - 2*k < 0:
		print(0)
	else:
		print(n - 2*k)

 
if __name__ == '__main__':
	main()

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

int main(){

    int n;
    cin>>n;
    vector<int> h(n),dp(n);
    for(int i=0;i<n;i++) cin>>h[i];

    for(int i=1;i<n;i++){
        if(i==1) dp[i]=abs(h[i]-h[i-1]);
        else{
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

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

using namespace std;

int main()
{
  int N, M;
  char a[64][64], b[64][64];
  
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < N; i++) {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < M; i++) {
    scanf("%s", b[i]);
  }
  
  bool ok = false;
  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool found = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (a[i + k][j + l] != b[k][l]) found = false;
        }
      }
      ok |= found;
    }
  } 
  
  printf("%s\n", ok ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
inline int pw(int n,int m,int p=MOD){int r=1;for(;m;m>>=1,n=1ll*n*n%p)if(m&1)r=1ll*r*n%p;return r;}
map<int,int> f;
int n,k;
inline int dfs(int x){
	if(f.count(x))return f[x];
	else if(x==1)return f[x]=k;
	ll p=pw(k,(x+1)/2);
	for(int i=1;i*i<=x;i++){
		if(!(x%i)){
			p=(p-dfs(i))%MOD;
			int y=x/i;
			if(y!=i&&y!=x){
				p=(p-dfs(y))%MOD;
			}
		}
	}
	return f[x]=(p+MOD)%MOD;
}
int main(){
	n=rd(),k=rd();
	ll p=0;
	dfs(n);
	for(int i=1;i*i<=n;i++)if(!(n%i)){
		p=(p+1ll*f[i]*i/(i%2?1:2))%MOD;
		int y=n/i;
		if(y!=i){
			p=(p+1ll*f[y]*y/(y%2?1:2))%MOD;
		}
	}
	cout<<p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    string s, t, u, p;
    int n, a, b;
    cin >> s >> n;
    rep(i, 0, n){
        cin >> t >> a >> b;
        if(t == "print"){
            u = s.substr(a, b - a + 1);
            cout << u << endl;
        }else if(t == "reverse"){
            reverse(s.begin() + a, s.begin() + b + 1);
        }else{
            cin >> p;
            s.replace(a, b - a + 1, p);
        }
    }
}

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

struct P {
	int index;
	int num;
};

bool cmpa(const P& a, const P& b) {
	return a.index < b.index;
}
bool cmpb(const P& a, const P& b) {
	return a.num < b.num;
}


int main() {
	int n;
	cin >> n;
	vector<P> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].num;
		a[i].index = i;
	}
	sort(a.begin(), a.end(), cmpb);
	int num = a[n - 1].num;
	a[n - 1].num = a[n - 2].num;
	for (int i = n - 2; i >= 0; i--) {
		a[i].num = num;
	}
	sort(a.begin(), a.end(), cmpa);
	for (int i = 0; i < n; i++) {
		cout << a[i].num << endl;
	}

}

Measured memory_bytes: 3200
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class SegmentTree():
    '''
    非再帰
    segment tree
    '''

    def __init__(self, n, func, init=float('inf')):
        '''
        n->配列の長さ
        func:func(a,b)->val,　func=minだとRMQになる
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.init = init
        self.data = [init]*(2*self.n)
        self.func = func

    def set(self, k, v):
        '''
        あたいの初期化
        '''
        self.data[k+self.n-1] = v

    def build(self):
        '''
        setの後に一斉更新
        '''
        for k in reversed(range(self.n-1)):
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        list[k]=aに更新する。
        更新ぶんをrootまで更新
        '''
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        '''
        [l,r)のfuncを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.init
        while L < R:
            if R & 1:
                R -= 1
                ret = self.func(ret, self.data[R-1])
            if L & 1:
                ret = self.func(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


INF = -float('inf')
N, M = map(int, input().split())
S = input()[:-1]
Seg = SegmentTree(N+1, lambda a, b: max(a, b), INF)
for i, c in enumerate(reversed(S)):
    if c == "0":
        Seg.set(i, i)
Seg.build()
ans = []
cur = 0

while True:
    nex = Seg.query(min(cur+1, N), min(cur+M+1, N+1))
    if nex == INF:
        ans = [-1]
        break
    else:
        ans.append(nex-cur)
        cur = nex
        if cur == N:
            break
print(" ".join(map(str, reversed(ans))))


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

int main(){
    char ch[101],ptn[100],rnkt[1000];
    
    scanf("%s %s",&ch,&ptn);
    strcpy(rnkt,ch);
    strcat(rnkt,ch);
    
    if(strstr(rnkt,ptn)!=NULL) printf("Yes\n");
    else printf("No\n");
    
    return(0);
    
}

Measured memory_bytes: 540
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
  string S;
  cin >> S;
  ll s = S.size();
  for(int i = 0;i<s;i++){
    if(S[i] == ',')cout << " ";
    else cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//input
	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i] - (i + 1);
	}

	sort(B.begin(), B.end());
	ll mid = B[N / 2];

	ll ret = 0;
	for (int i = 0; i < N; i++) {
		ret += abs(A[i] - (mid + i + 1));
	}

	cout << ret;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        char ch[150];
        for(int i = 0; i < 150; i++) ch[i] = '?';
        for(int i = 0; i < n; i++)
        {
            char a, b;
            cin >> a >> b;
            ch[a - '0'] = b;
        }
        int m;
        cin >> m;
        for(int i = 0; i < m; i++)
        {
            char c;
            cin >> c;
            if(ch[c - '0'] == '?') cout << c;
            else cout << ch[c - '0'];
        }
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3072
n = int(input())
A = list(map(int, input().split()))

from collections import deque
b = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        b.append(a)
    else:
        b.appendleft(a)

if n % 2 == 0:
    print(*b)
else:
    print(*reversed(b))

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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2020
#endif

void solve() {
    int n,k,c;
    cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> L(n + 1), R(n + 1);
    vector<int> sum(n + 1);
    int cnt = 0;
    for (int i = 0; i < n;) {
        if (s[i]=='o') {
            i += c+1;
            L[++cnt] = i;
        }else i++;
    }
    if (cnt != k) {
        cout << "\n"; return;
    }
    R[0] = n-1+c;
    for (int i = n-1, cnt = 0; i >= 0;) {
        if (s[i]=='o') {
            R[++cnt] = i-1;
            i -= c+1;
        } else i--;
    }
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + (s[i]=='o');
    }
    vector<int> res;
    for (int i = 1; i <= k; i++) {
        int l = L[i-1];
        int r = R[k-i];
dbg(i, l, r);
        r -= c;
        if (l > r) continue;
        if (sum[r+1] - sum[l] == 1) {
            for (int x = l; x <= r; x++) {
                if (s[x]=='o') res.push_back(x);
            }
        }
    }
    for (auto& x: res) {
        cout << x+1 << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int n; cin >> n;
	int cnt = 0;
	int next = 1;
	rep(i, n)
	{
		int a; cin >> a;
		if (a == next)
		{
			++cnt;
			++next;
		}
	}
	if (cnt == 0)cout << -1 << endl;
	else cout << n - cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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

  vector<pair<int, int>> drink(n);
  REP(i,n){
    int a, b;
    cin >> a >> b;
    drink[i].first = a;
    drink[i].second = b;
  }

  sort(ALL(drink));

  ll ans = 0;

  REP(i,n){
    if( m >= drink[i].second){
      ans += (ll)drink[i].first * drink[i].second;
      m -= drink[i].second;
      if(m == 0) break;
    }
    else{
      ans += (ll)drink[i].first * m;
      break;
    }

  }

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


Measured memory_bytes: 4020