akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int fac[100005];
int rev[100005];

int A[100005];

int N;

int mod = 1000000007;

int binpow(int x, int p, int m) {
    if (p == 0) return 1;

    if (p % 2 == 0)
        return binpow((x * x) % m, p / 2, m);
    else
        return (x * binpow(x, p - 1, m)) % m;
}

int nCr(int n, int r) {
    if (r > n) return 0;
    return ((fac[n] * rev[r]) % mod * rev[n - r]) % mod;
}

void precalc() {
    fac[0] = fac[1] = 1;
    FOR(i, 2, N + 2)
    fac[i] = (fac[i - 1] * i) % mod;

    rev[N + 1] = binpow(fac[N + 1], mod - 2, mod) % mod;
    REV(i, N) { rev[i] = (rev[i + 1] * (i + 1)) % mod; }
}

signed main() {
    cin >> N;
    REP(i, N + 1) cin >> A[i];

    map<int, int> cmap;
    REP(i, N + 1) {
        if (cmap.find(A[i]) == cmap.end()) {
            cmap[A[i]] = 1;
        } else {
            cmap[A[i]]++;
        }
    }

    int tc = 0;
    bool isMiddle = false;
    REP(i, N + 1) {
        if (cmap[A[i]] > 1) {
            isMiddle = !isMiddle;
        } else {
            if (!isMiddle) ++tc;
        }
    }

    precalc();

    FOR(i, 1, N + 2) {
        printf("%lld\n", ((nCr(N + 1, i) - nCr(tc, i - 1)) + mod) % mod);
    }

    return 0;
}


Measured memory_bytes: 9856
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<utility>


using namespace std;
using ll=long long;
ll solve(){
    ll n;ll k;
    vector<pair<ll,ll>> d;
    cin>>n>>k;
    ll M = 1e5;
    ll ret =0;
    vector<ll> l,other;
    vector<bool> did(n,false);
    for(int i=0;i<n;++i){
        int ti,di;
        cin>>ti>>di;
        d.push_back({di,ti});
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    int num = 0;
    for(int i=0;i<n;++i){
        if(i<k){
            ret += d[i].first;
            if(!did[d[i].second]){
            did[d[i].second] = true;
            num++;
            }else{
            l.push_back(d[i].first);
            }
        }else{
            if(!did[d[i].second]){
                other.push_back(d[i].first);
                did[d[i].second] = true;
            }
        }
    }
    ll cur = ret;
    ret +=1LL* num * num;
    sort(l.begin(),l.end());
    sort(other.begin(),other.end());
    reverse(other.begin(),other.end());
    int range = min(l.size(),other.size());
    l.resize(range);
    other.resize(range);
    for(int i=0;i<range;++i){
        if(i){
            l[i] += l[i-1];
            other[i] += other[i-1];
        }
        ret = max(ret,cur-l[i]+other[i]+(1LL*(num+i+1)*(num+i+1)) );
    }
    
    return ret;
}
int main(){
    cout << solve() << endl;
  return 0;
}


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

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

    if(N.at(0) == N.at(1) && N.at(1) == N.at(2) || N.at(1) == N.at(2) && N.at(2) == N.at(3)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a + b) / 2 * 2 == a + b)
    cout << (a + b) / 2;
  else
    cout << (a + b) / 2 + 1;
  cout << endl;
}

Measured memory_bytes: 256
N = int(input())
prime = []
l = [False] * (N+1)

for i in range(2, N+1):
  if l[i]: continue
  prime.append(i)
  j = 1
  while i * j <= N:
    l[i * j] = True
    j += 1

ans = 1
for i in prime:
  r = 1
  j = 1
  while i ** j <= N:
    k = 1
    while i ** j * k <= N:
      r += 1
      k += 1
    j += 1
  ans = ans * r % (10 ** 9 + 7)

print(ans)

Measured memory_bytes: 3064
n = gets.to_i
i = gets.chomp.split(" ").map(&:to_i)
if i[0]!=1 then
  i[0]-=1
end
  flag =0
(n-1).times{|t|
  if i[t]<i[t+1] then
    i[t+1]-=1
  elsif i[t]>i[t+1] then
    flag = 1;break;
  end
  }
if flag == 0 then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const string nl="\n";
const ll MOD=1000000007;

int main(){
   	string s;cin>>s;
   	int n=s.size();
   	int data[n]={};
   	int l=n-1,r=0;
   	for(int i=0;i<n;i++){
   		if(s[i]=='R'){
   			r=i;
   			// data[i]=pr;
   		}
   		else{
   			data[i]=r;
   		}
   		int j=n-1-i;
   		if(s[j]=='R'){
   			data[j]=l;
   		}
   		else{
   			l=j;
   		}
   	}
   	int ans[n][2]={};
   	for(int i=0;i<n;i++){
   		if(s[i]=='R'){
   			int moves=data[i]-i;
   			ans[data[i]][moves%2]++;
   			ans[data[i]-1][(1+moves%2)%2]++;
   		}
   		else{
   			int moves=i-data[i];
   			ans[data[i]+1][(1+moves%2)%2]++;
   			ans[data[i]][moves%2]++;
   		}
   	}
   	for(int i=0;i<n;i++){
   		cout<<ans[i][0]<<" ";
   	}
    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            break;
        }
        if(i==n-2){
            cout<<"YES"<<endl;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int att(ll H) {
	if (H == 1) {
		return 1;
	}
	else {
		return (2 * att(H / 2) + 1);
	}
}



int main() {

	ll H, an=1;
	cin >> H;
	while (H > 1) {
		an = 2 * an + 1;
		H /= 2;
	}
	cout <<an << endl;
}





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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 2");
            WillReturn.Add("#.#");
            WillReturn.Add(".#.");
            WillReturn.Add("#.#");
            WillReturn.Add("#.");
            WillReturn.Add(".#");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 1");
            WillReturn.Add("....");
            WillReturn.Add("....");
            WillReturn.Add("....");
            WillReturn.Add("....");
            WillReturn.Add("#");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int N = wkArr[0];
        int M = wkArr[1];

        var AList = new List<string>();
        for (int I = 1; I <= N; I++) {
            AList.Add(InputList[I]);
        }
        int UB_A = AList.Count - 1;

        var BList = new List<string>();
        for (int I = 1; I <= M; I++) {
            BList.Add(InputList[N + I]);
        }
        int UB_B = BList.Count - 1;

        for (int X1 = 0; X1 <= UB_A - UB_B; X1++) {
            for (int Y1 = 0; Y1 <= UB_A - UB_B; Y1++) {
                bool IsOK = true;
                for (int X2 = 0; X2 <= UB_B; X2++) {
                    for (int Y2 = 0; Y2 <= UB_B; Y2++) {
                        if (AList[Y1 + Y2][X1 + X2] != BList[Y2][X2]) {
                            IsOK = false;
                            break;
                        }
                    }
                    if (IsOK == false) break;
                }
                if (IsOK) {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}


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

int main()
{
	int n, res = 0;
	string s;
	cin >> n;
	
	unordered_map<string, int> m;
	while(n--)
	{
		cin >> s;
		if(m.count(s) == 0)
		{
			m.insert(make_pair(s, 1));
			res++;
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 17568
/// WA

#include<bits/stdc++.h>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()

using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtin() {
#ifdef ADIL    
    freopen(".in", "r", stdin);
#endif
}

const int N = 17;

int a[N][N];

ll dp[1<<N], p[1<<N];

void f(int pos, int mask, const vector<int>& nttkn, int group = 0) {
    if (pos == sz(nttkn)) {
        dp[mask] = max(dp[mask], p[group] + dp[mask^group]);
        return;
    }    
    f(pos+1, mask, nttkn, group);
    f(pos+1, mask|(1<<nttkn[pos]), nttkn, group|(1<<nttkn[pos])); 
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtin();
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    for (int mask = 0; mask < (1<<n); ++mask) 
        for (int i = 0; i < n; ++i) {
            if (!(mask & (1<<i))) 
                continue;
            for (int j = i+1; j < n; ++j) {
                if (!(mask & (1<<j))) 
                    continue;
                p[mask] += a[i][j];
            }
        }
    dp[0] = 0;
    for (int mask = 0; mask < (1<<n); ++mask) {
        vector<int> nttkn;
        for (int i = 0; i < n; ++i) {
            if (!(mask & (1<<i))) {
                nttkn.pb(i);
            }
        }
        f(0, mask, nttkn);
    }
    cout << dp[(1<<n)-1];                
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <queue>
#define LL long long
const int maxn = 2e5 + 5;
using namespace std;
int f[maxn];
int getf(int x){return x == f[x] ? x : f[x] = getf(f[x]);}
struct A{
	int a, b, id;
	bool operator<(A x)const{
		return 1ll * b * x.a > 1ll * a * x.b;
	}
	bool operator!=(A x)const{
		return a != x.a || b != x.b;
	}
}a[maxn]; LL ans = 0;
priority_queue <A> q;
int n, anc[maxn];
int main(){
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) scanf("%d", anc + i);
	for (int val, i = 1; i <= n; i++){
		scanf("%d", &val);
		f[i] = i;
		if (val == 0) a[i] = (A){1, 0, i};
		else a[i] = (A){0, 1, i};
		if (i != 1) q.push(a[i]);
	}
	while (!q.empty()){
		A t = q.top(); q.pop();
		int cur = getf(t.id);
		if (a[cur] != t) continue;
		int fa = getf(anc[cur]);
		ans += 1ll * a[fa].b * a[cur].a;
		a[fa].a += a[cur].a;
		a[fa].b += a[cur].b;
		f[getf(cur)] = f[getf(fa)];
		if (fa != 1) q.push(a[fa]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vector<int> h(n);
    rep (i, n) cin >> h[i];

    vector<int> dp(n, 0);
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(
            dp[i-1] + abs(h[i-1] - h[i]),
            dp[i-2] + abs(h[i-2] - h[i])
        );
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3960
S = input()
T = input()

sl = [0]*26
tl = [0]*26

for temp in S:
    tn = ord(temp) - ord("a")
    sl[tn] += 1

for temp in T:
    tn = ord(temp) - ord("a")
    tl[tn] += 1

sl.sort()
tl.sort()

ans = "Yes"
for n in range(26):
    if sl[n] == tl[n]:
        continue
    else:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 3632
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

LL solve(){
	LL t1, t2, a1, a2;
	{
		LL b1, b2;
		cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
		a1 -= b1;
		a2 -= b2;
	}
	LL delta = t1 * a1 + t2 * a2;
	if(delta == 0){
		return -1;
	}
	if(delta < 0){
		a1 = -a1;
		a2 = -a2;
		delta = -delta;
	}
	if(a1 > 0){ return 0; }

	LL u = (-a1 * t1 + delta - 1) / delta;
	LL ans = u * 2 - 1;
	if(a1 * t1 % delta == 0){ ++ans; }
	return ans;
}

void mainmain(){
	LL ans = solve();
	if(ans < 0){ puts("infinity"); }
	else{ printf("%lld\n", ans); }
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c <= a  + b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string S; cin>>S;
	// cout<<S<<"\n";//
	int N = S.size();
	vi counts(N);
	S += "R";
	// cout<<S<<"\n";//

	int even = 0, odd = 0;
	int l_pos = -1, r_pos = 0;
	int e = 0, o = 0;
	int r = 0, l = 0;
	rp(i,0,N){
		if(i%2) o++; else e++;

		if(S[i]=='R' && S[i+1]=='L'){
			r_pos = i;
			rp(j,l_pos+1, r_pos) cout<<0<<" ";
			l_pos = i + 1;
			if(r_pos%2){//odd
				r += o;
				l += e;
			}
			else{//even
				r += e;
				l += o;
			}
			o = e = 0;
		}
		else if(S[i]=='L' && S[i+1]=='R'){
			if(r_pos%2){//odd
				r += o;
				l += e;
			}
			else{//even
				r += e;
				l += o;
			}
			o = e = 0;
			cout<<r<<" "<<l<<(i+1<N?" ":"");
			r = l = 0;
		}

	}

	if(l_pos+1==N) cout<<"\n";
	else rp(i, l_pos+1, N) cout<<" "<<0<<(i+1==N?"\n":"");
}


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

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

    int k;
    k = result.size();

    int cnt_win = 0;
    for (int i = 0; i < k; i++) {
        if (result[i] == 'o') {
            cnt_win++;
        }
    }
    if ((cnt_win + (15 - k)) >= 8) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length()/2;i++){
        if(s[i]!=s[s.length()-1-i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	n := nextInt()

	var inputs []int
	for i := 0; i < n; i++ {
		inputs = append(inputs, nextInt())
	}

	index := maxIdx(inputs...)
	maxInput := max(inputs...)

	var sumOthers int
	for i, v := range inputs {
		if i != index {
			sumOthers += v
		}
	}

	if maxInput < sumOthers {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
class BinaryIndexedTree:  # 0-index !!!
    """
    init(n):     要素数nを与えて0で初期化
    add(i, x):   i番目の値にxを追加 O(logN)
    sum(i):      区間[0,i)の和を返す O(logN)
    query(l, r): 区間[l,r)の和を返す O(logN)
    """

    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)  # 内部的には1-indexで扱う

    def add(self, i, x):  # 0-index
        i += 1  # 内部的には1-indexで扱う
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):  # 0-index  sum of [0,i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def query(self, l, r):  # 0-index  sum of [l,r)
        return self.sum(r) - self.sum(l)

# ---------------------- #

n = int(input())
P = list(int(x) - 1 for x in input().split())

bit_a = BinaryIndexedTree(n)
bit_b = BinaryIndexedTree(n)
for i in range(n):
    bit_a.add(i, 1)
    bit_b.add(i, 1)
for i in reversed(range(n)):
    bit_a.add(P[i], i)
    bit_b.add(n - P[i] - 1, i)

A = []
B = []
for i in range(n):
    A.append(bit_a.sum(i + 1))
    B.append(bit_b.sum(i + 1))

print(*A)
print(*reversed(B))


Measured memory_bytes: 77444
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    if(n%2 != 0)
    {
        cout<<0;
        return 0;
    }
    sort(arr,arr+n);
    cout<<max(0ll, arr[n/2] - arr[n/2 - 1]);
	return 0;
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		int arr[n + 1], freq[n + 1];
		for (int i = 1; i <= n; i++) {
			cin >> arr[i];
			freq[i] = 1;
		}
		int index = 1, cnt = 0;
		while (1) {
			if (freq[index] == 0)
				break;
			freq[index]--;
			index = arr[index];
			cnt++;
		}
		int index1 = 1, cnt1 = 0;
		while (1) {
			if (index1 == index)
				break;
			index1 = arr[index1];
			cnt1++;
		}
		cnt = cnt - cnt1;
		if (k <= cnt1)
			index = 1;
		else {
			k = k - cnt1;
			k = k % cnt;
		}
		while (k > 0) {
			index = arr[index];
			k--;
		}

		cout << index << endl;
	}
	return 0;
}

Measured memory_bytes: 6776
// F - LCS https://atcoder.jp/contests/dp/tasks/dp_f
/* 入力例
axyb
abyxb
// →出力　axb or ayb
*/
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    string s, t;
    cin >> s >> t;
    int dp[s.length()+1][t.length()+1];
    for(int j=0;j<t.length()+1;j++){
        dp[0][j]=0;
    }
    for(int i=1;i<s.length()+1;i++){
        dp[i][0]=0;
        for(int j=1;j<t.length()+1;j++){
            if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int num=dp[s.length()][t.length()];
    string answer(num,'x');
    int x=t.length();
    int y=s.length();
    while(x>0 && y>0){
    if(dp[y][x]>dp[y][x-1] &&dp[y][x]>dp[y-1][x] &&dp[y][x]>dp[y-1][x-1]){
        answer[num-1]=s[y-1];
        num--;
        x=x-1;
        y=y-1;
    }
    else if(dp[y][x]==dp[y][x-1]){
        x=x-1;
    }
    else if(dp[y][x]==dp[y-1][x]){
        y=y-1;
    }
   }

    cout << answer << endl;
    return 0;
}


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

int main() {
    int D;
    cin >> D;
    if(D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    } else if(D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if(D == 24) {
        cout << "Christmas Eve" << endl;
    } else if(D == 25) {
        cout << "Christmas" << endl;
    }
}

Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

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


// Code from Here -------------------------------------------------------------------------------

void solver(){
	int n;
	cin >> n;
	vi arr(n);
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	sort(rall(arr));
	int ans=0;
	int x=n-1;
	for(int i=0; i<n-1; i++){
		if(x<=0)break;
		if(x==n-1){
			ans+=arr[i];
			x--;
		}
		else{
			if(x==1)ans+=arr[i], x--;
			else ans+=2*arr[i], x-=2;
		}
	}
	cout << ans << endl;
}

signed main() {
	tezz


	int t=1;
	// cin >> t;
	while(t--)solver();

	return 0;
}  


Measured memory_bytes: 4784
#include<stdio.h>

int main(){
    int N;
    int x4=0, x7=0;
    int i=0;

    scanf("%d", &N);

    while(x4<=N){
        x4 = 4*i;
        if((N-x4)%7 == 0){
            printf("Yes");
            break;
        }
        i++;
    }
    if(x4>N){
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		int X = sc.nextInt();
		int A = sc.nextInt();

		if(X < A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}

	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21076
#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.at(i);
  }
  sort(L.begin(),L.end());
  int sum = 0;
  for(int i=0;i<N-1;i++){
    sum+=L.at(i);
  }
  if(L.at(N-1)<sum){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int table[200][200] = {{0}};
  int c,r; //colum,row
  cin >> r >> c;
  for(int i=0; i<r; i++){
      for(int j=0; j<c; j++){
          cin >> table[i][j];
      }
  }

  //横計算する
  for(int i=0; i<r; i++){
      int sum = 0;
      for(int j=0; j<c; j++){
          sum += table[i][j];
      }
      table[i][c] = sum;
  }

  //縦計算する
  int sum=0;
  for(int i=0; i<r; i++){
      for(int j=0; j<c; j++){
          sum += table[i][j];
      }
      table[r][c] = sum;
  }

  //縦計算する
  for(int j=0; j<c; j++){
      int sum=0;
      for(int i=0; i<r; i++){
          sum += table[i][j];
      }
      table[r][j] = sum;
  }

  //出力を作る
  for(int i=0; i<=r; i++){
      for(int j=0; j<c; j++){
          cout << table[i][j] << " ";
      }
      cout << table[i][c];
      cout << endl;
  }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int main() {
    int n;
    cin >> n;
    cout << n*n*n << endl;
}



Measured memory_bytes: 256
D, G = map(int, input().split())
p = []
c = []
for _ in range(D):
    t1, t2 = map(int, input().split())
    p.append(t1)
    c.append(t2)
ans = float("inf")
for i in range(2**D):
    not_complete = []
    score = 0
    tmp = 0
    for j in range(D):
        if (i>>j & 1):
            score += 100 * (j+1) * p[j] + c[j]
            tmp += p[j]
        else:
            not_complete.append(j)
    if score >= G:
        ans = min(ans, tmp)
        continue
    
    not_complete.sort(reverse=True)
    for j in not_complete:
        rest = p[j]
        while score < G and rest > 1:
            rest -= 1
            score += 100*(j+1)
            tmp += 1
    if score >= G:
        ans = min(ans, tmp)
print(ans)
            

Measured memory_bytes: 74044
#include <iostream>
using namespace std;
 
int main() {
	int n;
  char a;
  cin>>n;
  int ans=0;
for(int i=0;i<n;i++){
  cin>>a;
  if(a=='Y')ans=1;
  }
  
  if(ans)cout<<"Four";
  else{cout<<"Three";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    REP(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

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

int main() {
    int n, temp = INT_MAX, ans = 0;
    cin >> n;
    vector<int> number(n);
    rep(i, n) cin >> number.at(i);
    rep(i, n) {
        if(temp > number.at(i)) {
            temp = number.at(i);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N,C=map(int, input().split())
IA=[[int(i)for i in input().split()]for _ in range(N)]
MS=[(0,0)]*(N+1)
CS=[0]*(N+1)
for i,[a,v] in enumerate(IA):
    CS[i+1]=CS[i]+v
    MS[i+1]=CS[i+1]-a if(CS[i+1]-a)>MS[i][0]else MS[i][0],CS[i+1]-2*a if(CS[i+1]-2*a)>MS[i][1]else MS[i][1]
res = 0
for i in range(N):
    ob=CS[N]-CS[i]
    res=max(res,ob+MS[i][0]-2*(C-IA[i][0]),ob+MS[i][1]-(C-IA[i][0]))
print(max(res, MS[N][0], 0))


Measured memory_bytes: 39288
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long q,h,s,d,n;cin>>q>>h>>s>>d>>n;
    cout<< (n/2)*min({q*8 , h*4 , s*2 , d}) + (n%2) * min({q*4 , h*2 , s});
}





Measured memory_bytes: 256
S=input()
N=len(S)
a=[0]*(N+1)
m=2019
for i,c in enumerate(reversed(S)):
    a[i+1]=(int(c)*pow(10,i,m)+a[i])%m
from collections import Counter
c=Counter(a)
r=0
for k,v in c.items():
    r+=v*(v-1)//2
print(r)

Measured memory_bytes: 16592
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	ll mx = 0;
	vector<vector<ll> > vv(2,vector<ll>());
	rep(i,0,2){
		rep(j,0,n){
			ll a;
			cin>>a;
			vv[i].pb(a);
		}
	}
	rep(i,0,n){
		ll c = 0;
		rep(j,0,n){
			if(j<i){
				c += vv[0][j];
			}
			else if(j==i){
				c += vv[0][j];
				c += vv[1][j];
			}
			else{
				c += vv[1][j];
			}
		}
		mx = max(mx,c);
	}
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int count = 0;
        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) {
                        // System.out.println("500: " + i + ",100: " + j + ",50: " + k);
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26856
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    int ans=0;
    for (int i = 1; i <= n; i++) {
        int t=i;
        int k=0;
        while(t){
            t/=10;
            k++;
        }
        if(k%2) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np

N, K = map(int,stdin.readline().rstrip().split())
VList = list(map(int,stdin.readline().rstrip().split()))
VList=np.array(VList)

maxNum=0
tryNum = min(N,K)
for i in range(tryNum+1):
  for j in range(tryNum+1-i):
    getList=VList[0:i]
    getList=np.append(getList,VList[N-j:N])
    getList.sort()
    throwNum=min(K-(i+j), len(getList))
    counter=0
    for k in range(throwNum):
      if getList[k] < 0:
        counter+=1
    getList=getList[counter:len(getList)]
    maxNum=max(maxNum, sum(getList))
print(maxNum)
    


Measured memory_bytes: 14428
let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let ax = Array.init n (fun _ ->
               Scanf.scanf " %d" (fun x -> x)) in
   let res = Array.fold_left (fun res x ->
                res + x - 1
              ) 0 ax in
  
  Printf.printf "%d\n" res
  

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

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  int ans = 0;
  vector<int> cnt(3);
  for (int i = 0; i < N; ++i) {
    string S;
    cin >> S;
    for (int j = 0; j + 2 <= S.size(); ++j) {
      if (S.substr(j, 2) == "AB") {
        ++ans;
      }
    }
    if (S[0] == 'B' && S.back() == 'A') ++cnt[2];
    else if (S[0] == 'B') ++cnt[1];
    else if (S.back() == 'A') ++cnt[0];
  }

  if (cnt[2]) {
    ans += cnt[2] - 1;
    if (cnt[0]) --cnt[0], ++ans;
    if (cnt[1]) --cnt[1], ++ans;
    ans += min(cnt[0], cnt[1]);
  } else {
    ans += min(cnt[0], cnt[1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] hasSnack= new int[n];
		
		for(int i = 0; i < k; i++){
			int d = sc.nextInt();
			for(int j = 0; j < d; j++){
				int a = sc.nextInt();
				hasSnack[a - 1]++;
			}
		}

		int ans = 0;
		for(int i = 0; i < n; i++){
			if(hasSnack[i] == 0) {
				ans++;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 46308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
unordered_map<int, int> Left[3], Right[3], val[3];
int num[3];
int root[3];
int f(string::iterator &itr, int index) {
    /*
    if(*itr == '[') {
        itr++;
        int now = 0;
        while(*itr != ']') {
            now *= 10;
            now += (*itr - '0');
            itr++;
        }
        itr++;
        num[index]++;
        val[index][num[index]] = now;
        return num[index];
    }
    */
    //cerr << *itr << endl;
    if(*itr == '(') {
        num[index]++;
        int pos = num[index];
        itr++;
        if(*itr == ')') {
            itr++;
            Left[index][pos] = -1;
        } else {
            Left[index][pos] = f(itr, index);
            itr++;
        }
        itr++;
        int now = 0;
        while(*itr != ']') {
            now *= 10;
            now += (int)((*itr) - '0');
            //cerr << "PLUS: " << *itr << endl;
            itr++;
        }
        val[index][pos] = now;
        itr++;
        itr++;
        if(*itr == ')') {
            itr++;
            Right[index][pos] = -1;
        } else {
            Right[index][pos] = f(itr, index);
            itr++;
        }
        return pos;
    }
}

void dfs(int now, int index) {
    cerr << "pos: " << now << " val: " << val[index][now] << " left: " << Left[index][now] << " right: " << Right[index][now] << endl;
    if(Left[index][now] != -1) dfs(Left[index][now], index);
    if(Right[index][now] != -1) dfs(Right[index][now], index);
}

void merge(int one, int two, int three) {
    //cerr << one << " " << two << " " << three << endl;
    if(Left[0][one] != -1 && Left[1][two] != -1) {
        num[2]++;
        Left[2][three] = num[2];
        val[2][Left[2][three]] = val[0][Left[0][one]] + val[1][Left[1][two]];
        merge(Left[0][one], Left[1][two], Left[2][three]);
    } else Left[2][three] = -1;
    if(Right[0][one] != -1 && Right[1][two] != -1) {
        num[2]++;
        Right[2][three] = num[2];
        val[2][Right[2][three]] = val[0][Right[0][one]] + val[1][Right[1][two]];
        merge(Right[0][one], Right[1][two], Right[2][three]);
    } else Right[2][three] = -1;
}

void print(int now) {
    if(now == -1) return;
    cout << "(";
    print(Left[2][now]);
    cout << ")";
    cout << "[" << val[2][now] << "]";
    cout << "(";
    print(Right[2][now]);
    cout << ")";
}

int main() {
    //cout.precision(10);
    string A, B;
    cin >> A >> B;
    auto itr = A.begin();
    root[0] = f(itr, 0);
    itr = B.begin();
    root[1] = f(itr, 1);
    //dfs(root[0], 0);
    //dfs(root[1], 1);
    //cerr << root[0] << endl;
    //cerr << num[0] << endl;
    //cerr << val[0][1] << " " << Left[0][1] << " " << Right[0][1] << endl;
    root[2] = 1;
    num[2] = 1;
    //cerr << root[0] << " " << root[1] << endl;
    val[2][1] = val[0][1] + val[1][1];
    merge(1, 1, 1);
    //dfs(1, 2);
    print(1);
    cout << endl;
    return 0;
}



Measured memory_bytes: 3260
#初めてのpython!!

# s = list(input())
# ans = 'Yes'
# if s.count('A') == 3 or s.count('B') == 3:
#     ans = 'No'
# print(ans)

s = input()
if(s[0] == s[1] == s[2]):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<ll, ll> P;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<pair<ll,ll>> a(N); REP(i,N){ll x; cin >> x; a[i].first=x; a[i].second=i;}
    ll mx=a[0].first, mn=a[0].first; REP(i,N-1){chmax(mx, a[i+1].first); chmin(mn, a[i+1].first);}

    vector<P> ans;
    if(abs(mx) >= abs(mn)){
        priority_queue<pair<ll,ll>> q; REP(i,N) q.push(a[i]);
        REP(i,N){
            a[i].first += q.top().first; ans.push_back(pair<ll,ll>(q.top().second, a[i].second));
            if(i != 0 && a[i-1].first > a[i].first){
                a[i].first += q.top().first; ans.push_back(pair<ll,ll>(q.top().second, a[i].second));
            }
            q.push(a[i]);
        }
    }
    else{
        priority_queue<P, vector<P>, greater<P>> q; REP(i,N) q.push(a[i]);
        for(int i=N-1; i>=0; i--){
            a[i].first += q.top().first; ans.push_back(P(q.top().second, a[i].second));
            if(i != N-1 && a[i].first > a[i+1].first){
                a[i].first += q.top().first; ans.push_back(P(q.top().second, a[i].second));
            }
            q.push(a[i]);
        }
    }
    int m = ans.size();
    cout << m << endl;
    REP(i,m){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	string s;
	cin >> s;
	int ok = 1;
	for (int i = 0; i < (int)s.size(); i += 2) {
		ok &= (s[i] == 'h' && s[i + 1] == 'i');
	}
	if (ok && ((int)s.size() % 2 == 0)) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int a, n;

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

    int resid = n % 500;

    if(resid > a) cout << "No" << endl;
    else cout << "Yes" << endl;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 510;
int k, n, mat[N][N];
int main() {
  cin >> k;
  if (k == 1) {
    puts("1\n1");
    return 0;
  }
  n = min(500, k);
  if (n&1) -- n;
  rep (i, 0, n-1) rep (j, 0, n-1)
    mat[i][j] = (i + j) % n + 1;
  int cur = k - n;
  rep (i, 1, cur) {
    for (int p = i-1, t = 1, v = 0; v < n; ++ v, p = (p + n - 1) % n, t = t ^ 1)
      if (t == 1) mat[v][p] = n + i;
  }
  printf("%d\n", n);
  rep (i, 0, n-1) {
    rep (j, 0, n-1) printf("%d ", mat[i][j]);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 2176
def examA():
    X,Y = LS()
    if ord(X)==ord(Y):
        ans = "="
    elif  ord(X)>ord(Y):
        ans = ">"
    else:
        ans = "<"
    print(ans)


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    // 絶対値の差が渡されるから、2パターンの配置先が決まる
    // 2パターンの配置先の組み合わせを考える
    ll res = 1;
    rep(i,n/2) res *= 2, res %= INF;
    // 偶数
    if(n%2==0){
        vi ve(n/2,0);
        rep(i,n) ve.at(a.at(i)/2)++;
        rep(i,ve.size()-1){
            if(ve.at(i)>2){
                res = 0;
                break;
            }
        }
    }
    // 奇数
    if(n%2==1){
        vi vo(n/2+1,0);
        rep(i,n) vo.at(a.at(i)/2)++;
        // rep(i,vo.size()-1) cout << "i:" << i << " vo.i:" << vo.at(i) << endl;
        rep(i,vo.size()-1){
            if(vo.at(i)>2 || vo.at(0)>1){
                res = 0;
                break;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
    static int MOD = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int output = 0;
      int N = sc.nextInt();
      int M = sc.nextInt();
      if(Math.abs(N - M) >= 2){
        System.out.println(output);
      }else if(Math.abs(N - M) == 1){
        System.out.println((fact(N) * fact(M)) % MOD);
      }else{
        //最後に2倍
        //System.out.println(fact(N));
        //System.out.println(fact(M));
        System.out.println(((fact(N) * fact(M)) % MOD) * 2 % MOD);
      }
	}
  
  public static Long fact(int a){
    Long ret = new Long(1);
    for(int i = 1; i <= a; i++){
      ret = (ret * i) % MOD;
    }
    return ret;
  }
}


Measured memory_bytes: 26068