akhauriyash/Code-Regression huggingface dataset:
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

const int64_t max = 500000;
const int64_t sentinel = 10000000000;

int64_t L[max / 2 + 2], R[max / 2 + 2];
int64_t cnt;

void merge(int64_t A[], int64_t n, int64_t left, int64_t mid, int64_t right) {
    int64_t n1 = mid - left;
    int64_t n2 = right - mid;
    for (int64_t i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int64_t i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = sentinel;
    int64_t i = 0, j = 0;
    for (int64_t k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int64_t A[], int64_t n, int64_t left, int64_t right) {
    if (left + 1 < right) {
        int64_t mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

void solve() {
    int64_t A[max], n;
    std::cin >> n;
    for (int64_t i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    mergeSort(A, n, 0, n);

    for (int64_t i = 0; i < n; i++) {
        if (i > 0) std::cout << " ";
        std::cout << A[i];
    }
    std::cout << std::endl;
    std::cout << cnt << std::endl;
    return;
}

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}



Measured memory_bytes: 10924
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a := nextInt()
	b := nextInt()

	if (a*b)%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}

// 以下がテンプレート

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, N;
  cin >> K >> N;
  int arr[N];
  for (int i=0; i<N; i++) cin >> arr[i];
  sort(arr, arr+N);
  int difference[N];
  difference[0] = K-arr[N-1]+arr[0];
  for (int i=1; i<N; i++) difference[i] = arr[i]-arr[i-1];
  sort(difference, difference+N);
  long long total = 0;
  for (int i=0; i<N-1; i++) total += difference[i];
  cout << total;
}

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

int main() {
  int N,a,b;
  cin >> N;
  
  a = N / 10;
  b = N % 10;
  
  if (a == 9 || b == 9) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n % 2) puts("No"),exit(0);
    string a(s.begin(),s.begin()+n/2),b(s.begin()+n/2,s.begin()+n);
    if(a == b) puts("Yes");
    else puts("No");
    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int M;
	int D;
	cin >> M >> D;
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 22; j <= D; j++) {
			if ((j % 10) * (j / 10) == i && (j % 10) > 1 && j / 10 > 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int i = 0, j = s.length() - 1;
    while(s[i] != 'A'){
        i++;
    }
    while(s[j] != 'Z')j--;
    cout << j - i + 1;

	return 0;

}


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

int f( long long x ) {
    int c=0;
    while ( x ) {
        x/=10;
        c++;
    }
    return c;
}


int main() {
    long long n;
    cin >> n;
    int ans=100;
    for ( long long i=1; i*i<=n; i++) {
        if ( n%i==0 ) {
            ans=min(ans,max(f(i),f(n/i)));
        }
    }
    cout << ans << '\n';
    return 0;
}

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

struct UnionFind{
	vector<int> d;
	UnionFind(int n) : d(n, -1){}
	int find(int x){
		if(d.at(x) < 0) return x;
		return d.at(x) = find(d.at(x));
	}
	bool unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d.at(x) > d.at(y)) swap(x, y);
		d.at(x) += d.at(y);
		d.at(y)= x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d.at(find(x)); }
};

int main(){
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	vector<pair<int, int>> vp(m);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		vp.at(i).first = a;
		vp.at(i).second = b;
	}
	vector<ll> va(m+1);
	va.at(m) = (ll)n * (ll)(n-1) / (ll)2;
	for(int i = m-1; i >= 0; i--){
		int a = vp.at(i).first, b = vp.at(i).second;
		bool be_uni = uf.same(a, b);
		int an = uf.size(a), bn = uf.size(b);
		uf.unite(a, b);
		bool af_uni = uf.same(a, b);
		if(be_uni != af_uni) va.at(i) = va.at(i+1) - (ll)an*(ll)bn;
		else va.at(i) = va.at(i+1);
	}
	
	rep(i, m) cout << va.at(i+1) << endl;
	
	return 0;
}

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

#define endl "\n"
#define ll long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define read(v) for(auto &it:v) cin>>it;
#define out(v) for(auto &it:v) cout<<it<<" ";
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vll;

#define deb(x) cout << ">" << #x << '=' << x << endl;
#define setbits(n) __builtin_popcountll(n)
#define done {cout<<"-1"<<endl; return;}

#define inf INT_MAX
#define ninf INT_MIN
const ll N = 1e5 + 5;
#define MOD 1000000007

void solve() {
	int n;
	cin >> n;
	vector<ll> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	ll ans = 0;
	vector<ll> sum1(n), diff1(n), diff2(n), sum2(n);
	for (int i = 0; i < n; i++) {
		sum1[i] = x[i] + y[i];
		diff1[i] = x[i] - y[i];
		sum2[i] = -x[i] - y[i];
		diff2[i] = y[i] - x[i];
	}
	ll cur = 0;
	ans = max(ans, *max_element(all(sum1)) - *min_element(all(sum1)));
	ans = max(ans, *max_element(all(sum2)) - *min_element(all(sum2)));
	ans = max(ans, *max_element(all(diff1)) - *min_element(all(diff1)));
	ans = max(ans, *max_element(all(diff2)) - *min_element(all(diff2)));
	cout << ans << endl;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputc.txt", "r", stdin);
	freopen("outputc.txt", "w", stdout);
#endif
	int t = 1;
	//cin>>t;
	while (t--) solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


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

int main(){
    int N, Q;
    cin >> N;
    int A;
    map<int, int> numbers;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A;
        numbers[A]++;
        ans  += A;
    }
    cin >> Q;
    int B, C;
    for(int i = 0; i < Q; i++){
        cin >> B >> C;
        int n = numbers[B];
        numbers[C] += n;
        numbers[B] = 0;
        ans += (long long) (C-B)* n;
        cout << ans << endl;
    }

}




Measured memory_bytes: 7956
s=input().rstrip()
x=list(s)
if len(x)==1:
    print(-1,-1)
elif len(x)==2:
    if x[0]==x[1]:
        print(1,2)
    else:
        print(-1,-1)
else:
    G=0;
    for i in range(0,len(x)-3+1):
        t=x[i:i+3]
        if len(list(set(t)))==1 or len(list(set(t)))==2:
            print(i+1,i+3)
            G=1;
            break;
    if G==0:
        print(-1,-1)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)INT_MAX*10000LL;
ll dp[105][100005];
void solve(){
	ll n, w, i, j;
	memset(dp, 0, sizeof(dp));
	cin>>n>>w;
	int wt[n], val[n];
	for(i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	ll sum=accumulate(val, val + n, 0);
	for(j=1;j<=sum;j++){
		dp[0][j]=inf;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=sum;j++){
			if(val[i-1]<=j){
				dp[i][j]=min(dp[i-1][j], dp[i-1][j-val[i-1]] + wt[i-1]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	for(i=sum;i>=0;i--){
		if(dp[n][i]<=w){
			cout<<i<<endl;
			break;
		}
	}
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 82304
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  char last =' ';
  char now;

  long ret =0;
  long renzoku =0;
  long lastrenzoku =0;
  
  rep(i,s.length())
  {
    now = s[i];
    
    if(last == now)
    {
      renzoku ++;
    }
    else
    {
      lastrenzoku = renzoku;
      renzoku =1;
    }
    
    if(now =='>' && renzoku <= lastrenzoku)
    {
      ret += renzoku -1;
    }
    else
    {
      ret += renzoku;
    }
    
    last =now;
  }

    cout <<ret;

	return 0;
}

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

using namespace std;
 
int main()
{
  int n , k;
  cin>>n>>k;
  int h[n];
  for(int i=0 ; i<n ; i++)
    cin>>h[i];
  
  int dp[n+1];
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(h[0]-h[1]);
  
  for(int i=3 ; i<=n; i++)
  {
    int res=INT_MAX;
    for(int j=1 ; j<=k ; j++)
    {
      if((i-j)>=1)
      	res=min(res , dp[i-j]+abs(h[i-j-1] - h[i-1]) );
    }
    dp[i]=res;
  }
  
  cout<<dp[n];
  return 0;
}

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

int main() {
	int a[5];
	rep(i, 5)scanf("%d", &a[i]);
	sort(a, a + 5, greater<>());
	rep(i, 5)cout << a[i] << (i == 4 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(){}
    UnionFind(const int node_size) : par(node_size){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    bool unite(int x, int y){
        int z;
        while(par[x] != par[y]){
            if(par[x] > par[y]) swap(x, y);
            z = par[x], par[x] = par[y];
            if(y == z) return false;
            x = z;
        }
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main()
{
    int n,m,q;
    int a,b;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        cin >> a >> b;
        uf.unite(a,b);
    }
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> a >> b;
        if(uf.same(a,b)){
            cout << "yes\n";
        }else{
            cout << "no\n";
        }
    }
}



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

int main () {
	
	long long int a=0, b=0;

	cin >> a  >> b;

	a += b;

	if (a%2 == 0) cout << (a/2) << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m,q;
	cin>>n>>m>>q;
	int a[n+1]={};
	int ans=0;
	int qu[q][4];
	for(int i=0;i<q;++i)
	{
		cin>>qu[i][0];
		cin>>qu[i][1];
		cin>>qu[i][2];
		cin>>qu[i][3];
	}
	for(int i=0;i<(1<<(n+m-1));++i)
	{
		if(__builtin_popcountll(i)==n)
		{
			int va=1;
			int c=1;
			for(int j=0;j<(n+m-1);++j)
			{
				if(i&(1<<j))
				{
					a[c]=va;
					++c;
				}
				else
					++va;
			}
			int ma=0;
			for(int j=0;j<q;++j)
			{
				if(a[qu[j][1]]-a[qu[j][0]]==qu[j][2])
					ma+=qu[j][3];
			}
			ans=max(ans,ma);
		}
	}
	cout<<ans;
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
} 

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std ;
const int rem = 1e9 + 7 ;
const int maxn = 1e5 + 1 ;
int a[maxn] , check[maxn] ;
int pow2(int x )
{
	long long sum = 1;
	for ( int i = 1 ; i<= x ; i++)
		sum = (sum*2) % rem ;
	return sum ;

}
int main()
{
	int n  , y ; 
	cin >> n ;
	for ( int  i = 0 ; i< n ; i++) 
		cin >> y , check[y] ++ ;
	if ( n % 2 == 1) 
	{
		bool b = false;
		if ( check[0] != 1 )	
			b = true  ;
		for ( int i = 2; i<=n ; i+=2)
			if ( check[i] != 2 ) 
				b = true  ;
		if ( !b ) 
			cout << pow2 ( n/2 ) << endl;
		else
			cout << 0 << endl;
		return 0 ;
		

	}
	else
	{
		bool b = false ;
		for ( int i = 1 ; i<= n ; i+=2 )
			if ( check [i] != 2 ) 
				b = true  ;
		if ( !b) 
			cout << pow2 ( n/2 ) << endl;
		else
			cout << 0 << endl;
		return 0 ;
	}


}

Measured memory_bytes: 640
//--------Anivia_kid---------//
//-------did you test n = 1 ?-------//
#include<bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back

typedef long long ll; 
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;

void Anivia_kid(){
	vector<int> v(3);
	for(int i = 0; i < 3; i++)
		cin>>v[i];
	sort(v.begin(), v.end());
	if((v[0] == v[1] && v[1] != v[2]) || (v[1] == v[2] && v[0] != v[1])) cout<<"Yes\n";
	else cout<<"No\n";

	return;
}
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin>>q;
	while(q--){
		Anivia_kid();
	}
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_N 15
int count(int a){
 if(a == 0)  return 0;
 return count(a >> 1) + (a & 1);
}
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	int A[MAX_N + 1];
	int x[MAX_N + 1][MAX_N + 1], y[MAX_N + 1][MAX_N + 1];

	//-------------input--------------
	for(int i = 1 ; i <= N ; i++){
	 cin >> A[i];
	 for(int j = 1 ; j <= A[i] ; j++)
	  cin >> x[i][j] >> y[i][j];
	}

	//-------------solve--------------
	int ans = 0;
	for(int bits = 1 ; bits < (1 << N) ; bits++){
	 //矛盾していないならtrue
	 bool check = true;
	  for(int i = 1 ; i <= N ; i++){

		//正直者でないと仮定しているなら無視
		if(!(bits & (1 << (i - 1))))  continue;
		for(int j = 1 ; j <= A[i] ; j++)
		 if(((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) check = false;
	  }
	 if(check)  ans = max(ans, count(bits));
	}

    //--------------output---------------
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vll s;
	ll ss = 0;
	rep(i, 0, N) {
		ll a;
		cin >> a;
		ss += a;
		s.push_back(ss);
	}
	int l = 0, r = 2, t = s.size() - 1;
	ll c = s[t];
	rep(m, 1, t - 1) {
		vll pqrs;
		while (s[l] < s[m] - s[l + 1]) {
			++l;
		}
		pqrs.push_back(s[l]);
		pqrs.push_back(s[m] - s[l]);
		while (s[r] - s[m] < s[t] - s[r + 1]) {
			++r;
		}
		pqrs.push_back(s[r] - s[m]);
		pqrs.push_back(s[t] - s[r]);
		sortv(pqrs);
		c = min(c, pqrs[3] - pqrs[0]);
	}
	cout << c << endl;
    return 0;
}

Measured memory_bytes: 2420
import java.util.*;

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

    String S = scn.nextLine();
    char[] tile = S.toCharArray();

    char[] model1 = new char[tile.length];
    char[] model2 = new char[tile.length];
    for (int i = 0; i < tile.length; i++) {
      model1[i] = String.valueOf(i % 2).toCharArray()[0];
      model2[i] = String.valueOf((i + 1) % 2).toCharArray()[0];
    }

    System.out.println(Math.min(countDiffernce(tile, model1), countDiffernce(tile, model2)));
  }

  public static int countDiffernce(char[] str1, char[] str2) {
    int count = 0;
    for (int i = 0; i < str1.length; i++) {
      if (str1[i] != str2[i]) {
        count++;
      }
    }
    return count;
  }
}

Measured memory_bytes: 42172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
int main() {
    int n, m;
    cin >> n >> m;
    string a[n], b[m];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
 
    bool isContained =  false;
    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            bool match = true;
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    if(a[i + y][j + x] != b[y][x]) {
                        match = false;
                    }
                }
            }
            if (match) {
                isContained = true;
            }
        }
    }
 
    if (isContained) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
 
    return 0;
}

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

using namespace std;

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> L(M), R(M); for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
    vector<int> p(Q), q(Q); for (int i = 0; i < Q; i++) cin >> p[i] >> q[i];

    vector<vector<int>> num(N + 1, vector<int>(N + 1)), csum(N + 1, vector<int>(N + 1));
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            num[i][j] = 0;
            csum[i][j] = 0;
        }
    }

    for (int i = 0; i < M; i++) {
        num[L[i]][R[i]]++;
    }
    for (int i = 0; i <= N; i++) {
        csum[i][0] = num[i][0];
        for (int j = 1; j <= N; j++) {
            csum[i][j] = csum[i][j - 1] + num[i][j];
        }
    }

    for (int i = 0; i < Q; i++) {
        int ans = 0;
        for (int j = p[i]; j <= N; j++) {
            ans += csum[j][q[i]];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5248
A, B, C, D = [int(x) for x in input().split()]
ans = 0

if B <= C or D <= A:
	ans = 0
elif A <= C and B <= D:
	ans = B - C
elif A <= C and D <= B:
	ans = D - C
elif C <= A and D <= B:
	ans = D - A
elif C <= A and B <= D:
	ans = B - A

print(ans)

Measured memory_bytes: 3060
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

n, k = MAP()
p = LIST()
p = sorted(p)
print(sum(p[:k]))

Measured memory_bytes: 72728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	 // int t ;
	 // cin>>t;
	 // whln(t){
  	string a ;
  	cin>>a;

  	rep(i,a.length())
  		cout<<"x";
  	
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3628
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
const int MAX=1000005;
int head[MAX],ver[MAX],next1[MAX],a[MAX];
int cnt=0;
int n,m;
void add(int u, int v) {
    ver[cnt] = v;
    next1[cnt] = head[u];
    head[u] = cnt++;
}
bool bfs(int x) {
    queue<int> q;
    q.push(x);
    a[x] = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = head[u]; ~i; i = next1[i]) {
            int v = ver[i];
            if (a[v] == -1) {
                a[v] = u;
                q.push(v);
            }
        }
    }
    for (int i = 2; i <= n; i++) {
        if (a[i] == -1) {
            return false;
        }
    }
    return true;
}
int main(void) {
    cin >> n >> m;    
    cnt = 0;
    memset(head, -1, sizeof(head));
    memset(a, -1, sizeof(a));
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        add(u, v);        
        add(v, u);        
    }

    if (!bfs(1)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 2; i <= n; i++) {
            cout << a[i] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 14600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

ll po(ll x,ll n){
    if(n==0) return 1;
    else if(n%2 == 0) return po((x*x)%MOD,n/2);
    else return (x*po((x*x)%MOD,(n-1)/2))%MOD;
}

void init(){
}

void solve( ll  tst ){
    ll k,n,m;
    cin>>k>>n>>m;
    n--;
    if( m/k - n/k) cout<<"OK"<<"\n";
    else cout<<"NG"<<"\n";
    return;
}

int main(){
    FAST;
    init();
    //cout<<"init"<<endl;
    ll t = 1;
    //cin>>t;
    for (ll i=1;i<=t;i++ ) solve(i);
    return 0;
} 

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
    if((a+b)%2==1){
      printf("%d",(a+b)/2+1);
    }
    else{
      printf("%d",(a+b)/2);
    }
  return 0;
}

Measured memory_bytes: 128
N,M=(map(int,input().split()))
a=input().split()
A=[int(i) for i in a]
x=0
for i in range(N):
  if A[i]>=sum(A)*(1/(4*M)):
    x+= 1
if x>=M:
  print("Yes")
else:
  print("No")
    



Measured memory_bytes: 9204
n=int(input())
a=list(map(int, input().split()))
cnt=[0]*(max(a)+1)
for i in range(n):
  cnt[a[i]]+=1
odd=0
even=0
for i in range((max(a)+1)):
  if cnt[i]>0:
    if cnt[i]%2==1:
      odd+=1
    else:
      even+=1
if even%2==1:
  print(odd+even-1)
else:
  print(odd+even)

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        auto mp = make_v(n + 1, n + 1, '*');
        REP(i, 0, n) {
            REP(j, 0, n) {
                cin >> mp[i + 1][j + 1];
            }
        }
        auto dp = make_v(n + 1, n + 1, 0);
        REP(i, 1, n + 1) {
            REP(j, 1, n + 1) {
                if (mp[i][j] == '.') {
                    dp[i][j] = min({dp[i - 1][j - 1], dp[i][j - 1], dp[i - 1][j]}) + 1;
                }
            }
        }
        int ans = 0;
        REP(i, 1, n + 1) {
            REP(j, 1, n + 1) {
                ans = max(ans, dp[i][j]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 7776
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAXN = 444;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
ll v[MAXN], sum[MAXN];
ll dp[MAXN][MAXN];

int main() {
    int n, m, k;
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%lld", v+i);
        sum[i] += sum[i-1] + v[i];
    }
    ll ans;
    for (int l = 2; l<=n; ++l) {
        for (int i = 1, j = l; j<=n; ++j, ++i) {
            ans = INFL;
            for (int k = i; k<j; ++k) {
                ans = min(ans, dp[i][k]+dp[k+1][j]);
            }
            dp[i][j] = ans+sum[j]-sum[i-1];
        }
    }
    printf("%lld\n", dp[1][n]);
}


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

int main() {
    string s; cin >> s;
    int size = s.size();
    int l,r; l = r = -1;
    for (int i=1; i < size; i++) {
        if (s[i-1] == s[i]) {
            l = i;
            r = i+1;
        }
        if (i >= 2 && s[i-2] == s[i]) {
            l = i-1;
            r = i+1;
        }
    }
    cout << l << ' ' << r << endl;
}

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

signed main(void)
{
	int n, k, ans;
	vector<int> a(3), ctoi(256);
	string t;

	cin >> n >> k;
	rep(i, 3) cin >> a[i];
	cin >> t;
	ctoi['r'] = 0;
	ctoi['s'] = 1;
	ctoi['p'] = 2;
	ans = 0;
	rep(i, k)
	{
		vector<char> vec;
		for(int j = i; j < n; j += k)
		{
			vec.push_back(t[j]);
		}
		int m = vec.size();
		vector<vector<int>> dp(m, vector<int>(3, 0));
		rep(p, m)
		{
			rep(j, 3)
			{
				rep(q, 3) 
				{
					if (p == 0)
					{
						if (j == (ctoi[vec[p]] + 2) % 3)
							dp[p][j] = a[j];
					}
					else
					{
						if (j == q) continue;
						if ((ctoi[vec[p]] + 2) % 3 == j)
							dp[p][j] = max(dp[p][j], dp[p - 1][q] + a[j]);
						dp[p][j] = max(dp[p][j], dp[p - 1][q]);
					}
				}
			}
		}
		int mx = 0;
		rep(i, 3) mx = max(mx, dp[m - 1][i]);
		ans += mx;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
string s;
cin >> s;

string ret = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] == '0' || s[i] == '1') ret += s[i];
else if (ret.size() > 0) {
ret = ret.substr(0, ret.size() - 1);
}
}
cout << ret << endl;
return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	string s;
	cin >> s;
	if ((int)s.size() % 2 == 1) {
		cout << "No";
		return;
	}
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

int i, j, k;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int n = a * 100 + b * 10 + c;
	if (n % 4 == 0)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n,0),B(n-1,0);rep(i,n-1) cin>>B[i];
  A[0]=B[0];A[n-1]=B[n-2];
  for(ll i=1;i<n-1;++i) A[i]=min(B[i-1],B[i]);
  ll ans=accumulate(A.begin(),A.end(),0);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
from math import factorial


def solve(N, A, B, Vs):
    Vs.sort(reverse=True)

    all_counter = Counter(Vs)
    first = Vs[:A]
    first_c = Counter(Vs[:A])

    second_c = Counter(Vs[A:])
    avg = sum(first) / A

    ans = 1
    for fv, fc in first_c.items():
        if fv == avg:
            ts = 0
            for c in range(A, min(all_counter[fv], B) + 1):
                ts += factorial(all_counter[fv]) // factorial(c) // factorial(all_counter[fv] - c)
            ans *= ts
        else:
            ans *= factorial(all_counter[fv]) // factorial(second_c[fv]) // factorial(fc)
    return "\n".join(["{:0.6f}".format(avg), str(ans)])

if __name__ == "__main__":
    N, A, B = map(int, input().split(" "))
    Vs = list(map(int, input().split(" ")))
    print(solve(N, A, B, Vs))


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

int n,m,M,a[1000],I=1000000010;
string b,s;

main(){
	while(cin>>n,n){
		bool e=0;
		s="none";
		M=I;m=-I;
		rep(i,n){
			a[i]=0;cin>>b;
			if(b=="x")a[i]=I;
			else rep(j,b.size()){
				if(b[j]=='-')continue;
				a[i]*=10;a[i]+=b[j]-'0';
			}
			if(b[0]=='-')a[i]*=-1;
		}
		rep(i,n-1)if(a[i]==a[i+1])e=1;
		rep(i,n-1)if(a[i]!=I&&a[i+1]!=I&&((i%2&&a[i]<=a[i+1])||(!(i%2)&&a[i]>=a[i+1])))e=1;
		if(e){
			cout<<s<<endl;
			continue;
		}
		rep(i,n)if(a[i]==I)e=1;
		if(!e){
			cout<<"ambiguous"<<endl;
			continue;
		}
		if(a[0]==I)M=a[1]-1;
		if(a[n-1]==I){
			if(n%2) M=min(M,a[n-2]-1);
			else m=a[n-2]+1;
		}
		for(int i=1;i<n-1;i++){
			if(a[i]!=I)continue;
			if(i%2) m=max(m,max(a[i-1],a[i+1])+1);
			else M=min(M,min(a[i-1],a[i+1])-1);
		}
		if(m==M)cout<<m<<endl;
		else{
			if(M>m)s="ambiguous";
			cout<<s<<endl;
		}
	}
}

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

if C==0:
  print("YES")
elif A%B==0:
  print("NO")
else:
  ans=True
  for i in range(1,B):
    if A*i%B != 0 and C % (A*i%B)==0:
      print("YES")
      ans=False
      break
  if ans:
    print("NO")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long e = (c * d) / gcd(c, d);
    long ans = 0;
    if(a == 1) {
      long t = (b / c);
      t += (b / d);
      t -= (b / e);
      ans = (b - t);
    } else {
      long t1 = (b / c);
      t1 += (b / d);
      t1 -= (b / e);
      long t2 = ((a - 1) / c);
      t2 += ((a - 1) / d);
      t2 -= ((a - 1) / e);      
      ans = (b - t1 + t2 - a + 1);      
    }
    System.out.println(ans);
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  bool sorted = true;
  for (int i = 0; i < n - 1; ++i) if (a[i] >= a[i + 1]) sorted = false;
  if (sorted) return cout << 1 << '\n', 0;
  auto chk = [&](int x) -> bool {
    if (x == 1) return false;
    map<int, int> c;
    auto g = [&](const auto& g, int j) -> void {
      if (!j) {
        ++c[j];
        return;
      }
      if (++c[j] == x) {
        c.erase(j);
        g(g, j - 1);
      }
    };
    for (int i = 1; i < n; ++i) {
      if (a[i - 1] < a[i]) continue;
      c.erase(c.lower_bound(a[i]), end(c));
      g(g, a[i] - 1);
    }
    return c[0] < x;
  };
  int ng = 1, ok = n;
  while (ok - ng > 1) {
    int mid = ng + ok >> 1;
    (chk(mid) ? ok : ng) = mid;
  }
  cout << ok << '\n';
}

Measured memory_bytes: 1024
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

const int mod = 1e9 + 7;
const int s = 1e6 + 1;

int32_t main()
{

	//shuru_krte_hai_bina_kisi_bakchodi_ke();
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int div[n+10]={0};
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			div[j]++;
		}
	}
	int ans = 0;
	for(int i=1;i<n;i++){
		//deb2(div[n-i],n-i);
		ans+=div[n-i];
	}
	cout<<ans;
	return 0;
}

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

int main()
{
	string s;
	cin>>s;
	int ans=0,max=0;
	int ln=s.size();

	for(int i=0 ; i<ln ; ++i)
	{
		ans=0;
		if(s.at(i)=='R')
		{
			ans++;
			for(int j=i+1 ; j<ln ; ++j)
			{
				if(s.at(j)!='R')
					break;
				ans++;
			}

			if(ans>max)
				max=ans;
		}
	}	

	cout<<max;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read() {
    LL x = 0, fh = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            fh = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar();
    }
    return x * fh;
}
const int N = 1e5 + 10;
LL n, c, ans, x[N], v[N], q1[N], q2[N];
int i;
int main() {
	n = read(); c = read();
	for (i = 1; i <= n; i++) { x[i] = read(); v[i] = read(); }
	for (i = 1; i <= n; i++) { q1[i] = q1[i - 1] + v[i]; }
	for (i = 1; i <= n; i++) { q1[i] = max((LL)0, max(q1[i] - x[i], q1[i - 1])); }
	for (i = n; i >= 1; i--) { q2[i] = q2[i + 1] + v[i]; }
	for (i = n; i >= 1; i--) { q2[i] = max((LL)0, max(q2[i] - c + x[i], q2[i + 1])); }
	for (i = 1; i <= n; i++) { ans = max(ans, q1[i] + max((LL)0, q2[i + 1] - x[i])); }
	for (i = n; i >= 1; i--) { ans = max(ans, q2[i] + max((LL)0, q1[i - 1] - c + x[i])); }
	cout << ans;
	return 0;
}

Measured memory_bytes: 6688
N,L=map(int,input().split())
A=list()
sa1=1000
ans=1000
for i in range(N):
    A.append(L+i)
for i in range(N):
    azi=sum(A)-A[i]
    sa2=sum(A)-azi
    if sa1>sa2:
        if sa2<0:
            sa2*=-1
        sa1=sa2
        ans=azi
print(ans)


Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d = inpl()
a -= 1
e = c*d//fractions.gcd(c,d)
B = b - (b//c + b//d - b//e)
A = a - (a//c + a//d - a//e)
print(B - A)

Measured memory_bytes: 5076
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <functional>
using namespace std;

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

  int x[N];
  int y[N];
  long long h[N];
  int index = 0;
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] > 0){
      index = i;
    }
  }

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      long long H = h[index] + abs(i - x[index]) + abs(j - y[index]);

      int flag = 1;
      for(int k=0;k<N;k++){
        if(h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0LL) ){
          flag = 0;
          break;
        }
      }
      if(flag == 1){
        cout << i << " " << j << " " << H << "\n";
        return 0;
      }
    }
  }


  return 0;
}


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

typedef long long ll;
const int N = 250033, mod1 = 1000000007, mod2 = 1000109107;
int qpow(int b, int p, int m) {
  int r = 1;
  for (; p; p >>= 1, b = (ll) b * b % m) if (p & 1) r = (ll) r * b % m;
  return r;
}
struct data {
  int x, y;
  data(int x = 0, int y = 0) : x(x), y(y) {}
  data operator + (const data &d) const {return data((x + d.x) % mod1, (y + d.y) % mod2);}
  data operator - (const data &d) const {return data((x + mod1 - d.x) % mod1, (y + mod2 - d.y) % mod2);};
  data operator * (const data &d) const {return data((ll) x * d.x % mod1, (ll) y * d.y % mod2);}
  data operator / (const data &d) const {return data((ll) x * qpow(d.x, mod1 - 2, mod1) % mod1, (ll) y * qpow(d.y, mod2 - 2, mod2) % mod2);}
  ll get() {return (ll) x << 30 | y;}
};
data X(159623, 102647), f[N], g[N], h[N], k(1, 1), b;
int n;
ll ans;
char s[N];
map<ll, int> mp;

int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == '+') b = b + k;
    if (s[i] == '-') b = b - k;
    if (s[i] == '>') k = k * X;
    if (s[i] == '<') k = k / X;
    f[i] = b;
  }
  g[0] = k = data(1, 1), h[0] = b = data(0, 0);
  for (int i = 1; i <= n; i++) {
    if (s[i] == '+') b = b - data(1, 1);
    if (s[i] == '-') b = b + data(1, 1);
    if (s[i] == '>') k = k / X, b = b / X;
    if (s[i] == '<') k = k * X, b = b * X;
    g[i] = k, h[i] = b;
  }
  for (int i = n; i >= 0; i--) {
    data t = (f[n] - h[i]) / g[i];
    ans += mp[t.get()];
    mp[f[i].get()]++;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 37632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s == "zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl;
		return 0;
	}
	if(s.size() == 26){
		vector<string> cand;
		rep(i, 1, s.size()){
			repb(j, i - 1, 0){
				if(s[i] > s[j]){
					string t = s.substr(0, j);
					t += s[i];
					// cout << i << ' ' << j << ' ' << t << endl;
					cand.push_back(t);
					break;
				}
			}
		} 
		sort(all(cand));
		cout << cand[0] << endl;
		return 0;
	}else{
		int d[26] = {};
		rep(i, 0, s.size()){
			d[s[i] - 'a']++;
		}
		rep(i, 0, 26){
			if(d[i] == 0){
				s += 'a' + i;
				cout << s << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int p[N/2];
bool vis[N+10];
int f[N+10];
int main(){
	int m=0;
	for(int i=2;i<=N;i++){
		if(!vis[i])p[++m]=i,f[i]=i;
		for(int j=1;j<=m&&p[j]*i<=N;j++){
			vis[p[j]*i]=true;
			f[p[j]*i]=p[j];
			if(i%p[j]==0)break;
		}
	}
	int n;
	cin>>n;
	bool pa=true;
	int d=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		d=__gcd(d,a);
		while(a>1){
			int j=f[a];
			if(vis[j])pa=false;
			vis[j]=true;
			for(a/=j;a%j==0;a/=j);
		}
	}
	puts(pa?"pairwise coprime":(d==1)?"setwise coprime":"not coprime");
}

Measured memory_bytes: 8828
#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;
ll n,k,i;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	while(k<n){
		i++;
		k+=i;
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
struct RollingHash2D{
  struct RollingHash{
    string S;
    ull B;
    vector<ull> hash,p;
    int len;
    RollingHash(){}
    RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();};
    void init(){
      len=S.length();
      hash.resize(len+1);
      p.resize(len+1);
      hash[0]=0;p[0]=1;
      for(int i=0;i<len;i++){
	hash[i+1]=hash[i]*B+S[i];
	p[i+1]=p[i]*B;
      }
    }
  //S[l,r)
    ull find(int l,int r){
      return hash[r]-hash[l]*p[r-l];
    }
  };
  vector<string> S;
  vector<RollingHash> rh;
  vector<vector<ull> > hash;
  vector<ull> p;
  int h,w,r,c;
  ull B;
  RollingHash2D(){}
  RollingHash2D(vector<string> S,int r,int c,ull B=9973):S(S),r(r),c(c),B(B){init();};
  void init(){
    h=S.size();
    w=S[0].size();
    hash.resize(h+1,vector<ull>(w-c+1,0));
    rh.resize(h);
    for(int i=0;i<h;i++) rh[i]=RollingHash(S[i]);
    p.resize(h+1);
    p[0]=1;
    for(int i=0;i<h;i++) p[i+1]=p[i]*B;
    for(int j=0;j<w-c+1;j++){
      hash[0][j]=0;		    
      for(int i=0;i<h;i++)
	hash[i+1][j]=hash[i][j]*B+rh[i].find(j,j+c);
    }
  }
  //S[l,r)
  ull find(int i,int j){
    return hash[i+r][j]-hash[i][j]*p[r];
  }
};
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  int r,c;
  cin>>r>>c;
  vector<string> t(r);
  for(int i=0;i<r;i++) cin>>t[i];
  RollingHash2D srh(s,r,c);
  RollingHash2D trh(t,r,c);
  for(int i=0;i<h-r+1;i++){
    for(int j=0;j<w-c+1;j++){
      if(srh.find(i,j)==trh.find(0,0)) cout<<i<<" "<<j<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 38612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N; cin >> N;
	vector<ll>A(N);
	rep(i, 0, N)cin >> A[i];
	vector<bool>ans(N, false);
	ans[N - 1] = true;
	sort(all(A));
	vector<ll>sum = A;
	rep(i, 1, N)sum[i] += sum[i - 1];
	rREP(i, 0, N - 1) {
		if (sum[i] * 2 >= A[i + 1] && ans[i + 1])ans[i] = true;
	}
	int cnt = 0;
	rep(i, 0, N)if (ans[i])++cnt;
	cout << cnt << "\n";

	return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans;
    if (a+b > c+d){
        ans = "Left";
    }else if(a+b == c+d){
        ans = "Balanced";
    }else{
        ans = "Right";
    }

    cout << ans << endl;
}

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

int main(int argc, char *argv[])
{
    int n, k;
    int ans;

    scanf("%d %d", &n, &k);

    if (n >= k * 2 - 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128