akhauriyash/Code-Regression huggingface dataset:
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
            
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }     
signed main()
{   jaldi
    int n;
    cin>>n;
    string str,ch;
    cin>>str>>ch;
    for(int i=0;i<n;i++)
    cout<<str[i]<<ch[i];
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<math.h>
using namespace std;

int main(void)
{
	int N , D;
	double X[10][10];

	cin >> N >> D;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < D; j++)
			cin >> X[i][j];

	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			double sum = 0.0;
			for (int k = 0; k < D; k++)
			{
				sum += pow( X[i][k] - X[j][k] , 2.0);
			}
			sum = sqrt(sum);
			if (sum == double((int)sum))
				cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#define int long long
using namespace std;
inline int read(){
	int x=0,w=0;char c=getchar();
	while(!isdigit(c))w|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w?-x:x;
}
int a,b,ans;
signed main(){
	a=ans=read();b=read();
	b=min(b,a-b);
	a=a-b;
	do{
		ans+=b*2*(a/b);
		int t=a;
		a=b;
		b=t%b;
	}while(b);
	printf("%lld",ans-a);
	return 0;
}

Measured memory_bytes: 3696
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
h = readints()
# h.append(-1)
dp = [10**9]*(2*n)
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], abs(h[i]-h[i+j])+dp[i])
print(dp[n-1])


Measured memory_bytes: 54696
package main

import (
	"fmt"
	"strings"
)

func main() {

	var s string
	fmt.Scan(&s)
	ss := strings.Split(s, "")

	ans := 0
	for _, v := range ss {

		if v == "1" {
			ans++
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int as[3], ans = 0;
	rep(3, i)
	{
		cin >> as[i];
		ans += as[i];
	}

	ans += max({as[0], as[1], as[2]}) * 9;

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
D = sorted(map(int,input().split()))[::-1]
M=int(input())
T = sorted(map(int,input().split()))

for t in T:
  while D:
    d = D.pop()
    if t==d : break
  else:
    print("NO")
    break
else:
  print("YES")

Measured memory_bytes: 33788
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;

main(){
  int n,m;
  while(cin>>n>>m && n){
    int in[m];
    for(int i=0;i<m;i++)cin>>in[i];
    sort(in,in+m);
    if (in[0] == 1)cout << setiosflags(ios::fixed) << setprecision(10) << 0. << endl;
    else cout << setiosflags(ios::fixed) << setprecision(10) << n/2. << endl;
  }
  return false;
}

Measured memory_bytes: 0
/*
    Author:zeke
    
    pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
int main(){
    int n,k;
    cin>>n>>k;
    V vec(n);
    V dp(k+1);
    rep(i,n)cin>>vec[i];
    rep3(i,1,k+1){
        bool h=false;
        rep(j,n){
            int k=i-vec[j];
            if(k>=0&&dp[k]==0)h=true;
        }
        if(h)dp[i]=1;
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

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

    sort(a.begin(), a.end(), greater<int>());
    int sum = accumulate(a.begin(), a.end(), 0);

    // cout << sum << endl;

    // for(auto v: a)
    //   cout << v << endl;

    // cout << (double)sum / (4 * M) << endl;

    if(a[M - 1] < (double)sum / (4 * M))
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    vector<pii> ans;
    int n = N-N%2;
    rep2(i, 1, n){
        rep2(j, 1, i-1){
            if(i+j != n+1) ans.pb(pii(j, i));
        }
    }
    if(N == n+1){
        rep2(i, 1, n) ans.pb(pii(i, N));
    }
    cout << sz(ans) << endl;
    for(auto &e: ans){
        cout << e.first << ' ' << e.second << endl;
    }
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var n = input[0];
            var m = input[1];
            var first = new bool[n+1];
            var second = new bool[n+1];
            for (int i = 0; i < m; i++)
            {
                input = Reads();
                if (input[0] == 1) first[input[1]] = true;
                if (input[1] == n) second[input[0]] = true;
            }
            bool f = false;
            for (int i = 1; i <= n; i++)
            {
                if (first[i] && second[i]) f = true;
            }


            if (f)
                Console.WriteLine("POSSIBLE");
            else
                Console.WriteLine("IMPOSSIBLE");





            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll add_l = 0, add_r = 0;
    ll sum = 0;
    rep1(i, n){
        if (s[i]==')') sum++;
        else sum--;
        add_l = max(add_l, sum);
    }
    sum = 0;
    rep1(i, n){
        if (s[n-1-i]=='(') sum++;
        else sum--;
        add_r = max(add_r, sum);
    }
    rep1(i, add_l) cout << '(';
    cout << s;
    rep1(i, add_r) cout << ')';
    cout << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3580
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

int findAngle(int hour, int min, int sec)
{
  int h = (hour * 360) / 12 + (min * 360) / (12 * 60) + (sec * 1 ) / 120;

  int m = (min * 360) / (60) + (sec * 6 ) /10;

  int angle = abs(h - m);

  if (angle > 180)
    angle = 360 - angle;

  return angle;
}
 
int main()
{
  _FI 
  int n;
  cin>>n;

  if(n%1000==0)
    cout<<0<<endl;
  else
    {
      int x= n/1000;
      x=x+1;
      x=x*1000;
      cout<<x-n;
    }

  
  return 0;
}















Measured memory_bytes: 3196
// #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
 #pragma GCC target("avx", "avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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


signed main() {
    accell();
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    double ans = 0;
    double cur = 0;
    for (int i = 0; i < k; ++i) {
        cur += (a[i] * (a[i] + 1) / 2) * 1.0 / (a[i] * 1.0);
    }
    ans = cur;
    for (int i = k; i < n; ++i) {
        cur -= (double)(a[i - k] * (a[i - k] + 1) / 2) / (a[i - k] * 1.0);
        cur += (double)(a[i] * (a[i] + 1) / 2) / (a[i] * 1.0);
        ans = max(ans, cur);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n,m;
	cin >> n >> m;
	vector<ll> x(n),y(n),z(n),a(n);
	rep(i,0,n)cin >> x[i] >> y[i] >>z[i];
	ll ans = 0;
	rep(i,0,8){//枚举8种状态(+-)x(+-)y(+-)z 
		int sta = i;//当前状态 
		rep(j,0,n)a[j] = (2*(sta&1)-1)*x[j] + (2*((sta>>1)&1)-1)*y[j] + (2*((sta>>2)&1)-1)*z[j];
		sort(all(a));
		ll sum = 0;
		rep(i,0,m)sum += a[n-1-i]; 
		ans = max(ans,sum);
	}
	cout << ans; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int n;
	cin >> n;
	itn a[n];
	multiset<int> st;	
	rep(i, n) {
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		auto it = st.lower_bound(a[i]);
		if(it == st.begin()) st.insert(a[i]);
		else{
			it--;
			st.erase(it);
			st.insert(a[i]);
		}
	}
	cout << sz(st);

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

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
int main(){
    int N;
    cin>>N;
    int A[N];
    rep(i,N)scanf("%d",&A[i]);
    map<int,int>cnts;
    rep(i,N)cnts[A[i]]++;
    int a=0;
    for(auto e:cnts)if(e.second&1)a++;
    cout<<a<<endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    set<char> abc;
    REP(i, S.size()) abc.insert(S[i]);
    if (abc.size() == 3) cout << YES << '\n';
    else cout << NO << '\n';
    return 0;
}


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

namespace ARC077C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var A = ss.Next(int.Parse, N);

            var ll = new LinkedList<int>();
            for (var i = 0; i < N; i++)
            {
                if (i % 2 == 0) ll.AddLast(A[i]);
                else ll.AddFirst(A[i]);
            }

            sw.WriteLine(string.Join(" ", N % 2 == 0 ? ll : ll.Reverse()));
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 52144
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
  int H, W;
  cin >> H >> W;
  int a[H][W];
  rep(i, H){
    rep(j, W){
      cin >> a[i][j];
    }
  }
  int N = 0;
  vector <vector<int>>ans;
  rep(i, H){
    rep(j, W-1){
      if (a[i][j] % 2 == 1){
        a[i][j+1] ++;
        ans.push_back({i+1, j+1, i+1, j+2});
        N++;
      }
    }
  }
  rep(i, H-1){
    if (a[i][W-1] % 2 == 1){
      a[i+1][W-1] ++;
      ans.push_back({i+1, W, i+2, W});
      N ++;
    }
  }
  cout << N <<endl;
  rep(i, N){
    cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << ' ' << ans[i][3] << endl;
  }
}
   

Measured memory_bytes: 9904
//13, 04, 2019, 09:31:38 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 1010;
int a[N];

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

    int n;

    cin >> n;

    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    
    int mx = 0;
    int see = 0;

    for(int i = 0 ; i < n ; i++){
        if(a[i] >= mx){
            see++;
            mx = a[i];
        }
    }

    cout << see << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
  long long int H, W;

  cin >> H >> W;

  if (H == 1 || W == 1)
  {
    cout << "1" << endl;
  }
  else if (H * W % 2 == 0)
  {
    cout << H * W / 2 << endl;
  }
  else
  {
    cout << H * W / 2 + 1 << endl;
  }
}


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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

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

int main()
{
int n;
cin>>n;
REP(i,n){
    cout<<"ACL";
}
cout<<endl;
}

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

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		int prizes[n];
		for(int i = 0; i < n; i++){
			cin >> prizes[i];
		}
		bool isNA = false;
		for(int i = 0; i < n; i++){
			if(prizes[i] >= 2){
				break;
			}
			if(i == n - 1){
				isNA = true;
			}
		}
		if(isNA){
			cout << "NA" << endl;
		}else{
			int count = 0;
			for(int i = 0; i < n; i++){
				if(prizes[i] != 0){
					count++;
				}
			}
			cout << count + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll a[200005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n;
	ll f=0;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]==0)
			f=1;
	}

	if(f==1)
	{
		cout<<0<<endl;
		return 0;
	}
	x=1e18,y=1;
	for(i=1;i<=n;i++)
	{
		if(x/a[i]>=y)
			y*=a[i];
		else
		{
			f=1;
			break;
		}
	}

	if(!f)
		cout<<y<<endl;
	else
		cout<<-1<<endl;

}

Measured memory_bytes: 4436
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <string>
#include <fstream>
#include <algorithm>

using namespace std;

const int NMAX=500+2;
int n,a[NMAX],k,best=1;
vector<int> elements;

bool tester(int x){
	
	//cout << x << ' ';
	elements.clear();
	
	for(int i=0;i<n;i++){
		elements.push_back(a[i]%x);
	}
	
	sort(elements.begin(),elements.end());
	
	int debut=0,fin=elements.size()-1,iterations=0;
	
	while(fin>debut){
		
		if(elements[debut]==0) debut++;
		else if(elements[fin]==0) fin--;
		else{
			int meilleur=min(elements[debut],x-elements[fin]);
			
			iterations+=meilleur;
			elements[debut]-=meilleur;
			elements[fin]=(elements[fin]+meilleur)%x;
		}
	}
	//cout << elements[debut] << ' ' << elements[fin] << ' ' << iterations << '\n';
	return (elements[fin]==0 && elements[debut]==0 && iterations<=k);
}

int main(){
	ios::sync_with_stdio(false);
	
	cin >> n >> k;
	
	int somme=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		somme+=a[i];
	}
	
	
	for(int d=1;d*d<=somme;d++){
		
		if(somme%d==0){
			
			if(tester(d)) best=max(best,d);
			if(tester(somme/d)) best=max(best,somme/d);
		}
	}
	cout << best << '\n';
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

LL n, k;

int main() {
	scanf ("%lld %lld", &n, &k);
	LL a;
	if (n < k) a = n;
	else {
		LL r = n / k - 1;
		a = n - r * k;
		a = abs(a - k);
	}
	LL res = min(a, abs(k - a));
	printf ("%lld\n", res);
	
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations


def dist(x1, y1, x2, y2):
    x = x1 - x2
    y = y1 - y2
    return (x**2+y**2)**0.5


n = int(input())
town = []
for _ in range(n):
    x, y = map(int, input().split())
    town.append((x, y))

ans = 0
cnt = 0
for order in permutations(range(n)):
    cnt += 1
    d = 0
    for s, t in zip(order[:-1], order[1:]):
        x1, y1 = town[s]
        x2, y2 = town[t]
        d += dist(x1, y1, x2, y2)
    ans += d
print(ans/cnt)


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    
    long long int kotae = 0;
    for(int i=0;i<n;i++){
        //aを求める
        auto p1 = lower_bound(a,a+n,b[i]);
        long long int dis1 = distance(a,p1);
        //bを求める
        auto p2 = upper_bound(c,c+n,b[i]);
        int index = distance(c,p2);
        long long int dis2 = n-index;
        
        kotae += dis1*dis2;
    }
    cout << kotae << endl;
}

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

int main(){
    int t;
    while(cin >> t, t){
        int n, sum = 0;
        cin >> n;
        for(int i=0; i<n; ++i){
            int s, f;
            cin >> s >> f;
            sum += (f - s);
        }
        if(t<=sum) cout << "OK" << endl;
        else cout << t-sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int X,N;
  cin >> X >> N;
  vector<int>p(101);
  for(int i=0;i<N;i++){
    int a;cin>>a;
    p[a]++;
  }
  int i=0;
  while(1){

    if(p[X-i]==0){
      cout<<X-i <<endl;
      break;
    }
    if(p[X+i]==0){
      cout<<X+i <<endl;
      break;
    }
    i++;
  }

}


Measured memory_bytes: 3732
#include <iostream>

using namespace std;

int vis[55];
int p[55][55];

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

    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>> a >> b;
        vis[a]++;
        vis[b]++;
        p[a][b]++;
        p[b][a]++;
    }
    int sum=0;
    int f=1;
    while(f)
    {
        f=0;
        int xi=-1;
        for(int i=1; i<=n; i++)
        {
            if(vis[i] == 1)
            {
                f=1;
                sum++;
                xi=i;
                vis[i]--;
                break;
            }
        }
        if(!f)break;

        for(int i=1; i<=n; i++)
        {
            if(p[xi][i])
            {
                vis[i]--;
                //p[xi][i]--;
            }
        }
    }
    cout << sum <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        long long int n;
        cin>>n;
        unsigned long long int s=1,c=0;
        c=pow(10,18);
       
        long long int arr[n];
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+n);
        int flag=1;
       if(arr[0]==0)
       cout<<0<<endl;
       else
       {
        for(int i=0;i<n-1;i++)
        {
            s=s*arr[i];
            if((c/s)<arr[i+1])
            {
                flag=0;
                break;
            }
            
        }
        s=s*arr[n-1];
        if(flag==0)
        cout<<-1<<endl;
        if(flag==1)
          cout<<s<<endl;
       }
        return 0;
    }

Measured memory_bytes: 4444
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
 
int main()
{
	priority_queue<ll> Q;
	string s;
	ll a;
	while(cin >> s && s!="end")
	{
		if(s=="insert")
		{
			cin >> a;
			Q.push(a);
		}
		else
		{
			cout << Q.top() <<endl;
			Q.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 11132
n = int(input())
s = input()

e = [0]
w = [0]
for let in s:
    if let == "E":
        e.append(e[-1] + 1)
        w.append(w[-1])
    else:
        e.append(e[-1])
        w.append(w[-1] + 1)

ans = len(s)
for i in range(1, len(s) + 1):
    l = w[i - 1]
    r = e[n] - e[i]
    ans = min(ans, l + r)

print(ans)


Measured memory_bytes: 17644
#include<stdio.h>
#include<stdlib.h>
int main(){
int stack[200],k=0;
char s[20];
stack[0]=0;
while(scanf("%s",s)!=EOF){
if(s[0]=='+'){
k--;
stack[k]=stack[k]+stack[k+1];
}
else if(s[0]=='-'){
k--;
stack[k]=stack[k]-stack[k+1];
}
else if(s[0]=='*'){
k--;
stack[k]=stack[k]*stack[k+1];
}
else{
k++;
stack[k]=atoi(s);
}
}
printf("%d\n",stack[1]);
return 0;
}


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

const int MAXN = 2e5+6.66;
int arr[MAXN];

int main() {
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", arr + i);
  bool ok = (arr[0] == 0);
  for(int i = 1; i < N; i++) ok &= (arr[i] - 1 <= arr[i - 1]);
  if(!ok) {
    printf("-1\n");
    return 0;
  }
  long long mvs = arr[N - 1];
  for(int i = N - 2; i > -1; i--) 
    if(arr[i] != arr[i + 1] - 1) mvs += arr[i];
  printf("%lld\n", mvs);
  return 0;
}


Measured memory_bytes: 1024
/*
Author : N_o_o_B
Created : April 22 2020 22:15:59 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    rep(i,1,n){
        int tmp = i;
        int sum = 0;
        while(tmp){
            sum += tmp%10;
            tmp /= 10;
        }
        if(sum >= a and sum <=b) ans += i;
    }
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

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

    vector<ll> b(s.size()+1);
    ll sum = 0;

    rep(i,b.size()){
        b[i] = 0;
    }
    rep(i,s.size()){
        if(s[i] == '<'){
            b[i+1] = b[i]+1;
        }
    }
    for(int i = s.size()-1; i >= 0; i--){
        if(s[i] == '>'){
            b[i] = max(b[i], b[i+1]+1);
        }
    }
    rep(i,b.size()) sum += b[i];

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

Measured memory_bytes: 4740
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = 0
    for i in range(n):
        if i%2 == 0:
            c += a[i]
        else:
            c -= a[i]
    x = c//2
    xs = []
    xs.append(x)
    for i in range(2, n+1):
        z = a[i-2] - xs[i-2]
        xs.append(z)
    for i in range(n):
        xs[i] = 2*xs[i]
    for i in range(n):
        if i == n-1:
            print(xs[i])
        else:
            print(xs[i], end=' ')
main()


Measured memory_bytes: 14400
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = ['' for i in range(n)]
maxd = len(bin(10 ** 12 + 1))-2
bink = bin(k)[2:]
digitk = len(bink)
bink1 = bin(k+1)[2:]
digitk1 = len(bink1)
bink = bink.zfill(maxd)[::-1]
bink1 = bink1.zfill(maxd)[::-1]
for i in range(n):
    b[i] = format(a[i], 'b').zfill(maxd)[::-1]
#print(b)

s = [0 for i in range(maxd)]
c = [0 for i in range(maxd)]
for i in range(maxd):
    c[i] = sum(list(map(lambda x: int(x[i]), b)))
for i in range(digitk1):
    if bink1[i] == '1':
        for j in range(i):
            if c[j] <= n/2:
                s[i] += (n-c[j]) * 2 ** j
            else:
                s[i] += c[j] * 2 ** j

        s[i] += c[i] * 2 ** i

        for j in range(i+1, digitk1):
            if bink1[j] == '1':
                s[i] += (n-c[j]) * 2 ** j
            else:
                s[i] += c[j] * 2 ** j

    for j in range(digitk1, maxd):
        s[i] += c[j] * 2 ** j
print(max(s))

Measured memory_bytes: 18684
s = str(input())
flag = 0
for i in range(len(s)):
    if s[i] == "C":
        flag += 1
        break
for j in range(i,len(s),1):
    if s[j] == "F":
        flag += 1
        break
if flag==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;

int main(){
    int32_t N, T;
    std::cin >> N >> T;

    vector<pair<int, int>> dishes(N);
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(N, vector<int>(T+1, 0)));
    for (auto& dish : dishes) {
        int a, b;
        cin >> a >> b;
        dish = make_pair(a,b);
    }
    
    for (int c = 0; c <= T; c++) {
        if (dishes[0].first <= c)
            dp[0][0][c] = dishes[0].second;
        if (c != 0)
            dp[1][0][c] = dishes[0].second;
    }
    
    for (int i = 1; i < N; i++) {
        for (int c = 0; c <= T; c++) {
            if (c - dishes[i].first >= 0) {
                dp[0][i][c] = max(dp[0][i-1][c], dp[0][i-1][c - dishes[i].first] + dishes[i].second);
                dp[1][i][c] = max(dp[1][i-1][c], dp[1][i-1][c - dishes[i].first] + dishes[i].second);
            } else {
                dp[0][i][c] = dp[0][i-1][c];
                dp[1][i][c] = dp[1][i-1][c];
            }
            if (c != 0) {
                dp[1][i][c] = max(dp[1][i][c], dp[0][i-1][c -1] + dishes[i].second);
            }
        }
    }
    int res = max(dp[0][N-1][T], dp[1][N-1][T]);
    cout << res << endl;        
                   
    return 0;
}

Measured memory_bytes: 106112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int a, b, c, d;
  cin >>a >> b>> c >>d;
  int l = a+b, r = c+d;
  if(l<r) cout <<"Right\n";
  if(l==r) cout <<"Balanced\n";
  if(l>r) cout <<"Left\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

ll k, n;
vector<ll> h;
void solve()
{
    cin >> k >> n;
    h.resize(n);
    for(auto &i: h)
        cin >> i;

    for(auto &i: h)
        i = i % k;
    sort(h.begin(), h.end());
    ll ans = k - h[n-1] + h[0];
    for(int i = 1; i < n; i++)
        ans = max(ans, h[i] - h[i-1]);
    cout << k-ans;
}


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

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

using namespace std;

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

    int S = a[0];
    for(int i = 1; i < N; i++) {
        S ^= a[i];
    }

    for(int j = 0; j < N; j++) {
        int tmp = S^a[j];
        if(j == N-1) {
            cout << tmp << endl;
        } else {
            cout << tmp << " ";
        }
    }
    

    return 0;
}

Measured memory_bytes: 3948
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int fact[100010];

signed main() {
    fact[0] = 1;
    rep(i,1,100010) (fact[i] = fact[i-1] * i) %= MOD;
    int N, M; cin >> N >> M;
    if(N < M) swap(N, M);
    if(N - M <= 1) {
        int ans = 1;
        (ans *= fact[N]) %= MOD;
        (ans *= fact[M]) %= MOD;
        if(N == M) (ans *= 2) %= MOD;
        cout << ans << endl;
    }
    else cout << 0 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll A,B; cin>>A>>B;

    ll m = max(A,B);

    for (int i=0;i<=m;i++) {
        if (abs(A-i) == abs(B-i)) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    
    return 0;
}

Measured memory_bytes: 256
data = raw_input()

q = data.split(" ")

x = int(q[0])
y = int(q[1])

if x == 1:
  x = 14
if y == 1:
  y = 14

if x == y:
  print "Draw"
  exit(0)

if x > y:
  print "Alice"
  exit(0)
print "Bob"


Measured memory_bytes: 2568
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n;
	cin >> n;

	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}

	sort(d.begin(), d.end(), greater<int>());

	int ans = 0;
	for(int i = 0; i < n; i++){
		bool f = false;
		for(int j = i; j < n; j++){
			if(d[i] != d[j]){
				i = j - 1;
				f = true;
				break;
			}
		}
		ans++;
		if(!f) break;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#define int long long
using namespace std;
struct node 
{
	int a,b;
}v[100010];
int n,m;
int ans;
bool cmp(const node &e,const node &w)
{
	return e.a<w.a; 
}
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>v[i].a>>v[i].b;
	sort(v+1,v+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=v[i].b;j++)
		{
			m--;
			ans+=v[i].a;
			if(m==0)
			{
				cout<<ans;
				return 0;
			}
		}
	}
}

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

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

        int D=*max_element(a.begin(), a.end());
        vector<int> cnt(N);
        for(int i=0;i<N;i++) cnt[a[i]]++;

        //for(int i=0;i<N;i++) cout<<cnt[i]<<' '; cout<<endl;
        int mn=N;
        for(int i=0;i<=D;i++){
                int d=max(i, D-i);
                mn=min(mn, d);
                if(cnt[d]==0){
                        cout<<"Impossible"<<endl;
                        return 0;
                }
                cnt[d]--;
        }
        //for(int i=0;i<N;i++) cout<<cnt[i]<<' '; cout<<endl;

        for(int i=1;i<=mn;i++) if(cnt[i]>0){
                cout<<"Impossible"<<endl;
                return 0;
        }
        cout<<"Possible"<<endl;
        return 0;
}


Measured memory_bytes: 256