akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, k, a;
bool f[30], g[30];

int main(int argc, char **argv) {
	CLEAR(f);
	cin >> n >> m;
	REP(i, n) {
		cin >> k;
		CLEAR(g);
		REP(j, k) {
			cin >> a;
			--a;
			g[a] = true;
		}
		REP(j, m) f[j] |= !g[j];
	}
	ll res = 0;
	REP(i, m) if (!f[i]) ++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<char> arr;
  map<char, int> amap;
  for(int i=0;i<N;++i) {
    if(amap[S[i]]==0) arr.push_back(S[i]);
    amap[S[i]]++;
  }
  ll ans = 1;
  for(int i=0;i<arr.size();++i) {
    ans *= amap[arr[i]]+1;
    ans %= mod;
  }
  cout<<ans-1<<endl;
}



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

int main(){
    int a, b;
    while(1){
        cin >> a >> b;
        if (a == 0 && b == 0){
            break;
        } else if (a < b) {
            cout << a << " " << b << endl;
        } else {
            cout << b << " " << a << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3088
/*input
2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vll sta,stb,stc;
    rep(i,0,a){
        cin>>j;
        sta.pb(j);
    }
    sort(sta.begin(),sta.end());
    reverse(sta.begin(),sta.end());
    rep(i,0,b){
        cin>>j;
        stb.pb(j);
    }
    sort(stb.begin(),stb.end());
    reverse(stb.begin(),stb.end());
    rep(i,0,c){
        cin>>j;
        stc.pb(j);
    }
    rep(i,0,x){
        stc.pb(sta[i]);
    }
    rep(i,0,y)stc.pb(stb[i]);
    sort(stc.begin(),stc.end());
    reverse(stc.begin(),stc.end());
    ll ans=0;
    rep(i,0,x+y)ans+=stc[i];
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 7920
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define endl "\n"
using namespace std;
using ll = long long;
using bnum = int64_t;
ll pi= static_cast<ll>(3.1415926535897932384626433l);
int diff(ll a){
    a = floor(a / 2);
    return a;
}
void solve(){
    ll a,b,c,d;
    vector<ll> s(3);
    for(int i = 0;i<3;++i){
        cin >> s[i];
    }sort(s.begin(),s.end());
    d = diff(s.at(2));
    cout << ((s.at(2) - d) * s.at(1) * s.at(0)) - (d * s.at(1) * s.at(0)) << endl;
}
int main(){
    solve();
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<6-a-b<<endl;

}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()


    x = NI()
    ans = 10 - x // 200

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68880
# coding: utf-8
# Your code here!


n=int(input())
pl = list(map(int,input().split()))

point = 0
for idx, p in enumerate(pl):
    if idx +1 != p:
        point += 1
if point == 2 or point == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
using namespace std;
#define INF 1LL<<30

class MaxFlow {
    // 辺を表す構造体（行き先、容量、逆辺）
    struct edge {
        long long to, cap, rev;
    };
    vector<vector<edge>> G;  // グラフの隣接リスト表現
    vector<long long> level;       // sからの距離
    vector<long long> iter;        // どこまで調べ終わったか

    // sからの最短距離をBFSで計算する
    void bfs(long long s) {
        fill(level.begin(), level.end(), -1);
        queue<long long> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()) {
            long long v = que.front();
            que.pop();
            for(auto &e : G[v]){
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    // 増加パスをDFSで探す
    long long dfs(long long v, long long t, long long f) {
        if (v == t) return f;
        for (long long &i = iter[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                long long d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    MaxFlow(long long V) : G(V), level(V), iter(V) {}

    // from から to へ向かう容量 cap の辺をグラフに追加する
    void add_edge(long long from, long long to, long long cap) {
        G[from].push_back((edge){to, cap, static_cast<long long>(G[to].size())});
        G[to].push_back((edge){from, 0, static_cast<long long>(G[from].size()) - 1});
    }
    // s から t への最大流を計算する
    long long max_flow(long long s, long long t) {
        long long flow = 0;
        while (bfs(s), level[t] >= 0) {
            fill(iter.begin(), iter.end(), 0);
            long long f;
            while ((f = dfs(s, t, INF)) > 0) flow += f;
        }
        return flow;
    }
};

int main(){
    int N;
    cin >> N;
    vector<long long> a(N+1);
    for(int i=1; i<=N; i++)
        cin >> a[i];

    long long ans = 0;
    for(int i=1; i<=N; i++)
        if(a[i] > 0)
            ans += a[i];

    MaxFlow mf(102);
    for(int i=1; i<=N; i++)
        if(a[i] > 0)
            mf.add_edge(i, N+1, a[i]);
        else if(a[i] < 0)
            mf.add_edge(0, i, -a[i]);

    for(int i=1; i<=N; i++)
        for(int j=2*i; j<=N; j+=i)
            mf.add_edge(i, j, INF);

    cout << ans - mf.max_flow(0, N+1) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numA - 1) * (numB - 1));

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int count = 0;
			for (int i = 1; i <= numN; i++) {
				if (i % 2 == 0) {
					continue;
				}
				int wk = i;
				Map<Integer, Integer> wkMap = new HashMap<Integer, Integer>();
				for (int j = 2; j < i;) {
					if (wk % j == 0) {
						wk /= j;
						wkMap.put(j, wkMap.get(j) == null ? 1 : wkMap.get(j) + 1);
					} else {
						j++;
					}
				}
				int wkRes = 1;
				for (Integer val1 : wkMap.values()) {
					wkRes *= (val1 + 1);
				}
				if (wkRes == 8) {
					count++;
				}
			}

			System.out.println(count);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		String wkS;
		long count = 0;

		try {
			scanner = new Scanner(System.in);
			wkS = scanner.next();
			count = scanner.nextLong();
			String wk = wkS;
			if (count <= wkS.length()) {
				wk = wkS.substring(0, (int) count);
			}
			for (int i = 0; i < wk.length(); i++) {
				if (wk.charAt(i) != '1') {
					System.out.println(wk.charAt(i));
					return;
				}
			}
			System.out.println(1);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll n;
        cin>>n;
        map<ll,ll> m;
        vll v(n);
        ll sum =0;
        loop(i,0,n) {
            cin>>v[i];
            m[v[i]]++;
            sum += v[i];
        }
        ll q;
        cin>>q;
        while(q--) {
            ll b,c;
            cin>>b>>c;
            sum -= m[b]*b;
            sum += m[b]*c;
            m[c] += m[b];
            m[b] = 0;
            cout<<sum<<'\n';
        }
    }
    return 0;
}

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

int main(){
    int n,m,l;
    cin>>n>>m>>l;
    int a[n][m],b[m][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            long long ans=0;
            for(int k=0;k<m;k++){
                ans+=a[i][k]*b[k][j];
            }
        if(j==l-1)cout<<ans;
        else{cout<<ans<<' ';}
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3184
package main

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

type card struct {
	mark string
	number int
}

// return 1 if x > y
// return -1 if x < y
// return 0 if x == y
func compare(x, y card) int {
	if x.number > y.number {
		return 1
	} else if x.number < y.number {
		return -1
	} else {
		return 0
	}
}

func isSame(x, y []card) bool {
	if len(x) != len(y) {
		return false
	}
	for i := 0; i < len(x); i++ {
		if x[i] != y[i] {
			return false
		}
	}
	return true
}

func partition(cards []card) int {
	n := len(cards)
	pos := 0
	pivot := cards[n-1]
	for i := 0; i < n-1; i++ {
		if compare(cards[i], pivot) <= 0 {
			cards[i], cards[pos] = cards[pos], cards[i]
			pos++
		}
	}
	cards[pos], cards[n-1] = pivot, cards[pos]
	return pos
}

func quickSort(cards []card) {
	if len(cards) <= 1 {
		return
	}
	p := partition(cards)
	quickSort(cards[:p])
	quickSort(cards[(p+1):])
}

func mergeSort(cards []card) []card {
	if len(cards) <= 1 {
		return cards
	}
	mid := len(cards) / 2
	leftCards := mergeSort(cards[:mid])
	rightCards := mergeSort(cards[mid:])

	var li, ri, i int
	newCards := make([]card, len(cards))
	for li < len(leftCards) && ri < len(rightCards) {
		if compare(leftCards[li], rightCards[ri]) <= 0 {
			newCards[i] = leftCards[li]
			li++
		} else {
			newCards[i] = rightCards[ri]
			ri++
		}
		i++
	}
	for i < len(cards) {
		if li == len(leftCards) {
			newCards[i] = rightCards[ri]
			ri++
		} else {
			newCards[i] = leftCards[li]
			li++
		}
		i++
	}
	return newCards
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	cards := make([]card, n)

	for i := 0; i < n; i++ {
		mark := nextText(sc)
		number, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		cards[i] = card{mark: mark, number:number}
	}

	sortedByMerge := mergeSort(cards)
	quickSort(cards)

	if isSame(sortedByMerge, cards) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%s %d\n", cards[i].mark, cards[i].number)
	}
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 15816
/* 
 * Author: aps
 * Time: 24-06-2019 18:02:17
**/
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const ll inf = 1e18;
const ll mod = 1e9+7;

inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n; cin >> n;
    vector<pii> a(n);
    for(int i=0;i<n;i++) cin >> a[i].se >> a[i].fi;
    sort(all(a));

    string ans = "Yes";
    int cur=0;
    for(int i=0;i<n;i++){
        cur += a[i].se;
        if(cur > a[i].fi){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    string s, t;
    cin >> s;
    rep(i, 0, s.size()){
        if (s.at(i) == '0') t += '0';
        if (s.at(i) == '1') t += '1';
        if (s.at(i) == 'B'){
            if (t.size() == 0) continue;
            else t = t.erase(t.size() - 1);
        }
    }
    cout << t << endl;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

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

    V<Vi> x,y;
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        Vi tmp_x,tmp_y;
        for(int j=0; j<a; j++){
            int b,c;
            cin>>b>>c;
            tmp_x.pb(b-1);
            tmp_y.pb(c);
        }
        x.pb(tmp_x);
        y.pb(tmp_y);
    }

    int bits = 1;
    for(int i=0; i<n; i++) bits<<=1;

    int max_num=0;
    for(int i=0; i<bits; i++){
        int tmp=i;
        Vi people;
        for(int j=0; j<n; j++){
            people.pb(tmp%2);
            tmp>>=1;
        }
        bool flag=true;
        for(int j=0; j<n; j++){
            if(people[j]==1){
                for(int k=0; k<x[j].size(); k++){
                    if(people[x[j][k]] != y[j][k]){
                        flag=false;
                        break;
                    }
                }
            }
            if(!flag) break;
        }
        if(flag){
            max_num = max(max_num,__builtin_popcount(i));
        }
    }


    cout<<max_num<<endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] & s[2] == s[3] & s[0] != s[2]) {
    cout << "Yes" << endl;
  } else if (s[0]==s[2] & s[1]==s[3]&s[0]!=s[1]) {
    cout << "Yes" << endl;
  } else if (s[0]==s[3] & s[1]==s[2]&s[0]!=s[1]) {
    cout<<"Yes"<<endl;
  } else {
    cout <<"No" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll N,m=1000000,ans=0; cin>>N;
    vel P(N),Min(N); rep0(i,N){cin>>P[i];m=min(m,P[i]);Min[i]=m;}
    for(ll i=1;i<N;i++){
        if(P[i]<=Min[i-1]){ans++;}
    }
    cout<<ans+1<<endl;
}


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

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,a,b = map(int,input().split())

ans = min(n*a,b)

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a, b, c;
		StringBuilder ans = new StringBuilder();
		
		a = sc.next();
		b = sc.next();
		c = sc.next();
		
		sc.close();
		
		a = a.toUpperCase();
		b = b.toUpperCase();
		c = c.toUpperCase();
		
		ans.append(a.charAt(0));
		ans.append(b.charAt(0));
		ans.append(c.charAt(0));
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
int n,m;
int a[max_n];
ll k[max_n],b[max_n];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    function<void(int,int,int,int)> add=[&](int l,int r,int kx,int bx){
        k[l]+=kx,k[r+1]-=kx,b[l]+=bx,b[r+1]-=bx;
    };
    function<void(int,int)> work=[&](int s,int t){
        if(s<t){
            add(1,s,0,t-s);
            add(s+1,t,-1,t+1);
            add(t+1,m,0,t-s);
        }
        else{
            add(1,t,-1,t+1);
            add(t+1,s,0,t+m-s);
            add(s+1,m,-1,t+m+1);
        }
    };
    for(int i=1;i<n;i++){
        work(a[i],a[i+1]);
    }
    for(int i=1;i<=m;i++)k[i]+=k[i-1],b[i]+=b[i-1];
    ll ans=1e18;
    for(int i=1;i<=m;i++)ans=min(ans,k[i]*i+b[i]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2176
fun main(args: Array<String>) {
    // 全体一括ソートは遅いはずだが，StringBuilder を使っている部分で実行速度が上がっている？？

    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    // 各県の初期ランクを定義
    var rank = IntArray(n + 1) { 1 }


    // 全ての市を year で一括並び替え
    val cities=(1..m).map {
        // map の中で複数の式を定義している
        val (p, y) = readLine()!!.split(" ").map { it.toInt() }

        // map の lambda式でのローカルリターンを定義（@map が付いていないと main でのリターンになってしまう)
        // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec
        // return が明示的に書かれているとわかりやすいが， return を書かなくても最後の式の評価結果が戻り値となる
        return@map Triple(it, p, y)
    }.sortedBy { it.third }


//    // StringBuilder を使う場合 1282ms
//    val sb=StringBuilder()
//
//    // 各市に県内で何番目かの情報を付与した後に，入力順にソート
//    cities.map {
//        // 同じ県内で何番目かの情報付与
//        Pair(it,rank[it.second]++)
//    }.sortedBy {
//        // データの入力順にソート
//        it.first.first
//    }.forEach {
//        // 出力文字列を StringBuilder に格納
//        sb.append(it.first.second.toString().padStart(6,'0'))
//        sb.append(it.second.toString().padStart(6,'0'))
//        sb.append("\n")
//    }
//
//    // まとめて出力
//    println(sb)

    // 仮にStringBuilder を使わなかった場合 -> 1305 ms
    val ans = cities.map {
        // 同じ県内で何番目かの情報付与
        Pair(it,rank[it.second]++)
    }.sortedBy {
        // データの入力順にソート
        it.first.first
    }.map {
        // 出力文字列を StringBuilder に格納
//        it.first.second.toString().padStart(6,'0') + it.second.toString().padStart(6,'0')
        "%06d%06d".format(it.first.second, it.second)
    }

    println(ans.joinToString("\n"))
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

vector<vector<ll> >arr(3001,vector<ll>(3001)),dp(3001,vector<ll>(3001,-1));
string s,t;

ll solve(ll i,ll j){
    if(i<0 || j<0){
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];

    if(s[i]==t[j]){
        dp[i][j]=1+solve(i-1,j-1);
        arr[i][j]=3;
        //ans+=s[i];
    }
    else{
        if(solve(i-1,j) >= solve(i,j-1)){
            dp[i][j]=solve(i-1,j);
            arr[i][j]=1;
        }
        else{
            dp[i][j]=solve(i,j-1);
            arr[i][j]=2;
        }
    }
    return dp[i][j];
}

int main(){
    cin>>s>>t;
    ll n=s.size()-1,m=t.size()-1;
    //cout<<"sdgsdf";
    ll p=solve(n,m);
    ll j=m,i=n;
    //cout<<p;
    string ans="";
    while(i>=0 && j>=0){
        if(arr[i][j]==3){
            ans+=s[i];
            i--;
            j--;
        }
        else if(arr[i][j]==2){
            j--;
        }
        else if(arr[i][j]==1){
            i--;
        }

    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    //cout<<ans;
    return 0;
}


Measured memory_bytes: 141696
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N;
	long long x, a[2001];
	scanf("%d %lld", &N, &x);
	for (i = 0; i < N; i++) scanf("%lld", &(a[i]));
	
	int j;
	long long ans = (long long)1 << 60, tmp, min[2001][2001];
	for (i = 0; i < N; i++) {
		min[i][0] = a[i];
		for (j = 1; j < N; j++) min[i][j] = (min[i][j-1] < a[(i-j+N)%N])? min[i][j-1]: a[(i-j+N)%N];
	}
	for (j = 0; j < N; j++) {
		for (i = 0, tmp = x * j; i < N; i++) tmp += min[i][j];
		if (tmp < ans) ans = tmp;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

bool Area(int Z){
  for(int y = 1;y * y <= Z;++y){
  //for(int y = 1;(2 * y + 1) <= Z - y;++y){
    if((Z - y) % (2 * y + 1) == 0){ 
      return true;
    }
  }
  return false;
}

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

  int temp;
  vector<int> area;
  for(int i = 0;i < N;++i){
    cin>>temp;
    area.push_back(temp);
  }

  int ans = 0;
  bool check;
  for(int e : area){
    check = Area(e);
    if(check == false){
      ++ans;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3220
// {{{ include and macros
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i, a, b) for(int i=a; i < b;i++)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
// }}}

// {{{ io
void newline() {cout << endl;}
template <typename T>
void display(T input){cout << input;}
template <typename T>
void put(T input){display(input); newline();}
template <typename T>
void vec_put(vector<T> v){
  for(auto &a: v){display(a);display(" ");}
  newline();}
  int input_int(){
    int a; cin >> a; return a;}
string input_string(){
  string a; cin >> a; return a;}
// }}}

bool isGuu(string str){
  int half = str.size() / 2;
  string a = str.substr(0, half);
  string b = str.substr(half, str.size());
  return a == b;
}

int main() {
  string input = input_string();
  input.erase(input.size()-1);
  for(int i=input.size()-1; i>0; i--){
    if(isGuu(input)){
      put(input.size()); 
      return 0;
    }
    input.erase(i);
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long a = Long.parseLong(sc.next());
        long v = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long w = Long.parseLong(sc.next());
        long t = Long.parseLong(sc.next());  
        if((v-w) <= 0) {
            System.out.println("NO");
        }else if(Math.abs(a-b) <= (v-w)*t) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
     }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; ++i) cin >> D[i];

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

    int ans = D[D.size()/2] - D[D.size()/2-1];

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

Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	ds := make([]int, n)
	for i := range ds {
		fmt.Scan(&ds[i])
	}
	sort.Sort(sort.IntSlice(ds))

	fmt.Println(ds[n/2] - ds[n/2-1])
}


Measured memory_bytes: 5504
using System;

public class Problem_D
{
  public static void Main(string[] args)
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int h = inputs[0], w = inputs[1], d = inputs[2];
    var grid = new Tuple<int, int>[(h * w) + 1];
    for (var i = 0; i < h; i++)
    {
      var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      for (var j = 0; j < line.Length; j++) grid[line[j]] = Tuple.Create(i + 1, j + 1);
    }
    var dist = new int[(h * w) + 1];
    for (var i = d + 1; i <= h * w; i++)
    {
      dist[i] = dist[i - d] + Math.Abs(grid[i].Item1 - grid[i - d].Item1) + Math.Abs(grid[i].Item2 - grid[i - d].Item2);
    }

    var q = int.Parse(Console.ReadLine());
    for (var i = 0; i < q; i++)
    {
      var move = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      int l = move[0], r = move[1];
      Console.WriteLine($"{dist[r] - dist[l]}");
    }
  }
}

Measured memory_bytes: 23220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cinm(char, n, m);
    CoutYn(m['R'] > m['B']);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N = 1e5 + 5;

unordered_map<ull,ull> cnt;

int main() {
    int n;
    ull sum = 0ll;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        ull a;
        scanf("%llu", &a);
        sum += a;
        ++cnt[a];
    }
    int q;
    scanf("%d", &q);
    while(q--) {
        ull x, y;
        scanf("%llu %llu", &x, &y);
        sum = sum - x*cnt[x] + y*cnt[x];
        cnt[y] += cnt[x];
        cnt[x] = 0;
        printf("%llu\n", sum);
    }

}

Measured memory_bytes: 7128
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] c = new int[3];
		c[0] = a+b;
		c[1] = a-b;
		c[2] = a*b;
		Arrays.sort(c);
		System.out.println(c[2]);
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
const ll MOD=1e9+7;

//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    string s;
    cin >> s;
    int n=s.size();
    int dp[100005][13]={};

    dp[0][0]=1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 13; j++) {
            if(s[i]=='?'){
                for(int k = 0; k < 10; k++) {
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                    dp[i+1][(j*10+k)%13]%=MOD;
                }
            }
            else{
                int k=s[i]-'0';
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=MOD;
            }
        }
    }
    cout << dp[n][5] << "\n";
    return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=1;i<=n;i++)
using namespace std;
typedef pair<int, int> P;

int c[100][100]={};
int t[100][100]={};

int main()
{
  int n,m,a,b;
  int i,j,k;
  int p,q,r;

  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;

    rep(i,m)rep(j,m)c[i][j]=t[i][j]=INF;//INFテ」ツ?ァテ・ツ按敕ヲツ慊淌・ツ個?
    rep(i,m)c[i][i]=t[i][i]=0;//テ・ツ青古ゥツァツ?」ツ?ッ0

    rep(i,n){
      cin>>a>>b;
      cin>>c[a][b]>>t[a][b];
      c[b][a]=c[a][b];
      t[b][a]=t[a][b];
    }
    
    rep(k,m)rep(i,m)rep(j,m){
      c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
    }

    cin>>k;
    rep(i,k){
      cin>>p>>q>>r;
      if(r)
	cout<<t[p][q]<<endl;
      else
	cout<<c[p][q]<<endl;
    }
  }
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    bool first = false;
    REP (i, N) if (A[i] % 2 == 1) first = true;
    puts(first? "first": "second");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 640
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long N = Long.parseLong(sc.next());
        sc.close();

        long ans;
        if (N % 2 == 0) {
            ans = N;
        } else {
            ans = N * 2;
        }
        out.printf("%d\n", ans);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
lli calc(vector<pair<lli, lli>> X, lli D)
{
  sort(X.begin(), X.end());
  lli right = -1e18;
  lli ret = 0;
  int N = X.size();
  map<lli, lli> right_memo;
  rep(i, N)
  {
    //cout << X[i].first << " " << X[i].second << " " << right << " " << endl;
    if (right < X[i].first)
    {
      ret += (X[i].second - X[i].first) / D + 1;
      right = X[i].second;
    }
    else
    {
      if (right < X[i].second)
      {
        ret += (X[i].second - right) / D;
        right = X[i].second;
      }
      else
      {
        continue;
      }
    }
  }
  //cout << endl;
  return ret;
}
void solve(long long N, long long X, long long D)
{
  map<lli, vector<pair<lli, lli>>> x;

  lli left = 0, right = 0;
  if (D == 0)
  {
    if (X == 0)
      cout << 1 << endl;
    else
      cout << N + 1 << endl;
    return;
  }
  if (D < 0)
  {
    D *= -1;
    X *= -1;
  }
  x[0].push_back(make_pair(0, 0));
  rep(i, N)
  {
    left += i;
    right += N - i - 1;
    x[(((i + 1) * X) % D + D) % D].push_back(make_pair((i + 1) * X + left * D, (i + 1) * X + right * D));
  }
  lli ret = 0;
  for (auto s : x)
  {
    ret += calc(s.second, D);
  }
  cout << ret << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  long long D;
  scanf("%lld", &D);
  solve(N, X, D);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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


int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }
    vector<bool> flag(1e9+1000, false);
    rep(i, N){
        if(flag[A[i]]){
            cout << "NO" << endl;
            return 0;
        }
        else{
            flag[A[i]] = true;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 123904
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) int(x.size())
#define pb push_back
#define int long long

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (auto &it : a)
		cin >> it;
	// if (n%2 == 0) {
	// 	int sum[2] = {0};
	// 	for (int i = 0; i < n; ++i)
	// 		sum[i%2] += a[i];
	// 	cout << max(sum[1], sum[0]) << '\n';
	// 	return 0;
	// }
	vector<int> pref(n, 0), suf(n, 0);
	pref[0] = a[0];
	pref[1] = a[1];
	for (int i = 2; i < n; ++i)
		pref[i] = pref[i-2] + a[i];

	suf[n-1] = a[n-1];
	suf[n-2] = a[n-2];
	for (int i = n-3; i >= 0; --i)
		suf[i] = suf[i+2] + a[i];

	int ans = -1e18;
	if (n%2 == 0) {
		ans = max(pref[n-1], pref[n-2]);
		for (int i = 1; i+2 < n; i += 2) {
			int x = 0;
			if (i) x += pref[i-1];
			if (i+2 < n) x += suf[i+2];
			ans = max(ans, x);
		}
		cout << ans << '\n';
		return 0;
	}
	ans = pref[n-2];
	for (int i = 0; i+1 < n; ++i) {
		int x = 0;
		if (i) x += pref[i-1];
		if (i+2 < n) x += suf[i+2];
		ans = max(ans, x);

		if (i > 0 and i+2 < n) {
			x = 0;
			if (i) x += pref[i-1];
			if (i+3 < n) x += suf[i+3];
			ans = max(ans, x);
		}
	}
	// Skip 2, twice
	// Must pick first and last
	// Say middle part is [i, j]
	// Then ans = pref[i-3] + pref[j] - pref[i-2] + suf[j+3]
	// 			= pref[i-3] - pref[i-2] + pref[j] + suf[j+3]
	multiset<int> m;
	for (int j = 3; j < n; j += 2)
		if (j+3 < n)
			m.insert(pref[j] + suf[j+3]);
	for (int i = 3; i+3 < n; i += 2) {
		if (m.empty()) break;
		m.erase(m.find(pref[i] + suf[i+3]));
		if (m.empty()) break;
		int x = pref[i-3] - pref[i-2];
		x += *m.rbegin();
		ans = max(ans, x);
	}
	cout << ans;

}
// 1 2 3 4 5 6 7 8 9
// 1 2 3 4 5 6

Measured memory_bytes: 12740
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <map>

using namespace std;
int a[100005];
long long sum[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
	//	cout<<sum[i]<<"ss";
	}
	int ans=1;
	for(int i=n-1;i>=1;i--)
	{
	//	cout<<a[i]<<"ss";
		if(sum[i]*2>=a[i+1])
		ans++;
		else
		break;
	}
	cout<<ans<<endl;
	 return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

#define NUMBER 100


void print_array(int array[],int num)
{
	int i;
	
	for(i = 0; i < num - 1; i++){
		
		printf("%d ", array[i]);
	}
	printf("%d\n", array[i]);
	
}
	
void insertSort(int array[],int num)
{
	int i, v, j;
	for(i = 1; i <= num - 1; i++){
		print_array(array, num);
		v = array[i];
		j = i - 1;
		while(j >= 0 && array[j] > v){
			array[j + 1] = array[j];
			j--;
			
		}
		array[j + 1] = v;
	
    }
}

int main(void)
{
	int i, num;
	int array[NUMBER];

	scanf("%d", &num);
	
	for(i = 0; i < num; i++)
	{
		scanf("%d", &array[i]);
	}
	
	insertSort(array , num);
	
	print_array(array , num);
	
	
	return 0;
}


Measured memory_bytes: 2752
////////
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long LL;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls (rt<<1)
#define rs (rt<<1|1)
#define F first
#define S second
#define mst(x,a) memset(x,a,sizeof(x))
#define Pr pair<int,int>
#define Prl pair<LL, LL>
#define Prd pair<double, double>
#define root 1,cnum,1
#define For(i,b,c) for(int i=b;i<=c;i++)
#define lowbit(x) (x&(-x))
const int maxn = 200020;
const LL mod = 1e9 + 7;
const LL mod2 = mod - 1;
const int INF = 0x7FFFFFFF;
const LL LINF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const LL maxx = 1LL<<61;
const double eps = 1e-8;
//*********
 
int n, m, q, k, G;
char s[maxn];
inline int read() { return
    cin >> s + 1
?1:0; }

LL qpow(LL a, LL n) {
    LL sum = 1;
    while(n > 0) {
        if(n&1) sum = sum * a % mod;
        a = a * a % mod;
        n >>= 1;
    } return sum;
}
int len;
LL Cal(char a, char b, char c) {
    LL dp[4] = {0}, tdp[4] = {0};
    for(int i = 1;i <= len;i++) {
        tdp[1] = tdp[2] = tdp[3] = 0;
        if(s[i] == a) {
            tdp[1] = 1;
        }
        if(s[i] == b) {
            tdp[2] = (tdp[2] + dp[1]) % mod;
        }
        if(s[i] == c) {
            tdp[3] = (tdp[3] + dp[2]) % mod;
        }
        for(int i = 1;i <= 3;i++) dp[i] = (dp[i] + tdp[i]) % mod;
        //cout << dp[1] << "|" << dp[2] << "|" << dp[3] << endl;
    }
    return dp[3];
}

void solve() {
    len = strlen(s + 1);
    LL num = 0;
    for(int i = 1;i <= len;i++) if(s[i] == '?') num++;
    LL ans = 0;
    ans = (ans + Cal('A', 'B', 'C') % mod * qpow(3, num) % mod) % mod;
    //cout << ans << endl;
    if(num >= 1) 
        ans = (ans + Cal('?', 'B', 'C') % mod * qpow(3, num - 1) % mod) % mod;
    //cout << ans << endl;
    if(num >= 1) 
        ans = (ans + Cal('A', '?', 'C') % mod * qpow(3, num - 1) % mod) % mod;
    //cout << ans << endl;
    if(num >= 1) 
        ans = (ans + Cal('A', 'B', '?') % mod * qpow(3, num - 1) % mod) % mod;
    //cout << ans << endl;
    if(num >= 2) 
        ans = (ans + Cal('?', '?', 'C') % mod * qpow(3, num - 2) % mod) % mod;
    //cout << ans << endl;
    if(num >= 2) 
        ans = (ans + Cal('A', '?', '?') % mod * qpow(3, num - 2) % mod) % mod;
    //cout << ans << endl;
    if(num >= 2) 
        ans = (ans + Cal('?', 'B', '?') % mod * qpow(3, num - 2) % mod) % mod;
    //cout << ans << endl;
    if(num >= 3) 
        ans = (ans + Cal('?', '?', '?') % mod * qpow(3, num - 3) % mod) % mod;
    //cout << ans << endl;
    cout << ans << endl;
}

int main() {
    guan();
    int t = 1;
    //cin >> t;
    int Cas = 1;
    while(t--) {
        while(read())
            //cout << "Case #" << Cas++ << ": " << endl;
            solve();
    }
    //cin >> t;
    return 0;
}


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

// 6th binary partition function (OEIS: A007729)

const ll mod=1e9+7;
map<ll,ll> dp;

ll calc(ll N){
	if(dp.count(N)) return dp[N];
	if(N%2==0) (dp[N]+=2ll*calc((N/2)-1)%mod+calc(N/2)%mod)%=mod;
	else (dp[N]+=2ll*calc(N/2)%mod+calc((N/2)-1)%mod)%=mod;
	return dp[N];
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin>>n;
	dp[0]=1;
	dp[1]=2;
	dp[2]=4;
	cout<<calc(n)<<'\n';
}



Measured memory_bytes: 3652
#include <stdio.h>

int main()
{
  int H,W;
  while(1)
  {
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
    {
      break;
    }
    for(int i = 0; i < H; i++)
    {
      for(int j = 0; j < W; j++)
      {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2052
// AOJ ALDS1_11_D: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_D

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

var nocolor = -1

type graph struct {
	graph  [][]int
	colors []int
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func newGraph(nodeNum int) *graph {
	colors := make([]int, nodeNum)
	g := make([][]int, nodeNum)
	for i := 0; i < nodeNum; i++ {
		g[i] = []int{}
		colors[i] = nocolor
	}

	return &graph{g, colors}
}

func constructGraph(sc *bufio.Scanner) *graph {
	usersNum := nextInt(sc)
	linkNum := nextInt(sc)

	g := newGraph(usersNum)
	for i := 0; i < linkNum; i++ {
		u := nextInt(sc) // node
		l := nextInt(sc) // link node
		// edge each other
		g.graph[u] = append(g.graph[u], l)
		g.graph[l] = append(g.graph[l], u)
	}
	return g
}

func (g *graph) dfs(r, color int) {
	g.colors[r] = color

	stack := list.New()
	stack.PushFront(r)

	for stack.Len() > 0 {
		v := stack.Remove(stack.Front()).(int)
		for _, u := range g.graph[v] {
			if g.colors[u] == nocolor {
				g.colors[u] = color
				stack.PushFront(u)
			}
		}
	}
}

func (g *graph) assignColor() {
	color := 1
	for u := 0; u < len(g.graph); u++ {
		if g.colors[u] == nocolor {
			g.dfs(u, color)
			color++
		}
	}
}

func (g *graph) isLink(s, t int) bool {
	return g.colors[s] == g.colors[t]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// construct graph and friendly colors
	g := constructGraph(sc)
	g.assignColor()

	// judge link
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		s := nextInt(sc)
		t := nextInt(sc)

		if g.isLink(s, t) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}



Measured memory_bytes: 13880