akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int n, a[10000], cnt, turn;
int main() {
	while (true) {
		turn = 0; cnt = 31;
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		cout << "31" << endl;
		while (cnt >= a[turn%n]) {
			cnt -= a[turn%n];
			turn++;
			if (cnt == 0) { break; }
			cout << cnt << endl;
			cnt -= (cnt + 4) % 5;
			cout << cnt << endl;
		}
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
#define int long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pr;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int>p(m);
    vector<int>y(m);
    vector<int>jun(m);
    vector<vector<pr>>v(n+5);
    for(int i=0;i<m;i++){
        cin>>p[i]>>y[i];
        if(n<p[i]){exit(1);}
    }
    for(int i=0;i<m;i++){
        v[p[i]].push_back(make_pair(y[i],i));
    }
    for(int i=1;i<=n;i++){
        sort(v[i].begin(),v[i].end());
    }
    for(int i=1;i<=n;i++){
        int x=1;
        for(auto itr=v[i].begin();itr!=v[i].end();itr++){
            jun[(*itr).second]=x;
    //        cout<<x<<endl;
            x++;
        }
    }
    vector<string> ans;
    for(int i=0;i<m;i++){
        string s=to_string(1000000*p[i]+jun[i]);
        string t;
        for(int j=0;j<12-s.length();j++){
            t=t+"0";
        }
        cout<<t+s<<endl;
    }

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans=0;
    ll sum=0;
    for(int i = 0; i < n-1; i++)
    {
        sum+=(ll)a[i];
        if(sum*2<a[i+1]){
            ans=i+1;
        }
    }
    cout << n-ans << endl;
}

Measured memory_bytes: 640
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Magic_ {
    int damage; /* 威力 */
    int mp;     /* 魔力消費 */
} Magic;

void calc_consumed_mp (int enemy_hp, Magic magic, long long consumed_mp[]) {
    int i;

    for ( i=1; i<=enemy_hp; i++ ) {
        if ( i <= magic.damage ) {
            /* 一撃で倒せる */
            if ( consumed_mp[i] > magic.mp )
                consumed_mp[i] = magic.mp;
        }
        else {
            /* 複数攻撃が必要 */
            if ( consumed_mp[i] > consumed_mp[i-magic.damage]+magic.mp )
                consumed_mp[i] = consumed_mp[i-magic.damage]+magic.mp;
        }
    }
}

int main (void) {
    int h, n, i;
    scanf("%d%d", &h, &n);
    Magic magic[n];
    long long consumed_mp[h+1];
    consumed_mp[0] = 0;
    for ( i=1; i<=h; i++ )
        consumed_mp[i] = LLONG_MAX;
    for ( i=0; i<n; i++ ) {
        scanf("%d%d", &magic[i].damage, &magic[i].mp);
        calc_consumed_mp(h, magic[i], consumed_mp);
    }

    printf("%lld\n", consumed_mp[h]);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()!=b.size()){
        if(a.size()>b.size())cout<<"GREATER"<<endl;
        else cout<<"LESS"<<endl;
    } else {
        for(int i=0;i<a.size();i++){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            } else if(a[i]<b[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}

int main() {
  
  int n, k; cin>>n>>k;
  ld a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  ld lf = 0.00, ri = 1e10;
  for(int i=0;i<200;i++){
    ld md = (lf + ri) / 2; // 長さmd以下にするには何個にする？
    // 何個にする→2.3個にするなら、3個で、仕切りは2個
    ll p = 0;
    for(int j=0;j<n;j++) {
      p += a[j] / md;
    }
    if (p <= k) ri = md;
    else lf = md;
    //cout << p << " " << md << endl;
  }
  /*
  ld lf; cin>>lf;
  ll p1 = lf;
  ll p2 = p1 + 1;
  //ll p0 = p1 -1;
  if (abs(lf - p1) < abs(lf - p2)) {
    cout<<p1<<endl;
  } else {
    cout<<p2<<endl;
  }
  cout<<(int)round(lf)<<endl;*/
  lf -= 1e-7;
  cout<<(int)ceil(lf)<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++) cin >> L[i];
  sort(L.begin(),L.end());
  
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i]) continue;
        if(L[k] < L[i]+L[j]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
void ex(int &a,int &b)
{
	int tem;
	tem = a;
	a = b;
	b = tem;
}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a > b)	ex(a,b);
	if(a > c)	ex(a,c);
	if(b > c)	ex(b,c);
	printf("%d\n",c-a);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	cout<<(a*b)<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

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







Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

Measured memory_bytes: 33180
n = gets.to_i
x = gets.chomp.split(" ").map(&:to_i)
ans = 10000000
for i in 1..100
  sum = 0
  for j in 0..n-1
    sum += (i - x[j]) * (i - x[j])
  end
  ans = sum < ans ? sum : ans
end

puts ans

Measured memory_bytes: 1788
#!/usr/bin/env python3

N, A, B = map(int, input().split())

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B == N:
    print(A)
elif A + B > N and N >= A:
    print(A)
elif A + B > N and N < A:
    print(N)
# 8 10 4
# bbbbbbbb bbrrrr
else:
    r = int(N / (A+B))
    q = N % (A+B)
    if (q <= A):
        print(r * A + q)
    else:
        print(r * A + A)

# 8 1 4
# brrrrbrr rr

# -----
# 8 4 2
# bbbbrrbb bb

# 13 4 2
# bbbb rr bbbb rr b

# 2 4 2
# bb

# r = N / (A+B)
# q = N % (A+B)
# r * A + q


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

using namespace std;

const int N = 3e3 + 7;
const int mod = 1e9 + 7;

double dp[N][N];

int main() {
	int n;
	cin >> n;
	dp[0][0] = 1;
	for ( int i = 0; i < n; i++ ) {
		double p;
		cin >> p;
		for ( int j = 0; j <= i; j++ ) {
			dp[i + 1][j + 1] += dp[i][j] * p;
			dp[i + 1][j] += dp[i][j] * (1.0 - p);
		}
	}
	double ans = 0;
	for ( int i = (n + 1) / 2; i <= n; i++ ) {
		ans += dp[n][i];
	}
	cout << fixed << setprecision(15) << ans;
}

Measured memory_bytes: 68992
//import java.lang.Math;
import java.util.*;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;

class Main{

	public static void main(String[] arg) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] demo = new int[n];
		for (int i = 0; i < n; i++) {
			demo[i] = sc.nextInt();

		}

		int m = sc.nextInt();
		
		for (int i = 0; i < m; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			int cnt =0;
			int key=sc.nextInt();
			for(int j=a;j<b;j++){
				
				if(key==demo[j]) cnt++;
				
			}
			System.out.println(cnt);

		}

	}
}


Measured memory_bytes: 36908
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a),c(a),d(a);
  For(i,0,a)
    ci(b[i]>>c[i]>>d[i]);
  string an="Yes";
  For(i,0,a){
    ll ans=c[i]+d[i];
    //co(ans);
    if((ans%2==1&&b[i]%2==0)||(ans%2==0&&b[i]%2==1)){
      an="No";
      break;
    }
    if(ans>b[i]){
      an="No";
      break;
    }
  }
  co(an);
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

constexpr double EPS = 1e-8;

struct state {
	double a, b;

	state(double a_, double b_):a(a_), b(b_) {}

	bool operator<(const state &s) const {
		return a + EPS < s.a || (abs(a - s.a) < EPS && b + EPS < s.b);
	}
};

typedef pair<double, state> P;

inline double calc(double p1, double q1, double p2, double q2, double q) {
	if(q1 == q2) return p2;
	return (q - q1) / (q2 - q1) * (p2 - p1) + p1;
}

double dijkstra(const vector<int> &x, const vector<int> &y) {
	const int n = x.size();
	const state start(x.front(), x.back());

	map<state, double> dist;
	priority_queue<P, vector<P>, greater<P>> que;

	dist[start] = 0;
	que.push({0, start});

	while(!que.empty()) {
		const auto d = que.top().first;
		const auto s = que.top().second;
		que.pop();

		if(dist[s] + EPS < d) continue;
		if(abs(s.a - s.b) < EPS) return d;

		double a = s.a;
		double b = s.b;

		for(const bool &change : {false, true}) {
			const int curr_a = upper_bound(begin(x), end(x), static_cast<int>(a)) - begin(x) - 1;
			const int curr_b = upper_bound(begin(x), end(x), static_cast<int>(b)) - begin(x) - 1;

			const double py = (abs(a - x[curr_a]) < EPS ? y[curr_a] : y[curr_b]);

			for(const int &da : {-1, 1}) {
				int next_a = curr_a + da;
				if(da == -1 && !(abs(x[curr_a] - a) < EPS)) next_a = curr_a;
				if(next_a < 0 || next_a >= n) continue;

				const bool up = (py <= y[next_a]);

				for(const int &db : {-1, 1}) {
					int next_b = curr_b + db;
					if(db == -1 && !(abs(x[curr_b] - b) < EPS)) next_b = curr_b;

					bool ok = false;
					if(0 <= next_b && next_b < n) {
						if(up) ok = (y[next_a] <= y[next_b]);
						else   ok = (y[next_a] >= y[next_b]);
					}

					if(!ok && abs(py - y[next_a]) < EPS && abs(x[curr_b] - b) < EPS) {
						ok = true;
						next_b = curr_b;
					}

					if(ok) {
						const double ny = y[next_a];

						double ax = x[next_a];
						double bx = calc(b, py, x[next_b], y[next_b], ny);

						const double next_d = d + hypot(ax - a, ny - py) + hypot(bx - b, ny - py);

						if(change) swap(ax, bx);
						const state next_s(ax, bx);

						if(!dist.count(next_s) || dist[next_s] - EPS > next_d) {
							dist[next_s] = next_d;
							que.push({next_d, next_s});
						}
					}
				}
			}

			swap(a, b);
		}
	}
	assert(false);
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n; cin >> n && n;) {
		vector<int> x(n), y(n);

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

		cout << dijkstra(x, y) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1616
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
  double x1,y1;//(x1,y1)
  double x2,y2;//(x2,y2)
  cin >> x1 >> y1 >> x2 >> y2;
  cout <<fixed<<setprecision(12) <<sqrt(pow((x2-x1),2)+pow((y2-y1),2)) << endl;

  }

Measured memory_bytes: 1284
import numpy as np
N, K = map(int, input().split())
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1, N):
    s = max(i-K, 0)
    dp[i] = np.min(dp[s:i]+np.abs(H[s:i]-H[i]))


print(dp[-1])


Measured memory_bytes: 22832
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n,a; cin >> n >> a;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    //i := i枚目
    // j := j枚使う
    // k := 合計値
    vvvl dp(n+1,vvl(n+1, vl(2600,0)));
    // rep(i,n+1) dp[i][0][0] = 1;
    dp[0][0][0] = 1;
    //配る
    rep(i,n){
        // if(!i)continue;
        rep(j,i+1){
            // if(!j)continue;;
            rep(k,2500){
                if(dp[i][j][k]){
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                    dp[i+1][j][k] += dp[i][j][k];
                }
            }
        }
    }

    // rep(i,6+1){
    //     rep(j,i+1){
    //         rep(k,30){
    //             print(i,j,k, dp[i][j][k]);
    //         }
    //     }
    // }

    ll res = 0;
    rep(j,n+1){
        if(!j)continue;
        res += dp[n][j][j*a];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 54272
#include <stdio.h>
int main(){
	int x, y, i, j, k;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)break;
		for(i = 0; i < x; i++){
			for(j = 0; j < y; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
using namespace std;
 
class Node{
public:
  Node* prev;
  Node* next;
  int data;
  Node(){
    prev=0;
    next=0;
    data=0;
  }
};
 
class List{
private:
  Node head;
public:
  List(){
    head.next=&head;
    head.prev=&head;
  }
  int insert(int a){
    Node* p = new Node();
 
    if(p==0){
      return -1;
    }
 
    Node* q = &head;
    Node* r = head.next;
 
    p->prev = q;
    p->next = r;
    p->data = a;
 
    q->next = p;
    r->prev = p;
 
    return 0;
  }
 
  int del(int a){
    Node* p;
 
    for(p=head.next;p!=&head;p=p->next){
      if(p->data==a){
        break;
      }
    }
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  int deleteFirst(){
    Node* p = head.next;
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  int deleteLast(){
    Node* p = head.prev;
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  void print(){
    for(Node* p=head.next;p!=&head;p=p->next){
      cout << p->data;
 
      if(p->next!=&head){
        cout << ' ';
      }else{
        cout << endl;
      }
    }
  }
};
 
int main(){
  List L;
 
  int n;
  cin >> n;
 
  for(int i=0;i<n;i++){
    char com[20];
    cin >> com;;
 
    if(com[0]=='i'){
      int x;
      cin >> x;
 
      L.insert(x);
    }else if(com[6]=='F'){
      L.deleteFirst();
    }else if(com[6]=='L'){
      L.deleteLast();
    }else{
      int x;
      cin >> x;
 
      L.del(x);
    }
  }
 
  L.print();
 
  return 0;
}


Measured memory_bytes: 34316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(non_snake_case, unused_variables)]
fn main() {
    input!{
        N: usize,
    }
    let mut ans: usize = 0;
    for i in 1..N+1 {
        if i%2==0 {
            continue;
        }
        let mut cnt: usize = 0;
        for tmp in 1..i+1 {
            if i%tmp==0 {
                cnt += 1;
            }
        }
        if cnt==8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void print(std::vector<int> const &input)
{
	for (int i = 0; i < input.size(); i++) {
		std::cout << input.at(i) << ' ';
	}
}

signed main(void){
    int K,temp=0;
    cin >> K;
    int sum=0;
    vector<int> p;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            if(i==1|| j==1){
                p.pb(1);
            }else if(i==j){
                p.pb(i);
            }else{
                p.pb(gcd(i,j));
            }
        }
    }
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K*K;j++){
            if(i==1 || p[j-1]==1){
                sum++;
            }else if (i == p[j-1])
            {
                sum += i;
            }else{
                sum += gcd(i,p[j-1]);
            }
            // cout <<"j="<< j <<endl;
        }
        // cout <<"i="<< i <<endl;
    }
    // print(p);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, Y;
  cin >> N >> Y;

  rep(i, 2001) {
    rep(j, 2001) {
      ll k = N - i - j;
      if (k < 0) {
        continue;
      }

      ll price = 10000 * i + 5000 * j + 1000 * k;
      ll maisu = i + j + k;
      if (maisu == N && price == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long ll;

ll N,A,B;

int main(){
	cin >> N >> A >> B;
	if(A>B) cout << 0 << endl;
	else if(N==1){
		cout << (A==B? 1:0) << endl;
	}
	else if(N==2) cout << 1 << endl;
	else if(A==B) cout << 1 << endl;
	else cout << (N-1)*B+A-(N-1)*A-B+1 << endl;
}

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

int main(){

    while(1){
        int n,m;
        cin >>n >> m;
        if(n==0&&m==0){
            break;
        }
        vector<vector<int>> a(m);

        for(int i=0;i<n;i++){
            int d,v;
            cin >> d >> v;
            d--;
            a[d].push_back(v);
        }
        int ans=0;
        for(int i=0;i<m;i++){
            sort(a[i].begin(),a[i].end());
            ans+=a[i].back();
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,N,E;
int to[200001],fir[200001],nex[200001],flag[200001],size[200001][2];
bool co[200001],gg[200001];
void add(int x,int y)
{
	to[++E]=y;nex[E]=fir[x];fir[x]=E;
}
void dfs(int now)
{
	size[N][co[now]]++;
	flag[now]=N;
	for(int i=fir[now];i;i=nex[i])
	if(flag[to[i]]==N)
	{
		if(co[to[i]]==co[now])
			gg[N]=1;
	}
	else
	if(!flag[to[i]])
		co[to[i]]=!co[now],dfs(to[i]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x,&y),
		add(x,y),add(y,x);
	for(int i=1;i<=n;i++)
	if(!flag[i]) ++N,dfs(i);
	long long ans=0;
	for(int i=1;i<=N;i++)
	if(gg[i])
		ans+=(long long)(size[i][0]+size[i][1])*(size[i][0]+size[i][1]-1)/2;
	else
		ans+=(long long)size[i][0]*size[i][1];
	printf("%lld\n",ans-m);
	return 0;
 } 

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var A = item[0];
            var B = item[1];

            var answer = -1;
            foreach (var i in Enumerable.Range(1, 1250))
            {
                if ((int)(i * 0.08) == A && (int)(i * 0.10) == B)
                {
                    answer = i;
                    break;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        int inputA = Integer.parseInt(input.split(" ")[0]);
        int inputB = Integer.parseInt(input.split(" ")[1]);
        int inputC = Integer.parseInt(input.split(" ")[2]);
        if(inputA >= inputB && inputA >= inputC){
            System.out.println(inputA * 10 + inputB + inputC);
        }else if(inputB >= inputA && inputB >= inputC){
            System.out.println(inputB * 10 + inputA + inputC);
        }else{
            System.out.println(inputC * 10 + inputA + inputB);
        }
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int G = 5;
const int N = 1 << 20;
const int mod = 924844033;

int n, E;
int fir[N], nex[N], arr[N];
LL A[N], B[N], fac[N], inv[N], fav[N], res[N];

inline void Add_Edge(int x, int y) {
	nex[++E] = fir[x];
	fir[x] = E; arr[E] = y;
}

LL Qpow(LL x, int p) {
	LL ans = 1;
	while (p) {
		if (p & 1) ans = ans * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return ans;
}

LL Inv(LL x) {
	return Qpow(x, mod - 2);
}

LL C(int x, int y) {
	if (x < y) return 0;
	return fac[x] * fav[y] % mod * fav[x - y] % mod;
}

namespace init {
	int siz[N], num[N];

	void dfs(int x, int fa) {
		siz[x] = 1;
		for (int i = fir[x]; i; i = nex[i]) {
			if (arr[i] == fa) continue;
			dfs(arr[i], x);
			++num[siz[arr[i]]];
			siz[x] += siz[arr[i]];
		}
		++num[n - siz[x]];
	}
	
	void main() {
		dfs(1, 0);
		fac[0] = fav[0] = 1;
		inv[1] = fav[1] = fac[1] = 1;
		for (int i = 2; i < N; ++i) {
			inv[i] = -mod / i * inv[mod % i] % mod + mod;
			fac[i] = fac[i - 1] * i % mod;
			fav[i] = fav[i - 1] * inv[i] % mod;
		}
		for (int i = 0; i <= n; ++i) {
			A[i] = num[i] * fac[i] % mod;
			if (A[i] < 0) A[i] += mod;
			B[i] = fav[n - i];
 		}
	}
}

namespace convolution {
	int rev[N];

	void NTT(LL *a, int lim, int type) {
		for (int i = 0; i < lim; ++i) {
			if (i < rev[i]) swap(a[i], a[rev[i]]);
		}
		for (int len = 2; len <= lim; len <<= 1) {
			int mid = len >> 1;
			LL Wn = Qpow(G, (mod - 1) / len);
			if (type == -1) Wn = Inv(Wn);
			for (int i = 0; i < lim; i += len) {
				LL W = 1;
				for (int j = 0; j < mid; ++j) {
					LL x = a[i + j], y = a[i + j + mid] * W % mod;
					a[i + j] = (x + y >= mod) ? (x + y - mod) : (x + y);
					a[i + j + mid] = (x < y) ? (x + mod - y) : (x - y);
					W = W * Wn % mod;
				}
			}
		}
		if (type == -1) {
			LL tmp = Inv(lim);
			for (int i = 0; i < lim; ++i) {
				a[i] = a[i] * tmp % mod;
			}
		}
	}

	
	void Solve() {
		int lim = 1, l = 0;
		while (lim < n + n + 2) lim <<= 1, ++l;
		for (int i = 1; i < lim; ++i) {
			rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << l - 1);
		}
		NTT(A, lim, 1); NTT(B, lim, 1);
		for (int i = 0; i < lim; ++i)
			A[i] = A[i] * B[i] % mod;
		NTT(A, lim, -1);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		Add_Edge(x, y);
		Add_Edge(y, x);
	}
	init::main();
	convolution::Solve();
	for (int i = 1; i <= n; ++i) {
		LL tmp = C(n, i) * n % mod;
		tmp = tmp - fav[i] * A[i + n] % mod;
		if (tmp < 0) tmp += mod;
		printf("%lld\n", tmp);
	}
	return 0;
}


Measured memory_bytes: 61312
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        System.out.println(comp(scan.nextInt() , scan.nextInt()));
    }

    /**
     * 比較して結果を返します。
     */
    private static String comp(int a, int b) {
        if (a == b) {
            return "a == b";
        } else if (a > b) {
            return "a > b";
        } else if (a < b) {
            return "a < b";
        } else {
            return null;
        }
    }
}

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

int main(void)
{
    int n,c=0; cin>>n;
    vector<int> color(9,0);
    rep(i,n){
        int a; cin>>a;
        if(a<3200) color[a/400]++;
        else color[8]++;
    }
    rep(i,8) if(color[i]) c++;
    if(c) cout << c;
    else cout << 1;
    cout << " " << c+color[8] << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <vector>

#define fin stdin
#define fout stdout
//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");

#define MOD 1000000007

#define MAXN 520

int ans[MAXN][MAXN];

int k;

void solve(std::vector < int > &a) {
    if (a.size() == 1)
        return ;
    bool avem = 0;
    if (a.size() % 2) {
        k++;
        avem = 1;
        for (auto &x : a)
            ans[x][a.back()] = k;
        a.pop_back();
    }

    k++;
    for (int i = 0; i < (int)a.size(); i++)
        for (int j = 0; j < (int)a.size(); j++)
            if (i % 2 != j % 2)
                ans[a[i]][a[j]] = k;

    std::vector < int > par, impar;
    for (int i = 0; i < (int)a.size(); i += 2)
        par.push_back(a[i]);
    for (int i = 1; i < (int)a.size(); i += 2)
        impar.push_back(a[i]);

    solve(par);
    solve(impar);

    k--;

    k -= avem;
}

int main() {
    int n;
    fscanf(fin, "%d", &n);

    int noulN = 1;
    while (noulN < n)
        noulN *= 2;

    std::vector < int > v(noulN);
    for (int i = 0; i < noulN; i++)
        v[i] = i + 1;

    solve(v);

    for (int i = 1; i <= n; i++, fprintf(fout, "\n"))
        for (int j = i + 1; j <= n; j++)
            fprintf(fout, "%d ", std::max(ans[i][j], ans[j][i]));

    fclose(fin);
    fclose(fout);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long> vx(N), vy(N), vh(N);
	int si = -1;
	for (int i = 0; i < N; ++i) {
		cin >> vx[i] >> vy[i] >> vh[i];
		if (vh[i] > 0) si = i;
	}
	
	long long resx = -1, resy = -1, resh = -1;
	for (long long x = 0; x <= 100; ++x) {
		for (long long y = 0; y <= 100; ++y) {
			long long h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
			bool ok = true;
			for (int i = 0; i < N; ++i) {
				if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
				if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
			}
			if (ok) resx = x, resy = y, resh = h;
		}
	}
	cout << resx << " " << resy << " " << resh << endl;
}


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

using namespace std;

#define foorp(i , a , n) for (int (i) = (a); (i) < (n); (i)++)
#define foorm(i , a , n) for (int (i) = (a); (i) > (n); (i)--)
#define ll long long int

const int maxn = 220;
int sum , n , a[maxn];

int main()
{
    cin >> n;
    n *= 2;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort (a, a + n);
    for (int i = 0; i < n; i += 2)
        sum += min(a[i] , a[i + 1]);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,x[4];
  cin>>n;
  for(int i=3;i>=0;i--){
    x[i]=n%10;
    n/=10;
  }
  const int N=7;
  if(x[0]+x[1]+x[2]+x[3]==N)cout<<x[0]<<"+"<<x[1]<<"+"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
  else if(x[0]+x[1]-x[2]+x[3]==N)cout<<x[0]<<"+"<<x[1]<<"-"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
  else if(x[0]+x[1]+x[2]-x[3]==N)cout<<x[0]<<"+"<<x[1]<<"+"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
  else if(x[0]+x[1]-x[2]-x[3]==N)cout<<x[0]<<"+"<<x[1]<<"-"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
  else if(x[0]-x[1]+x[2]+x[3]==N)cout<<x[0]<<"-"<<x[1]<<"+"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
  else if(x[0]-x[1]-x[2]+x[3]==N)cout<<x[0]<<"-"<<x[1]<<"-"<<x[2]<<"+"<<x[3]<<"=7"<<endl;
  else if(x[0]-x[1]+x[2]-x[3]==N)cout<<x[0]<<"-"<<x[1]<<"+"<<x[2]<<"-"<<x[3]<<"=7"<<endl;
  else if(x[0]-x[1]-x[2]-x[3]==N)cout<<x[0]<<"-"<<x[1]<<"-"<<x[2]<<"-"<<x[3]<<"=7"<<endl;

  return 0;
}


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

int poww(int a, int b)
{
    int ans = 1;
    for (int i = 0; i < b; i++)
    {
        ans *= a;
    }

    return ans;
    
}

int keta(int a)
{
    int ans = 0;
    while (a != 0)
    {
        a /= 10;
        ans++;
    }

    return ans;
    
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> hokan(9, vector<int>(9, 0));
    int ans = 0;

    for (int i = 1; i <= N; i++)
    {
        if (i%10 == 0)
        {
            continue;
        }
        
        hokan.at(i/poww(10,keta(i)-1)-1).at(i%10-1) ++;
    }

    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            ans += hokan.at(i).at(j) * hokan.at(j).at(i);
        }
        
    }

    cout << ans;

    


}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        // AGC 008 Simple Calculator
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt() - 1;
        long a = sc.nextInt();
        long b = sc.nextInt();

        if (a > b) {
            System.out.println(0);
            return;
        }
        if (n == 0 && a != b) {
            System.out.println(0);
            return;
        }

        long min = n * a + b;
        long max = a + n * b;

        System.out.println(max - min + 1);
    }
}

Measured memory_bytes: 24276
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

ll cnt[65][35];

int main()
{
    int n; scanf("%d", &n);
    ll int_cnt = 0;
    for (int i = 1; i <= n; i++) {
        char s[40]; scanf("%s", s);
        ll val = 0;
        bool after_dec = false; int after_dec_cnt = 0;
        for (int x = 0; s[x]; x++) {
            if (s[x] >= '0' && s[x] <= '9') {
                val *= 10LL; val += (ll)(s[x] - '0');
            }
            if (after_dec) after_dec_cnt++;
            if (s[x] == '.') after_dec = true;
        }
        for (int x = 1; x <= 9 - after_dec_cnt; x++) {
            val *= 10LL;
        }
        if (val % 1000000000LL == 0) int_cnt++;
        int two_cnt = 0; int five_cnt = 0;
        while (val % 2LL == 0) {
            two_cnt++; val /= 2LL;
        }
        while (val % 5LL == 0) {
            five_cnt++; val /= 5LL;
        }
        //printf("%d %d\n", two_cnt, five_cnt);
        cnt[two_cnt][five_cnt]++;
    }
    ll ans = 0;
    for (int i = 0; i <= 60; i++) {
        for (int j = 0; j <= 30; j++) {
            for (int k = 0; k <= 60; k++) {
                for (int l = 0; l <= 30; l++) {
                    if (i + k >= 18 && j + l >= 18)
                        ans += cnt[i][j] * cnt[k][l];
                }
            }
        }
    }
    ans -= int_cnt;
    ans /= 2LL;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[]S = s.split(" ");
        sc.close();
        int a = Integer.parseInt(S[0]);
        int b = Integer.parseInt(S[1]);
        int c = Integer.parseInt(S[2]);
        
        String ans = "No";

        if((c > a && c < b) || (c > b && c < a)){
            ans = "Yes";
        }
        System.out.println(ans);
    } 
}    

Measured memory_bytes: 21460
(* --------------Encoder-------------- *)
(* -----function----- *)
(*
let encoder = 0
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
(*
let decoder ans = ""
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(*
let processor dat = 0
*)

(* -------test------- *)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*
let () = print_endline (decoder (processor encoder))
*)
(* ------------------------------------ *)
let rec f lst = 
        match lst with
                [] -> 0
                | first :: rest -> 
                                let frest = f rest in
                                if first = 1 then
                                        1 + frest
                                else
                                        frest
        
let () = Scanf.scanf "%1d %1d %1d" (fun a b c -> f [a; b; c])
|> Printf.printf "%d\n"


Measured memory_bytes: 384
n = int(input())
p = list(map(int, input().split()))
count = 0
for idx in range(1, n - 1):
	three = [p[idx-1], p[idx], p[idx+1]]
	if(p[idx] != min(three) and p[idx] != max(three)):
		count += 1
print(count)

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

int main(){
    
    int i_input_s;
    int i_h, i_m, i_s;
    
    cin >> i_input_s;
    
    if(i_input_s < 0 || i_input_s >= 86400){
        return 1;
    }
    
    i_h = i_input_s / 3600;
    i_input_s -= i_h * 3600;
    i_m = i_input_s / 60;
    i_s = i_input_s % 60;
    
    cout << i_h << ":" << i_m << ":" << i_s << endl;
    
    return 0;
}


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

#define ll long long
#define M 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl;
#define foi(a,b) for(int i=a;i<b;i++)
#define foj(a,b) for(int j=a;j<b;j++)
#define fod(a,b) for(int i=a;i>b;i--)
#define MAX  1e9
#define MIN -1e9
#define nl cout<<"\n";
#define show(arr,a,b) for(int i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl;
#define  mp(a,b) pair<ll,ll> p(a,b)
#define pb push_back
typedef pair<ll,ll> p1;
typedef vector<ll> vecd;
typedef vector<string> vecsd;
typedef map<ll,ll> mpd;
typedef set<ll> setd;
typedef multiset<ll> msetd;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    ll a[n],b[n],c[n],dp[n][3];
    foi(0,n){
        cin>>a[i]>>b[i]>>c[i];
        dp[i][0]=a[i];
        dp[i][1]=b[i];
        dp[i][2]=c[i];
    }
    foi(1,n){
        dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
    return 0;
}


Measured memory_bytes: 4992
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

n = int(ri())
a = Ri()

dic = {}
cnt = 0
for i in range(len(a)):
    if (i+1)-a[i] > 0 and (i+1)-a[i] in dic:
        cnt+=dic[(i+1)-a[i]]

    if i+1+a[i] in dic:
        dic[i+1+a[i]]+=1
    else:
        dic[i+1+a[i]] = 1
print(cnt)


Measured memory_bytes: 118820
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
vector<int> vec[MAXN];
int rt[MAXN],n,a[MAXN],b[MAXN],alim,blim;
int findrt(int x){return rt[x]==x?rt[x]:rt[x]=findrt(rt[x]);}
int pre[MAXN],inv[MAXN];
int ans,tot;
void get(int u,int t)
{
	int o=-1;
	while(o+1<vec[u].size()&&vec[u][o+1]+t<=blim)++o;
	if(o!=-1)//与其他的连上了
	{
		while(o+1<vec[u].size()&&vec[u][o+1]+vec[u][0]<=alim)++o;
		tot+=o+1;ans=1LL*ans*inv[o+1]%mod;
	}
}
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();alim=read(),blim=read();
//	for(int i=1;i<=n;i++)rt[i]=i;
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		vec[a[i]].push_back(b[i]);	
	}
	int mn1=(1<<31-1),mn2=(1<<31-1);ans=1;
	for(int i=1;i<=n;i++)sort(vec[i].begin(),vec[i].end());
	for(int i=1;i<=n;i++)if(vec[i].size())
	{
		int u=vec[i][0];
		if(u<=mn1)swap(mn1,mn2),mn1=u;
		else if(u<=mn2)mn2=u;
	}
	for(int i=1;i<=n;i++)if(vec[i].size())get(i,mn1==vec[i][0]?mn2:mn1);
	ans=1LL*ans*pre[tot]%mod;
	pr2(ans);
//	int ans=1;
//	for(int i=1;i<=n;i++)if(rt[i]==i)
//	{
//		int tot=0;
//		for(int j=1;j<=30;j++)tot+=col[i][j];
//		ans=1LL*ans*pre[tot]%mod;
//		for(int j=1;j<=30;j++)ans=1LL*ans*inv[col[i][j]]%mod;
//	}pr2(ans);
	return 0;
}


Measured memory_bytes: 13184
#include<stdio.h>
#include<string.h>
int main()
{
    char a;
    int b,c,d;
    scanf("%d %c %d",&b,&a,&c);
    if(a=='+')
    {
        d=b+c;
        printf("%d\n",d);
    }
    else
    {
        d=b-c;
        printf("%d\n",d);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;
    int n = SZ(s);

    int ans = 1;
    string t;
    t.push_back(s[0]);
    for(int i = 1; i < n; i++){
        string u;
        u.push_back(s[i]);
        if(t == u){
            if(i == n - 1){
                break;
            }
            i++;
            u.push_back(s[i]);
        }
        ans++;
        t = u;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1336
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
	int n, x[100], y[100];
	double d, max;
	int i, j;


	scanf("%d", &n);
	for(i=0;i<n;i++)
		scanf("%d", &x[i]);
	for(i=0;i<n;i++)
		scanf("%d", &y[i]);


	for(i=1;i<=3;i++){
		d = 0;
		for(j=0;j<n;j++){
			d += pow(abs(x[j] - y[j]), i);
		}
		d = pow(d, 1.0 / i);
		printf("%f\n", d);
	}


	max = 0;
	for(i=0;i<n;i++){
		if(abs(x[i] - y[i]) > max)
			max = abs(x[i] - y[i]);
	}
	printf("%f\n", max);

	return 0;
}

Measured memory_bytes: 1268