akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll d;
    cin >> d;

    int ans = 0;

    rep(i,n){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y<=d*d)ans++;
    }

    cout << ans << endl;
    return 0;
}




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


int main() {
	int n;	
	int sum = 0;
	int mini = 1e6;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		mini = tmp % 10 != 0 ? min(mini, tmp) : mini;
		sum += tmp;
	}
	
	int sol = sum % 10 == 0 ? 0 : sum;
	if (sum % 10 == 0 && mini != 1e6) {
		sol = sum - mini;
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int a , b; 
	cin>>a>>b;
	int st = 1 ;
	int ans = 0;
	while(st<b){
		st--;
		st +=a ;
		ans++;
	}
	cout<<ans<<endl;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main() {
  int N, K, num = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (num < K) {
      num *= 2;
    } else {
      num += K;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

string S;

int main() {
    cin >> S;

    bool tuyoi = true;
    rep(i, (S.length() - 1) / 2) {
        if (S[i] != S[(S.length() - 1) / 2 - 1 - i]) tuyoi = false;
    }
    REP(i, (S.length() + 3) / 2, S.length()) {
        if (S[i] != S[S.length() - 1 - i]) tuyoi = false;
    }

    cout << Yes(tuyoi) << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE -2

int row[N],col[N],dpos[15],dneg[15],init[N];
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(j==row[i]) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
  
void putQueen(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  if(init[i]==NOT_FREE) putQueen(i+1);
  else{
    for(j=0;j<N;j++){
      
      if((col[j]==NOT_FREE) || (dpos[i+j]==NOT_FREE) || (dneg[i-j+N-1]==NOT_FREE)) continue;
      
      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
      
      putQueen(i+1);
    
      col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
  }
}

int main(){
  int i,k,r ,c;
  for(i=0;i<N;i++) row[i]=col[i]=init[i]=FREE;
  
  for(i=0;i<15;i++) dneg[i]=dpos[i]=FREE;
    
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    row[r]=c;
    col[c]=dpos[r+c]=dneg[r-c+N-1]=init[r]=NOT_FREE;
  }

  putQueen(0);

  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

int N, Q;

int main() {
    cin >> N >> Q;
    set<P> D;
    vector<tuple<int,int,int>> X;
    rep(i,N) {
        int s, t, x;
        cin >> s >> t >> x;
        X.emplace_back(x,s-x,t-x);
    }
    rep(i,Q) {
        int d;
        cin >> d;
        D.insert(P(d,i));
    }
    vector<int> res(Q,-1);
    sort(ALL(X));
    rep(i,N) {
        int s, t, x;
        tie(x,s,t) = X[i];
        // if (D.empty()) continue;
        auto it = D.lower_bound(P(s,-1));
        while(it != D.end()) {
        // while(D.size() && it != D.end()) {
            if (it->first >= t) break;
            res[it->second] = x;
            D.erase(it++);
        }
    }
    rep(i,Q) cout << res[i] << endl;
}

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

int main() {
  int h,w;
  string a;
  cin >> h >> w;
  rep(i,h){
    cin >> a;
    cout << a << endl;
    cout << a << endl;
  }
}

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

using namespace std;

int main(void)
{
    string s;
    int dval[50000];
    long long pond_size[20000], pond_pos[20000];

    for (int i = 0; i < 50000; i++){
        dval[i] = -1;
    }

    dval[25000] = 0;
    int depth = 0;
    long long ans = 0;
    int pond_num = 0;
    cin >> s;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == '\\'){
            --depth;
        }
        else if (s[i] == '/'){
            ++depth;
            if (dval[depth + 25000] != -1){
                ans += i - dval[depth + 25000];
                long long tmp = i - dval[depth + 25000];
                while (pond_num > 0 && dval[depth + 25000] < pond_pos[pond_num - 1]){
                    tmp += pond_size[pond_num - 1];
                    pond_num--;
                }
                pond_size[pond_num] = tmp;
                pond_pos[pond_num++] = dval[depth + 25000];
            }
        }

        dval[depth + 25000] = i + 1;
    }
    cout << ans << endl;
    cout << pond_num << (pond_num == 0 ? '\n' : ' ');

    for (int i = 0; i < pond_num; i++){
        cout << pond_size[i] << (i + 1 == pond_num ? '\n' : ' ');
    }
    return 0;
}



Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;    
#define ll long long
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    map<string , int>mp;
    int T; cin >> T;
    while(T--) {
        string s;
        cin >> s;
        mp[s] ++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x "  << mp["RE"] << "\n";
} 

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=111;
const int mod=1e9+7;
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}

int n,h[maxn];

pii solve(int l,int r,int v)
{
	if(l==r)return mp(qpow(2,h[l]-v),0);
	
	int mn=*min_element(h+l,h+r+1);
	vector<int> pos;pos.pb(l-1);for(int i=l;i<=r;i++)if(h[i]==mn)pos.pb(i);pos.pb(r+1);
	vector<pii> ansv;
	for(int i=1;i<(int)pos.size();i++)if(pos[i]>pos[i-1]+1)ansv.pb(solve(pos[i-1]+1,pos[i]-1,mn));
	
	int v1=2,v2=qpow(2,(int)pos.size()-2);
	for(int i=0;i<(int)ansv.size();i++)
	{
		v1=(LL)v1*ansv[i].ff%mod;
		v2=(LL)v2*(ansv[i].ff*2ll+ansv[i].ss)%mod;
	}
	v2-=v1;if(v2<0)v2+=mod;
	v1=(LL)v1*qpow(2,mn-v-1)%mod;
	return mp(v1,v2);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",h+i);
	
	pii ans=solve(1,n,0);
	printf("%d\n",(ans.ff+ans.ss)%mod);
	return 0;
}

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

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	char a, b;
	cin >> a >> b;

	cout << ((a == 'H') xor (b == 'H') ? "D" : "H");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a>b) swap(a,b);
  int ans = a+w>b ? 0:b-a-w;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

bool cmp(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<int> a(n);
	for(int i = 0; i < m; i++){
		int l, r;
		cin>>l>>r;
		l--; r--;
		a[l]++;
		if(r + 1 < n)a[r + 1]--;
	}
	for(int i = 1; i < n; i++){
		a[i] += a[i - 1];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += (a[i] == m);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
result = 0
for i in range(N):
  D = 0
  A = list(map(int,input().split()))
  for j in range(M):
    D += B[j]*A[j]
  if D+C> 0:
    result += 1
  else:
    None
print(result)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int i,j;
	int a[99999];

	for(i=0;i<99999;i++)
		a[i]=1;

	i=0;

	while(!(a[i]==0))
	{
		i++;

		scanf("%d",&a[i]);		
	}

	j=i;
	i=1;

	while(!(i==j))
	{
		printf("Case %d: %d\n",i,a[i]);

		i++;

	}

	return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
using namespace std;
//990589
//4076361
const int mod=2019;
int a[990589+10];
int main()
{
	int l,r;
	cin>>l>>r;
	int n1=l/mod;
	int n2=r/mod;
//	if(r%mod==0) n2--;
	int qq=0;
//	a[qq++]=n*mod;
	if(n1==n2)
	{
//		printf("%d %d\n",(l%mod),((l+1)%mod));
//		int woc[2019];
		
//		int a1=l+(l+1);
//		int a2=r*(r-1);
//		int www=a1/2019;
//		if(a1%2019!=0) www++;
//		int www2=a2/2019;
////		if(a2%2019!=0) 
//		for(int i=www;i<=www2;i++)
//		{
//			
//			if((www*2019)%)
//		}
//		cout<<((l%mod)*((l+1)%mod))%mod<<endl;
		int minn=1000000000;
//		cout<<l<<r<<endl;
		for(int i=l;i<r;i++)
		{
			for(int j=i+1;j<=r;j++)
			{
//				cout<<(i*j)%mod<<endl;
//				getchar();
				minn=min(minn,((i%mod)*((j)%mod))%mod);
//			if(minn==0) cout<<i<<j<<endl;
			}
		}
		cout<<minn<<endl;
	}
	else{
		cout<<0<<endl;
	}

	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		char a = sc.next().toCharArray()[0];
		char b = sc.next().toCharArray()[0];
		char c = sc.next().toCharArray()[0];
		System.out.print((char)(a - 'a' + 'A'));
		System.out.print((char)(b - 'a' + 'A'));
		System.out.print((char)(c - 'a' + 'A'));
		System.out.println();
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
	long long n, k, ans = (long long)1e+18;
	cin >> n >> k;
	vector<long long> x(n);
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = k; i <= n; i++){
		long long l, r;
		l = abs(x[i - k]) + abs(x[i - k] - x[i - 1]);
		r = abs(x[i - 1]) + abs(x[i - k] - x[i - 1]);
		ans = min({ans, l, r});
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n,k,a,u=1,n2,n3,y=0;
  cin >> n >> k;
  int D[k];
  n2=n;
  vector<int> d{0,1,2,3,4,5,6,7,8,9};
  vector<int> d2;
  for(int i=0;i<k;i++){
    cin >> D[i];    
    d.erase(d.begin() + D[i]-i);
  }
  
      while(n2!=0){
        n2 /= 10;
        y++;
    }

  while(1){
    u=1;
    n3 = n;
    for(int i=0;i<5;i++){
     
     int a2 = n3%10;
      if(i>y-1&&a2==0);
      else{
        for(int j=0;j<k;j++){
        if(a2==D[j]) u=0;
      }
      }
      n3 /=10;
    }
    if(u==1) break;
    n++;
  }


cout << n << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 100000

int main(void){
  int N, i;
  char S[MAX][4];
  char reS[4][4] = {"AC", "WA", "TLE", "RE"};
  int C[4] = {0};
  
  scanf("%d", &N);
  
  for(i = 0; i < N; i++){
    scanf("%s", S[i]);
    
    if(strcmp(S[i], reS[0]) == 0)  C[0]++;
    else if(strcmp(S[i], reS[1]) == 0)  C[1]++;
    else if(strcmp(S[i], reS[2]) == 0)  C[2]++;
    else if(strcmp(S[i], reS[3]) == 0)  C[3]++;
  }
  
  printf("AC x %d\n", C[0]);
  printf("WA x %d\n", C[1]);
  printf("TLE x %d\n", C[2]);
  printf("RE x %d\n", C[3]);
  
  return 0;
}

Measured memory_bytes: 2120
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

char m[300][300] = {};
int ans[300][300] = {};
ll s[300] = {};
ll t[300] = {};
ll x = 0;
int total = 0;
int main() {
	ll h, w, k; cin >> h >> w >> k;

	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> m[i][j];
			if (m[i][j] == '#') {
				total++;
				s[i]++;
				t[i]++;
				x = min(x, i);
			}
		}
	}

	ll b = 1;
	rep(i, 0, h) {
		if (s[i] == 0)continue;
		rep(j, 0, w) {
			ans[i][j] = b;
			if (m[i][j] == '#' && s[i] != 1) {
				b++;
				s[i]--;
			}
		}
		b++;
	}

	rep(i, 0, h) {
		if (t[i] != 0 && t[i+1] == 0) {
			rep(j, 0, w) {
				ans[i+1][j] = ans[i][j];
			}
			t[i+1] = 1;
		}
	}
	rep_re(i, 0, h) {
		if (t[i] != 0 && t[i-1] == 0) {
			rep(j, 0, w) {
				ans[i-1][j] = ans[i][j];
			}
			t[i - 1] = 1;

		}
	}

	rep(i, 0, h) {
		rep(j, 0, w) {
			cout << ans[i][j];
			if (j != w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<ll, ll>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (ll i = begin; i < n; i++)
#define repe(i, begin, n) for (ll i = begin; i <= n; i++)
#define repr(i, begin, n) for (ll i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (ll i = begin; i >= end; 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;
}

const ll inf = 1000000007;
const ll MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N, M;
vector<int> Graph[301010];
int S, T;
int dist[301010];

int main() {
  cin >> N >> M;
  rep(i, 0, M) {
    ll u, v;
    cin >> u >> v;
    Graph[3 * u].push_back(3 * v + 1);
    Graph[3 * u + 1].push_back(3 * v + 2);
    Graph[3 * u + 2].push_back(3 * v);
  }
  cin >> S >> T;

  rep(i, 0, 301010) { dist[i] = inf; }
  dist[S * 3] = 0;

  queue<int> que;
  que.push(S * 3);
  while (!que.empty()) {
    int cv = que.front();
    que.pop();

    for (auto nv : Graph[cv]) {
      if (dist[nv] != inf) continue;

      dist[nv] = dist[cv] + 1;
      que.push(nv);
    }
  }

  if (dist[T * 3] == inf) {
    cout << -1;
  } else if (dist[T * 3] % 3 != 0) {
    cout << -1;
  } else {
    cout << dist[T * 3] / 3;
  }
}


Measured memory_bytes: 21196
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d);
	
	
	return 0;
}





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

int main(void) {
    int N;
    scanf("%d", &N);

    int t[N+1], x[N+1], y[N+1];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for (int i = 1; i <= N; i++) {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }

    for (int i = 0; i < N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

        if (dt < dist) {
            printf("No\n");
            return 0;
        }

        if (dt % 2 != dist % 2) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int m[] = new int[N];
        int total = 0;
        
        for(int i = 0; i < N; i++){
            m[i] = sc.nextInt();
            total += m[i];
        }
        int d = X - total;
        int ans = 0;
        int min = m[0];
        for(int i = 0; i < N; i++){
            if(min > m[i]){
                min = m[i];
            }
        }
        ans = N + d / min;
        System.out.println(ans);
    }
}


Measured memory_bytes: 36068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    long N;
    std::cin >> N;
    long A[200000];
    for(long i=0; i<N; i++){
        std::cin >> A[i];
    }
    long sum=0;
    long temp_max=A[0];
    for(long i=1; i<N; i++){
        if(temp_max>A[i]){
            sum+=temp_max-A[i];
        }else{
            temp_max=A[i];
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 4740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
   int X,Y,Z,K; cin >> X >> Y >> Z >> K;
   vector<ll> A(X),B(Y),C(Z);
   rep(i,X) cin >> A[i];
   rep(i,Y) cin >> B[i];
   rep(i,Z) cin >> C[i];
   sort(A.begin(),A.end(),greater<ll>());
   sort(B.begin(),B.end(),greater<ll>());
   sort(C.begin(),C.end(),greater<ll>());
   vector<ll> res1;
   rep(i,A.size()){
       rep(j,B.size()){
           res1.push_back(A[i]+B[j]);
       }
   }
   sort(res1.begin(),res1.end(),greater<ll>());
   vector<ll> res2;
   rep(i,min((int)res1.size(),K)){
       rep(j,min((int)C.size(),K)){
           res2.push_back(res1[i]+C[j]);
       }
   }
   sort(res2.begin(),res2.end(),greater<ll>());
   rep(i,K) cout << res2[i] << endl;

}


Measured memory_bytes: 42728
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>

#define ll long long
#define LINF LLONG_MAX

using namespace std;

int main() {
  ll N;
  cin >> N;
  ll X, L;
  pair<ll, ll> P[100005];
  for (int i = 0; i < N; i++) {
    cin >> X >> L;
    P[i].first = X + L;
    P[i].second = X - L;
  }
  sort(P, P + N);

  ll ans = 0, t = -LINF;
  for (int i = 0; i < N; i++) {
    if (t <= P[i].second) {
      ans++;
      t = P[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s; cin >> s;
  int n = s.size();
  vector<int> a(n + 1);
  a[0] = 0, a[1] = 1;
  if (s[0] == s[1]) a[2] = 1;
  else a[2] = 2;
  for (int i = 3; i <= n; i ++) {
    if (s[i - 1] == s[i - 2]) a[i] = a[i - 3] + 2;
    else a[i] = a[i - 1] + 1;
  }

  cout << a[n] << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;
    cin >> K;

    rep(i,100)
    {
        if(S[i] != '1')
        {
            if(A>=K)cout << 1;
            else cout << S[i];
            return 0;
        }
        A++;
    }
    cout << 1;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<int> a(n + 1, 0);
	for(int i = 0; i < m; i++){
		int x; cin>>x;
		a[x] = 1;
	}
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		dp[i] %= mod;
		if(i + 1 <= n && !a[i + 1])dp[i + 1] += dp[i];
		if(i + 2 <= n && !a[i + 2])dp[i + 2] += dp[i];
	}
	dp[n] %= mod;
	cout<<dp[n]<<endl;

	return 0;
}

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

const int N = 1e5 + 10;

int gets(int x) {
    int s = 0;
    while(x) {
        s += x % 10;
        x /= 10;
    }
    return s;
}

int main() {
    int n; cin >> n;
    int ans = 123456;
    for(int i = 1; i < n; i++) {
        int x = n - i;
        ans = min(ans, gets(x) + gets(i));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left >= n && right >= n) return;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



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

int main(){
  int x;cin>>x;
  for(int i=1;i<10000000;i++){
    if((x*i)%360==0){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <string>
using namespace std;

const int ME = 3010;
const int MV = 6010;
int fir[MV], rfir[MV];
int n, m, cap, u[ME], v[ME], nex[ME], rnex[ME], w[ME];
int dis[MV][2010];
bool oil_sta[MV];

struct dot{
	int oil, p;
}rear, front;

int main () {
	//freopen("in.txt", "r", stdin);
	while(~scanf("%d%d%d", &n, &m, &cap)){
//		printf("%d %d %d\n", n, m, cap);
		if(!n && !m && !cap) break;
		map<string, int>city;
		string start, des;
		cin >> start >> des;
		city[start] = 1; city[des] = 2;
		int d;
		string x, y;
		int cou = 2;
		memset(fir, -1, sizeof(fir));
		memset(rfir, -1, sizeof(rfir));
		//int ee = 0;
		for(int ee = 0; ee < n; ee++) {
			cin >> x >> y >> d;
			if(city[x] == 0) city[x] = ++cou;
			if(city[y] == 0) city[y] = ++cou;
			//if(d > cap * 10 ) continue; 
			u[ee] = city[x];
			v[ee] = city[y];
			w[ee] = d;
			nex[ee] = fir[u[ee]]; fir[u[ee]] = ee;
			rnex[ee] = rfir[v[ee]]; rfir[v[ee]] = ee;
			//ee++;
		}
		memset(oil_sta, 0, sizeof(oil_sta));
		for(int i = 0; i < m; i++) {
			cin>>x;
			if(!city[x]) continue;
			oil_sta[city[x]] = 1;
		}
		queue<dot>q;
		front.oil = cap * 10;
		front.p = 1;
		q.push(front);
		int ok = 0;
		memset(dis, 0x3f, sizeof(dis));
	//	memset(inq, 0, sizeof(inq));
		dis[1][cap*10] = 0;
	//	inq[1][cap*10] = 1;
		int mmin = 0x3f3f3f3f;
		while(!q.empty()){
			front = q.front();
			q.pop();
		//	inq[front.p][front.oil] = 0;
			if(front.p == 2 && !ok) { ok = 1; continue; }
			for(int e = fir[front.p]; e != -1; e = nex[e]){
				if(front.oil < w[e]) continue;
				rear.oil = front.oil - w[e];
				rear.p = v[e];
				if(oil_sta[v[e]]) rear.oil = cap * 10;
				if(dis[v[e]][rear.oil] > dis[front.p][front.oil] + w[e]){
					dis[v[e]][rear.oil] = dis[front.p][front.oil] + w[e];
			//		if(!inq[v[e]][rear.oil]){
			//			inq[v[e]][rear.oil] = 1;
						q.push(rear);
				//	}
				}
			}
			for(int e = rfir[front.p]; e != -1; e = rnex[e]){
				if(front.oil < w[e]) continue;
				rear.oil = front.oil - w[e];
				rear.p = u[e];
				if(oil_sta[u[e]]) rear.oil = cap * 10;
				if(dis[u[e]][rear.oil] > dis[front.p][front.oil] + w[e]){
					dis[u[e]][rear.oil] = dis[front.p][front.oil] + w[e];
				//	if(!inq[u[e]][rear.oil]){
					//	inq[u[e]][rear.oil] = 1;
						q.push(rear);
				//	}
				}
			}
		}
		if(ok) {
			for(int i = 0; i <= cap*10; i++) if(dis[2][i] < mmin) mmin = dis[2][i];
			printf("%d\n", mmin);
		}
		else puts("-1");
	}
}

Measured memory_bytes: 58932
from scipy.sparse.csgraph import floyd_warshall

H, W = map(int, input().split())

c = []
for i in range(10):
    c1 = list(map(int, input().split()))
    c.append(c1)
    
d = floyd_warshall(c)

ans = 0
for i in range(H):
    a = list(map(int, input().split()))
    for j in a:
        if j != -1 and j != 1:
            ans += d[j][1]

print(int(ans))

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

long long calc(long long H, long long M) {
    long long res = LLONG_MAX;
    for(int i = 1; i < M; i++) {
        res = min(res, max((H&1) * i, max((M-i) * H - (H/2*i), ((H+1)/2*i) - (M-i) * H)));
    }
    return res;
}
int main() {
    int H, M;
    scanf("%d%d", &H, &M);
    long long ans = min(bool(H % 3 > 0) * M, bool(M % 3 > 0) * H);

    ans = min(ans, calc(H, M));
    ans = min(ans, calc(M, H));

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;

namespace Atcoder2
{
    class Program
    {

        public static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));

            long people = long.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            long[] length = new long[people];
            for(long i = 0; i < people; i++)
            {
                length[i] = long.Parse(input[i]);
            }
            long ans = 0;

            for (long j = 1; j < people; j++)
            {
                long difference = length[j - 1] - length[j];
                if(difference > 0)
                {
                    ans = ans + difference;
                    length[j] = length[j] + difference;
                }
            }

            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 46540
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], x, ans;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &x), (x > n) ? ans++ : a[x]++;
    for (int i = 1; i <= n; i++)
        if (a[i] != 0)
            if (a[i] < i)
                ans += a[i];
            else if (a[i] > i)
                ans += a[i] - i;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader((System.in)));
        StringTokenizer s = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(s.nextToken());
        int b = Integer.parseInt(s.nextToken());
        int yen = b * 10;
        while (yen < (b+1) * 10 && (int)(yen * 0.08) != a)
            yen++;
        System.out.println(yen < (b+1)*10 ? yen : -1);
    }
}

Measured memory_bytes: 24660
#include<bits/stdc++.h>
#define taskname "TriangularRelationship"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n, k;   cin >> n >> k;
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= n; ++i)
        if (i % k == 0) ++sum1;
        else if (i % k == k / 2) ++sum2;
    if (k & 1) cout << sum1 * sum1 * sum1;
    else cout << sum1 * sum1 * sum1 + sum2 * sum2 * sum2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, k, s;

    cin >> n >> k >> s;

    for (int i = 0; i < k; i++) {
        cout << s << " ";
    }
    for (int i = 0; i < (n - k); i++) {
        cout << ((s - 1) > 0
                     ? (s - 1)
                     : (s + 1))
             << " ";
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    if (c < a + b)
        puts("No");
    else if ((c - a - b) * (c - a - b) <= 4 * a * b)
        puts("No");
    else
        puts("Yes");
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# 2 * 10^5
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for _ in range(N)]

first_max = 0
second_max = 0
first_max_index = 0
second_max_index = 0

for i in range(N):
    if A[i] > first_max:
        first_max = A[i]
        first_max_index = i
        continue

    if A[i] > second_max:
        second_max = A[i]
        second_max_index = i
    

for i in range(N):
    if i == first_max_index:
        print(second_max)
    else:
        print(first_max)


Measured memory_bytes: 84012
n, q = map(int, input().split(' '))
p = []
time = 0
counter = 0
for i in range(n):
    tmp_n, tmp_p = input().split(' ')
    tmp_p = int(tmp_p)
    p.append((tmp_n, tmp_p))

while len(p) > 0:
    task = p.pop(0)
    tmp_p = task[1] - q
    if( tmp_p > 0):
        time += q
        p.append((task[0], tmp_p))
    elif( tmp_p <= 0):
        time += task[1]
        print('{} {}'.format(task[0], time))


Measured memory_bytes: 12088
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

    sc.Split(bufio.ScanWords)
    n, m := nextInt(), nextInt()

    ac, pena := make([]int, n), make([]int, n)
    for i := 0; i < m; i++ {
        p := nextInt()
        s := nextStr()

        p -= 1

        if ac[p] == 1{ continue }
        if s == "AC" {
            ac[p]++
        } else {
            pena[p]++
        }
    }

    var AC, PENA int
    for i := 0; i < n; i++ {
        AC += ac[i]
        if ac[i] == 1 {
            PENA += pena[i]
        }
    }


    fmt.Println(AC, PENA)

}



//===========================
//
// Library
//
//===========================

//===========================
//  round(12.54, 0) -> 13.0
//  round(12.54, -1) -> 12.5
//===========================

func round(num float64, digit uint) float64 {
    d := float64(digit)
    return float64(int(num * math.Pow(10, d) + 0.5)) / math.Pow(10, d)
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)));
}

func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)));
}

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//===========================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//===========================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextStr() string {
    sc.Scan()
    return sc.Text()
}



Measured memory_bytes: 2944
from collections import defaultdict
from heapq import heappush, heappop
import math
import bisect
import random

def LI(): return list(map(int, input().split()))
def I(): return int(input())
def LIM(): return list(map(lambda x:int(x) - 1, input().split()))
def LS(): return input().split()
def S(): return input()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007



def main():
    s = input()
    lose_cnt = 0
    win_cnt = 0
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == 'p':
                lose_cnt += 1
        else:
            if s[i] == 'g':
                win_cnt += 1
    return win_cnt - lose_cnt



print(main())


Measured memory_bytes: 40816
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    string s;
    int a[4]={0};
    cin>>s;
    for(auto x:s)
    {if(x=='N')a[0]++;else if(x=='S')a[1]++;else if(x=='W')a[2]++;else a[3]++;}
    if((a[1]>0 && a[0]==0)||(a[0]>0 && a[1]==0)||(a[2]>0 && a[3]==0)||(a[3]>0 && a[2]==0))
    cout<<"No";
    else
    cout<<"Yes";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
#define upd(X,Y) X=(X+Y)%MOD
typedef unsigned long long ull;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e6+3;
const ll maxn=1e5+7;
const int MAX=2e5+7;
const ll MOD=1e9+7;
const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
ll n;
ll a[MAX];
ll cnt[MAX];
ll an,he;
int main()
{
    scanf("%lld",&n);
    int i,j,k;
    FOR(i,1,n)
        scanf("%lld",&a[i]);
    while(1)
    {
        he=0;
        FOR(i,1,n)
        {
            cnt[i]=a[i]/n;
            he+=cnt[i];
        }
        FOR(i,1,n)
        {
            a[i]=a[i]%n+he-cnt[i];
        }
        if(!he)
            break;
        an+=he;
    }
    printf("%lld\n",an);
    return 0;
}
/*
499999999999999999
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

int main() {

	ll n, m, sum=0;
	cin >> n >> m;
	vector<ll> x(m),dis(m-1);

	for (int i = 0; i < m; i++)
		cin >> x[i];
	sort(x.begin(), x.end());

	for (int i = 0; i < m - 1; i++)
		dis[i] = x[i + 1] - x[i];
	sort(dis.begin(), dis.end());
	
	for (int i = 0; i < m - 1 - n + 1; i++)
	{
		sum += dis[i];
	}
	
	cout << sum << endl;

}

Measured memory_bytes: 1792
def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ans = [1 for i in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        if h[a-1]>h[b-1]:
            ans[b-1]=0
        elif h[a-1]==h[b-1]:
            ans[a-1]=ans[b-1]=0
        else:
            ans[a-1]=0
    print(sum(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 20048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public struct Work
{
	public int Time;
	public int Op;
	public int Point;

	public Work(int t, int o, int p)
	{
		Time = t;
		Op = o;
		Point = p;
	}
}


public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int Q = GetInt();
		var works = new Work[2 * N];
		for(int i = 0; i < N; i++)
		{
			int S = GetInt();
			int T = GetInt();
			int X = GetInt();
			works[i * 2] = new Work(S - X, 1, X);
			works[i * 2 + 1] = new Work(T - X, -1, X);
		}
		works = works.OrderBy(x => x.Time).ThenBy(x => x.Op).ToArray();
		int[] D = Enumerable.Range(0, Q).Select(_ => GetInt()).ToArray();

		string[] ans = new string[Q];
		var set = new SortedSet<int>();
		set.Add(int.MaxValue);
		int id = 0;
		for(int i = 0; i < Q; i++)
		{
			while((id < 2 * N) && (works[id].Time <= D[i]))
			{
				if(works[id].Op == 1)
					set.Add(works[id].Point);
				else
					set.Remove(works[id].Point);

				id++;
			}
			ans[i] = (set.Min < int.MaxValue) ? set.Min.ToString() : "-1";
		}

		Console.WriteLine(string.Join("\n", ans));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL v(n);
	map<int,int> odd,even;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (i%2==0) {
			even[v[i]]++;
		}
		else {
			odd[v[i]]++;
		}
	}
	if (even.size() == 1 and odd.size() == 1 and even.begin()->first == odd.begin()->first) {
		cout << n/2 << endl;
		return 0;
	}
	int ans = 0;

	int odd_max_value = 0;
	VL odd_max_keys;
	int even_max_value = 0;
	VL even_max_keys;

	for (auto&& var : odd) {
		if (odd_max_value == var.second) {
			odd_max_keys.PB(var.first);
		}
		if (odd_max_value < var.second) {
			odd_max_value = var.second;
			odd_max_keys.clear();
			odd_max_keys.PB(var.first);
		}
	}
	for (auto&& var : even) {
		if (even_max_value == var.second) {
			even_max_keys.PB(var.first);
		}
		if (even_max_value < var.second) {
			even_max_value = var.second;
			even_max_keys.clear();
			even_max_keys.PB(var.first);
		}
	}

	if (odd_max_keys != even_max_keys or odd_max_keys.size() > 1) {
		ans = n - odd_max_value - even_max_value;
	}
	else {
		int odd_second_value = 0,odd_second_key;
		int even_second_value = 0,even_second_key;
		for (auto&& var : odd) {
			if (odd_second_value < var.second and odd_max_value > var.second) {
				odd_second_value = var.second;
				odd_second_key = var.first;
			}
		}
		for (auto&& var : even) {
			if (even_second_value < var.second and even_max_value > var.second) {
				even_second_value = var.second;
				even_second_key = var.first;
			}
		}
		ans = min(n - odd_second_value - even_max_value,n - odd_max_value - even_second_value);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6904
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i)
cnt = 0

while cnt >= 0
    n.times do |i|
        if ary[i].odd?
            puts cnt
            exit
        else
            ary[i] /= 2
        end
    end
    cnt += 1
end


Measured memory_bytes: 1788
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] H = sc.intarr;

            int max = 0;
            int count = 0;

            for(int i=0; i<n; i++)
            {
                if(H[i] >= max)
                {
                    count += 1;
                    max = H[i];
                }
            }




            wr.wri(count);
        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 5e3 + 5;
int A[N];

int main() {
	long long sum = 0;
	int n, k, ans = 0; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n, greater<int>());
	for (int i = 0; i < n; i++) {
		sum += A[i];
		if (sum < k) ans++;
		else sum -= A[i], ans = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc177/tasks/abc177_d
ll fa[212121];
ll sz[212121];
void init(ll n){
    for(int i = 0;i<n;i++){
        fa[i] = i;
        sz[i] = 1;
    }
}
ll find(ll x){
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}
void merge(ll x, ll y){
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (sz[x] < sz[y])
        swap(x, y);
    fa[y] = x;
    sz[x] += sz[y];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,m;
    cin >> n >> m;
    init(n+1);
    for(int i = 0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        merge(a,b);
    }
    ll ans = 0;
    for(int i = 1;i<=n;i++){
        if(fa[i] == i) ans = max(ans,sz[i]);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  cout<<n/3<<endl;
  return 0;
}


Measured memory_bytes: 256