akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int n, m, k;
long long a[200005];
long long b[200005];
long long suma[200005];
long long sumb[200005];

bool canread(int num){
  bool ans = false;
  for(int i=0;i<=num;i++){
    int j = num - i;
    //Aからi冊 Bからj冊読めるか
    // cout << "num" << num << "n" << n << "m" << m << "i" << i << "j" << j << endl;
    if(n<i||m<j)continue;
    if(suma[i]+sumb[j]<=k){
      ans = true;
      // cout << "ok" << endl;
      break;
    }
  }
  return ans;
}

int main(){  
  cin >> n >> m >> k;
  rep(i, n){
    cin >> a[i];
    suma[i+1]=suma[i]+a[i];
  }
  rep(i, m){
    cin >> b[i];
    sumb[i+1]=sumb[i]+b[i];
  }

  int l=0, r=n+m+1;
  while(r-l>1){
    int c = (r+l)/2;
    // cout << "[" << l << "," << r << "]" << c;
    if(canread(c)) l = c;
    else r = c;
  }
  
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 9864
import itertools
import numpy as np
N=int(input())
retu=[i for i in range(N)]
XY=[]
for i in range(N):
    x=list(map(int,input().split()))
    XY.append(x)
permi=list(itertools.permutations(retu))
goukei=0
count=0
for i in permi:
    count+=1
    for k in range(1,N):
        a=XY[i[k - 1]][0]- XY[i[k]][0]
        b=XY[i[k - 1]][1]- XY[i[k]][1]
        goukei+=(a**2+b**2)**0.5
print(goukei/count)

Measured memory_bytes: 17004
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int N = 41, MOD = 1e9 + 7;
int dp[N][2][1 << 18] = {};
inline void add (int &a, int x) {
    a += x;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    dp[0][0][1] = 1;
    int S = x + y + z + 1, tm = (1 << x) + (1 << (x + y)) + (1 << (x + y + z));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            for (int mask = 0; mask < (1 << S); mask++) {
                if (!dp[i][j][mask]) continue;
                for (int k = 1; k < 11; k++) {
                    int m = (mask << k) & ((1 << S) - 1);
                    m |= 1;
                    add(dp[i + 1][j | ((m & tm) == tm)][m], dp[i][j][mask]);
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << S); i++) add(ans, dp[n][1][i]);
    cout << ans << '\n';
}


Measured memory_bytes: 82176
n, m = list(map(int, input().split()))
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = False
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l]==b[k][l]:
          pass
        else:
          flag = True
          break
      if flag:
        break
    if flag==False:
      print("Yes")
      exit()
print("No")

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

const double pi = 3.1415926535;
/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y % x, x);
}

ll powM(ll x, ll y, ll m) {
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}

map<long long, long long> factorize(long long n) {
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}
/* **********END OF TEMPLATE*********** */
const int mx = 1e5 + 5;


//dfs
queue<int> q;
//bool visited[N];
ll ddd[mx] = {};
vector<ll>  adj[mx];
bool visited[mx];
/*
void bfs(int x) {
	visited[x] = true;
	distance[x] = 0;
	q.push(x);
	while (!q.empty()) {
		int s = q.front(); q.pop();
		// process node s
		//CODE HERE:
		for (auto u : adj[s]) {
			if (visited[u]) continue;
			visited[u] = true;
			distance[u] = distance[s] + 1;
			q.push(u);
		}
	}
}
*/
int main() {
	FAST();
	ll n, m;
	cin >> n >> m;
	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int x = 0;
	visited[x] = true;
	ddd[x] = 0;
	q.push(x);
	while (!q.empty()) {
		int s = q.front(); q.pop();
		// process node s
		//CODE HERE:
		for (auto u : adj[s]) {
			if (visited[u]) continue;
			visited[u] = true;
			ddd[u] = ddd[s] + 1;
			q.push(u);
		}
	}
	bool ok = true;
	for (int i = 0; i < n; i++) {
		ok &= visited[i];
	}
	if (!ok) {
		cout << "No";
	}
	else {
		cout << "Yes\n";
		for (int i = 1; i < n; i++) {
			ll rr = INT_MAX, city = -1;
			for (int x : adj[i]) {
				if (ddd[x] < rr) {
					rr = ddd[x];
					city = x;
				}
			}
			cout << city + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 12988
#include<bits/stdc++.h>
#pragma GCC optimize("inline,Ofast",3)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
#define gc getchar()
#define lowbit(x) (x&(-x))
//register
//inline
//i=-~i
inline long long read(){
	long long sum=0,f=1;
	char ch=gc;
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch)){
		sum=(sum<<1)+(sum<<3)+(ch^48);
		ch=gc;
	}
	return f*sum;
}
long long n,k;
int main(){
	n=read(),k=read();
	if(n*500>=k)printf("Yes");
	else printf("No");
	return 0;
}


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

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    char s = S[0];
    int i = 1;
    while (K) {
        for (; i < N; i++) {
            if (S[i] != s) {
                i++;
                break;
            }
        }
        for (; i < N; i++) {
            if (S[i] == s) {
                i++;
                break;
            }
        }
        if (i == N) {
            cout << N - 1 << endl;
            return 0;
        }
        K--;
    }
    for (; i < N; i++) if (S[i] != s) break;
    int ans = i - 1;
    while (i < N) {
        s = S[i];
        i++;
        for (; i < N; i++) {
            if (S[i] == s) ans++;
            else break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,g;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		if(t!=i){
			g++;
		}
	}
	if(g>2){
		cout<<"NO";
	}
	else{
		cout<<"YES";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = 0;
		int b = 0;
		int menseki = 0;
		int shu = 0;

		a = sc.nextInt();
		b = sc.nextInt();

		menseki = a * b;
		shu = ( a * 2 ) + ( b * 2 );

		System.out.println( menseki + " " + shu );
	}
}

Measured memory_bytes: 26092
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int t[][] = new int[n - 1][3];

		for (int i = 0; i < n - 1; i++) {
			t[i][0] = scanner.nextInt();
			t[i][1] = scanner.nextInt();
			t[i][2] = scanner.nextInt();
		}

		int time = 0;
		for (int i = 0; i < n - 1; i++) {
			time = t[i][0] + t[i][1];
			for (int j = i + 1; j < n - 1; j++) {
				if (time < t[j][1]) {
					time = t[j][1] + t[j][0];
				} else if (time < t[j][2]) {
					time = t[j][2] + t[j][0];
				} else {
					time = calcWaiting(time, t[j][2]) + t[j][0];
				}
			}
			System.out.println(time);
		}

		System.out.println(0);
	}

	private static int calcWaiting(int time, int f) {
		int cnt = 0;
		while (time > f * cnt) {
			cnt++;
		}
		return f * cnt;
	}
}


Measured memory_bytes: 26216
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//a-zの26通りやる。

int main(void){
	string s,alphabet="abcdefghijklmnopqrstuvwxyz",a,b;
	int before=-1,dist=0,ans=99999999;
	cin>>s;
	rep(i,26){
		a = alphabet[i];
		dist = 0;
		before = -1;
		rep(j,s.size()){
			b = s[j];
			if(a==b){
				if(before==-1){
					dist = j;
					// cout<<"最初"<<j<<","<<a<<dist<<endl;
				}else if(dist<j - before - 1){
					dist = j - before - 1;
					// cout<<"途中"<<j<<","<<a<<dist<<endl;
				}
				before = j;//到達したら問答無用で到達フラグ
			}
		}
		if(before==-1){
			dist = s.size();
		}else if(dist<s.size()-1-before){
			dist = s.size()-1-before;
		}
		if(ans>dist)ans = dist;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int k, x; cin >> k >> x;
  if (500*k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

#define EPS 1e-10

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		double dn, nm, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4 );

		dn = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );
		nm = ( x3 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y3 - y1 );

		if ( fabs( dn ) < EPS ) {
			double h1 = x1 == x2 ? ( y3 - y1 ) / ( y2 - y1 ) : ( x3 - x1 ) / ( x2 - x1 );
			double h2 = x1 == x2 ? ( y4 - y1 ) / ( y2 - y1 ) : ( x4 - x1 ) / ( x2 - x1 );

			if ( ( h1 < h2 ? h1 : h2 ) < 0.0 && fabs( h1 < h2 ? h2 : h1 ) < EPS ) {
				x = x1;
				y = y1;
			} else if ( fabs( ( h1 < h2 ? h1 : h2 ) - 1.0 ) < EPS && 1.0 < ( h1 < h2 ? h2 : h1 ) ) {
				x = x2;
				y = y2;
			}
		} else {
			x = x1 + nm / dn * ( x2 - x1 );
			y = y1 + nm / dn * ( y2 - y1 );
		}

		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 668
// E - Simple String Queries
// Segment Tree version
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using vi = vector<int>;
using vvi = vector<vi>;

// Segment Tree (sum)
// int INF = (1LL<<31)-1;
template<class T> struct SegmentTree{//(0_origin)
private:
	int n;//最下段データ数
	T node;//セグ木
public:
	SegmentTree(const T &v){// データ配列 v をセグ木にする。
		int size = v.size();
		for(n=1; n<size; n<<=1);//最下段領域数
		node.resize(2*n-1, 0);//セグ木領域
		for(int i=0; i<size; ++i) node[n-1 + i] = v[i];//最下段データ設定
		for(int i=n-2; i>=0; --i) node[i] = node[2*i+1] + node[2*i+2];//ボトムアップで初期設定(sum)

		// if(node[0]==0){}
		// else{
		// 	int k=1;
		// 	rep(i,2*n-1){
		// 		if(k-1==i){
		// 			puts("");
		// 			k<<=1;
		// 		}
		// 		cout<<node[i]<<" ";
		// 	}puts("");//////
		// }/////

	}
	void update(int ix, int val){
		ix += n-1;//最下段のindex
		// cout<<"\nix "<<ix<<"\n";//
		if(node[ix] == val) return;
		node[ix] = val;//ボトムアップで更新
		while(ix){
			ix = (ix-1)/2;
			node[ix] = node[2*ix+1] + node[2*ix+2];//(sum)
		}

			// int k=1;
			// rep(i,2*n-1){
			// 	if(k-1==i){
			// 		puts("");
			// 		k<<=1;
			// 	}
			// 	cout<<node[i]<<" ";
			// }puts("");//////

	}
	int sum(int a, int b, int k=0, int l=0, int r=-1){// data:[a,b) segT:[l,r) k:self index
		if(r<0) r = n;//first call [l,r)=[0,n)
		if(r<=a || b<=l) return 0;//unmatch: !(l<b & a<r)
		if(a<=l && r<=b) return node[k];//finish
		int retL = sum(a, b, 2*k+1, l, (l+r)/2);//left(sum)
		int retR = sum(a, b, 2*k+2, (l+r)/2, r);//right(sum)
		return retL + retR;//(sum)
	}
	// int sum(int a, int b, int k=0, int l=0, int r=-1){// data:[a,b) segT:[l,r) k:self index
	// 	if(r<0) r = n;//first call [l,r)=[0,n)
	// 	if(r<=a || b<=l) return 0;//unmatch. !(l<b & a<r) out of range
	// 	if(a<=l && r<=b) return node[k];//finish. just match
	// 	int retL = sum(a, b, 2*k+1, l, (l+r)/2);//left(sum)
	// 	int retR = sum(a, b, 2*k+2, (l+r)/2, r);//right(sum)
	// 	return retL + retR;//(sum)
	// }
};

using SEGT = SegmentTree<vi>;
using VSEG = vector<SEGT>;

int main(){
	int N,Q;
	string S;
	cin>>N>>S>>Q;
	vvi abc(26,vi(N));

	rep(i,N) abc[S[i]-'a'][i] = 1;

	// rep(i,26){
	// 	cout<<char(i+'a')<<") ";
	// 	rep(j,N) cout<<abc[i][j]<<" ";puts("");
	// }puts("");/////

	VSEG segT;

	rep(i,26){
		// cout<<char(i+'a')<<"\n";//
		segT.push_back(SEGT(abc[i]));
	}

	while(Q--){
		int t;
		cin>>t;
		if(t-1){//type2 out
			int l,r,ans=0;
			cin>>l>>r;
			rep(i,26){
				int ret = segT[i].sum(l-1, r);//[l,r)
				if(ret) ans++;
			}
			printf("%d\n",ans);

// 	int ans = 0;
// 	rep(i,26){
// 		auto it = abc[i].lower_bound(l);
// 		if(it == abc[i].end()) continue;
// 		if(*it <= r) ans++;
// 	}
		// printf("%d\n",ans);


		}
		else{//type1 update
			int i; char c;
			cin>>i>>c;
			// cout<<i-1<<" "<<char(S[i-1])<<" -> "<<c<<"\n";//
			// cout<<i-1<<" "<<char(S[i-1])<<" -> ";//

			segT[S[i-1]-'a'].update(i-1, 0);//del
			S[i-1] = c;
			// cout<<i-1<<" -> "<<char(S[i-1])<<"\n";//
			segT[S[i-1]-'a'].update(i-1, 1);//add

// 	if(S[i] == c) return;
// 	abc[S[i]-'a'].erase(i);
// 	S[i] = c;
// 	abc[S[i]-'a'].insert(i);

		}
	}
}


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

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

    vector<int> b(n+1);
    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i+i; j <= n; j += i){
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
    vector<int> ans;
    for(int i = 1; i <= n; i++){
        if(b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i,ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] task = {a, b, c};
        Arrays.sort(task);
 
        int result = (task[2]-task[1]) + (task[1]-task[0]);

        System.out.println(result);
    }
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> B(M); for (auto &b : B) cin >> b;
    int ans = 0;
    Int a_sum = 0;
    Int b_sum = accumulate(begin(B), end(B), 0LL);
    int j = M;
    for (int i = 0; i <= N && a_sum <= K; i++) {
        while (j > 0 && a_sum + b_sum > K) {
            b_sum -= B[j - 1];
            j--;
        }
        ans = max(ans, i + j);
        if (i < N) a_sum += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double r_h, r_m, between;
    r_m = m*6;
    r_h = h*30 + 0.5*m;
    if(r_m > r_h) between = (r_m - r_h)/180*M_PI;
    else between = (r_h - r_m)/180*M_PI;
    double ans;
    ans = sqrt(a*a + b*b - 2*a*b*cos(between));
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 4164
N, K = tuple(map(int, input().split()))
cnt = [0] * (10**5+1)
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    cnt[a] += b

for i in range(1, 10**5+1):
    if K <= cnt[i]:
        print(i)
        exit()
    K -= cnt[i]


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

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

    vector<int> h(n);
    rep(i,n){
        cin >> h.at(i);
    }

    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a.at(i) >> b.at(i);
    }


    ll count=0;
    vector<bool> ans(n,true);
    rep(i,m){
        
        // rep(j,m){
        //     if(a.at(j)-1==i){
        //         if(h.at(b.at(j)-1)>=h.at(i)){
        //             ans = false;
        //         }
        //     }
        //     // else if(b.at(j)-1==i){
        //     //     if(h.at(a.at(j)-1)>=h.at(i)){
        //     //         ans = false;
        //     //     }
        //     // }
        // }
        if(h.at(a.at(i)-1)==h.at(b.at(i)-1)){
            ans.at(a.at(i)-1)=false;
            ans.at(b.at(i)-1)=false;
        }else if(h.at(a.at(i)-1)>h.at(b.at(i)-1)){
            ans.at(b.at(i)-1)=false;
        }else{
            ans.at(a.at(i)-1)=false;
        }

        
    }

    rep(i,n){
        if(ans.at(i)){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4540
import numpy as np

K,N=list(map(int, input().split()))

A=list(map(int, input().split()))


A=np.array(A)

lin=np.array(A[:-1])
le=np.array(A[1:])

length=abs(lin-le)

rem=abs(K-A[-1]+A[0])

A=np.append(length,rem)

M=np.max(A)

print(K-M)

Measured memory_bytes: 34140
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>

constexpr long long MOD = 1000000007;

int main()
{
  std::string S;
  std::cin >> S;
  int rem = 15 - S.size();
  int n = 0;
  for (auto c: S)
  {
    if (c == 'o')
      ++n;
  }
  if (8 <= n + rem)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
  return 0;
}



Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
string s;
set < int > ch[26];

int main(){
    cin >> n >> s;
    s = " " + s;
    for(int i = 1; i <= n; i++){
        ch[s[i] - 'a'].insert(i);
    }
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            int idx;
            char x;
            cin >> idx >> x;
            ch[s[idx] - 'a'].erase(idx);
            s[idx] = x;
            ch[x - 'a'].insert(idx);
        } else {
            int cnt = 0;
            int l , r;
            cin >> l >> r;
            for(int i = 0; i < 26; i++){
                if(ch[i].lower_bound(l) == ch[i].end())
                    continue;
                int idx = *ch[i].lower_bound(l);
                if(l <= idx && idx <= r)
                    cnt++;
            }
            cout << cnt << endl;
        }
    }
}


Measured memory_bytes: 24216
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    string s;
    cin >> s;
    LL w;
    cin >> w;
    string ans;
    for(LL i = 0; i < s.size(); i += w){
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main(){

	string num;
	bool fi=false;
	while(cin>>num){
		if(fi)
			cout<<endl;
		fi=true;
		if(num.size()<5){
			while(num.size()<5){
				num='0'+num;
			}
		}
		for(int i = 0; i < 5; i++){
			if(num[i]>='5'){
				cout<<' ';
			}
			else
				cout<<'*';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			if(num[i]>='5'){
				cout<<'*';
			}
			else
				cout<<' ';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			cout<<'=';
		}
		cout<<endl;

		for(int i = 0; i < 5; i++){
			if(num[i]!='0'&&num[i]!='5'){
				cout<<'*';
			}
			else
				cout<<' ';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			if(num[i]!='1'&&num[i]!='6')
				cout<<'*';
			else
				cout<<' ';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			if(num[i]!='2'&&num[i]!='7')
				cout<<'*';
			else
				cout<<' ';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			if(num[i]!='3'&&num[i]!='8')
				cout<<'*';
			else
				cout<<' ';
		}
		cout<<endl;
		for(int i = 0; i < 5; i++){
			if(num[i]!='4'&&num[i]!='9')
				cout<<'*';
			else
				cout<<' ';
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
#define ll long long

int main(){

    int a, b; cin >> a >> b;

    if(a % 2 == 1 && b % 2 == 0){
        cout << "IMPOSSIBLE";
    }
    else if(a % 2 == 0 && b % 2 == 1){
        cout << "IMPOSSIBLE";
    }
    else{
        cout << (a + b)/2;
    }

    return 0;
}

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

namespace ABC084_B_Postal_Code
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			string s = Console.ReadLine();
			List<string> sList = new List<string>();

			for (int i = 0; i < s.Length; i++)
				sList.Add(s.Substring(i, 1));
			
			int hihunCount = sList.Count(x => x == "-");
			if (hihunCount != 1 || sList.Count != a + b + 1)
			{
				Console.WriteLine("No");
			}
			else if (sList[a] == "-")
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

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

struct Ant{
    int num;
    char direc;
    Ant(){}
    Ant(int num, char direc):num(num),direc(direc){}
    bool operator<(const Ant& a) const{ return num < a.num; }
    bool operator>(const Ant& a) const{ return num > a.num; }
};

int main(){
    
    while(1){
        int n, l; cin >> n >> l;
        if(!n) break;

        vector<vector<set<Ant> > > tunnel(2, vector<set<Ant> > (l + 1));
        

        
        for(int i = 1; i <= n; i++){
            char d; cin >> d;
            int loc; cin >> loc;
            tunnel[0][loc].insert(Ant(i, d));
        }

        int t = 0;
        int now = 0;
        int next = 1;
        for(;;){

            /*de
            cout << endl;
            for(int i = 0; i <= l; i++){
                cout << i << ": ";
                for(auto ant : tunnel[now][i]){
                    cout << "(" << ant.num << ", " << ant.direc << ") ";
                }
                cout << endl;
            }*/


            int cnt_ant = 0;
            for(int i = 1; i < l; i++){
                cnt_ant += (int)tunnel[now][i].size();
            }
            if(cnt_ant == 0){
                if(tunnel[now][0].size() == 1){
                    for(auto ant : tunnel[now][0]){
                        cout << t << " " << ant.num << endl;
                    }
                }else{
                    for(auto ant : tunnel[now][l]){
                        cout << t << " " << ant.num << endl;
                    }
                }

                break;
            }

            for(int i = 1; i < l; i++){
                for(auto ant : tunnel[now][i]){
                    if(ant.direc == 'R'){
                        tunnel[next][i + 1].insert(ant);
                    }else{
                        tunnel[next][i - 1].insert(ant);
                    }
                }
            }

            for(int i = 1; i < l; i++){
                if(tunnel[next][i].size() == 2){
                    set<Ant> tmp;
                    for(auto ant : tunnel[next][i]){
                        if(ant.direc == 'L') ant.direc = 'R';
                        else ant.direc = 'L';
                        tmp.insert(ant);
                    }
                    tunnel[next][i] = tmp;
                }
            }

            t++;
            swap(now, next);
            for(int i = 0; i <= l; i++) tunnel[next][i].clear();
        }


    }
}


Measured memory_bytes: 2980
N = int(input())
A = [[0]*10 for i in range(10)]
for i in range(1,N+1):
    h = int(str(i)[0])
    t = int(str(i)[-1])
    A[h][t] += 1
ans = 0
for i in range(1,10):
    for j in range(0,10):
        ans += A[i][j] * A[j][i]
print(ans)

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

using namespace std;

int main(){
    int H,W; cin >> H >> W;
    map<char, int> mp;
    char c;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c;
            mp[c]++;
        }
    }

    bool flag = true;
    if(H%2==0 && W%2==0){
        for(char c='a';c<='z';c++){
            if(mp[c]%4 !=0){
                flag = false;
                break;
            }
        }
    }else if(H%2==0 && W%2 == 1){
        int mod2 = 0;
        for(char c='a';c<='z';c++){
            if(mp[c]%2 == 1){
                flag = false;
                break;
            }else if(mp[c]%4 == 2){
                mod2++;
            }
        }
        if(mod2 > H/2){
            flag = false;
        }
    }else if(H%2==1 && W%2 == 0){
        int mod2 = 0;
        for(char c='a';c<='z';c++){
            if(mp[c]%2 == 1){
                flag = false;
                break;
            }else if(mp[c]%4 == 2){
                mod2++;
            }
        }
        if(mod2 > W/2){
            flag = false;
        }
    }else if(H%2 == 1 && W%2 == 1){
        int odd = 0;
        int mod2 = 0;
        for(char c='a';c<='z';c++){
            if(mp[c]%2 == 1){
                odd++;
            }else if(mp[c]%4 == 2){
                mod2++;
            }
        }
        if((mod2 > (H-1)/2 + (W-1)/2) || (odd != 1)){
            flag = false;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
ll dp[15][2];
int a[15];
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            dp[i + 1][0] = dp[i][0] * 3 + dp[i][1];
            dp[i + 1][1] = dp[i][1] * 2;
        } else {
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][0] = (dp[i][0] + dp[i][1]) * 2 + dp[i][0];
        }
        //cout << dp[i + 1][0] << " " << dp[i + 1][1] << endl;
    }
    cout << dp[n][0] << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> d(k);
	for(auto &ref : d){
		cin >> ref;
	}

	while(true){
		string str_n = to_string(n);
		bool find_f = false;
		for(auto i : d){
			if(str_n.find(to_string(i)) != -1){//嫌いな数字が含まれていた場合
				find_f = true;
			}
		}
		if(!find_f){//嫌いな数字が一つも含まれていなかった場合
			break;//ループを抜けて出力
		}
		n++;
	}
	cout << n;
}


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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

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

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

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

    int size(int x){
        return sz[find(x)];
    }
};

void fin(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    int64_t N, M, Q;
    cin >> N >> M >> Q;
    UnionFind uf(N);
    vector<pair<int, int>> differ;
    for(int i=0; i<Q; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if(c){
            differ.emplace_back(a, b);
        }else{
            uf.unite(a, b);
        }
    }
    for(auto& p : differ) if(M == N-1 || uf.same(p.first, p.second)) fin(false);
    int64_t C = 0;
    for(int i=0; i<N; i++) if(uf.find(i) == i) C++;
    fin(2*M <= 2*N + C*(C-3));
    return 0;
}


Measured memory_bytes: 2168
#!python
# -*- coding: utf-8 -*-

A, B, C, X, Y = list(map(int, input().split(' ')))

if not(X >= Y):
    X, Y = Y, X
    A, B = B, A

P1 = (A * X + B * Y)
P2 = (C * (X * 2))
P3 = (C * (Y * 2) + A * (X - Y))

print(min(P1, P2, P3))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int a[212345];
int b[212345];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		a[i] = x + y;
		b[i] = x - y;
	}
	int x, y;
	x = a[0], y = a[0];
	for (int i = 0; i < n; ++i) {
		x = max(x, a[i]);
		y = min(y, a[i]);
	}
	int t = x - y;
	x = y = b[0];
	for (int i = 0; i < n; ++i) {
		x = max(x, b[i]);
		y = min(y, b[i]);
	}
	t = max(t, x - y);
	cout << t << endl;
}

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

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || '9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x*f;
}

inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}

#define guo cerr<<"guo"<<endl
const int N=2e5+9;
const int K=22;
const int M=1<<K;

int n,m,v;
int x[N];
int vs[K],vtop;
int pre[K][N],suf[K][N];
int pr[M],su[M],mp[M];

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();v=read();
	for(int i=1;i<=n;i++)
		x[i]=read();
	for(int a=v>>1;vs[vtop++]=a;a>>=1);
	m=1<<vtop;vs[vtop]=v;

	for(int k=0;k<=vtop;k++)
	{
		pre[k][0]=0,suf[k][n+1]=n+1;
		for(int i=1,j=1;i<=n;i=j+1)
		{
			for(j=i;j+1<=n && x[j+1]-x[j]<=vs[k];j++);
			for(int l=i;l<=j;l++)
				pre[k][l]=i,suf[k][l]=j;
		}
	}

	for(int i=0;i<m;i++)
		su[i]=n+1;
	for(int i=1;i<m;i++)
		for(int j=0;j<vtop;j++)
			if(i&(1<<j))
			{
				chkmin(su[i],pre[j][su[i^(1<<j)]-1]);
				chkmax(pr[i],suf[j][pr[i^(1<<j)]+1]);
			}

	for(int i=0;i<m;i++)
		chkmax(mp[su[m-1-i]-1],pr[i]+1);
	for(int i=0;i<=n;i++)
		chkmax(mp[i+1],mp[i]);

	for(int i=1;i<=n;i++)
	{
		if(mp[suf[vtop][i]]>=pre[vtop][i])
			puts("Possible");
		else
			puts("Impossible");
	}

	return 0;

}


Measured memory_bytes: 42368
from collections import Counter
N = int(input())
a = list(map(int,input().split()))
counter = Counter(a)
ans=[]
for k,v in counter.items():
    if k-1 in counter:
        v+=counter[k-1]
    if k+1 in counter:
        v+=counter[k+1]
    ans.append(v)
print(max(ans))

Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e16;
const ll MM=1e18;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}
const ll MaxSize = 3e5;
ll facts[MaxSize], invFacts[MaxSize];

void preproc() {
  facts[0] = 1;
  for (int i = 1; i < MaxSize; i++) {
    facts[i] = ((ll)facts[i - 1] * i) % mod;
  }
  invFacts[MaxSize - 1] = expo(facts[MaxSize - 1], mod - 2,mod);

  for (int i = MaxSize - 2; i >= 0; i--) {
    invFacts[i] = ((ll)invFacts[i + 1] * (i + 1)) % mod;
  }
}

ll combination(ll n, ll k) {
  if(n<k) return 0;
  ll res = facts[n];
  res = ((ll)res * invFacts[k]) % mod;
  return ((ll)res * invFacts[n - k]) % mod;
}

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


void solve()
{
    
    int n, m;
    cin >> n >> m;
    vector<int> h(n+5);
    vector<int> mx(n+5);
    for(int i = 1; i <= n; i++) {
        cin >> h[i];
        mx[i] = 0;
    }
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a  >> b;
        mx[a] = max(mx[a], h[b]);
        mx[b] = max(mx[b], h[a]);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
       cnt += h[i] > mx[i];
    }
    cout << cnt << endl;
} 
int main()
{
  boost;
  int m;
  //cin >> m;
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}



Measured memory_bytes: 3956
#include <iostream>

int main(int argc, char const* argv[])
{
	std::string snum;
	std::cin >> snum;
	while (snum != "0") {
		unsigned sum{};
		for (auto&& var : snum) {
			sum += var - '0';
		}
		std::cout << sum << std::endl;
		std::cin >> snum;
	}
	return 0;
}

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

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

            var list = new List<int>();
            
            for(int i = 0; i < N; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }

            list.Sort();

            
            int u = list.First();
            
            int cnt = 0;
            int ans = 0;
            for(int i = 0; i < N; i++)
            {
                if(list[i] != u)
                {
                    
                    if(cnt % 2 != 0)
                    {
                        ans++;
                    }
                    u = list[i];
                    cnt = 1;
                }
                else
                {
                    cnt++;
                }

            }

            
            if(cnt % 2 != 0)
            {             
                ans++;
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 16096
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll INF = 2000000000000000000;
  vll a(n);re(i, n) std::cin >> a[i];
  vvl dp = VV(n/2+1, 3, -INF, ll);

  for(int i=1;i<=n/2;i++){
    for(int j=0;j<3;j++){
      if((i-1)*2+j>=n) continue;
      ll num = a[(i-1)*2 + j];
      if(i==1){
        dp[1][j] = num;
      }else{
        for(int k=0;k<=j;k++) {
          dp[i][j] = max(dp[i][j], dp[i-1][k] + num);
        }
      }
    }
  }
  ll ans = -INF;
  for(int i=0;i<3;i++) ans = max(ans, dp[n/2][i]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 9956
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



vector<long long> LISLDS(long long N, long long A, long long B) {
    vector<long long> res;
    for (long long i = B-1; i >= 0; --i) res.push_back(i);
    if (A == 1) return res;
    long long rem = N - B;
    long long p = rem / (A-1);
    long long r = rem % (A-1);
    long long b = r;
    long long c = A-1-r;
    for (int i = 0; i < b; ++i) {
        int size = (int)res.size();
        for (int j = 0; j < p+1; ++j) {
            res.push_back(size + p - j);
        }
    }
    for (int i = 0; i < c; ++i) {
        int size = (int)res.size();
        for (int j = 0; j < p; ++j) {
            res.push_back(size + p-1 - j);
        }
    }
    return res;
}


int main() {
    long long N, A, B;
    while (cin >> N >> A >> B) {
        if (A + B > N+1 || A * B < N) cout << -1 << endl;
        else {
            auto res = LISLDS(N, A, B);
            for (auto v : res) cout << v+1 << " ";
            cout << endl;
        }
    }
}


Measured memory_bytes: 6384
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        while(true)
        {
            int[] data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int m = data[0];
            int f = data[1];
            int r = data[2];
            if(m == -1 && f == -1 && r == -1){break;}
            
            if(m == -1 || f == -1)
            {
                Console.WriteLine("F");
            }else if(m + f >= 80)
            {
                Console.WriteLine("A");
            }else if(m + f >= 65)
            {
                Console.WriteLine("B");
            }else if(m + f >= 50 || (m + f >= 30 && r >= 50))
            {
                Console.WriteLine("C");
            }else if(m + f >= 30)
            {
                Console.WriteLine("D");
            }else
            {
                Console.WriteLine("F");
            }
        }
    }
}


Measured memory_bytes: 18412
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N, Y;
    cin >> N >> Y;
    vector<int> paper(3, -1);
    for (int i = 0; i < N+1; i++)
    {
        for (int j = 0; j < N - i+1; j++)
        {
            int k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y)
            {
                paper[0] = i;
                paper[1] = j;
                paper[2] = k;
            }
        }
    }
    cout << paper[0] << " " << paper[1] << " " << paper[2] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define max1 100001
vector<vector<int> > arr(max1);


int main(){	
	int n;
	cin>>n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	if(n==2){
		cout<<a[1]<<" "<<a[0]<<endl;
	}
	else{
		
		int txor=0;
		for (int i = 0; i < n; i+=2)
		{
			txor=txor^(a[i]^a[i+1]);
		}
		for (int i = 0; i < n; ++i)
		{
			int ans=txor^a[i];
			cout<< ans;
			cout<<" ";
		}
		cout<<endl;
	}




}

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

int main(){
  int N;
  cin>>N;
  int temp=N;
  int S=0;
  while(N>0){
    S=S+N%10;
    N=N/10;
  }
  if(temp%S==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
  
}

  

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


int main()
{


        long long n,m,a,b,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        //scanf("%lld",&n);

        cin>>fr>>sc;

        if(fr==1 || sc==1)
        {
            cout<<"1"<<endl;
        }
        else
        {


        d=fr*sc;

        e=d/2; b=0;


        if(d%2==1)b=1;

        cout<<e+b<<endl;
        }















    return 0;
}





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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll maxi = 0;
    string S;
    map<char, ll> m;
    cin >> N >> S;
    for(ll i = 0;i < N;i++) {
        ll count = 0;
        set<char> L, R;
        for(ll j = i;j >= 0;j--) L.insert(S[j]);
        for(ll j = i + 1;j < N;j++) R.insert(S[j]);
        for(auto &i: L) {
            if(R.find(i) != R.end()) count++;
        }
        maxi = max(count, maxi);
    }
    cout << maxi << endl;
    return 0;
}


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

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

	vector<int> yakusu;

	for(int i = 0; i < a; ++i){
		int j = a -i;
		if(((a%j)==0) && ((b%j)==0)){
			yakusu.push_back(j);
		}
	}

	cout << yakusu[k-1] << endl;


	return 0;
}

Measured memory_bytes: 256
local read = io.read
local insert = table.insert
local abs = math.abs

local X, N = read("*n", "*n")
local p = {}
for i = 1, N do
	p[i] = read("*n")
end

local not_p = {}
for i = 0, 101 do
	local can_ins = true
	for j = 1, N do
		if p[j] == i then
			can_ins = false
			break
		end
	end
	if can_ins then
		insert(not_p, i)
	end
end

local out = math.huge
for i = 1, #not_p do
	if abs(not_p[i] - X) < abs(out - X) then
		out = not_p[i]
	end
end

print(out)


Measured memory_bytes: 2744