akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 8/5/2020

 21:03-

 */

const int MAX_N=2e3+1;
LL A[MAX_N],Z,W;
int N;

LL memo[MAX_N][2];
//const LL Inf=1e18;
LL f(int p, int t) {
  LL &res=memo[p][t];
  if(res>=0) return res;
  if(t==0) {
    LL op=p==0?W:A[p-1];
    res=abs(A[N-1]-op);
    FOR(i,p+1,N) {
      SMAX(res,f(i,1));
    }
  } else {
    LL op=p==0?Z:A[p-1];
    res=abs(A[N-1]-op);
    /*
    if(p==2&&t==1) {
      dump(op,A[N-1],res);
    }*/
    FOR(i,p+1,N) {
      SMIN(res,f(i,0));
    }
  }
  return res;
}

void solve() {
  MINUS(memo);
  cout<<f(0,0)<<endl;
}

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

  cin>>N>>Z>>W;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 3676
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        String[] a=new String[n];
        String[] b=new String[m];
        boolean tmp;
        for(int i=0;i<n;i++){
            a[i]=sc.next();
        }
        for(int i=0;i<m;i++){
            b[i]=sc.next();
        }
        for(int i=0;i<n-m+1;i++){
            for(int j=0;j<n-m+1;j++){
                tmp=true;
                for(int k=0;k<m;k++){
                    tmp=tmp&&a[j+k].substring(i,i+m).equals(b[k]);
                }
                if(tmp){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<string>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
const double PI	 = 3.141592;
const int	 MOD = 1e9 + 7;
using namespace std;

void solve() {
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 1009; ++i) {
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

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

Measured memory_bytes: 3576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <complex>

using namespace std;

#define mod 1000000007

vector<vector<int> > graph(100001);
vector<int> pre(100001, -1);
vector<int> low(100001, -1);

int dfs(int now, int before, int cnt)
{
	pre[now] = cnt;
	low[now] = cnt;
	for(int i = 0; i < graph[now].size(); i++){
		int next = graph[now][i];
		if(next == before) continue;
		if(pre[next] == -1){
			cnt = dfs(next, now, cnt + 1);
		}
		low[now] = min(low[now], low[next]);
	}
	// cout << now << " " << pre[now] << " " << low[now] << endl;
	return cnt;
}

int main()
{
	int v, e;
	cin >> v >> e;
	for(int i = 0; i < e; i++){
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(0, -1, 0);
	vector<pair<int, int> > ans;
	for(int i = 0; i < v; i++){
		for(int j = 0; j < graph[i].size(); j++){
			int next = graph[i][j];
			if(pre[i] < pre[next] && pre[next] == low[next]) ans.push_back(make_pair(min(i, next), max(i, next)));
		}
	}
	sort(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}



Measured memory_bytes: 7376
n = gets.to_i
now = [0,0]
ans = "Yes"
i = 0
n.times do
  if ans == "Yes"
    t,x,y = gets.split().map(&:to_i)
    t -= i
    t.times do
      if now[0] < x
        now[0] += 1
      elsif now[1] < y
        now[1] += 1
      elsif now[0] == x && now [1] == y
        now[0] += 1
      elsif now[0] > x
        now[0] -= 1
      elsif now[1] > y
        now[1] -= 1
      end
      i += 1
    end
    if not now[0] == x && now [1] == y
      ans = "No"
    end
  end
end
puts ans

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

using namespace std;

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

  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    int N;
    cin >> N;
    for(int i = 1; i <= 9; ++i) {
        if(N > 111 * i)
            continue;
        cout << 111 * i << endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

string text,in,dum;
int cur,len;

int main()
{
	int CS, n;
	cin >> CS; getline(cin, dum);
	for (int cs = 0; cs < CS; cs++) {
		getline(cin,text);
		cin >> n; getline(cin, dum);
		len = text.size();
		cur = 0;
		for (int i = 0; i < n; i++) {
			getline(cin, in);
			if (in == "forward char")
				cur = min(cur+1,len);
			else if (in == "backward char")
				cur = max(cur-1,0);
			else if (in == "delete char") {
				if (cur >= text.size()) continue;
				text.erase(text.begin()+cur); len--;
			} else if (in.find("insert") != in.npos) {
				int s = in.find('"'), t = in.find('"',s+1);
				text = text.substr(0,cur) + in.substr(s+1,t-s-1) + text.substr(cur);
				cur += t-s-1; len += t-s-1;
			} else if (in == "forward word") {
				while (cur < len && text[cur] == ' ') cur++;
				while (cur < len && text[cur] != ' ') cur++;
			} else if (in == "backward word") {
				while (cur > 0 && text[cur-1] == ' ') cur--;
				while (cur > 0 && text[cur-1] != ' ') cur--;
			}
			else if (in == "delete word") {
				int s = cur, t;
				while (text[s] == ' ') s++;
				if (s >= len) continue;
				for(t = s; text[t] != ' ' && t < len; t++);
				text = text.substr(0,cur) + text.substr(t);
				len -= t-cur;
			}
		}
		cout << text.substr(0,cur) << "^" << text.substr(cur) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
char s[120];
int main(){
    int n;
    cin>>s;
    cin>>n;
    for (int i=0;i<strlen(s);i++){
        char ch=s[i];
        if (ch=='1'){
            n--;
            if (n==0){
                cout<<1;
                return 0;
            }
        }
    else
        {
            cout<<ch;
            break;
        }
        ch=getchar();
    }
}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        map<char, char> conv;
        int m;
        char t, f;

        for (int i = 0; i < n; i++) {
            cin >> f >> t;
            conv[f] = t;
        }
        
        cin >> m;
        for (int i = 0; i < m; i++) {
            char ch;

            cin>> ch;
            if (conv.count(ch) != 0)
                cout << conv[ch];
            else
                cout << ch;
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const int m = 2019;

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

   int xa = min(a,k);
   k -= xa;
   int xb = min(b, k);
   k -= xb;
   int xc = min(c, k);
   cout << xa - xc;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
int main()
{
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

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

	if (a == b) {
		if (a == c) {
			cout << "No" << "\n";
		}
		else {
			cout << "Yes" << "\n";
		}
	}
	else {
		if (a == c || b == c) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d%d", $n, $d, $a);

$monsters = [];
$x_list = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d%d", $x, $h);
    $monsters[] = [
        'x' => $x,
        'h' => $h,
        'attack_num_to_defeat' => (int)ceil($h / $a),
        'min_monster_index' => null,
    ];
    $x_list[] = $x;
}

array_multisort($monsters, $x_list, SORT_ASC, SORT_NUMERIC);

$i = 0;
$j = 0;
while ($i < $n && $j < $n) {
    if ($monsters[$j]['x'] - $monsters[$i]['x'] <= 2 * $d) {
        $monsters[$j]['min_monster_index'] = $i;
        ++$j;
    } else {
        ++$i;
    }
}

$accumulated_attack_num = [0];
for ($i = 0; $i < $n; ++$i) {
    $has_attacked_num = $accumulated_attack_num[$i] - $accumulated_attack_num[$monsters[$i]['min_monster_index']];

    $attack_num = $monsters[$i]['attack_num_to_defeat'] - $has_attacked_num;
    $accumulated_attack_num[$i + 1] = $attack_num > 0 ? $accumulated_attack_num[$i] + $attack_num : $accumulated_attack_num[$i];
}

echo $accumulated_attack_num[$n];


Measured memory_bytes: 129692
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <tr1/unordered_map>
#include <cmath>
#include <map>
#include <bitset>
#include <set>
#include <iomanip>
#include <utility>    
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector< ii > vii;
///////////////////////////////UTIL/////////////////////////////////
#define ALL(x) (x).begin(),x.end()
#define CLEAR0(v) memset(v, 0, sizeof(v))
#define CLEAR(v, x) memset(v, x, sizeof(v))
#define COPY(a, b) memcpy(a, b, sizeof(a))
#define CMP(a, b) memcmp(a, b, sizeof(a))
#define REP(i,n) for(int i = 0; i<n; i++)
#define REPP(i,a,n) for(int i = a; i<n; i++)
#define REPD(i,n) for(int i = n-1; i>-1; i--)
#define REPDP(i,a,n) for(int i = n-1; i>=a; i--)
#define pb push_back
#define pf push_front
#define sz size()
#define mp make_pair
/////////////////////////////NUMERICAL//////////////////////////////
#define INF 0x3f3f3f3f
#define EPS 1e-9
/////////////////////////////BITWISE////////////////////////////////
#define CHECK(S, j) (S & (1 << j))
#define CHECKFIRST(S) (S & (-S)) 
#define SET(S, j) S |= (1 << j)
#define SETALL(S, j) S = (1 << j)-1  
#define UNSET(S, j) S &= ~(1 << j)
#define TOOGLE(S, j) S ^= (1 << j)
///////////////////////////////64 BITS//////////////////////////////
#define LCHECK(S, j) (S & (1ULL << j))
#define LSET(S, j) S |= (1ULL << j)
#define LSETALL(S, j) S = (1ULL << j)-1ULL 
#define LUNSET(S, j) S &= ~(1ULL << j)
#define LTOOGLE(S, j) S ^= (1ULL << j)
//__builtin_popcount(m)
//scanf(" %d ", &t);
//L[i]=L[i/2]+1;

#define PI 3.14159265359

int n;
int a[1000];

int main(){
	while(cin >> n){
		n *= 2;
		REP(i, n) cin >> a[i];
		sort(a, a+n);
		int ans = 0;
		for(int i = n-2; i>=0; i -= 2) ans += a[i];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int s = a * b;
    if (s % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, s, e) for(int i=s; i<e; i++)
#define print(i) cout << i << endl;

int cnt = 0;
int n;
int k;

int main(){

    cin >> n;

    int vmax = pow(4, 9);
    bool flag = false;
    ll cnt = 0;
    for(int i=1; i<vmax; i++){
        flag = false;
        int k = i;
        vector<int> v;
        while(k > 0){
            switch(k % 4){
                case 0:
                    v.push_back(0);
                    break;
                case 1:
                    v.push_back(3);
                    break;
                case 2:
                    v.push_back(5);
                    break;
                case 3:
                    v.push_back(7);
                    break;
            }
            k /= 4;
        }
        int m = 0;
        reverse(v.begin(), v.end());
        set<int> st;
        for(auto x: v){
            if(x == 0){
                flag = true;
                break;
            }
            m *= 10;
            m += x;
            st.insert(x);
        }
        if(flag) continue;

        
        if(m <= n && st.size() == 3){
            // cout << m << " " << n << endl;
            cnt++;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
  print(0)
else:
  d=sorted([x[i+1]-x[i] for i in range(len(x)-1)])[::-1]
  l=0
  for i in range(n-1):
    l+=d[i]
  print(x[m-1]-x[0]-l)

Measured memory_bytes: 13960
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 100000+9;
const int MOD = 1000000007;
const LL INF = 4e18;

LL A,B,LIM[2],s[N];
int n,f[2][N],sum[2][N],lst[2][N],pre[2][N];

inline LL read() {
	char c=getchar(); LL f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	//freopen("11input.in","r",stdin);
	n = read(); A = LIM[0] = read(); B = LIM[1] = read();
	for (int i=1,l1=1,l2=1,p1=0,p2=0;i<=n;i++) {
		s[i] = read();
		while (l1 < i && s[i] - s[l1+1] >= A) l1++; lst[0][i] = l1;
		while (l2 < i && s[i] - s[l2+1] >= B) l2++; lst[1][i] = l2;
		if (i > 1 && s[i] - s[i-1] < A) p1 = i - 1; pre[0][i] = p1;
		if (i > 1 && s[i] - s[i-1] < B) p2 = i - 1; pre[1][i] = p2; 
	}
	lst[0][n+1] = lst[1][n+1] = n; 
	s[n+1] = INF; s[0] = -INF;
	for (int i=1,l,r;i<=n;i++) {
		for (int j=0;j<=1;j++) {
			r = min(i-1, lst[j^1][i+1]);
			if (s[i+1] - s[lst[j^1][i+1]] >= LIM[j^1]) 
				if (l = pre[j][i], l <= r) f[j][i] = (sum[j^1][r] - sum[j^1][l-1]) % MOD;
			if (s[pre[j][i]+1] - s[pre[j][i]] >= LIM[j]) f[j][i]++;
			sum[j][i] = (sum[j][i-1] + f[j][i]) % MOD;
		}
	}
	printf("%d\n",((f[0][n]+f[1][n])%MOD+MOD)%MOD);
	return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <string>
int main() {
    using namespace std;
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a + b << endl;
        return 0;
    }
    int ans = 2 * max(a, b) - 1;
    cout << ans << endl;

    return 0;
}

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

int main() {
  int x;
  cin >> x ;
  int a,b,c,d;
  a = x/1000;//1桁目
  b = (x - a*1000)/100;//2桁目   
  c = (x - a*1000 - b*100)/10;
  d = x - a*1000 - b*100 - c*10; 
  int h1 = a*100+b*10+c;//３桁の整数abc
  int h2 = b*100+c*10+d; //３桁の整数bcd
  if(h1 % 111 == 0 || h2 % 111 == 0)
  {
      cout << "Yes";
  }
  else cout << "No";  
  return 0;  
}

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


int main()
{
    /*
    string s;
    cin>>s;
    if(s=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else
    {
        cout<<"ABC"<<endl;
    }
    */
   /*
    int n,k;
    cin>>n>>k;
    map <int,int> mp;
    for(int i=1;i<=k;i++)
    {
        int d;
        cin>>d;
        for(int j=1;j<=d;j++)
        {
            int a;
            cin>>a;
            mp[a]++;
        }
    }
    int count=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]==0)
        {
            count++;
        }
    }

    cout<<count<<endl;
    */

    int n,m;
    cin>>n>>m;
    vector <pair<bool,ll>> h(n+1);  //良いか悪いか、標高
    for(int i=1;i<=n;i++)
    {
        int height;
        cin>>height;
        h[i].first=true;
        h[i].second=height;
    }

    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        if(h[a].second<=h[b].second)
        {
            h[a].first = false;
        }
        if(h[a].second>=h[b].second)
        {
            h[b].first=false;
        }
    }

    int count=0;

    for(int i=1;i<=n;i++)
    {
        if(h[i].first)
        {
            count++;
        }
    }

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

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

int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<P> q;
    for(int i=0; i<n; i++){
        ll A;
        cin >> A;
        q.push(P{A, 1});
    }
    for(int i=0; i<m; i++){
        ll B, C;
        cin >> B >> C;
        q.push(P{C, B});
    }

    ll ans = 0;
    while(n > 0){
        P p = q.top();
        q.pop();
        if(n >= p.second) ans += (p.first * p.second);
        else ans += (p.first * n);
        n -= p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll a,b;
    cin >> a >> b;
    ll t = b-a;
    ll low = t*(t-1)/2;
    cout << low-a << endl;
}


Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
}


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

using namespace std;

const int MOD = 1e9 + 7;

int s[2005], t[2005];
long long dp[2005][2005];

long long solve(int x, int y) {
	if (x < 0 || y < 0) return 0LL;
	if (dp[x][y] != -1) return dp[x][y];
	
	long long val = 0;
	
	if (s[x] != t[y]) val = solve(x - 1, y) + solve(x, y - 1) - solve(x - 1, y - 1);
	else val = 1LL + solve(x - 1, y) + solve(x, y - 1);
	
	val %= MOD;
	val += MOD;
	val %= MOD;
	
	return dp[x][y] = val;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < n; i++) scanf("%d", &s[i]);
	for (int i = 0; i < m; i++) scanf("%d", &t[i]);
	
	memset(dp, -1, sizeof(dp));
	
	printf("%lld\n", (solve(n - 1, m - 1) + 1) % MOD);
}


Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;

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



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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<bool> ng(n, true);
  while (k--) {
    int d;
    cin >> d;
    while (d--) {
      int a;
      cin >> a;
      a--;
      ng[a] = false;
    }
  }
  int ans = 0;
  for (auto&& e : ng) {
    ans += e;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
/*
No i'm not down, No I'm not out
*/
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<long long>
#define M map<int,int>
#define F     first
#define S    second
#define nl "\n"
#define lb lower_bound
#define ub upper_bound
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define mem(a,n)  memset(a, n, sizeof(a))
#define all(v) v.begin(), v.end()
int dx[8] ={0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] ={1, -1, -1, 0, 1, -1, 0, 1};
#define mod 10000007
#define N 100005

int main()
{
    fast();
    int n;
    cin >> n;
    int a, b, c, x = 0, y = 0, z = 0, x1, y1, z1;
    f(i, 0, n)
    {
        cin >> a >> b >> c;
        x1 = max(y, z) + a;
        y1 = max(x, z) + b;
        z1 = max(x, y) + c;
        x = x1, y = y1, z = z1;
    }
    cout << max(x, max(y, z));
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
broken_list = [int(input()) for i in range(M)]

dp = [1] * (N+1)
for broken in broken_list:
    dp[broken] = 0
for i in range(2, len(dp)):
    if dp[i] != 0:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print (dp[N] % 1000000007)

Measured memory_bytes: 7824
/*
 * Author       : YangDavid
 * Created Time : 2019年07月14日 星期日 17时31分35秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 111111;
int r[maxn], w[maxn], n, m, tot;
int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i)
        w[i] = 1;
    r[1] = 1;
    rep(i, m) {
        int x, y; 
        scanf("%d%d", &x, &y);
        w[x]--, w[y]++;
        if(r[x]) r[y] = true;
        if(w[x] == 0) r[x] = false;
    }
    rep(i, n) tot += r[i];
    printf("%d\n", tot);

    return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<char> stack;
    for (char c : s) {
        while (!stack.empty() && stack.back() == c) {
            stack.pop_back();
        }
        stack.push_back(c);
    }
    cout << stack.size() << '\n';

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;

int main(){
    vector<int> x(5);
    int y = 0,z = 1e9,end = 0;
    rep(i,5){
        cin >> x[i];
        y = x[i]%10;
        if(y!=0 && z>y){
            z = y;
            end = i;
        }
    }

    int sum = 0;
    rep(i,5){
        if(i==end || x[i]%10==0) sum += x[i];
        else{
            sum += x[i] + (10 - x[i]%10);
        }
    }
    cout(sum);

    

    return 0;
}

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

typedef long long ll;

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<int> v(n + 5), vis(n + 5, -1);
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    int i, ans = 1, cl = 0;
    vis[1] = 0;
    for (i = 1; i <= k; i++) {
        ans = v[ans];
        if (vis[ans] != -1) {
            cl = i - vis[ans];
            break;
        } else {
            vis[ans] = i;
        }
    }
    // cout << ans << " " << i << " " << cl << '\n';
    // starting at ans move k - i
    if (cl) {
        k = (k - i) % cl;
        while (k--)
            ans = v[ans];
    }
    cout << ans << '\n';
}

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

    solve();
    return 0;
}

Measured memory_bytes: 4784
#include <stdio.h>

void ans(int a,int b,int c);

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    ans(a,b,c);
    return 0;
}
//abcの順に大きさを並べ替える
void ans(int a,int b,int c){
    int max = 0;
    if(b<c){
        max = c;
        c = b;
        b = max;
    }
    if(a<b){
        max = b;
        b = a;
        a = max;
    }
    printf("%d", a*10+b+c);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#pragma GCC optimize(2)
#define int long long
#define MAXN 2000000
#define INF (1e13 + 7)
#define MANX MAXN

using namespace std;

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

int vis[MAXN];

signed main()
{
	int x = read(), n = read();
	for (int i = 1; i <= n; i++) vis[read()] = 1;
	int MIN = INF, ans = 0;
	for (int i = 0; i <= 110; i++)
	{
		if (vis[i]) continue;
		if (abs(x - i) < MIN)
		{
			MIN = abs(x - i);
			ans = i;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
n,x=map(int,input().split())
c=n
def sol(a,b):
    global c
    if a==b:c+=a
    elif a%b==0:c+=b*(2*(a//b)-1)
    elif b%a==0:c+=a*(2*(b//a)-1)
    elif a>b:
        c+=b*(a//b)*2
        sol(a-a//b*b,b)
    else:
        c+=a*(b//a)*2
        sol(a,b-b//a*a)
sol(x,n-x)
print(c)

Measured memory_bytes: 3060
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 int n;
  cin >> n;
  vector<int> avec(n);
  vector<int> bvec(n);
  for(int i=0;i<n;i++){
    cin >> avec.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> bvec.at(i);
  }
  int sum=bvec.at(n-1);
  for(int i=0;i<n;i++){
    sum=sum+avec.at(i);
  }
  int ans=sum;//ansは暫定的な最大値
  
  for(int i=0;i<n-1;i++){
    sum=sum-avec.at(n-1-i)+bvec.at(n-i-2);
    if(sum>ans){
      ans=sum;
    }//sumがansより大きければその値で更新
  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const int mod = 1000000007;
long long dp[2][100005];
int main(){
    string L;
    cin >> L;
    int n = L.length();
    dp[0][0]=1;
    for(int i = 0; i < n; i++){
        if(L[i]=='0'){
            dp[0][i+1] = dp[0][i] % mod;
            dp[1][i+1] = (dp[1][i] * 3) % mod;
        }else{
            dp[0][i+1] = (dp[0][i] * 2) % mod;
            dp[1][i+1] = ((dp[1][i] * 3) % mod + dp[0][i]) % mod;
        }
    }
    int ans = (dp[0][n] + dp[1][n]) % mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (s[k - 1] == 'A')s[k - 1] = 'a';
    if (s[k - 1] == 'B')s[k - 1] = 'b';
    if (s[k - 1] == 'C')s[k - 1] = 'c';
    cout << s << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(n);
    ll ans=0;
    for(ll a=1;a<=n;a++){
        ans+=(n-1)/a;
    }
    out(ans);
}

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

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

int n, j, ans, a[100000], l[100000], r[100000];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	l[0] = a[0];
	r[n - 1] = a[n - 1];
	rep(i, n - 1) {
		l[i + 1] = gcd(l[i], a[i + 1]);
		j = n - 2 - i;
		r[j] = gcd(r[j + 1], a[j]);
	}
	rep(i, n) {
		if (i == 0) {
			ans = r[i + 1];
		}
		else if (i == n - 1) {
			ans = max(ans, l[i - 1]);
		}
		else {
			ans = max(ans, gcd(l[i - 1], r[i + 1]));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

	int data[110] = {0};


	int a, b;
	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		data[a] = b;
	}

	int dp[110][9] = {0};
	// 0:11, 1:12, 2:13, 3:21, 4:22, 5:23, 6:31, 7:32, 8:33 
	if (data[1] == 0) {
		if (data[2] == 0) {
			for (int i = 0; i < 9; i++) {
				dp[2][i] = 1;
			}
		} else if (data[2] == 1) {
			dp[2][0] = dp[2][3] = dp[2][6] = 1;
		} else if (data[2] == 2) {
			dp[2][1] = dp[2][4] = dp[2][7] = 1;
		} else {
			dp[2][2] = dp[2][5] = dp[2][8] = 1;
		}
	} else if (data[1] == 1) {
		if (data[2] == 0) {
			dp[2][0] = dp[2][1] = dp[2][2] = 1;
		} else if (data[2] == 1) {
			dp[2][0] = 1;
		} else if (data[2] == 2) {
			dp[2][1] = 1;
		} else {
			dp[2][2] = 1;
		}
	} else if (data[1] == 2) {
		if (data[2] == 0) {
			dp[2][3] = dp[2][4] = dp[2][5] = 1;
		} else if (data[2] == 1) {
			dp[2][3] = 1;
		} else if (data[2] == 2) {
			dp[2][4] = 1;
		} else {
			dp[2][5] = 1;
		}
	} else {
		if (data[2] == 0) {
			dp[2][6] = dp[2][7] = dp[2][8] = 1;
		} else if (data[2] == 1) {
			dp[2][6] = 1;
		} else if (data[2] == 2) {
			dp[2][7] = 1;
		} else {
			dp[2][8] = 1;
		}
	}
	// 0:11, 1:12, 2:13, 3:21, 4:22, 5:23, 6:31, 7:32, 8:33 
	for (int i = 3; i <= n; i++) {
		if (data[i] == 0) {
			dp[i][0] += (dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][1] += (dp[i-1][0]+dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][2] += (dp[i-1][0]+dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][3] += (dp[i-1][1]+dp[i-1][4]+dp[i-1][7])%10000;
			dp[i][4] += (dp[i-1][1]+dp[i-1][7])%10000;
			dp[i][5] += (dp[i-1][1]+dp[i-1][4]+dp[i-1][7])%10000;
			dp[i][6] += (dp[i-1][2]+dp[i-1][5]+dp[i-1][8])%10000;
			dp[i][7] += (dp[i-1][2]+dp[i-1][5]+dp[i-1][8])%10000;
			dp[i][8] += (dp[i-1][2]+dp[i-1][5])%10000;
		} else if (data[i] == 1) {
			dp[i][0] += (dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][3] += (dp[i-1][1]+dp[i-1][4]+dp[i-1][7])%10000;
			dp[i][6] += (dp[i-1][2]+dp[i-1][5]+dp[i-1][8])%10000;
		} else if (data[i] == 2) {
			dp[i][1] += (dp[i-1][0]+dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][4] += (dp[i-1][1]+dp[i-1][7])%10000;
			dp[i][7] += (dp[i-1][2]+dp[i-1][5]+dp[i-1][8])%10000;
		} else {
			dp[i][2] += (dp[i-1][0]+dp[i-1][3]+dp[i-1][6])%10000;
			dp[i][5] += (dp[i-1][1]+dp[i-1][4]+dp[i-1][7])%10000;
			dp[i][8] += (dp[i-1][2]+dp[i-1][5])%10000;
		}
	}
	int cc = 0;
	for (int i = 0; i < 9; i++) {
		cc += dp[n][i];
		cc %= 10000;
	}
	cout << cc << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

struct node
{
    string name;int score,id;
    bool operator < (const node e) const
    {
        if(name != e.name) return name < e.name;
        return score > e.score;
    }
}a[105];

int main()
{
    fastio();
    int n;
    cin>>n;
    rep(i,1,n){
        cin>>a[i].name>>a[i].score;
        a[i].id = i;
    }
    sort(a+1,a+n+1);
    rep(i,1,n) cout<<a[i].id<<endl;

    return 0;
}


Measured memory_bytes: 3624
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n * 3];
        for (int i = 0; i < n * 3; i++) {
            a[i] = in.nextInt();
        }

        Arrays.sort(a);

        long t = 0;
        for (int i = 3 * n - 2; i >= n; i -= 2) {
            t += a[i];
        }

        out.println(t);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

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

int main(){
    int a[5];
    for(int i = 0; i < 5; i++) cin >> a[i];
    int k;
    cin >> k;
    if(a[4] - a[0] <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
import sys

data = sys.stdin.readlines()
f = lambda x:int(x.rstrip())
data = [f(x) for x in data][1:]

vmin = data[0]
out = data[1] - data[0]

for x in data[1:]:
  out = max(out,x-vmin)
  vmin = min(x,vmin)

print(int(out))



Measured memory_bytes: 29416
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, K;
	cin >> N >> M >> K;
	bool f = false;
	int a;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			a = 0;
			a += i*j;
			a += (N - i)*(M - j);
			if (a == K) {
				f = true;
				break;
			}
			a = N + M - a;
			if (a == K) {
				f = true;
				break;
			}
		}
	}
	if(f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

string s;

// a = now b = next
int valid(int foot, int a, int b) {
    if (foot) {
        if (a == 1 || a == 4 || a == 7) return 0;
        else if (a == 2 || a == 8) {
            if (b != 1 && b != 4 && b != 7) return 0;
            else return 1;
        }
        else {
            if (b == 3 || b == 6 || b == 9) return 0;
            else return 1;
        }
    }
    else {
        if (a == 3 || a == 6 || a == 9) return 0;
        else if (a == 2 || a == 8) {
            if (b != 3 && b != 6 && b != 9) return 0;
            else return 1;
        }
        else {
            if (b == 1 || b == 4 || b == 7) return 0;
            else return 1;
        }
    }
}

int check(int f) {
    vector<int> dp(s.size()+1, 1e9);
    dp[0] = 0;
    
    for (int i = 1; i < s.size(); i++) {
        int now = s[i-1]-'0';
        int next = s[i]-'0';
        int foot;
        (i%2) == f ? foot = 1 : foot = 0;
        //printf("f=%d i=%d foot=%d    valid=%d now=%d next=%d\n",f,i,foot,valid(foot,now,next), now, next);
        int v = valid(foot,now,next);
        if (v) f = (f+1)%2;
        dp[i] = min(dp[i], dp[i-1] + v);
    }
    //printf("f=%d return=%d\n",f, dp[s.size()-1]);
    return dp[s.size()-1];
}

int main(void){
    while (cin>>s && s[0] != '#') {
        int ans = min(check(0), check(1));
        cout << ans << endl;
        //cout << "--------------------" << endl;
    }
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int sum=0;
  
  for(int i=0; i<N; i++){
    
    int x,y;
    cin >> x >> y;
    sum += (y-x+1);
  }
  
  cout << sum << endl;
}
    

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

int main(){
    bool flag=true;
    long long ans=0,tap=1;
    int a,b;
    cin >>a>>b;


    while (tap < b){
        ans++;
        tap--;
        tap += a;
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int n;
	int M[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> M[i];
	}
	int maxv = -2000000000;
	int minv = M[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, M[i] - minv);
		minv = min(minv, M[i]);
	}
	cout << maxv << endl;
	return 0;
	
}


Measured memory_bytes: 3880
#include <stdio.h>
     
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}

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

int main() {
  int cake = 4, donut = 7;
  int n = 0;
  bool flag = false;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int total = 4 * i + 7 * j;
      if (total == n) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
}

Measured memory_bytes: 24236
#include <iostream>

using namespace std;

int main()
{
	int n,ans=1;
	string s;
	cin >>n>> s;
	char bs = s[0];
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
# ABC061C - Big Array
import sys
input = sys.stdin.readline

from itertools import accumulate
from bisect import bisect_left as bs


def main():
    N, K = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    memo = [0] * (10 ** 5 + 1)  # memo[i] := the number of times i appears
    for a, b in A:
        memo[a] += b
    ans = bs(list(accumulate(memo)), K)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 24012
N = int(input())
P = list(map(int, input().split()))
res = 0
for idx in range(len(P) - 1):
    if P[idx] == idx + 1:
        P[idx], P[idx+1] = P[idx+1], P[idx]
        res += 1

if P[-1] == N:
    res += 1

print(res)


Measured memory_bytes: 14008
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

template<typename T>
constexpr std::vector<std::pair<T, T>> primeFactorization(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors;
	T quotient = number;
	for (T i = 2; i*i <= quotient; ++i) {
		if (quotient%i == 0) {
			T prime = i, power = 1;

			quotient /= i;
			while (quotient%i == 0) {
				++power;
				quotient /= i;
			}

			primeFactors.push_back(std::pair<T, T>(prime, power));
		}
	}
	if (quotient != 1) primeFactors.push_back(std::pair<T, T>(quotient, 1));

	return primeFactors;
}

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

	ll x;
	cin >> x;


	while (true) {
		auto t = primeFactorization(x);

		if (t.size() == 1 && t[0].first == x && t[0].second == 1) break;
		else ++x;
	}

	cout << x << "\n";

	return 0;
}


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

using namespace std;

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

    vector<int> h(n), c(n), x(k + 1);

    for (int i = 0; i < n; i++) cin >> h[i];

    for (int i = 1; i < n; i++) {
        int _n = k + 1, m = INT_MAX;

        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                x[j] = abs(h[i] - h[i - j]);
            } else {
                _n = j;
                break;
            }
        }

        for (int j = 1; j < _n; j++) m = min(m, c[i - j] + x[j]);

        c[i] = m;
    }

    cout << c[n - 1];

    return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long x;
	cin>>x;
	long long year=0;
	for(long long i=100;;)
	{
		year++;
		i+=i/100;
		if(i>=x){
			cout<<year<<"\n";
			break; 
		}
	}
}

Measured memory_bytes: 3648