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

int main(void) {
  int N;
  cin >> N;
  vector<Pll> v(N);
  for (int i = 0; i < N; i++) {
    long long A, B;
    cin >> A >> B;
    v[i] = Pll(B, A);
  }

  sort(v.begin(), v.end());

  long long time = 0;
  for (int i = 0; i < N; i++) {
    time += v[i].second;
    if (time > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

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

    if (2 * K - 1 <= N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 1e6 + 10;
int n, pr[MAXN], a[MAXN];
void div(int x)
{
	for (int i = 2; i*i <= x; i++)
	{
		if (x%i == 0)
		{
			pr[i] += 1;
			while (x%i == 0)
				x /= i;
		}
	}
	if (x > 1)
		pr[x] += 1;
}
int main()
{
//	freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		div(a[i]);
	}
	int flag = 0;
	for (int i = 1; i <= 1e6; i++)
	{
		if (pr[i] > 1)
			flag = 1;
		if (pr[i] == n)
		{
			flag = 2;
			break;
		}
	}
	if (flag == 0)
		printf("pairwise coprime\n");
	else if (flag == 1)
		printf("setwise coprime\n");
	else
		printf("not coprime\n");
	return 0;
}


Measured memory_bytes: 11416
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

string s;
void in(){
    cin >> s;
}

void solve(){
    
    int ans = 0;
    int i = 0;
    int n = sz(s);

    while(i < n){
        
        int cnt = 0;
        int j = i;
        while(j < n && (s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G')){
            cnt++;
            j++;
        }
        
        chmax(ans, cnt);
        if(i == j){
            i = j + 1;
            continue;
        }
        i = j;

    }

    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    string s;
    cin >> s;
    map<char, int> m;
    REP(i, 0, 4) {
        m[s[i]]++;
    }
    REP(i, 0, 4) {
        if (m[s[i]] != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
            cout << "Yes" << endl;

}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
//#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */



int main() {
	FAST
	int a;cin>>a;
	string s;cin>>s;
	if(a<3200){
		cout<<"red"<<endl;
	}
	else{
		cout<<s<<endl;
	}
 	return 0;
	
}

	

Measured memory_bytes: 256
N,Y = map(int,input().split())
ans = [-1,-1,-1]

for i in range(N+1):
    for j in range(N-i+1):
            if i*10000 + j*5000 + (N-i-j)*1000 == Y:
                ans = [i,j,N-i-j]

print(*ans)

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

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

    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vi vector <int>
#define pi pair <int, int>

vector <vector <pi> > adj;
vi val;
int n;

void input()
{
	int x, y, w;
	cin >> n;
	adj.resize(n + 1);
	val.resize(n + 1);
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y >> w;
		adj[x].push_back(make_pair(y, w));
		adj[y].push_back(make_pair(x, w));
	}
}

void dfs(int cur = 1, int prev = 0, int w = 0)
{
	if (w % 2) val[cur] = val[prev] ^ 1;
	else val[cur] = val[prev];
	
	for (auto i: adj[cur])
		if (i.first != prev)
			dfs(i.first, cur, i.second);
}

int main()
{
	input();
	dfs();
	for (int i = 1; i <= n; i++) cout << val[i] << "\n";
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	string ans = "";
	rep(i, s.size()) {
		if (s[i] == 'B' && ans.size()) {
			ans.erase(ans.size() - 1);
		}
		else if (s[i] != 'B') {
			ans += s[i];
		}
	}
	cout << ans << endl;
}

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

int main(){
  int n;
  int d[50];
  int sum = 0;
  
  cin >> n;
  for(int i=0;i<n;i++)cin >> d[i];

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum += d[i]*d[j];
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s %s", $n, $m);
if ($n > 1 && $m > 1) {
	$x = ($n - 2) * ($m - 2);
} elseif ($n * $m == 1) {
	$x = 1;
} else {
	$x = max($n, $m) - 2;
}
echo $x;

Measured memory_bytes: 4728
N,D = map(int,input().split())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

c=0

for i in range(N):
  if (x[i]**2+y[i]**2)**0.5 <=D:
    c += 1
print(c)

Measured memory_bytes: 116600
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e5+2;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int n;
    cin>>n;
    int a[n];
    map<int,int>cnt1,cnt2;
    lp(i,0,n){
        cin>>a[i];
        if(i%2){
            cnt1[a[i]]++;
        } else
            cnt2[a[i]]++;
    }
    vector<pair<int,int>>v,x;
    for(auto i:cnt1)
        v.pb({i.S,i.F});
    for(auto i:cnt2)
        x.pb({i.S,i.F});
    sort(v.rbegin(),v.rend());
    sort(x.rbegin(),x.rend());
    int temp=v[0].F+x[0].F;
    if(v[0].S==x[0].S){
        if(sz(v)==1&&sz(x)==1)
            temp-=x[0].F;
        else if(sz(v)==1)
            temp+=-x[0].F+x[1].F;
        else if(sz(x)==1)
            temp+=-v[0].F+v[1].F;
        else
            temp-=v[0].F,temp+=max(x[1].F,v[1].F);
    }
    cout<<n-temp;
}


Measured memory_bytes: 9244
n = int(input())
#入力

res = n
for i in range(n+1):
    cc = 0
    t = i
    while t > 0:
        cc += t%6
        t = t//6
    t = n-i
    while t > 0:
        cc += t%9
        t = t//9
    if res > cc:
        res = cc

print(res)

Measured memory_bytes: 40812
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int MAXN1=301;
const int MAXN2=1e5+1;
int n,H,W,D,Q,key,Start,End;
struct place{
	int I,J;
	place(int ii=0,int jj=0) {I=ii;J=jj;}
}num[MAXN1*MAXN1];
int dp[MAXN1*MAXN1];
inline int getdist(int x,int y)
{
	return abs(num[x].I-num[y].I)+abs(num[x].J-num[y].J);
}
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	memset(dp,0,sizeof(dp));
	H=read();W=read();n=H*W;
	D=read();
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			{key=read();num[key]=place(i,j);}
	Q=read();
	for(int i=1;i<=n;++i){
		if(i<=D) dp[i]=getdist(0,i);
		else dp[i]=dp[i-D]+getdist(i-D,i);
	}
	for(int i=1;i<=Q;++i){
		Start=read();End=read();
		printf("%d\n",dp[End]-dp[Start]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    ll k; cin >> k;
    int n = s.size();
    ll ans = 0;
    if(s==string(n,s[0])) {
        ans = n*k/2;
    }
    else {
        vector<int> v;
        REP(i,n) {
            int cnt = 1;
            while(i+1<n && s[i] == s[i+1]) {
                ++ cnt;
                ++ i;
            }
            v.emplace_back(cnt);
        }
        int l = v.size();
        REP(i,l) {
            ans += v[i]/2;
        }
        ans *= k;
        if(s[0]==s[n-1]) {
            ans -= (v[0]/2 + v[l-1]/2 - ((v[0]+v[l-1])/2)) * (k-1);
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

int main()
{
    ll n, weight; cin >> n >> weight;
    vector<ll> w(n + 1), v(n + 1);
    for(int i = 1; i<= n; i++)
    {
        cin >> w[i] >> v[i];
    }

    //-----------------pull dp

    // vvll state(n+1, vll(weight + 1, LONG_LONG_MIN));

    // state[0][0] = 0;

    // for(ll i = 1; i <= n; i++)
    //     for(ll j = 0; j <= weight; j++)
    //     {
    //         state[i][j] = max(state[i-1][j], ((j >= w[i]) ? (state[i-1][j - w[i]] + v[i]) : LONG_LONG_MIN));
    //     }
    
    // ll ans = LONG_LONG_MIN;
    // for(ll j = 0; j <= weight; j++)
    //     ans = max(ans, state[n][j]);
    // cout << ans << endl;


    //-------------push dp
    ll state[2][weight + 1];
    memset(state, -63, sizeof(state));
    state[0][0] = 0;

    for(int i = 0; i < n; i++)
    {
        memset(state[(i+1)&1], -63, sizeof(state[(i+1)&1]));
        for(int j = 0; j < weight + 1; j++)
        {
            state[(i+1)&1][j] = max(state[i&1][j], state[(i+1)&1][j]);
            if(j + w[i + 1] < weight + 1)
                state[(i+1)&1][j + w[i + 1]] = max(state[i&1][j] + v[i+1], state[(i+1)&1][j + w[i + 1]]);
        }
    }
    ll ans = LONG_LONG_MIN;
    for(int j = 0; j < weight + 1; j++)
        ans = max(ans, state[n&1][j]);
    cout << ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  if(n>=0){
    vector<string> vv = {"00", "10", "01", "11"};

    string ans = vv[n%4];
    n += 2;
    n /= 4;
    while(n > 0){
      ans += vv[n%4];
      n += 2;
      n /= 4;
    }
    if(ans.size() >=2 && ans.back()=='0') ans.pop_back();
    reverse(all(ans));
    cout << ans << endl;
  } else {
    vector<string> vv = {"00", "11", "01", "10"};

    n *= -1;
    string ans = vv[n%4];
    n += 1;
    n /= 4;
    while(n > 0){
      ans += vv[n%4];
      n += 1;
      n /= 4;
    }
    if(ans.size() >=2 && ans.back()=='0') ans.pop_back();
    reverse(all(ans));
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;

#define int ll
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define sz(x) int(x.size())



signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a;
	int b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		int a,b;
		cin>>a>>b;
		ans+=b-a+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<P> a(n), b(n);
    rep(i,n) {
        cin>>a[i].first>>a[i].second;
        b[i].first = a[i].first;
        b[i].second = a[i].second;
    }
    
    sort(a.begin(), a.end(), [](const P &x, const P &y) {
        return x.first+x.second > y.first+y.second;
    });

    sort(b.begin(), b.end(), [](const P &x, const P &y) {
        return x.first-x.second > y.first-y.second;
    });

    ll max_a = a[0].first+a[0].second;
    ll min_a = a.back().first+a.back().second;
    ll max_b = b[0].first-b[0].second;
    ll min_b = b.back().first-b.back().second;
    ll A = abs(max_a-min_a);
    ll B = abs(max_b-min_b);
    cout << max(A,B) << '\n';

    return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
 int A[100005],B[100005],dp[100005][1],i,n,sum,say;

int main()
{
	
	
	
	scanf("%d",&n);
	
		
		
	
	
	printf("%d\n",3*n*n);
	
	

	
	return 0;
}

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

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,u,v,a,b,depU[100000]={0},depV[100000]={0};
vector<int> vec[100000];
void deepU(int s,int num){
	if(depU[s]==0){
		depU[s]=num;
		for(int i=0;i<vec[s].size();i++){
			deepU(vec[s][i],num+1);
		}
	}
}
void deepV(int s,int num){
	if(depV[s]==0){
		depV[s]=num;
		for(int i=0;i<vec[s].size();i++){
			deepV(vec[s][i],num+1);
		}
	}
}
int main(){
	int maxL=0;
	cin>>N>>u>>v;
	u-=1;v-=1;
	for(int i=0;i<N-1;i++){
		cin>>a>>b;
		a--;b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	
	deepU(u,1);
	deepV(v,1);
	for(int i=0;i<N;i++){
		if(depU[i]<depV[i]){
			maxL=max(maxL,depV[i]);
		}
	}
	if(maxL>0)maxL--;
	cout<<maxL-1;
	return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

std::vector<std::vector<long long>> warshall_floyd(std::vector<std::vector<long long>> dist) {
  const long long LINF = 1000000000000000018LL;
  int n = (int)dist.size();
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (dist[i][k] == LINF) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if (dist[k][j] == LINF) {
          continue;
        }
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}

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

  const long long LINF = 1000000000000000018LL;

  int N, M, L;
  std::cin >> N >> M >> L;

  std::vector<std::vector<long long>> Graph(N, std::vector<long long>(N, LINF));
  for (int i = 0; i < M; i++) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A, --B;
    Graph[A][B] = C;
    Graph[B][A] = C;
  }

  auto d = warshall_floyd(Graph);

  std::vector<std::vector<long long>> Graph2(N, std::vector<long long>(N, LINF));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (d[i][j] <= L) {
        Graph2[i][j] = 1;
        Graph2[j][i] = 1;
      }
    }
  }

  auto d2 = warshall_floyd(Graph2);

  int Q;
  std::cin >> Q;

  while (Q--) {
    int s, t;
    std::cin >> s >> t;

    long long ans = d2[s - 1][t - 1];
    std::cout << (ans == LINF ? -1 : ans - 1) << "\n";
  }

  return 0;
}

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

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

	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(M)]
b = [1] * N
p = [0] * (N + 1)
p[1] = 1
for move in m:
  b[move[0] - 1] -= 1
  b[move[1] - 1] += 1
  p[move[1]] += p[move[0]]
  if b[move[0] - 1] == 0:
    p[move[0]] = 0
res = 0
for i in range(N):
  if p[i + 1] > 0 and b[i] > 0:
    res += 1
print(res)

Measured memory_bytes: 57820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin>>h>>w;
    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = h*w/2;
    if((h%2==1) && (w%2==1)) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, m, x, y, i, ap[100005];
int main()
{
    cin >> n >> m;
    while(m--)
    {
        cin >> x >> y;
        ++ap[x];
        ++ap[y];
    }

    for(i=1; i<=n; ++i)
        if(ap[i]&1)
        {
            cout << "NO\n";
            return 0;
        }

    cout << "YES\n";

    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int mod(int a,int b)
{
if(a>b)
    return a-b;
return b-a;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    vector<int> v1(n+1);
    v1[n]=0;
    v1[n-1]=mod(v[n-1],v[n]);
    for(int i=n-2;i>0;i--)
    {
        int mn=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i+j>n)
                break;
            mn=min(mod(v[i],v[i+j])+v1[i+j],mn);
        }
        v1[i]=mn;
    }
    cout<<v1[1]<<endl;
    return 0;
}


Measured memory_bytes: 4044
//problem 11.b

#include <stdio.h>
#define M 10000
#define N 100
#define WHITE 1
#define GRAY 0
#define BLACK -2 
#define INF -1

void enq( int );
int deq( void );
void bfs( int );

int n, Q[M], adj[N+10][N+10], color[N+10], d[N+10], tail = 0, head = 0;//Q is queue, p is where queue is, and d is distance from 0 vertex to n vertex

int main(){
    int i, j, k;
    
    //initialize
    for(i = 0; i<=N; i++)
	for(j = 0; j<=N; j++)
	    adj[i][j] = -1;

    //input
    scanf("%d", &n);
    for(i = 1; i<=n; i++){//1-origin
	scanf("%d%d", &i, &k);
	for(j = 0; j<k; j++)//0-origin 
	    scanf("%d", &adj[i][j]);
    }
    //calculate
    bfs( 1 );
    //print
    for(i = 1; i<=n; i++) printf("%d %d\n",i, d[i]);
    return 0;
}

//------------------------------------------------------------------
void enq( int data ){

    if( tail == M )  tail = 0;
    Q[tail] = data;
    tail++;
    
    return ;
}

int deq( void ){
    int retval;

    if( head == M ){
	head = 0;
	retval = Q[head];
	head++;
    }
    else {
	head++;
	retval = Q[head-1];
    }

    return retval;
}

//--------------------------------------------------------------
void bfs( int start ){
    int i, j, u, v;

    //initialize
    for(i = 0; i<=n; i++){
	color[i] = WHITE;
	d[i] = INF;
    }
    color[start] = GRAY;
    d[start] = 0;
    enq( start );

    //calculate
    while(head != tail){
	u = deq();
	for(j = 0; adj[u][j] != -1; j++){
	    if( color[ adj[u][j] ] == WHITE ){
		color[ adj[u][j] ] = GRAY;
		d[ adj[u][j] ] = d[u] +1;
		enq( adj[u][j] );
	    }
	}
	color[u] = BLACK;
    }

    return ;
}



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

int dp[10005];

int main(){
	int h,n;
	cin>>h>>n;
	vector< pair<int,int> > yoyo(n);
	for(int i=0;i<n;i++){
		cin>>yoyo[i].first>>yoyo[i].second;
	}
	
	dp[0]=0;
	for(int i=1;i<h+1;i++)dp[i]=2e8;
	
	
	for(int i=0;i<n;i++){
		for(int j=1;j<h+1;j++){
			if(j<=yoyo[i].first) {
				dp[j]=min(yoyo[i].second,dp[j]);
			}
			else dp[j]=min(dp[j],yoyo[i].second+dp[j-yoyo[i].first]);
		}
	}
	
	
	cout<<dp[h]<<endl;
	
}

Measured memory_bytes: 3652
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String result = "";
		for(int i=0; i<a.length()+b.length(); i++){
			if(i%2==0){
				result += a.charAt(i/2);
			}else{
				result += b.charAt((i-1)/2);
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 39024
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  
 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 123;

int n, m, k;
vector < pii > gr[N];
int a[N];
int dp1[N] , cnt1[N], dp2[N], cnt2[N] , w[N] , v[N] , u[N];

main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int s , t;
//input
	cin >> n >> m >> s >> t;

	rep(i , 1 , n)
		dp1[i] = dp2[i] = 1e17;
	dp1[s] = dp2[t] = 0;
	cnt1[s] = cnt2[t] = 1;
	
	for(int i = 1; i <= m; i++){
		cin >> u[i] >> v[i] >> w[i];
		gr[u[i]].pb({v[i],w[i]});
		gr[v[i]].pb({u[i],w[i]});
	}
	set < pii > st;
	st.insert({0 , s});
	
	while(sz(st) != 0){
		int u = (*st.begin()).se;
		st.erase(st.begin());
		for(auto to : gr[u]){
			if(dp1[to.fi] == dp1[u] + to.se)
				cnt1[to.fi] += cnt1[u], cnt1[to.fi] %= mod;
			else if(dp1[to.fi] > dp1[u] + to.se){
				st.erase({dp1[to.fi] , to.fi});
				dp1[to.fi] = dp1[u] + to.se;
				cnt1[to.fi] = cnt1[u];
                st.insert({dp1[to.fi],to.fi});
			}
		}
	}    

	st.insert({0 , t});
	while(sz(st) != 0){
		int u = (*st.begin()).se;
		st.erase(st.begin());
		for(auto to : gr[u]){
			if(dp2[to.fi] == dp2[u] + to.se)
				cnt2[to.fi] += cnt2[u] , cnt2[to.fi] %= mod;
			else if(dp2[to.fi] > dp2[u] + to.se){
				st.erase({dp2[to.fi] , to.fi});
				dp2[to.fi] = dp2[u] + to.se;
				cnt2[to.fi] = cnt2[u];
                st.insert({dp2[to.fi],to.fi});
			}
		}
	}	
	int tot = cnt1[t] * cnt1[t]%mod;
	for(int i = 1; i <= m; i++){
		if(dp1[u[i]] + dp2[v[i]] > dp2[u[i]] + dp1[v[i]])
			swap(u[i],v[i]);
		if(dp1[u[i]] + dp2[v[i]] + w[i] == dp1[t]){
			int l = max(dp1[u[i]],dp2[v[i]]) , r = min(dp1[u[i]],dp2[v[i]])+w[i];
			if(l < r)
				tot -= cnt1[u[i]] * cnt2[v[i]] % mod * cnt1[u[i]] % mod * cnt2[v[i]] % mod , tot += mod , tot %= mod;
		}
	}

	for(int i = 1; i <= n; i++)
		if(dp1[i] + dp2[i] == dp1[t] and dp1[i] == dp2[i])
			tot -= cnt1[i] * cnt2[i] % mod * cnt1[i] %mod * cnt2[i] % mod , tot += mod , tot %= mod;


	ret(tot);
        
}

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
using namespace std;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(void) {

    int k, n , dst;

    
    
    cin >> k;
    cin >> n;

    int* a_pt = new int[n];

    int stIndex = 0;
    int max = 0 , max_c = 0 , sum = 0;

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

    for (int i = 0; i < n; i++ ) {
        
        if (i == n - 1) {
            max_c = k - a_pt[i] + a_pt[0];
        }else{
            max_c = a_pt[i + 1] - a_pt[i];
        }
        
        sum = sum + max_c;

        if (max_c > max) {
            max = max_c;
        }
    }
    
    sum = sum - max;


    cout << sum;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)

	var cost int
	if A >= 13 {
		cost = B
	} else if A <= 12 && A >= 6 {
		cost = B / 2
	} else {
		cost = 0
	}

	fmt.Printf("%d\n", cost)

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){

  int a,b,n,m,flag;
  
  cin >> m;
  for(int j=0;j<m;j++){
    a = b = flag = 0;
    for(int i=0;i<10;i++){
      
      cin >> n;
      
      if(a<n&&b>n) a=n;
      else if(a>n&&b<n) b=n;
      
      else if(a<n&&b<n){
	if( (a>b)? a=n:b=n);
      }
      else flag++;
      
    }
    printf("%s\n",(flag==0)? "YES":"NO");
  }

  return (0);
}

Measured memory_bytes: 2968
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    S = SLI()
    l = len(S)
    MOD = 1000000007
    dp = [[0]*13 for _ in range(l+1)]
    dp[0][0] = 1
    mul = 1
    for i in range(l):
        s = S[-(i + 1)]
        if s == '?':
            for q in range(10):
                for j in range(13):
                    dp[i+1][(q*mul + j)%13] += dp[i][j]
                    dp[i+1][(q*mul + j)%13] %= MOD
        else:
            for j in range(13):
                k = int(s)
                dp[i+1][(k*mul + j)%13] += dp[i][j]
                dp[i+1][(k*mul + j)%13] %= MOD

        mul = mul * 10 % 13
    # print(dp[-1])
    print(dp[-1][5] % MOD)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 65272
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    long long cnt=0,m=2,a=1;
    if(n==1)
    {
        cout<<1<<NL;
        return 0;
    }
    n-=1;
    while(n--)
    {
        cnt=m+a;
        m=a;
        a=cnt;
    }
    cout<<cnt<<NL;
    return 0;
}


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

using namespace std;
 
int n[2],m[2];
map< pair<string,string> , int > memo[501][501];
vector< vector<int> > a[2];
vector< vector<string> > b[2];
 
int dfs(int p1,int p2,string s1,string s2){
        //cout << p1 << " " << p2 << " [" << s1 << "] [" << s2 << "]" << "{" << n[0] << " " << n[1] << endl;
        if(p1 == n[0]-1 && p2 == n[1]-1) return (s1 == "" && s2 == "");
		if(memo[p1][p2].count(make_pair(s1,s2))) return memo[p1][p2][make_pair(s1,s2)];

        int ans = 0;
		if(p1 <= p2 || p2 == n[1]-1){
			for(int i = 0 ; i < a[0][p1].size() ; i++){
					string x = s1 + b[0][p1][i];
					string y = s2;
					int I = 0 , J = 0;
					for( ; I < x.size() && J < y.size() && x[I] == y[J] ; ) I++ , J++ ;
					if( I == x.size() || J == y.size() ){
							
							if( I == x.size() && I == y.size() ) x = "" , y = "";
							else if( I == x.size() ) x = "" , y = y.substr(J);
							else if( J == y.size() ) x = x.substr(I) , y = "";
							
							ans = ( ans + dfs(a[0][p1][i],p2,x,y) ) % 1000000007;
					}
			}
		}
        
		if(p1 > p2 || p1 == n[0]-1){
			for(int j = 0 ; j < a[1][p2].size() ; j++){
					string x = s1;
					string y = s2 + b[1][p2][j] ;
					int I = 0 , J = 0;
					for( ; I < x.size() && J < y.size() && x[I] == y[J] ; ) I++ , J++ ;
					if( I == x.size() || J == y.size() ){
							
							if( I == x.size() && I == y.size() ) x = "" , y = "";
							else if( I == x.size() ) x = "" , y = y.substr(J);
							else if( J == y.size() ) x = x.substr(I) , y = "";
							
							ans = ( ans + dfs(p1, a[1][p2][j],x,y) ) % 1000000007;
					}
			}
		}
        return memo[p1][p2][make_pair(s1,s2)] = ans;
}
 
int main(){
        int T;cin >> T;
        while(T--){
                for(int i = 0 ; i < 2 ; i++){
                        cin >> n[i] >> m[i];
                        //cout << n[i] << " " << m[i] << endl;
                        a[i].clear(); b[i].clear(); a[i].resize((unsigned)n[i]) , b[i].resize((unsigned)n[i]);
                        for(int j = 0 ; j < m[i] ; j++){
                                int A,B; string C;
                                cin >> A >> B >> C;
                                a[i][A].push_back(B);
                                b[i][A].push_back(C);
                        }
                }
				for(int i = 0 ; i < 501 ; i++)
					for(int j = 0 ; j < 501 ; j++)
						memo[i][j].clear();
                cout << dfs(0,0,"","") << endl;
        }
}

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

int main()
{
  int a1, h1, a2, h2;
  
  cin >> h1 >> a1 >> h2 >> a2;
  
  do{
    h2 -= a1;
    if(h2 <= 0){
      cout << "Yes";
      break;
    }
    h1 -= a2;
    if(h1 <= 0)
      cout << "No";
  }while(h1 > 0);
  
  return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            long[] c = new long[n-1];
            long[] s = new long[n-1];
            long[] f = new long[n-1];
            for(int i=0;i<n-1;++i)
            {
                var tmp = ReadAndParseIntArr();
                c[i] = tmp[0];
                s[i] = tmp[1];
                f[i] = tmp[2];
            }

            for(int i=0;i<n-1;++i)
            {
                long sec = CalcSec(i, c, s, f);



                Console.WriteLine(sec);
            }
            Console.WriteLine(0);
        }
        private static long CalcSec(int startStation, long[] c, long[] s, long[] f)
        {
            long time = 0;
            for(int i = startStation;i<c.Length;++i)
            {
                if(s[i] <= time && (time % f[i] == 0))
                {
                    time += c[i];
                }
                else if (time < s[i])
                {
                    time = s[i] + c[i];
                }else
                {
                    // 待ち
                    //time += (time - s[i]) % f[i];
                    time = f[i] * (long) Math.Ceiling((1.0 + time) / f[i]);
                    time += c[i];
                }
            }
            return time;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

typedef long long ll;
const int N = 100054;

int n, t;
int x[N];
ll f[N];

inline void down(ll &x, const ll y) {x > y ? x = y : 0;}

int main() {
	int i, j = 0; ll ans, r = 0x3f3f3f3f3f3f3f3fll;
	scanf("%d%lld%d", &n, &ans, &t);
	for (i = 1; i <= n; ++i) {
		for (scanf("%d", x + i); x[j + 1] < x[i] - t / 2; ++j)
			down(r, f[j] - 2 * x[j + 1]);
		down(f[i] = r + 2 * x[i], f[j] + t);
	}
	printf("%lld\n", ans + f[n]);
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int A, Z, i;
char c;
int main(){
  c=getchar();
  A=200000;
  while(c!=10){
    if(c=='A'){
      if(i<A){A=i;}
    }else if(c=='Z'){
      if(i>Z){Z=i;}
    }
    c=getchar(); i++;
  }
  printf("%d\n", Z-A+1);
}


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

// ABC 087 B
int main () {
  int a, b, c, x;
  int counter;
  cin >> a >> b >> c >> x;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) counter++;
      }
    }
  }
  cout << counter << endl;
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  
  if((A==5 && B==7 && C==5)||(A==5 && B==5 && C==7)||(A==7 && B==5 && C==5))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

}

Measured memory_bytes: 3560
fun main (args:Array<String>) {
    val money = readLine()!!.toInt()
    var happy = 0
    val numOf500yen = money / 500
    val numOf5yen = (money - (numOf500yen * 500)) / 5

    if(numOf500yen >= 1) {
        happy += numOf500yen * 1000
    }
    if(numOf5yen >= 1){
        happy += 5 * numOf5yen
    }
    print(happy)
}

Measured memory_bytes: 34528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  std::vector<int> cumulative_num_east(N);
  int min_num_return = 0;
  std::vector<int> num_return(N);
  int index_S = 0;
  int tmp_cumulative_num_east = 0;
  for (const auto& s: S) {
    if (s == 'E') {
      cumulative_num_east[index_S] = ++tmp_cumulative_num_east;
    } else {
      cumulative_num_east[index_S] = tmp_cumulative_num_east;
    }
    ++index_S;
  }
  int num_east_in_left, num_east_in_right;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      num_east_in_left = 0;
      num_east_in_right = cumulative_num_east[N-1] - cumulative_num_east[i];
    } else if (i == N) {
      num_east_in_left = cumulative_num_east[i-1];
      num_east_in_right = 0;
    } else {
      num_east_in_left = cumulative_num_east[i-1];
      num_east_in_right = cumulative_num_east[N-1] - cumulative_num_east[i];
    }
    num_return[i] = i - num_east_in_left + num_east_in_right;
  }
  std::cout << *std::min_element(num_return.begin(), num_return.end()) << std::endl;
}

Measured memory_bytes: 3076
#!/usr/bin/env python3
import sys


def solve(A: "List[int]"):
    if sum(A) >= 22:
        print('bust')
    else:
        print('win')
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


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

int main() {
    long long ans;
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N), F(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++) {
        cin >> F.at(i);
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<int>());
    long long X = 0;
    for(int i = 0; i < N; i++) {
        long long Y = (A.at(i) + 1) * F.at(i);
        X = max(X, Y);
    }
    long long l = 0, r = X;
    while(l < r) {
        long long M = (l + r) / 2;
        long long Count = 0;
        for(int i = 0; i < N; i++) {
            if(M < A.at(i) * F.at(i))
                Count += A.at(i) - M / F.at(i);
        }
        if(K >= Count)
            r = M;
        else
            l = M + 1;

        // cout << l << " " << r << endl;
    }
    ans = l;

    cout << ans << endl;
}


Measured memory_bytes: 3328
void main() {
	(N => N.iota.map!(i => readAs!ulong).array.split(0).map!(v => v.sum / 2).sum)(ri).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4220
A = list(map(int,input().split()))

# A.sort()
#
# # for i in range(len(A)):
# #     for j in range(len(A)):
# #         for k in range(len(A)):
# cnt = 0
# if A[0] != A[1] and A[0] != A[2]:
#     cnt += 1
# if A[0] !=

# a,b,c = map(int,input().split())
#
# if a!=b and a!=c and b!=c:
#     print(3)
# if

print(len(set(A)))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

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

int main(){

	int n,m,kyo,iin,de,max;
	vector<int> a,b;

	cin >> n >> m;
	
	int res[n];

	rep(i,n){
		cin >> kyo;
		a.push_back(kyo);
		res[i] = 0;
	}

	rep(i,m){
		cin >> iin;
		b.push_back(iin);
	}
	
	rep(i,b.size()){
		rep(j,a.size()){
			if(b[i] >= a[j]){ 
				res[j] += 1; 
				break;
			}
		}
	}

	//rep(i,n) cout << i+1 << "," << res[i] << endl;

	de = 1;
	max = res[1];

	rep(i,n){
		if(max <= res[i]){
			de = i + 1;
			max = res[i];
		}
	}
	
	//cout << "max:" << max << endl;

	cout << de << endl;
		
	return 0;	
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

// atcoder 解説
// https://youtu.be/TdR816rqc3s

struct UnionFind {
  // d[i] = 頂点番号iの親（の番号）
  // マイナスなら根（かつ、サイズ * -1 を示す（そうすると配列一つですむ））
  vector<int> d;

  // コンストラクタ
  // 頂点n個で初期化。最初は全部に根するので-1
  UnionFind(int n = 0) : d(n, -1) {}

  // 親の番号を返す
  int find(int x) {
    if (d[x] < 0) return x;  // 根ならそのまま頂点番号返す

    return d[x] = find(
               d[x]);  // 根じゃないなら親を返す（かつ計算量を削減のためメモ化する）
  }

  // 木と木をくっつける
  bool unite(int x, int y) {
    x = find(x);  // xの親の番号
    y = find(y);  // yの親の番号

    if (x == y) return false;  // 親が同じなら何もする必要はない

    // x のほうがサイズを大きくしたい
    if (-d[x] < -d[y]) swap(x, y);  // （*-1のサイズなので注意）

    // 小さいほうの木（y）を大きい方（x）にくっつける
    d[x] += d[y];
    d[y] = x;

    return true;
  }

  // 同じグループか
  bool same(int x, int y) { return find(x) == find(y); }

  // 頂点xのサイズ
  int size(int x) { return -d[find(x)]; }
};

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

  int n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);

  int frd[n + 10] = {};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
    frd[a]++;
    frd[b]++;
  }

  vector<int> blk[n + 10];
  for (int i = 0; i < k; i++) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    blk[c].push_back(d);
    blk[d].push_back(c);
  }

  for (int i = 0; i < n; i++) {
    int ans = uf.size(i) - 1 - frd[i];
    for (int v: blk[i]) {
      if(uf.same(i, v)) {
        ans--;
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 6784