akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
ll X[MAX_N];
ll Y[MAX_N];
ll S[MAX_N];
ll T[MAX_N];

ll solve(int N, ll L) {
  REP(i, N+1) Y[i] = (L - X[i]);

  S[0] = X[0];
  for (int i = 1; i <= N; i++) S[i] = S[i-1] + X[i];
  T[N] = Y[N];
  for (int i = N-1; i >= 0; i--) T[i] = T[i+1] + Y[i];

  // pv(X, X + N + 1);
  // pv(S, S + N + 1);
  // pv(Y, Y + N + 1);
  // pv(T, T + N + 1);

  ll res = 0;
  for (int first = 1; first <= N; first++) {
    ll val = 0;
    int n = N - first + 1;

    if (n % 2 == 1) {
      int m = first + (n)/2;
      val += 2 * (S[m] - S[first-1]) - X[m];
      val += 2 * T[m+1];
    } else {
      int m = first + (n-1)/2;
      val += 2 * (S[m] - S[first-1]);
      val += 2 * T[m+1] - Y[m+1];
    }
    // int left = first;
    // int right = N;
    // REP(i, n) {
    //   if (i == 0) {
    //     val += X[left];
    //   } else if (i % 2 == 1) {
    //     val += X[left];
    //     val += Y[right];
    //     left++;
    //   } else if (i % 2 == 0) {
    //     val += X[left];
    //     val += Y[right];
    //     right--;
    //   }
    // }
    chmax(res, val);
    // cout << "first=" << first << ", val=" << val << endl;
  }
  return res;
}

int main2() {
  CLR(X, 0);
  CLR(Y, 0);

  ll L = nextLong();
  int N = nextInt();
  REP(i, N) X[i+1] = nextLong();
  ll ans = 0;
  chmax(ans, solve(N, L));

  REP(i, N) X[i+1] = L - X[i+1];
  reverse(X + 1, X + N + 1);
  chmax(ans, solve(N, L));
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 6784
S = input()
N = len(S)
A = [0] * (N + 1)
for i, s in enumerate(S):
  if s == '<':
    A[i + 1] = max(A[i] + 1, A[i + 1])
for i, s in enumerate(S[::-1]):
  if s == '>':
    A[N - i - 1] = max(A[N - i] + 1, A[N - i - 1])
print(sum(A))

Measured memory_bytes: 23740
#include<bits/stdc++.h>
int main(){
	int N,M;
	int x[51]={};
	int a,b;
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++){
		scanf("%d %d",&a,&b);
		x[a]++;
		x[b]++;
	}
	for(int i=0;i<N;i++){
		printf("%d\n",x[i+1]);
	}
	return 0;
}

Measured memory_bytes: 256
#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<ll,ll>;
using vv = vector<vector<ll>>;
template <class _T> inline bool chmax (_T& a,_T b){if(a<b){a=b;return true;}return false;}
template <class _T> inline bool chmin (_T& a,_T b){if(a>b){a=b;return true;}return false;}

const long long INF = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    cout.precision(17);
    int n;cin >> n;
    vector<double>x(n),y(n);
    for(int i=0;i<n;i++){
	cin >> x[i] >> y[i];
    }
    vector<int> k(n);
    for(int i=0;i<n;i++) k[i] = i;
    double t=0;
    double ans = 0;
    do{
	for(int i=0;i<n-1;i++){
	    ans += sqrt((x[k[i]]-x[k[i+1]])*(x[k[i]]-x[k[i+1]])+(y[k[i]]-y[k[i+1]])*(y[k[i]]-y[k[i+1]]));
	}
	t++;
    }while(next_permutation(k.begin(),k.end()));
    cout << ans/t << endl;
    return 0;
}


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

int main( )
{
    int n, i, j, k;
    vector< pair<int, int> > v;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        v.push_back(make_pair(j, i));
    }
    sort(v.begin(), v.end());
    for (i = 0; i < n; i++) {
        if (i != 0) cout << ' ';
        cout << v[i].second;
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1780
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  for(int i=0;i<5;i++){
    int x;
    cin>>x;
    if(x==0){
      cout<<i+1<<endl;
    }
  };
  return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    if(2 * K > N + 1)return 0 & puts("-1");
    unsigned long k_1 = N / 2, k_2 = (N + 1) / 2;
    for(unsigned long i = K, j = K + 2 * N; i < K + k_2; ++i, j += 2){
        cout << i << " " << i + k_1 + N << " " << j << endl;
    }
    for(unsigned long i = K + k_2, j = K + 2 * N + 1; i < K + N; ++i, j += 2){
        cout << i << " " << i - k_2 + N << " " << j << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N, D;

	cin >> N >> D;

	cout << (N + 2 * D) / (2 * D + 1) << endl;

	return 0;
}

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

int main(){
   int x; cin>>x;
   int a;
   int maxr=0;
   if(x==1){
      cout<<1<<endl;
      return 0;
   }
   for(int i=2;i<=x;i++){
      int j=2;
      int ans=i;
      if(ans*ans<=x){
         while(ans*i<=x){
            ans*=i;
            //cout<<ans<<" ";
         }
         //cout<<endl;
         //cout<<ans<<endl;
         maxr=max(maxr,ans);
      }
   }
   cout<<maxr<<endl;
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[2005];

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  ll ans = 0;
  for(int i = 0; i < n - 2; i++) {
    for(int j = i + 1; j < n - 1; j++) {
      int res = (lower_bound(a + j + 1, a + n, a[i] + a[j]) - a) - j - 1;
      ans += res;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const int MAXN = 1e5;

struct operation{
	int y1,x1,y2,x2;
};

int main()
{
	int h,w;
	cin >> h >> w;
	int a[500][500] = {0};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}

	vector<operation> ans;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i==h-1 && j==w-1) break;
			if(a[i][j] % 2 != 0){
				if(j == w-1){
					operation p = {i+1,j+1,i+2,j+1};
					ans.push_back(p);
					a[i+1][j]++;
					//a[i][j]--;
				}else {
					operation p = {i+1,j+1,i+1,j+2};
					ans.push_back(p);
					a[i][j+1]++;
					//a[i][j]--;
				}
			}
		}
	}

	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i].y1 << " " << ans[i].x1 << " " <<  ans[i].y2 << " " <<  ans[i].x2 << endl;
	}

	return 0;
}

Measured memory_bytes: 5232
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const int N = 555;

int a[N][N];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int H = readInt(), W = readInt(), h = readInt(), w = readInt();
    int kek = 3999;
    if (H % h == 0 && W % w == 0) {
    	cout << "No";
    	return 0;
    }
    cout << "Yes\n";
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i % h == h - 1 && j % w == w - 1) {
				a[i][j] = -kek * (h * w - 1) - 1;				
			} else {
				a[i][j] = kek;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << a[i][j] << ' ';
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;
ll t,e;
ll x[100005];

struct data{
	ll val,lazy;
	data(){}
	data(ll vv,ll la){
		val=vv;
		lazy=la;
	}
};

data dp[1<<21];

void lazy_evaluate(int k){
	dp[k].val+=dp[k].lazy;
	if(k+1<n_){
		dp[k*2+1].lazy+=dp[k].lazy;
		dp[k*2+2].lazy+=dp[k].lazy;
	}
	dp[k].lazy=0;
}

void lazy_update(int k){
	dp[k].val=min(dp[k*2+1].val,dp[k*2+2].val);
}

ll query(int a,int b,int k=0,int l=0,int r=n_){
	lazy_evaluate(k);
	if(r<=a || b<=l)return INF*INF;
	if(a<=l && r<=b)return dp[k].val;
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	lazy_update(k);
	return min(vl,vr);
}

void add(int a,int b,ll v,int k=0,int l=0,int r=n_){
	lazy_evaluate(k);
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		dp[k].lazy+=v;
		lazy_evaluate(k);
		return;
	}
	add(a,b,v,k*2+1,l,(l+r)/2);
	add(a,b,v,k*2+2,(l+r)/2,r);
	lazy_update(k);
}

int main(void){
	scanf("%d%lld%lld",&n,&e,&t);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x[i]);
	}
	n_=1;
	while(n_<=n)n_*=2;
	add(1,n+1,x[n]+n*t);
	int now=0;
	for(int i=0;i<=n;i++){
		if(i>0){
			while(now<i){
				ll ela=x[i]-x[now+1];
				if(ela+x[i]-x[now+1]>=t){
					//dp[i]=min(dp[i],dp[now]+(x[i]-x[now+1])*2LL);
					now++;
				}else{
					ll rest=t-(ela+x[i]-x[now+1]);
					ll vi=query(i,i+1);
					ll vi2=query(now,now+1);
					if(vi>vi2+rest){
						add(i,i+1,vi2+rest-vi);
					}
					break;
				}
			}
		}
		ll vi=query(i,i+1);
		ll vi2=query(0,now);
		if(vi>vi2){
			add(i,i+1,vi2-vi); 
		}
		if(i>0 && i<n)add(0,i,(x[i+1]-x[i])*2LL);
		/*
		for(int j=0;j<=i;j++){
			printf("%lld ",query(j,j+1));
		}
		printf("\n");
		*/
	}
	/*
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			//printf("%d %d %lld\n",i,j,dp[i][j]);
			if(i<n)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+x[i+1]-x[i]);
			if(i>=1 && j<i){
				ll ela=dp[i][j]-dp[j+1][j];
				//printf("%lld\n",ela);
				if(ela+x[i]-x[j+1]>=t){
					dp[i][i]=min(dp[i][i],dp[i][j]+(x[i]-x[j+1])*2LL);
				}else{
					ll rest=t-(ela+x[i]-x[j+1]);
					dp[i][i]=min(dp[i][i],dp[i][j]+(x[i]-x[j+1])*2LL+rest);
				}
			}
		}
	}
	*/
	printf("%lld\n",query(n,n+1)+e);
	return 0;
}


Measured memory_bytes: 4608
try:
    while True:
        L=0
        M=0
        
        A=list(map(int,input().split()))
        B=list(map(int,input().split()))
        
        for i in range(4):
            if A[i]==B[i]:
                L+=1
            
            C=A.count(B[i])
            if C>=1:
                M+=1
                
        print(L,M-L)
        
except EOFError:
    pass


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << "\n";
		return 0;
	}
	if (k <= a + b) {
		cout << a << "\n";
		return 0;
	}
	cout << a - (k - a - b) << "\n";
	return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <bitset>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

void Output(string s,int n,char used_char){
  if(s.size()==n){
    cout<<s<<endl;
  }else{
    for(char c='a';c<=used_char;c++){
      string new_string=s+c;
      Output(new_string,n,used_char);
    }
    used_char++;
    string new_string=s+used_char;
    Output(new_string,n,used_char);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;

  Output("a",n,'a');


  return 0;
}




Measured memory_bytes: 1536
/*
AizuOnline A0019
Factorial
*/
#include <stdio.h>

unsigned long long int fact(unsigned long int n)
{
  if (n == 0)
    return(1);
  else
    return(n * fact(n-1));
}



main()
{
unsigned long int n;

  while(EOF !=scanf("%ld",&n))
    {
      printf("%llu\n",fact(n));
    }
return(0);
}

Measured memory_bytes: 0
count = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L, R = A[left: left + n1], A[mid: mid + n2]

    L.append(2000000000)
    R.append(2000000000)

    i, j = 0, 0
    for k in range(left, right):
        global count
        count += 1
        #print("k", k, "l", left, "m", mid, "r", right, "L", L, "R", R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    #print("l", left, "r", right)
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
input_list = list(map(int, input().split(' ')))

mergeSort(input_list, 0, n)

print(*input_list)
print(count)




Measured memory_bytes: 63696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

string alp{"zyxwvutsrqponmlkjihgfedcba"};

int main(int argc, char **argv)
{
	string str; cin >> str;
	if (str == alp) {
		std::cout << -1 << std::endl;
		return 0;
	}

	ll N = (ll)str.size();
	set<char> s;
	for (auto &e : str)
		s.insert(e);

	string res{""};
	if (s.size() == 26)
	{
		ll i{0};
		for (; i < N;)
		{
			ll j = i + 1;
			while (j < N && str[j-1] > str[j]) {++j;}
			if (j == N) break;
			i = j;
		}

		// std::cout << "i : " << i<< std::endl;
		// std::cout << "s[i-1] : " << str[i-1] << std::endl;
		// std::cout << "right : " << str.substr(i, N-i) << std::endl;
		string right = str.substr(i-1, N-i+1);
		sort(right.begin(), right.end());
		char t;
		for (auto &c : right)
		{
			if (str[i-1] < c)
			{
				t = c;
				break;
			}
		}
		res = str.substr(0, i-1) + t;
	}
	else
	{
		char t;
		for (ll i = 0; i < 26; ++i)
		{
			if (!s.count(char('a'+i)))
			{
				t = (char)('a' + i);
				break;
			}
		}

		res = str + t;
	}
	std::cout << res << std::endl;
}


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

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n,t;
	cin >> n >> t;
	ll arr[n];
	for(int i=0 ; i<n ; i++)
		cin >> arr[i];

	ll ans = 0;
	for(int i=0 ; i<n-1 ; i++)
	    ans += min((ll)t , arr[i+1]-arr[i]);
	    
	cout << ans+t;
	return 0;
}

Measured memory_bytes: 1792
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int a, b;
    cin >> a >> b;
    
    int sockets = 1;
    int count = 0;
    while(sockets < b)
    {
        sockets += a - 1;
        count++;
    }
    
    
    cout << count << endl;
    
    return 0;
}


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

#define sentinel INT_MAX

int count = 0;


void merge(int A[], int left, int right, int mid) {
	int n1 = mid - left;
	int n2 = right - mid;
	//make 2 arrays Left and Right
int L[n1],R[n2];
int i,j,k;
i=0;
j=0;
k=left;

	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}

	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}

	L[n1] = sentinel;
	R[n2] = sentinel;


	for (k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
            i++;
		}
		else {
			A[k] = R[j];
            j++;
		}
	}

}

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

int main() {
	int size;
    int i;
	scanf("%d", &size);

	int A[1000000];
	
	for (i = 0; i != size; i++) {
		scanf("%d", &A[i]);
	}

	merge_sort(A, 0, size);

	for (int i = 0; i < size - 1; i++) {
		printf("%d ", A[i]);
	}
	printf("%d\n%d\n", A[size - 1],count);
	return 0;
}




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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int n;
	int h[E5];
	double t,a;
	cin >> n;
	cin >> t >> a;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}

	double d = 1e18, id = -1;
	for (int i = 0; i < n; ++i) {
		double tmp = t - h[i] * 0.006;
		if (abs(tmp-a) < d) {
			d = abs(tmp-a);
			id = i;
		}
	}

	cout << id+1 << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

const int N_MAX = 10010;
const int INF = N_MAX;

int N, M; 
vector<int> A;

int mn[] = {-INF,2,5,5,4,5,6,3,7,6};
int dp[N_MAX];

int main(void){
  cin >> N >> M;
  A.resize(M);
  for(int i = 0; i < M; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());

  for(int i = 0; i < N_MAX; i++) dp[i] = -INF;

  dp[0] = 0;
  //for(int i = 1; i <= 9; i++){
  //  dp[mn[i]] = 1;
  //}

  for(int i = 1; i <= N; i++){
    for(int j = 0; j < M; j++){
      if(i-mn[A[j]] >= 0 && dp[i-mn[A[j]]] != -INF){
        dp[i] = max(dp[i], dp[i-mn[A[j]]] + 1);
      }
    }
  }

  string ans;
  int match = N;
  for(int d = 0; d < dp[N]; d++){
    for(int i = 0; i < (int)A.size(); i++){
      if(match - mn[A[i]] < 0) continue;
      if(dp[match-mn[A[i]]] == dp[match] - 1){
        // ans = ans*10LL + (ll)A[i];
        ans = ans + string(1, '0' + A[i]);
        match = match - mn[A[i]];
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,k[10001];
    cin>>a>>b;
    for(int i=0;i<b;i++)
    {
        cin>>k[i];
    }
    if(b==1)
    {
        cout<<k[0]-1<<endl;
        return 0;
    }
    else
    {
        int ans=0;
        for(int i=0;i<b;i++)
        {
            for(int j=0;j<b;j++)
            {
                ans+=k[j];
            }
            ans-=k[i];
            if(ans<k[i])
            {
                cout<<k[i]-ans-1<<endl;
                return 0;
            }
            else
            {
                ans=0;
            }
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define SIZE 2010
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, k;
int main() {
	io(); cin >> n >> k;
	vector<int> a(k);
	for (auto& i : a) cin >> i;
	sort(a.begin(), a.end());
	int maxd = *a.begin() + n - a.back();
	rep(i, 1, (k - 1)) maxd = max(a[i] - a[i - 1], maxd);
	cout << n - maxd;
}

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

int main()
{
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N), y(M);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	x.push_back(X);
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}
	y.push_back(Y);
	puts(*max_element(x.begin(), x.end()) + 1 <= *min_element(y.begin(), y.end()) ? "No War" : "War");
	return 0;
}


Measured memory_bytes: 256
package main

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

var (
	N             int
	a, b          [154321]int
	suma, sumb, K int
	answer        string = "Yes"
)

func main() {
	readVariables()
	K = sumb - suma
	needed := 0
	for i := 0; i < N; i++ {
		// if a[i] > b[i] {
		// needed += a[i] - b[i]
		// }
		if a[i] < b[i] {
			needed += (b[i] - a[i] + 1) / 2
		}
	}
	if K < needed {
		answer = "No"
	}
	fmt.Println(answer)
}

func readVariables() {
	N = nextInt()
	for i := 0; i < N; i++ {
		a[i] = nextInt()
		suma += a[i]
	}
	for i := 0; i < N; i++ {
		b[i] = nextInt()
		sumb += b[i]
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskC {
private:
	Debugger debugger;
	int n , m, q;
	vector<int> a, b, c, d;
	int ans = 0;
	void dfs(int pos, vector<int> curr){
		if(pos == n){
			//debugger.printVector(curr);
			int score = 0;
			for(int i = 0; i < q; i++){
				if(curr[b[i]] - curr[a[i]] == c[i]){
					score += d[i];
				}
			}
			ans = max(ans, score);
			return;
		}
		for(int nxt = (curr.empty()?1:curr.back()); nxt <= m; nxt++){
			curr.push_back(nxt);
			dfs(pos+1, curr);
			curr.pop_back();
		}
	}

public:
	void solveOne(int it){
		cin >> n >> m >> q;
		a.assign(q,0);
		b.assign(q,0);
		c.assign(q,0);
		d.assign(q,0);
		for(int i = 0; i < q; i++){
			cin >> a[i] >> b[i] >> c[i] >> d[i];
			a[i]--;
			b[i]--;
		}
		dfs(0,vector<int>());
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}


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

int n,i,j,len;
long long k,ans;
char s[100007];
int a[100007];

class Node {
public:
    Node(int v) {
        data = v;
        left = NULL;
        right = NULL;
    }
 
    int data;
    Node* left;
    Node* right;
};

long long nyan(long long x) {
	if (x == 0) {
		//printf("%lld\n",x);
		return 0;
	}
	long long yes = 1;
	while (x % 2 == 0) {
		yes *= 2;
		x /= 2;
	}
	//printf("%lld\n",yes);
	return yes;
}

int main() {
	Node* root = new Node(0);
	
	scanf("%d%lld",&n,&k);
	for (i=0 ; i<n ; i++) {
		scanf("%s",&s);
		len = strlen(s);
		
		Node* cur = root;
		for (j=0 ; j<len ; j++) {
			if (s[j] == '0') {
				if ((cur->left) == NULL) {
					//a[j]++;
					ans ^= nyan(k-j);
					Node* x = new Node(0);
					cur->left = x;
					cur = (cur->left);
				} else {
					cur = (cur->left);
				}
			} else {
				if ((cur->right) == NULL) {
					//a[j]++;
					ans ^= nyan(k-j);
					Node* x = new Node(0);
					cur->right = x;
					cur = (cur->right);
				} else {
					cur = (cur->right);
				}
			}
		}
	}
	
	if (ans > 0) { //for (i=0 ; i<=100000 ; i++) if (a[i] % 2 != 0) {
		printf("Alice\n");
		return 0;
	}
	printf("Bob\n");
}


Measured memory_bytes: 3456
/*


*/
#include<stdio.h>


/*
x这一堆的个数
y 0的个数
Σ i*(x/n)*(y/n)^(i-1)
p=y/n
res=Σ i*x*y^(i-1)/n^i=Σ i*x/y*p^i=x/y*p+2*x/y*p^2+...
res*(1-p)=x/y*p+x/y*p^2+x/y*p^3+...
=x/y*p/(1-p)
res=x/y*p/(1-p)/(1-p)
	=x/(n-y)*n/(n-y)

*/

int n;
double dp[305][305][305];
double dfs(int x, int y, int z) {
	//printf("%d%d%d\n", x, y, z);
	if (x + y + z == 0)return 0;
	if (dp[x][y][z] > 0)return dp[x][y][z];
	int k =  x + y + z;
	/*
	dp[x][y][z]=1+k/n*dp[x][y][z]+x/n*dp[x-1][y][z]+y/n*dp[x][y-1][z]+z/n*dp[x][y][z-1]
	(x+y+z)dp[x][y][z]=n+x*dp[x-1][y][z]+y*dp[x][y-1][z]+z*dp[x][y][z-1]
	 */
	dp[x][y][z] = 1.0*n ;
	if (x)dp[x][y][z] += dfs(x - 1, y, z)*x;
	if (y)dp[x][y][z] += dfs(x + 1, y - 1, z)*y;
	if (z)dp[x][y][z] += dfs(x, y + 1, z - 1)*z;
	dp[x][y][z] /= k;
	return dp[x][y][z];
}

int cnt[4] = { 0 };

int main() {
	int x;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &x);
		cnt[x]++;
	}
	printf("%.9f\n", dfs(cnt[1], cnt[2], cnt[3]));
}

Measured memory_bytes: 219392
#include<bits/stdc++.h>
#define MAXN 27
using namespace std;
char str[MAXN];
set <int>s;
int main()
{
    for(int i=1;i<=MAXN-1;i++)
    {
        s.insert(i);
    }
    scanf("%s",str+1);
    int n=strlen(str+1);
    for(int i=1;i<=n;i++)
    {
        s.erase(str[i]-'a'+1);
    }
    if(!s.empty())
    {
        printf("%s",str+1);printf("%c",(char)((*s.begin()-1)+'a'));
    }
    else
    {
        int flag=0;
        int i;
        for(i=n;i>=1;i--)
        {
            //当前有没用的
            if(!s.empty())
            {
                for(set<int>::iterator it=s.begin();it!=s.end();it++)
                {
                    if(*it>str[i]-'a'+1)
                    {
                        str[i]=(char)((*it-1)+'a');
                        for(int j=i+1;j<=n;j++)
                        {
                            str[j]='\0';
                        }
                        flag=1;
                        break;
                    }
                }
            }
            if(flag)
            {
                break;
            }
            else
            {
                s.insert(str[i]-'a'+1);
            }
        }
          if(i)
          {printf("%s",str+1);
          }
          else
          {
              printf("-1");
          }
    }
}


Measured memory_bytes: 256
import sys
X, N = map(int, input().split())
if N==0:
    P = {}
else:
    P = set(map(int, input().split()))

answer = sys.maxsize

for i in range(100):
    A = X-i
    B = X+i

    if A in P:
        pass
    else:
        print(A)
        exit()

    if B in P:
        pass
    else:
        print(B)
        exit()


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll A;
    string Bs;
    cin >> A >> Bs;

    int B = (Bs[0] - '0') * 100 + (Bs[2] - '0') * 10 + (Bs[3] - '0');

    ll ans = A * B / 100;

    cout << ans << endl;
}


Measured memory_bytes: 3600
class Main
  a = gets.split(" ").map!{|i|i.to_i}
  i = a.length()
  j = 0
  
  while i > 0
    while j < i-1
      if (a[j] > a[j+1])
        tmp = a[j]
        a[j] = a[j+1]
        a[j+1] = tmp
      end
      j += 1
    end
    i -= 1
    j = 0
  end
  
  puts "#{a[0]} #{a[1]} #{a[2]}"
end


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

int main(){
	int N;
	cin >> N;
	vector<tuple<string,int,int>> r;
	string s;
	int p;
	for(int i(1);i<=N;++i){
		cin >> s >> p;
		p = -p;
		r.push_back(tie(s,p,i));
	}
	sort(r.begin(),r.end());
	for(int i(0);i<N;++i){
		cout << get<2>(r[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[100001];
int main()
{
	int l,r,res=0,i;
	scanf("%s",s);
	l=0;r=strlen(s)-1;
	while(l<r)
    {
		if(s[l]==s[r]) {l++,r--;}
		else if(s[l]=='x') {res++,l++;}
		else if(s[r]=='x') {res++,r--;}
		else
		{
			puts("-1");
			return 0;
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, A, B; cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;
    return 0;
}


Measured memory_bytes: 256
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

h1, m1, h2, m2, k = map(int, input().split())

minute = ((h2 * 60) + m2) - ((h1 * 60) + m1)

print(minute - k)

Measured memory_bytes: 9452
#include<cstdio>
#include<stdlib.h>
#include <bits/stdc++.h>

using namespace std;

//#define MAX_N 100
#define MAX_N 200000

int N;


//int64_t mul(int64_t a,int64_t b);

int main(){
  cin>>N;
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=make_pair(b,a);
  }

  sort(p.begin(),p.end());
  /*
  cout<<N<<endl;
  for(int i=0;i<N;i++){
    cout<<p.at(i).second<<p.at(i).first<<endl;
  }
  */
  int64_t sum=0;
  bool b=true;
  for(int i=0;i<N;i++){
    sum=sum+p.at(i).second;
    if(sum>p.at(i).first){
      b=false;
      break;
    }
  }
  
  if(b==false){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int h,w,n;
	int i,j;
	int x,y,x1,y1,a,b;
	int c=0;
	
	scanf("%d %d %d",&w,&h,&n);
	scanf("%d %d",&x1,&y1);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&x,&y);
		if(x1==x){
			if(y1<y){
				c+=y-y1;
			}
			else{
				c+=y1-y;
			}
		}
		else if(y1==y){	
			if(x1<x){
				c+=x-x1;
			}
			else{
				c+=x1-x;
			}
		}
		else if(x1<x){
			if(y1<y){
				a=x-x1;
				b=y-y1;
				if(a<b){
					c+=b;
				}
				else{
					c+=a;
				}
			}
			else{
				a=x-x1;
				b=y1-y;
				c+=a+b;
			}
		}
		else if(x1>x){
			if(y1<y){
				a=x1-x;
				b=y-y1;
				c+=a+b;
			}
			else {
				a=x1-x;
				b=y1-y;
				if(a<b){
					c+=b;
				}
				else {
					c+=a;
				}
			}
		}
		x1=x;
		y1=y;
	}
	printf("%d\n",c);
	return 0;
}
	

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

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    for(int i;i < h;i++) cin >> s[i];
    for(int i=0;i < h;i++){
        for(int j=0;j < w;j++){
            if(s[i][j] == '#') continue;
            if(s[i][j] == '.'){
                int counter = 0;
                if(j - 1 >= 0) if(s[i][j-1] == '#') counter++;
                if(j + 1 < w) if(s[i][j+1] == '#') counter++;
                if(i - 1 >= 0){
                    if(s[i-1][j] == '#') counter++;
                    if(j - 1 >= 0) if(s[i-1][j-1] == '#') counter++;
                    if(j + 1 < w) if(s[i-1][j+1] == '#') counter++;
                }
                if(i + 1 < h){
                    if(s[i+1][j] == '#') counter++;
                    if(j - 1 >= 0) if(s[i+1][j-1] == '#') counter++;
                    if(j + 1 < w) if(s[i+1][j+1] == '#') counter++;
                }
                s[i][j] = '0' + counter;
            }
        }
    }
    for(int i;i < h;i++) cout << s[i] << endl;
    return 0;
}


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

using namespace std;
int ce(int a,int b)
{
    return a/b+(a%b==0 ? 0 : 1);
}
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (ce(c,b)<=ce(a,d))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3604
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    std::cout << n * 800 - n / 15 * 200 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int p[4] = {};
    for (int i = 0; i < n; i++) {
        p[string("NWSE").find(s[i])] = 1;
    }

    cout << (p[0] == p[2] && p[1] == p[3] ? "Yes" : "No") << endl;

    return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll x;
    cin >> x;
    ll sum = 0, i = 0;
    while(sum < x){
        i++;
        sum += i;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N+1):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1

if erase_apple == N:
  erase_apple = N-1

apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
#define min(q,w) ((q)>(w)?(w):(q))
#define max(q,w) ((q)<(w)?(w):(q))
using namespace std;
typedef long long LL;
const int N=200500,mo=1e9+7;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int a[N];
LL b[100];
LL jc[N],jcn[N];
int B[2*N][2],A[N],B0;
LL ksm(LL q,int w)
{
	LL ans=1;
	for(;w;w>>=1,q=q*q%mo)if(w&1)ans=ans*q%mo;
	return ans;
}
void link(int q,int w)
{
	B[++B0][0]=A[q],A[q]=B0,B[B0][1]=w;
	B[++B0][0]=A[w],A[w]=B0,B[B0][1]=q;
}
int main()
{
	int q,w;
	read(n);
	char ch=' ';
	for(;ch<'a'||ch>'z';ch=getchar());
	ans=1;
	fo(i,1,n)
	{
		q=ch-'a'+1,ch=getchar();
		++b[q];
	}
	fo(i,1,26)ans=ans*(b[i]+1LL)%mo;
	printf("%lld\n",(ans-1)%mo);
	return 0;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key)
{
    Node *node = (Node*)malloc(sizeof(Node));
    node->key = key;
    node->left = NIL;
    node->right = NIL;
    Node *y, *x;
    y = root;
    while(y != NIL){
        x = y;
        y = y->key > key ? y->left : y->right;
    }
    if(y == root) root = node;
    else{
        if(x->left == NIL && x->key > key) x->left = node;
        else x->right = node;
        node->parent = x;
    }
    return;
}

void preorder(Node *node)
{
    if(node != NIL){
        printf(" %d", node->key);
        preorder(node->left);
        preorder(node->right);
    }
}

void inorder(Node *node)
{
    if(node != NIL){
        inorder(node->left);
        printf(" %d", node->key);
        inorder(node->right);
    }
}

Node* find(int key)
{
    Node *node = root;
    while(node != NIL && node->key != key)
    {
        if(node->key > key) node = node->left;
        else node = node->right;
    }
    return node;
}

Node* getSuccesor(Node *node)
{
    Node* x = node->right;
    while(x->left != NIL){
        x = x->left;
    }
    return x;
}

void deleteNode(int key)
{
    Node *x, *y, *node = find(key);
    if(node == NIL) return;
    if(node->left == NIL || node->right == NIL){
        y = node;
    }
    else y = getSuccesor(node);

    if(y->left != NIL) x = y->left;
    else x = y->right;

    if(x != NIL) x->parent = y->parent;

    if(y == root) root = x;
    else if(y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;

    if(y!=node) node->key = y->key;
    free(y);
}

int main()
{
    root = NIL;
    int n, key;
    char com[10];
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%s", com);
        if(com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else{
            scanf("%d", &key);
            if(com[0] == 'i') insert(key);
            else if(com[0] == 'f'){
                if(find(key) == NIL) printf("no\n");
                else printf("yes\n");
            }
            else deleteNode(key);
        }
    }
}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> cost(N);
  vector<vector<int>> list(N, vector<int>(M));
  rep(i, N) {
    cin >> cost[i];
    rep(j, M) {
      cin >> list[i][j];
    }
  }
  int tc = 0;
  int mini = 99999999;
  int flag = 0;
  rep(bit, 1 << N) {
    tc = 0;
    vector<int> S;
    vector<int> ok(M);
    rep(i,N){
      if (bit & (1 << i)) {  // 列挙に i が含まれるか
        S.push_back(i);
      }
    }
    for (int i = 0; i < (int)S.size(); ++i) {
      tc += cost[S[i]];
      rep(q, M){
        ok[q] += list[S[i]][q];
      }
    }
    flag = 0;
    rep(i, M) {
      if (ok[i] < X) {
        flag = 1;
        //cout << "!!!" << i << "/" << bit << "/" << ok[i] << endl;
      }
    }
    if (flag == 0) {
      mini = min(mini, tc);
    }
  }
  if (mini == 99999999) {
    cout << -1;
  } else {
    cout << mini;
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);


*/


Measured memory_bytes: 3636