akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.math.*;

class Main{
		public static int circle_calc(ArrayList<Double> list){
			int res;
			double xa,ya,ra,xb,yb,rb,d;
			
			xa = list.get(0);
			ya = list.get(1);
			ra = list.get(2);
			xb = list.get(3);
			yb = list.get(4);
			rb = list.get(5);
			
			d = (xb-xa)*(xb-xa)+(yb-ya)*(yb-ya);
			d = Math.sqrt(d);
			
			if(d<Math.abs(ra-rb)){
				if(ra>rb)
					res = 2;
				else res = -2;
					
			}
			else if(d > ra+rb)
				res = 0;
			else res = 1;
					
			return res;
		}
		
		public static void main(String args[]) throws IOException{
			String str;
			ArrayList <Double> inp = new ArrayList<Double>();
			int out;

			Scanner scan = new Scanner(System.in);
			str = scan.next();
			
			while(scan.hasNext()){
				inp.clear();
				
				for(int i=0;i<6;i++){
					str = scan.next();
					double x = Double.parseDouble(str);
					inp.add(x);
				}
				out = circle_calc(inp);
				System.out.println(out);
			}
		}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>

int main(){
	int N;
	std::cin >> N;
	
	while(N--){
		double xa, ya, ra, xb, yb, rb;
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = hypot((xa - xb), (ya - yb)); //distance
		
		if(d > ra + rb)
			std::cout << 0 << std::endl;
		else if(d < fabs(ra - rb))
			std::cout << (ra > rb ? 2 : -2) << std::endl;
		else
			std::cout << 1 << std::endl;
	}
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int N, L;

  cin >> N >> L;

  string S[110];

  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }

  sort(S,S + N);

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

  return 0;
}


Measured memory_bytes: 256
n = int(input())
heap = list(map(int, input().split()))
for i in range(len(heap)):
    out = 'node {}: key = {}, '.format(i + 1, heap[i])
    parent = (i - 1) // 2
    out += 'parent key = {}, '.format(heap[parent]) if parent >= 0 else ''
    left = 2 * i + 1
    out += 'left key = {}, '.format(heap[left]) if left < len(heap) else ''
    right = 2 * i +2
    out += 'right key = {}, '.format(heap[right]) if right < len(heap) else ''
    print(out)

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int X, Y;
    cin >> X >> Y;

    if(2*X-Y/2>=0 && Y%2==0 && Y/2-X>=0)
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k)
    {
        if(k>a)
            cout<<a;
        else
            cout<<k;
        return ;
    }
    int ans=a-(k-a-b);
    cout<<ans;
}
int32_t main()
{
    // clock_t tStart = clock();
    #ifndef ONLINE_JUDGE
    _READ
    #endif
    
    solve();
    
    // #ifndef ONLINE_JUDGE
    // cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    // #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,q;
  cin >> n >> q;
  dsu d(n);
  while(q--){
    int op,u,v;
    cin >> op >> u >> v;
    if(op == 0){
      d.merge(u,v);
    }
    else{
      if(d.same(u,v)) cout << 1 << '\n';
      else cout << 0 << '\n';
    }
  }
  return 0;
}

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

int N;
int A[310][310];
bool isrem[310][310];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) rep(j, N) cin >> A[i][j];
    int ans = 0;
    rep(i, N) rep(j, N) isrem[i][j] = false;
    
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            for (int k=j+1; k<N; k++) {
                if (A[i][j]>A[i][k]+A[k][j] || A[j][k]>A[j][i]+A[i][k] || A[k][i]>A[k][j]+A[j][i]) {
                    cout << -1 << endl;
                    exit(0);
                }
                if (A[i][j]==A[i][k]+A[k][j]) isrem[i][j] = true;
                if (A[j][k]==A[j][i]+A[i][k]) isrem[j][k] = true;
                if (A[k][i]==A[k][j]+A[j][i]) isrem[i][k] = true;
            }
        }
    }
    for (int i=0; i<N; i++) for (int j=i+1; j<N; j++) if (!isrem[i][j]) ans += A[i][j];
    cout << ans << endl;
}

Measured memory_bytes: 1152
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

use std::cmp::Reverse;

fn main() {
    input! {
        _n: usize,
        m: usize,
        ab_: [(usize, usize); m],
    }
    let ab: Vec<(usize, usize)> = ab_.clone().iter().map(|(a, b)| (a - 1, b - 1)).collect();

    let mut que = std::collections::BinaryHeap::new();
    for i in 0..m {
        que.push(Reverse((ab[i].0, 0, i)));  // start
        que.push(Reverse((ab[i].1 - 1, 1, i)));  // end
    }
    let mut fulfilled = vec![false; m];
    let mut stack = vec![];
    let mut ret = 0;
    while let Some(Reverse((_, t, b))) = que.pop() {
        if fulfilled[b] {
            continue;
        }
        stack.push(b);
        if t == 1 {
            for bb in &stack {
                fulfilled[*bb] = true;
            }
            stack.clear();
            ret += 1;
        }
    }

    println!("{}", ret);
}


Measured memory_bytes: 11472
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mem(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mn=1e5+5;

int n;
ll c;
pll p[mn];
ll pre[mn],suf[mn];

priority_queue<ll> qp,qs;

int main() {
	scanf("%d%lld",&n,&c);
	for(int i=1; i<=n; i++)
		scanf("%lld%lld",&p[i].first,&p[i].second);
	ll ans=0;
	for(int i=1; i<=n; i++) {
		pre[i]=pre[i-1]+(p[i-1].first-p[i].first)+p[i].second;
		ans=max(ans,pre[i]);
		//printf("%d %lld\n",i,pre[i]);
	}
	p[n+1]=make_pair(c,0);
	for(int i=n; i; i--) {
		suf[i]=suf[i+1]+(p[i].first-p[i+1].first)+p[i].second;
		ans=max(suf[i],ans);
		//printf("%d %lld\n",i,suf[i]);
	}
	for(int i=1; i<=n; i++) {
		if(!qs.empty()) {
            ans=max(suf[i]+p[i].first-c+qs.top(),ans);
			//printf("%d %lld %lld %lld %lld\n",i,suf[i],p[i].first,qs.top(),ans);
		}
		qs.push(pre[i]);
	}
	for(int i=n; i; i--) {
		if(!qp.empty()) {
            ans=max(pre[i]-p[i].first+qp.top(),ans);
		}
		qp.push(suf[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int MAX_N = 100000;
constexpr long long MAX_T = 1000000000000000000;

long long N, T, Q;

long long pos[MAX_N], target[MAX_N];
int dir[MAX_N];
std::vector<long long> stops;

void solve();

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

	std::cin >> N >> T >> Q;

	for(int i = 0; i < N; ++i){
		std::cin >> pos[i] >> dir[i];
	}

	for(int i = 0; i < N - 1; ++i){
		if(dir[i] == 1 && dir[i + 1] == 2 && (pos[i + 1] - pos[i]) <= (T * 2)){
			stops.push_back((pos[i + 1] + pos[i]) / 2);
		}
	}

	for(int i = 0; i < Q; ++i){
		int input;
		std::cin >> input;
		--input;

		long long res = MAX_T;
		if(dir[input] == 1){ //When a citizen heads east.
			auto itr = std::lower_bound(stops.begin(), stops.end(), pos[input]);
			if(itr != stops.end() && *itr <= pos[input] + T){
				res = *itr;
			}
		}
		else{ //When a citizen heads west.
			auto itr = std::lower_bound(stops.begin(), stops.end(), pos[input] - T);
			while(itr != stops.end() && *itr <= pos[input]){
				res = *itr;
				++itr;
			}
		}

		if(res == MAX_T){
			if(dir[input] == 1){
				std::cout << pos[input] + T << std::endl;
			}
			else{
				std::cout << pos[input] - T << std::endl;
			}
		}
		else{
			std::cout << res <<  std::endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4448
//
//  main.cpp
//  chat in a circle
//
//  Created by Bryan on 05/07/20.
//  Copyright © 2020 mac. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    long long N;
    scanf ("%lld", &N);
    long long arr[N+3];
    for (long long f = 0; f<N;f++)
        scanf ("%lld", &arr[f]);
    sort(arr,arr+N,greater<>());
    long long ans = 0;
    long long temp;
    for (long long f = 1; f<N;f++)
    {
        if (f==1)
            ans += arr[f-1];
        else
        {
            temp = (f/2);
            ans+=arr[temp];
        }
        
        
    }
    printf ("%lld\n",ans);
}


Measured memory_bytes: 5384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>

#define PI 3.14159265358979323846

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++)cin >> A[i];

    int sum = accumulate(A.begin(), A.end(), 0);
    int pDays = N - sum;
    if (pDays >= 0)cout << pDays << endl;
    else cout << "-1" << endl;
    
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>

using namespace std;

const int MAX_N = 2e2+10;

int main(int argc, char const *argv[])
{
    int n, l, taste[MAX_N];
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        taste[i] = l+i;
    }
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += taste[i];
    }
    if (l>=0) {
        sum -= taste[0];
    }
    else {
        sum -= min(taste[n-1],0);
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
from math import ceil
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

A = A - B
ng, ok = 0, 10 ** 9 + 1
while abs(ok - ng) > 1:
    X = (ng + ok) // 2
    H_damaged = [h - B * X for h in H]
    need = sum([max(ceil(h / A), 0) for h in H_damaged])

    if need <= X:
        ok = X
    else:
        ng = X

print(ok)


Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int temp;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N - 1);
  for (int i = 0; i < N; i++) {
    cin >> temp;
    temp--;
    a[i] = temp;
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += b[a[i]];
    if (i != 0) {
      if (a[i] == a[i - 1] + 1) {
        ans += c[a[i-1]];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

	int n, d;
	cin >> n >> d;
	vector<vector<double>> vvd;

	for (int i = 0; i < n; i++) {
		vector<double> vt;
		for (int j = 0; j < d; j++) {
			double tmp;
			cin >> tmp;
			vt.push_back(tmp);
		}
		vvd.push_back(vt);
	}

	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			double tmp = 0;
			for (int s = 0; s < d; s++) {
				double ttt = abs(vvd[i][s] - vvd[j][s]);
				tmp += ttt * ttt;
			}
			tmp = pow(tmp, 0.5);
			if (ceil(tmp) == floor(tmp)) ans++;
		}
	}




	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e5+50;
int n,v,lg,x[N];
int len[20], bin[20];
int mxr[1<<20], mnl[1<<20];

struct BIT_MAX {
	int bit[N];
	BIT_MAX() {for(int i=0;i<N;i++) bit[i]=-1e9;}
	inline void inc(int p,int v) {
		for(int i=p;i<=n+1;i+=(i&(-i))) bit[i]=max(bit[i],v);
	}
	inline int ask(int p,int v=-1e9) {
		for(int i=p;i;i-=(i&(-i))) v=max(v,bit[i]);
		return v;
	}
	inline void init(int lim) {
		for(int l=1,r;l<=n;l=r+1) {
			r=l;
			while(r<n && x[r+1]-x[r]<=lim) ++r;
			inc(l,r);
		}
	}
} bit_max[21];

struct BIT_MIN {
	int bit[N];
	BIT_MIN() {for(int i=0;i<N;i++) bit[i]=1e9;}
	inline void inc(int p,int v) {
		for(int i=p;i;i-=(i&(-i))) bit[i]=min(bit[i],v);
	}
	inline int ask(int p,int v=1e9) {
		if(!p) ++p;
		for(int i=p;i<=n;i+=(i&(-i))) v=min(v,bit[i]);
		return v;
	}
	inline void init(int lim) {
		for(int l=1,r;l<=n;l=r+1) {
			r=l;
			while(r<n && x[r+1]-x[r]<=lim) ++r;
			inc(r,l);
		}
	}
} bit_min[20];

int ok[N];
int main() {
	n=rd(), v=rd();
	for(int i=1;i<=n;i++) x[i]=rd();
	
	for(int t=v;;t/=2) {
		len[lg++]=t;
		if(!t) break;
	}
	for(int i=0;i<lg;i++) {
		bin[i]=1<<i;
		bit_max[i].init(len[i]);
		bit_min[i].init(len[i]);
	} 
	
	mxr[0]=0; mnl[0]=n+1; bin[lg]=1<<lg;
	for(int s=1;s<bin[lg];++s) {
		if(s&1) continue;
		int mx=0, mn=n+1;
		for(int k=0;k<lg;++k) if(s&bin[k]) {
			mx=max(mx,bit_max[k].ask(mxr[s^bin[k]]+1));
			mn=min(mn,bit_min[k].ask(mnl[s^bin[k]]-1));
		}
		mxr[s]=mx; mnl[s]=mn;
	}
	
	for(int i=0;i<bin[lg];++i) {
		if(!(i&1)) {
			int s1=i, s2=(bin[lg]-1)^1^i;
			bit_max[20].inc(mnl[s2],mxr[s1]);
		}
	}
	for(int l=1,r;l<=n;l=r+1) {
		r=l;
		while(r<n && x[r+1]-x[r]<=v) ++r;
		if(bit_max[20].ask(r+1)>=l-1) for(int i=l;i<=r;i++) ok[i]=1;
	}
	for(int i=1;i<=n;i++) puts((ok[i]) ? "Possible" : "Impossible");
}

Measured memory_bytes: 43648
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll gcd(ll a, ll b){
  if(a%b==0) return b;
  else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

ll not_div(ll n, ll c, ll d){
  return n-(n/c+n/d-n/lcm(c,d));
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << not_div(b,c,d)-not_div(a-1,c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
import collections
N,M = map(int,input().split())
edge = collections.defaultdict(list)
for _ in range(M):
    u,v = map(int,input().split())
    edge[u-1].append(v-1)
S,T = map(int,input().split())
dp = [[-3 for _ in range(3)] for _ in range(N)]
dp[S-1][0] = 0
q = collections.deque()
q.append((S-1,0))
while q:
    p,step = q.popleft()
    next_step = (step+1)%3
    for e in edge[p]:
        if dp[e][next_step] == -3:
            dp[e][next_step] = dp[p][step] + 1
            q.append((e,next_step))
            if e == T-1 and next_step == 0:
                break
print(dp[T-1][0] // 3)

Measured memory_bytes: 81240
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
	int main (void){
	int jou1,mat1,sec1,eng1,jou2,mat2,sec2,eng2,sou1=0,sou2=0;
	scanf("%d %d %d %d",&jou1,&mat1,&sec1,&eng1);
	scanf("%d %d %d %d",&jou2,&mat2,&sec2,&eng2);
	sou1=jou1+mat1+sec1+eng1;
	sou2=jou2+mat2+sec2+eng2;
	if(sou1>sou2){
		printf("%d\n",sou1);
	}
	else if(sou1<sou2){
		printf("%d\n",sou2);
	}
	else if(sou1==sou2){
		printf("%d\n",sou1);
	}
			return 0;
}


Measured memory_bytes: 2036
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 0;

    for(int i = 1; i < n - 1; i++){

        int t = 0;
        int now = 0;

        for(int j = 0; j + i < n; j++){
            if(s[j] == s[j + i]) now++;
            else now = 0;
            t = max(now, t);
        }
        ans = max(ans, min(i, t));
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 501

static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;

    void dfs_visit(int u){
    int v;
    color[u] = GRAY;
    tt++;
    d[u] = tt;
    for ( v = 0; v < n; v++ ){
        if ( M[u][v] == 0 ) continue;
        if ( color[v] == WHITE ){
        dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
    }

    void dfs(){
    int i, u;
    for ( i = 0; i < n; i++ ) color[i] = WHITE;
    tt = 0;
    for ( u = 0; u < n; u++ ){
        if ( color[u] == WHITE ){
            dfs_visit(u);
        } 
    }
    for ( i = 0; i < n; i++ ){
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
    }


    int main(){
    int u, k, v; 
    int i, j;

    scanf("%d", &n);

    for ( i = 0; i <n; i++ ){
        for ( j = 0; j <n; j++ ) M[i][j] = 0;
    }
    
    for ( i = 0; i < n; i++ ){
        scanf("%d %d", &u, &k);
        u--;
        for ( j = 0; j < k; j++ ){
        scanf("%d", &v);
        v--;
        M[u][v] = 1;
        }
    }
    
    dfs();

    return 0;
    }


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

typedef long long ll;
const int maxn = 1e5 + 5;
int n, m;
int bs3[15];
ll a[105], w[15];
ll lfw[maxn], rtw[maxn];
vector<ll> v[105], tmp;
ll solve()
{
    for(int i = 0; i < n; ++i)
        v[i].clear();
    int mx = bs3[m];
    for(int i = 1; i < mx; ++i){//遍历 3的m次方种组合方式{
        lfw[i] = rtw[i] = 0;
        int ii = i;
        for(int j = 0; j < m; ++j){
            /*  相当于按位枚举 如13 就相当于 111 14相当于211
                                  28  相当于 100 30      010
            */
            int rm = ii%3;
            if(rm == 0) { }//不添加
            else if(rm == 1)//左天平
                lfw[i] += w[j];
            else            //右天平
                rtw[i] += w[j];
            ii /= 3;//下一个砝码 所处于的状态
        }
    }
    int tot = 0;
    // printf("mask: %lld\n", mask);
    for(int i = 0; i < n; ++i)//枚举药品
    {
        bool ok = false;
        for(int j = 0; j < mx; ++j)//枚举所有组合
        {
            ll lf = lfw[j], rt = rtw[j];
            ll nd = abs(lf - rt - a[i]);
            //cout << lf << rt << endl;
            if(nd == 0)//天平平衡
            {
                ok = true;
                break;
            }
        }
        if(ok)
            continue;
        for(int j = 0; j < mx; ++j)//不平衡 则把所有情况所需砝码（即可满足解）储存
        {
            ll lf = lfw[j], rt = rtw[j];
            ll nd = abs(lf - rt - a[i]);
            v[tot].push_back(nd);
        }
        //vecotr去重 先排序 然后用unique (本质是将无重复序列放在前端覆盖重复序列 即大小并未改变)
        // 并返回无重复序列的终端
        sort(v[tot].begin(), v[tot].end());
        v[tot].erase(unique(v[tot].begin(), v[tot].end()), v[tot].end());
        ++tot;
    }
    if(tot == 0)//初始时即平衡
        return 0;
    for(int i = 1; i < tot; ++i)
    {
        // printf("%d: ", i);
        // for(auto x:v[¨]) {
        // printf(" %lld", x);
        // } // puts("");
        tmp.clear();
        //set_intersection 并不是只适用于set 而是适用于有set性质的函数 即排序无重复的
        //并且只是复制给另一个容器 所以通过back_inserter实现插入操作
        set_intersection(v[0].begin(), v[0].end(), v[i].begin(), v[i].end(), back_inserter(tmp));
        v[0].assign(tmp.begin(), tmp.end());//assign 将元素复制到该容器中 并删除原容器中的元素
        if(v[0].empty())//无交集 即与题意不符
            break;
    }
    if(v[0].empty())
        return -1;
    return v[0][0];//输出交集中第一个元素 就是最小的可满足解
}
int main()
{
    bs3[0] = 1;
    for(int i = 1; i <= 12; ++i)
    {
        bs3[i] = bs3[i - 1]*3;
    }
    while(scanf("%d%d", &n, &m) != EOF)
    {
        if(n == 0 || m == 0)
            break;
        for(int i = 0; i < n; ++i)
        {
            scanf("%lld", &a[i]);
        }
        for(int i = 0; i < m; ++i)
        {
            scanf("%lld", &w[i]);
        }
        ll ans = solve();
        printf("%lld\n", ans);
    }
    return 0;
}



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

int main( void ) {
	
	int i;
	char str[21];

	scanf( "%s", str );
	
	for ( i = strlen( str ) - 1; i >= 0; i-- ) {

		printf( "%c", str[i] );

	}

	printf( "\n" );

	return 0;

}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 X,Y;
    cin >> X >> Y;

    int ans=0;
    while(X<=Y){
        ++ans;
        X*=2;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){    
char number[1001];    
int i, sum;    
while(1){        
scanf("%s", number);        
if(number[0]=='0')break;        
sum=0;       
 for(i=0;number[i]!='\0';i++){            
sum+=number[i]-'0';        }        
printf("%d\n", sum);    }    
return 0;
}



Measured memory_bytes: 2104
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F3F3F3F3F
#define N 1000005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int _gcd(int x, int y){
    return y == 0 ? x : _gcd(y, x % y);
}
int n, m;
char sn[N], sm[N];
int main(){
//    IN;
    SCC(n, m);
    scanf("%s", sn + 1);
    scanf("%s", sm + 1);
    int gcd = _gcd(n, m);
    int x = n / gcd, y = m / gcd;
    int ok = 1;
    for(int i = 1, j = 1; i <= n; i += x, j += y){
        if(sn[i] != sm[j]) {
            ok = 0;
            break;
        }
    }
    if(ok) cout << 1LL * n * m / gcd << endl;
    else puts("-1");
    return 0;
}


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

#define ntest 0

using namespace std;

int h,w,k,res;
int cal(int x, int y, vector<vector<char>> v) {
    for (int i = 0; i < h; ++i)
    if (x&(1<<i)) {
        for (int j = 0; j < w; ++j) v[i][j] = '$';
    }
    for (int i = 0; i < w; ++i)
    if (y & (1<<i)) {
        for (int j = 0; j < h; ++j) v[j][i] = '$';
    }
    int cnt = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) cnt += v[i][j] == '#';
    return cnt == k;
}
void solve() {
    cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char>(w));
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) cin >> c[i][j];
    for (int i = 0; i < (1<<h); ++i)
        for (int j = 0; j < (1<<w); ++j) res += cal(i,j, c);
    cout << res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3544
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
	for j in range(B+1):
		for k in range(C+1):
			if 500*i + 100*j + 50*k == X:
				count += 1
print(count)

Measured memory_bytes: 3060
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 10001
#define most_prime_number 20000010
#define prime_MAX_arr 20000010/2
ll PRIME[prime_MAX_arr];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/
#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 1000000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;

int main()
{
 ll n, a;
 cin >> n;
 a = n;
 ll b= 0;
 while(n)
 {
     b += n%10;
     n/=10;
 }
 if(a%b) cout <<"No";
 else cout <<"Yes";
    R_0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 2147483647;

int main(void)
{
    int n;
    cin >>n;
    vector<int> h(n);
    for (int i=0;i<n;i++){
        cin >> h.at(i);
    }
    vector<int> dp(n,INF);
    dp[0] = 0;
    dp[1] = abs(h.at(1)-h.at(0));
    for(int i=2;i<n;i++){
        dp[i] = abs(h.at(i-1)-h.at(i))+dp[i-1];
        dp[i] = min(dp[i],abs(h.at(i-2)-h.at(i))+dp[i-2]);
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define INF (1 << 30)
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    int c, t, min_cost = INF;
    for (int i = 0; i < N; i++) {
        cin >> c >> t;
        if (t <= T && c < min_cost) min_cost = c;
    }
    if (min_cost == INF) cout << "TLE" << endl;
    else cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    split_count = 1
    increasing = None
    for i in range(1, N):
        if increasing == None:
            if A[i-1] < A[i]:
                increasing = True
            elif A[i-1] > A[i]:
                increasing = False
            # unsure if A[i-1] == A[i]
        elif increasing and A[i-1] > A[i]:
            split_count += 1
            increasing = None # unsure if it increases or not at this point
        elif not increasing and A[i-1] < A[i]:
            split_count += 1
            increasing = None # unsure if it increases or not at this point
    print(split_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15192
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n), cnt(1e6 + 1, 0);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	int g = a[0];
	for(int i = 1; i < n; ++i) {
		g = gcd(g, a[i]);
	}
	
	if( g > 1 ) {
		cout << "not coprime" << endl;
		return 0;
	}
	
	int maxa = *max_element(a.begin(), a.end());
	
	vector<int> primes, is_prime(maxa + 1, 1);
	is_prime[0] = 0;
	is_prime[1] = 0;
	
	for(int i = 2; i <= maxa; ++i) {
		if( is_prime[i] ) {
			primes.push_back(i);
			
			for(int j = i; j <= maxa; j += i) {
				is_prime[j] = 0;
			}
		}
	}

	bool pc = true;
	for(auto& x : primes) {
		int sum = 0;

		for(int i = x; i <= maxa; i += x) {
			sum += cnt[i];
		
			if( sum >= 2 ) {
				pc = false;
				break;
			}
		}
		
		if( !pc ) break; 
	}
	
	if( pc ) {
		cout << "pairwise coprime" << endl;
	} else {
		cout << "setwise coprime" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 15532
N = int(input())
S = []
for _ in range(N):
    S.append(input())

A = [0] * 5
for i in range(N):
    if S[i][0] == "M":
        A[0] += 1
    elif S[i][0] == "A":
        A[1] += 1
    elif S[i][0] == "R":
        A[2] += 1
    elif S[i][0] == "C":
        A[3] += 1
    elif S[i][0] == "H":
        A[4] += 1

ans = A[0]*A[1]*A[2] + A[0]*A[1]*A[3] + A[0]*A[1]*A[4] + A[0]*A[2]*A[3] + A[0]*A[2]*A[4] + A[0]*A[3]*A[4] + A[1]*A[2]*A[3] + A[1]*A[2]*A[4] + A[1]*A[3]*A[4] + A[2]*A[3]*A[4]

print(ans)

Measured memory_bytes: 9776
#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() {
  deque<char> d;
  string s;
  int q, t, f, l;
  char c;
  int flag = 0;
  cin >> s;
  l = s.size();
  rep(i,l) d.push_back(s[i]);
  cin >> q;
  rep(i,q) {
    cin >> t;
    if (t==1) flag = (flag+1) % 2;
    else if (t==2){
      cin >> f >> c;
      if ((flag+f)%2==1) d.push_front(c);
      else d.push_back(c);
    }
  }
  l = d.size();
  s = "";
  //rep(i, l) {cout << d.back(); d.pop_back();}
  if (flag==1) {
    rep(i,l) {s += d.back(); d.pop_back();}
  } else {
    rep(i,l) {s += d.front(); d.pop_front();}
  }
  cout << s << endl;
}


Measured memory_bytes: 1280
import java.util.*;

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(a < b) System.out.println("a < b");
		else if(a > b) System.out.println("a > b");
		else System.out.println("a == b");
		/*int[] time_get = henkan(scan.nextInt());
	
		for(int i = 0; i < 3; i++) {
			if(i != 2) System.out.print(time_get[i] + ":" );
			else System.out.println(time_get[i]);
		}

	}

	static int[] henkan(int time_input) {
		int[] times = new int[3];
		times[0] = time_input / 3600;
		time_input = time_input - times[0] * 3600;
		times[1] = time_input /60;
		times[2] = time_input - times[1] * 60;
		
		return times;*/
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

const ll mod = 1e9 + 7;
const int maxn = 2e6 + 5;

ll f[maxn];

ll mul(ll a, ll b, ll M){
	return a * b % M;
}

ll pow(ll a, ll b, ll M)
{
	ll x = 1;
	for (; b > 0; b >>= 1)
	{
		if (b & 1) x = mul(x, a, M);
		a = mul(a, a, M);
	}
	return x;
}

ll inv(ll x){
	return pow(x, mod - 2, mod);
}

ll n_k(ll n, ll k){
	if(k > n)
		return 0;
	ll num = f[n];
	ll den = f[k] * f[n - k] % mod;
	den = inv(den);

	return num * den % mod;
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	f[0] = 1ll;
	for(int i = 1; i < maxn; i++)
		f[i] = (f[i - 1] * 1ll * i) % mod;	

	int k;
	string s;
	cin >> k >> s;

	ll ans = 1;

	ll K = (ll)s.size();
	ll N = (ll)s.size() + k;

	for(ll j = 0; j <= N - K; j++){
		ll v1 = n_k(N, j + K);
		ll v2 = pow(25ll, N - K - j, mod);
		ans = (ans + v1 * v2 % mod) % mod;
	}

	cout << (ans + mod - 1) % mod << endl;


	return 0;
}

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

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

    auto prefix = vector<int>(), suffix = vector<int>();
    for (auto i = 1; N > 1; i++)
    {
        if (N % 2 == 0)
        {
            prefix.push_back(i);
            N /= 2;
        }
        else
        {
            suffix.push_back(i);
            N--;
        }
    }
    reverse(begin(suffix), end(suffix));

    const auto K = int(prefix.size() + suffix.size());
    cout << 2*K << endl;

    for (const auto x : prefix) cout << x << " ";
    for (const auto x : suffix) cout << x << " ";

    for (auto i = 1; i <= K; i++)
        cout << i << " ";
    cout << endl;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int a, b;

  scanf("%d %d",&a,&b);

  if ((a > 0 && b < 0) || (a < 0 && b > 0)) {
    printf("Zero\n");
    exit(0);
  }

  int sum = 0;
  FOR (i, a, b + 1) {
    if (i < 0) sum ++;
  }

  if (sum % 2 == 1) printf("Negative\n");
  else printf("Positive\n");
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()
a = [LIST() for _ in range(H)]

op = []
for i in range(H):
	for j in range(W-1):
		if a[i][j]%2:
			a[i][j] -= 1
			a[i][j+1] += 1
			op.append((i+1, j+1, i+1, j+2))

for i in range(H-1):
	if a[i][-1]%2:
		a[i][-1] -= 1
		a[i+1][-1] += 1
		op.append((i+1, W, i+2, W))

print(len(op))
print(*[" ".join(map(str, x)) for x in op], sep = "\n")

Measured memory_bytes: 41600
import java.util.Scanner;

public class Main {
	static int meiji = era(1868,9,8),
			taisho = era(1912,7,30),
			showa = era(1926,12,25),
			heisei = era(1989,1,8);
	static int era(int y, int m, int d ){
		return y*10000 + m*100 + d;
	}
	static String ans(int temp ,int y , int m ,int d){
		y++;
		if( meiji <=temp &&temp < taisho)return "meiji "+ String.valueOf(y - 1868)+" " + m +" "+ d;
		else if(taisho <= temp&&temp < showa)return "taisho "+ String.valueOf(y - 1912)+" " + m +" "+ d;
		else if(showa <= temp&&temp < heisei)return "showa " + String.valueOf(y - 1926)+" " + m +" "+ d;
		else if (temp >= heisei)return "heisei " + String.valueOf(y - 1989)+" " + m +" "+ d;
		else return "pre-meiji";
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		while(sc.hasNext()){
			int
			 y = sc.nextInt(),
			 m = sc.nextInt(),
			 d = sc.nextInt();
			System.out.println(ans(era(y,m,d),y,m,d));
		}

	}
}

Measured memory_bytes: 26284
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    prev_K_sum = max_K_sum = sum(P[:K])
    start = 0
    for i in range(N-K):
        cur_K_sum = prev_K_sum - P[i] + P[i+K]
        if cur_K_sum > max_K_sum:
            start = i + 1
            max_K_sum = cur_K_sum
        prev_K_sum = cur_K_sum
    target = P[start:start+K]
    ans = sum([(num+1)/2.0 for num in target])
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 32084
n = 1000000

ns = (n**0.5).to_i + 1
is_prime = [false, false] + [true]*(n-1)
2.upto(ns) do |i|
  next if !is_prime[i]
  (i*i).step(n, i) do |j|
    is_prime[j] = false
  end
end

cnt = 0
list = (0..n).map do |i|
  cnt += 1 if is_prime[i]
  cnt
end

while (ln=gets)
  puts list[ln.to_i]
end

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

int w, h;
char a[1019][1019];
long long dp[1019][1019];

int main() {
	cin >> w >> h;
	for (int i = 1; i <= w; i++) {
		for (int j = 1; j <= h; j++) {
			cin >> a[i][j];
		}
	}
	dp[1][1] = 1;
	for (int i = 1; i <= w; i++) {
		for (int j = 1; j <= h; j++) {
			if (a[i][j] == '#')
				continue;
			if (a[i + 1][j] != '#')
				dp[i + 1][j]+=dp[i][j];
			if (a[i][j + 1] != '#')
				dp[i][j + 1]+=dp[i][j];
			dp[i][j + 1] %= 1000000007;
			dp[i + 1][j] %= 1000000007;
		}
	}
	cout << dp[w][h];
	return 0;
}


Measured memory_bytes: 9344
h, w = [int(x) for x in input().split()]
n = int(input())
a = [int(x) for x in input().split()]

matrix = []
for _y in range(h):
    row = []
    for _x in range(w):
        row.append(-1)
    matrix.append(row)

cells = h * w
x, y = 0, 0
dx = 1

for idx, ccount in enumerate(a):
    color = idx + 1
    for _ in range(ccount):
        matrix[y][x] = str(color)
        # print(x, y)

        if x == w - 1 and dx == 1:
            y += 1
            dx = -1
        elif x == 0 and dx == -1:
            y += 1
            dx = 1
        else:
            x = x + dx

for row in matrix:
    print(' '.join(row))




Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 100010;
int n, m;
int a1[MAX];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a1[i]);
    scanf("%d", &m);
    int ans = 0;
    for (int i = 0; i < m; i++) {
        int num = 0;
        scanf("%d", &num);
        int index = lower_bound(a1, a1+n, num) - a1;
        if (index < n && a1[index] == num) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3540
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int n, k;
int d[10];

bool f(int x)
{
  bool ans = true;
  while (x > 0)
  {
    int y = x % 10;
    for (int i = 0; i < k; i++)
    {
      if (y == d[i])
      {
        ans = false;
        x = 0;
        break;
      }
    }
    x /= 10;
  }
  return ans;
}


int main()
{
  cin >> n >> k;
  for (int i = 0; i < k; i++)
  {
    cin >> d[i];
  }
  int ans = n;
  while (ans < 300000)
  {
    if (f(ans))
    {
      break;
    }
    else
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

s = input()

num = str(len(s)-2)

print(s[0] + num + s[-1])


Measured memory_bytes: 8956
n = int(input())
S_list = list(input())

rsum = 0
gsum = 0
bsum = 0

for s in S_list:
	if s == "R":
		rsum += 1
	elif s == "G":
		gsum += 1
	elif s == "B":
		bsum += 1

sum = rsum * gsum * bsum

for i in range(n-2):
	p = (n-i-1) // 2
	for j in range(1,p+1):
		if S_list[i] != S_list[i+j] and S_list[i+2*j]  != S_list[i+j] and S_list[i] != S_list[i+2*j]:
			sum -= 1

print(sum)


Measured memory_bytes: 9228
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int itemCount = inpt[0];
        int kindCount = inpt[1];

        Dictionary<int, int> cnt = new Dictionary<int, int>();
        Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToList().ForEach(a =>
        {
            if(cnt.ContainsKey(a)) {
                cnt[a]++;
            }  else {
                cnt.Add(a, 1);
            }
        });

        List<KeyValuePair<int, int>> list = cnt.OrderBy(a => a.Value).ToList();
        int ans = 0;
        for (int i = 0; i < list.Count - kindCount; i++) {
            ans += list[i].Value;
        }
        Console.WriteLine(ans);
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





10 3
5 1 3 2 4 1 1 2 3 4


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 42564
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,x[100],y[100];
vector<pair<double,pair<int,int>>>v;
double res;

int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>x[i]>>y[i];
		v.push_back(mkp(atan2(y[i],x[i]),mkp(x[i],y[i])));
		v.push_back(mkp(atan2(y[i],x[i])+2*3.14159265358979323846264338,mkp(x[i],y[i])));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<N*2;++i){
		double cx,cy;
		cx=cy=0;
		for(int j=i;j<N*2&&j<i+N;++j){
			cx+=v[j].second.first;
			cy+=v[j].second.second;
			res=max(res,sqrt(cx*cx+cy*cy));
		}
	}
	printf("%.15f\n",res);
}


Measured memory_bytes: 256