akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
int32_t main()
{
fastio;
int test;in test;
int ans=0;
unordered_map<string,int> hash;
while(test--){
  string s;in s;
//  vector<char> ch;
//  out ch.size()<<endl;
  //rep(i,s.size()){
    //ch.pb(s[i]);
  //}
  sort(s.begin(),s.end());
  //out "changed"<<endl;
//sort(ch.begin(),ch.end());
    hash[s]++;

}
for(auto itr=hash.begin();itr!=hash.end();itr++)
    {
      int t=itr->second;
      ans+=(t*(t-1)/2);
    }
out ans;
    return 0;
}


Measured memory_bytes: 10660
#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>
#if __cplusplus >= 201103L
#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>
#endif
#define int long long
using namespace std;
const long long maxn = 1000100, mod = 1e9 + 7, maxa = 3e6 + 100, maxb = 23, base = 737, base2 = 3079, mod2 = 242121643;
const long long inf = 2e18 + 13;
long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}



int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n, m;
    cin >> n >> m;
    cout << (1 << m) * (m * 1900 + (n - m) * 100) << endl;
    return 0;
}












Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    inlis.sort()
    #print(inlis)

    if k >= n:
        print(0)
        exit()
    elif k > 0:
        total = sum(inlis[:-k])
    elif k == 0:
        total = sum(inlis)
    print(total)

    
if __name__ == "__main__":
    main()


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


int main(){

 int a,b,c,d;
 cin>>a>>b>>c>>d;

 	int p=0;

 	while(c>0){
 		p++;
 		c-=b;
 	}
 	int dd=0;
	while(a>0){
	  dd++;
	  a-=d;
	}

	if(p<=dd){
		cout<<"Yes";
	}else{
		cout<<"No";
	}

}

Measured memory_bytes: 3636
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    # a = list(map(int, input().split()))
    
    ans = a[0]
    if 0 in a:
        ans = 0
    else:    
        for i in range(1, n):
            ans *= a[i]
            if ans > 10 ** 18:
                ans = -1
                break

    print(f'{ans}')


if __name__ == '__main__':
    main()

Measured memory_bytes: 21672
a, b, c, d = gets.chomp.split("").map(&:to_i)
op = []
flag = false
(0..1).each do |i|
    (0..1).each do |j|
        (0..1).each do |k|
            if a + (i*2-1)*b + (j*2-1)*c + (k*2-1)*d == 7
                op.push(i, j, k)
                flag = true
            end
            break if flag
        end
        break if flag
    end
    break if flag
end
(0..2).each do |i|
    if op[i] == 1
        op[i] = '+'
    else 
        op[i] = '-'
    end
end

puts "#{a}#{op[0]}#{b}#{op[1]}#{c}#{op[2]}#{d}=7"

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

int main(void){
	int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int i;
	scanf("%d",&i);
	printf("%d",k[i-1]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<-1<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  map<int,int> s;
  s[-LINF]=1;
  typedef pair<int,int> P;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    P p=*--s.lower_bound(a);
    if(p.first<0){
      s[a]++;
      continue;
    }
    s[p.first]--;if(s[p.first]==0)s.erase(p.first);
    s[a]++;
  }
  int ans=-1;
  for(auto q:s)ans+=q.second;
  cout<<ans<<endl;
}


Measured memory_bytes: 6400
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    if a[i] <= b[i]:
        ans += a[i]
        b[i] -= a[i]
    else:
        ans += b[i]
        b[i] = 0

    if a[i+1] <= b[i]:
        ans += a[i+1]
        a[i+1] = 0
    else:
        ans += b[i]
        a[i+1] -= b[i]
print(ans)

Measured memory_bytes: 24136
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint X;
	cin >> X;
	lint ans = 0;
	ans += (X / 11)*2;
	X %= 11;
	if (X >= 7) {
		ans += 2;
	}
	else if(X!=0) {
		ans += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		ll N; input_returnner(ll N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(ll N) { return std::move(input_returnner(N)); }
}

const ll MOD = 1e9 + 7;

void solve();

signed main() {
	SETUP;
	solve();
#ifdef _DEBUG
	system("pause");
#endif
	return 0;
}

int dp[302][302][301] = {}; // dp[l][r][x] : x個文字列を変更する権利を使用した時に, [l,r)間で最長となる回文

void solve() {
	string S; cin >> S;
	int K; cin >> K;
	REP(i, S.size()) REP(x,K+1){
		dp[i][i + 1][x] = 1;
	}
	FOR(w, 2, S.size()+1) {
		FOR(l, 0, S.size() + 1 - w) {
			FOR(x, 0, K+1) {
				int r = l + w;
				// cout << S[l] << " " << S[r-1] << endl;
				if (S[l] == S[r-1]) {
					dp[l][r][x] = dp[l + 1][r - 1][x] + 2;
				}
				else {
					dp[l][r][x] = max(dp[l + 1][r][x], dp[l][r - 1][x]);
					if(x-1 >= 0) dp[l][r][x] = max(dp[l][r][x], dp[l + 1][r - 1][x - 1] + 2);
				}
			}
		}
	}
	int res = 0;
	REP(i, K+1) {
		res = max(res, dp[0][S.size()][i]);
	}
	cout << res << endl;
}


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

ll mod = 1000000007;

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

int sum[500][500];

int rsum(int l, int r, int p) {
	if (l == 0) return sum[r][p];
	int ret = sum[r][p] - sum[l - 1][p];
	if (ret < 0) ret += mod;
	return ret;
}

int dp[500][500];

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

	int n, c;
	cin >> n >> c;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	for (int i = 1; i < 500; i++) {
		rep(j, 500) {
			sum[i][j] = sum[i - 1][j] + modpow(i, j);
			if (sum[i][j] > mod) sum[i][j] -= mod;
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= c; j++) {
			for (int k = 0; k <= j; k++) {
				dp[i][j] += dp[i - 1][k] * rsum(a[i - 1], b[i - 1], j - k);
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n][c] << endl;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
long long work(long long c,long long n);
int main(){
	long long a,b,x;
      cin >> a >> b >> x;
  long long total = work(b,x) - work(a - 1,x);
  cout << total << endl;
return 0;
}

long long work(long long c,long long n){
  if(c < 0){
    return 0;
  }else{
    return c / n + 1;
}
}

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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();

		if(A+B<=K)
			System.out.println("0 0");
		else if  (A >= K)
			System.out.println( (A - K) + " " + B);
		else if (A < K)
			System.out.println("0 " + (B - K + A));
	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
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: 23124
#include <stdio.h>

int N, M, x[112345], y[112345];
int num[112345];
bool red[112345];
int ans;

int main(void)
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) { scanf("%d%d", &x[i], &y[i]); }

	for (int i = 0; i < N; ++i)
	{
		num[i] = 1;
		red[i] = false;
	}
	red[0] = true;
	for (int i = 0; i < M; ++i)
	{
		if (red[x[i] - 1] == true)
		{
			red[y[i] - 1] = true;
		}
		--num[x[i] - 1];
		++num[y[i] - 1];
		if (num[x[i] - 1] == 0)
		{
			red[x[i] - 1] = false;
		}
	}

	for (int i = 0; i < N; ++i)
	{
		if (red[i] == true)
		{
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main(){
    string s,c;
    int n,i,j,k;
    cin>>n;
    if(n%10==3){cout<<"bon";}
    else if(n%10==0||n%10==1||n%10==6||n%10==8){cout<<"pon";}
    else {cout<<"hon";}


    return 0;
}


Measured memory_bytes: 3636
use std::io;

fn main() {
    let mut input_line: String = String::new();
    io::stdin().read_line(&mut input_line).expect("err");

//    let inputs: Vec<&str> = input_line.split_whitespace().collect();

    let chars: Vec<char> = input_line.to_string().chars().collect();

    let mut begin_pos: i32 = 0;
    let mut end_pos: i32 = 0;

    //前からAを見つけて
    for i in 0..chars.len(){
        // println!("checking:{} (i:{})", chars[i], i);

        if chars[i] == "A".parse().unwrap() {
            begin_pos = i as i32;
            // println!("find! i:{}", i);
            break;
        }
    }

    //最後のZを見つけて
    for i in 0..chars.len(){
        // println!("checking:{} (i:{})", chars[i], i);

        if chars[i] == "Z".parse().unwrap(){
            end_pos = i as i32;
            // println!("find! i:{}", i);
        }
    }

    print!("{}", end_pos - begin_pos + 1);

}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
const long long mod = 998244353;
long long power(long long a, long long b){
    long long res = 1;
    while(b > 0){
        if(b % 2){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b /= 2;
    }
    return res;
}
long long n;
int main(){
    long long n, val, ans = 0, f[N] = {0}, tot[N] = {0}, prodsum[N] = {0};
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++){
        scanf("%lld", &val);
        f[val]++;
    }
    for(long long int i = 1; i < N; i++){
        for(long long int j = i; j < N; j += i){
            long long cnt = 1LL * f[j] * (f[j] - 1) / 2;
            prodsum[i] += cnt * j % mod * j % mod;
            prodsum[i] %= mod;
            prodsum[i] += 1LL * tot[i] * j % mod * f[j] % mod;
            prodsum[i] %= mod;
            tot[i] += 1LL * j * f[j] % mod;
            tot[i] %= mod;
        }
    }
    for(long long int i = N - 1; i >= 1; i--){
        for(long long int j = 2 * i; j < N; j += i){
            prodsum[i] -= prodsum[j];
            prodsum[i] %= mod;
            prodsum[i] += mod;
            prodsum[i] %= mod;
        }
        ans += 1LL * prodsum[i] * power(i, mod - 2) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 23808
def solve(n,a,i,j,ans,last,nextSmall)
  while (n-i+j+1) > 0
    if n-i+j == 0
      ans += [(a[i]-last.min).abs,(a[i]-last.max).abs ].max
      i += 1
    elsif nextSmall
      ans += last[0] + last[1] - a[i] - a[i+1]
      last = [a[i],a[i+1]]
      i += 2
      nextSmall = false
    else
      ans += a[j] + a[j-1] - last[0] - last[1]
      last = [a[j],a[j-1]]
      j -= 2
      nextSmall = true
    end
  end
  return ans
end

n = gets.to_i
a = []
n.times do
  a << gets.to_i
end
a.sort!
if n == 2
  p a[1] - a[0]
elsif
  ans = []
  # 最小値を中央
  i,j = 1,-3
  v = a[-1] + a[-2] - a[0] * 2
  last = [a[-1],a[-2]]
  ans << solve(n,a,i,j,v,last,true)
  #最大値を中央
  i,j = 2,-2
  v = a[-1] * 2 - a[0] - a[1]
  last = [a[0],a[1]]
  ans << solve(n,a,i,j,v,last,false)
  p ans.max
end


Measured memory_bytes: 5624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;
int maxh;

Node treeSearch(Node u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  int H;
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  maxh=0;
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20480
#include<stdio.h>
 int main()
 {

     int D;
     scanf("%d",&D);
     if(D==25)
        printf("Christmas");
        else if(D==24)
        printf("Christmas Eve");
        else if(D==23)
        printf("Christmas Eve Eve");
     else if(D==22)
        printf("Christmas Eve Eve Eve");
    else

     return 0;
 }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e6+10,mod=1e9+7;

int main ()
{
    FASTIO
    ll n , m ;
    cin >> n >> m ;
    cout << (n-1)*n/2 + m*(m-1)/2 << endl;
    return 0;
}
/**
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, C;
    cin >> N >> C;
    vector<pair<int, int>> sushi(N);
    for (int i = 0; i < N; i++) cin >> sushi[i].first >> sushi[i].second;
    vector<int> left(N), right(N);
    int sum = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        sum += sushi[i].second;
        ans = max(ans, sum - sushi[i].first);
        if (i == 0) left[i] = sum - 2 * sushi[i].first;
        else left[i] = max(left[i - 1], sum - 2 * sushi[i].first);
    }
    sum = 0;
    for (int i = N - 1; i >= 0; i--) {
        sum += sushi[i].second;
        int temp = C - sushi[i].first;
        ans = max(ans, sum - temp);
        if (i == N - 1) right[i] = sum - 2 * temp;
        else right[i] = max(right[i + 1], sum - 2 * temp);
    }
    sum = 0;
    for (int i = 0; i < N; i++) {
        sum += sushi[i].second;
        if (i == N - 1) {
            ans = max(ans, sum - sushi[i].first);
            break;
        }
        ans = max(ans, right[i + 1] + sum - sushi[i].first);
    }
    sum = 0;
    for (int i = N - 1; i > 0; i--) {
        sum += sushi[i].second;
        int temp = C - sushi[i].first;
        if (i == 0) {
            ans = max(ans, sum - temp);
            break;
        }
        ans = max(ans, left[i - 1] + sum - temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
var
s,s1:string;
i,j,n,m:longint;
 begin
read(s1);
for i:=1 to length(s1) do
 begin
  if s1[i]='1' then s:=s+'1';
  if s1[i]='0' then s:=s+'0';
  if s1[i]='B' then delete(s,length(s),1);
end;
writeln(s);
end.

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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

char str[1011];

int main(){
	scanf("%s",str);
	int l=strlen(str);
	int n=0,s=0,w=0,e=0;
	REP(i,l){
		if(str[i]=='N')
			n++;
		if(str[i]=='S')
			s++;
		if(str[i]=='W')
			w++;
		if(str[i]=='E')
			e++;
	}
	if((n&&s==0)||(n==0&&s)||(e&&w==0)||(e==0&&w))
		printf("No\n");
	else
		printf("Yes\n");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 4) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 4) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2]);
      t.step = step;

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2]));
      que.peekLast().step = cur.step + 1;
      que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2]));
      que.peekLast().step = cur.step + 1;
      que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2));
      que.peekLast().step = cur.step + 1;

      que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2]));
      que.peekLast().step = cur.step + 1;
      que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1));
      que.peekLast().step = cur.step + 1;
      que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1));
      que.peekLast().step = cur.step + 1;
      
    }
  }

  class Tuple3 {
    int[] e;
    int state;
    int step;

    public Tuple3(int a, int b, int c) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      state = (a*10000) + (b*100) + c;
      step = 0;
    }

    @Override
    public boolean equals(Object obj) {
      if(obj == this) return true;
      if(obj == null) return false;
      if(!(obj instanceof Tuple3)) return false;

      Tuple3 ref = (Tuple3) obj;

      return this.state == ref.state ? true : false;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

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

int main() {
	int n, ans;
  	cin >> n;
  	ans = 0;
  	vector<int> p(n);
  	for (int i=0; i<n; i++) {
      	cin >> p[i];
    }
  	for (int i=1; i<n-1; i++) {
      if  ((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) {
        	ans++;
      }
    }
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]
// ModInt
type ModInt = MVal of int64

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module ModInt =
  let modulo = (int64 1e9)+7L

  let inline init (x: ^a): ModInt =
    let x = (int64 x) % modulo
    match x with
    | _ when x < 0L -> MVal (x + modulo)
    | _ -> MVal x
  
  let value (MVal x) = x
  
type ModInt with
  static member inline ( + ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x+y)
  static member inline ( - ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x-y)
  static member inline ( * ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x*y)
  static member inline ( / ) (lhs: ModInt, rhs: ModInt) =
    let rec pow n m = (if (m&&&1L)=1L then n else ModInt.init 1) * (if m=0L then ModInt.init 1 else (pow (n*n) (m>>>1)))
    let invB = pow rhs (ModInt.modulo-2L)
    lhs * invB
// ModInt

// start
let (N,K) = readPair int64 int64 ()

let sum l r = (l+r)*(r-l+1L)/2L

let min k = sum 0L (k-1L)
let max k = sum (N-k+1L) N

seq {
  for k in K..(N+1L) -> (max k)-(min k)+1L
}
|> Seq.map ModInt.init
|> Seq.fold (+) (ModInt.init 0)
|> ModInt.value
|> printfn "%d"

Measured memory_bytes: 39324
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int s[10];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	int dummy;



	//データの読み込み


//	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e);
//	scanf_s("%d %d %d %d %d %d",&a,&b,&c,&d,&e);

	for(i=0;i<5;i++){
		scanf("%d",&s[i]);
//		scanf_s("%d",&s[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp=0;
	ans=0;
	for(i=0;i<5;i++){
		temp=max(temp,(s[i]+9)/10*10-s[i]);
		ans=ans+(s[i]+9)/10*10;
	}



	//	printf("計算部分終了\n");

	//出力
	printf("%lld",ans-temp);


/*	for(i=0;i<b+w;i++){
		printf("%lld %lld\n",black[i],white[i]);
	}*/


	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		System.out.println(3 * N * N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21204
from collections import Counter
import collections

N = int(input())
a = [input() for i in range(N)]

c = collections.Counter(a)
hoge = c.most_common()
i = 0

list = []
if(len(hoge) == 1):
	list.append(hoge[0][0])
elif(len(hoge) == N):
  list = a
else:
  ##for i in range(0,len(c.most_common())-1):
    while(hoge[i][1] == hoge[0][1]):
        list.append(hoge[i][0])
        i += 1



list.sort()

print(' \n'.join(map(str, list)))

    



Measured memory_bytes: 50800
N, M = map(int, input().split())
Xs = sorted(list(map(int, input().split())))
diffs = sorted([Xs[i+1] - Xs[i] for i in range(len(Xs)-1)])
if N >= M:
  ans = 0
else:
  ans = sum(diffs[:M-N])

print(ans)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
  int n,w;
  scanf("%d %d",&n,&w);
  vector<pair> v(n+1);
  for(int i=1;i<=n;i++)
    scanf("%d %d",&v[i].f,&v[i].se);
 // auto it=v.begin();it++;
 // sort(it,v.end());
  ll ans[n+1][w+1];
  for(int i=0;i<=n;i++)
    ans[i][0]=0;
  for(int i=0;i<=w;i++)
    ans[0][i]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=w;j++)
    {
     // cout<<v[i].f<<" "<<v[i].se<<"\n";
      if(v[i].f>j)
        ans[i][j]=ans[i-1][j];
      else
        ans[i][j]=max(ans[i-1][j],ans[i-1][j-v[i].f]+v[i].se);
    }
  }
 /* for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
      printf("%d ",ans[i][j]);
    printf("\n");
  }*/
  printf("%lli",ans[n][w]);
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,q;
int a[SIZE],b[SIZE];
ll x[SIZE];

int c;
vector<int> E[SIZE];
ll d[SIZE]; //init:0

void dfs(int v,ll y){
  d[v]=y+x[v];
  for(int to : E[v]) if(d[to] == -1){
    dfs(to,d[v]);
  }
}

int main(){
  cin >> n >>q;
  rep(i,1,n){
    cin >> a[i] >> b[i];
    E[a[i]].push_back(b[i]);
    E[b[i]].push_back(a[i]);
  }
  rep(i,0,q){
    int p;
    ll y;
    cin >> p >> y;
    x[p] += y;
  }
  fill(d,d+SIZE,-1);
  dfs(1,0);

  rep(i,0,n){
    if(i!=0) cout << " ";
    cout << d[i+1];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####

def solve(N, K, A):
    snackless = set(range(1, N+1))
    for row in A:
        for x in row:
            snackless.discard(x)
    return len(snackless)

N,K = rrm()
A = []
for _ in xrange(K):
    rri()
    A.append(rrm())
print solve(N, K, A)


Measured memory_bytes: 69116
#include <iostream>
#include <random>
#include <map>
#include <cstring>
#include <stdio.h>
#include <string>
#include <cctype>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
typedef long long ll;
typedef vector<int> vi;
typedef string::const_iterator State;
map<string,bool> mp;
string board[15];
int main(int argc,char const* argv[])
{
  string info;
  int sx,sy,gx,gy;
  while(cin >> info && info!="#")
    {
      string board[15]={};
      string ans="";
      int H=0,W=0;
      bool slash=false;
      int dot=0;
      cin >> sy >> sx >> gy >> gx;
      sx--,sy--,gx--,gy--;
      for(int i=0;i<int(info.size());i++)
	{
	  if(info[i]=='/')
	    {
	      H++;
	      if(!slash) slash=true;
	    }
	  else if(info[i]=='b')
	    {
	      board[H]+='b';
	      if(!slash) W++;
	    }
	  else
	    {
	      dot=(info[i]-'0');
	      for(int j=0;j<dot;j++)
		{
		  board[H]+='.';
		}
	      if(!slash) W+=dot;
	    }
	}
      board[sy][sx]='.';
      board[gy][gx]='b';
      for(int i=0;i<=H;i++)
	{
	  int now=0;
	  for(int j=0;j<W;j++)
	    {
	      if(board[i][j]=='.') now++;
	      else if(board[i][j]=='b')
		{
		  if(now>0)
		    {
		      ans+=to_string(now);
		    }
		  ans+='b';
		  now=0;
		}
	    }
	  if(now>0)
	    {
	      ans+=to_string(now);
	    }
	  if(i!=H) ans+='/';
	}
      cout << ans << endl;
    }
  return 0;
}



Measured memory_bytes: 3296
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long int;
//// 任意長整数型
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;



int main(int argc, char *argv[])
{
	//input
	ll h, w;
	cin >> h >> w;


	//calc
	ll ans;
	if (h == 1 || w == 1){
		ans = 1;
	}
	else{
		ans = (h / 2) * (w / 2) * 2;
		ans += (h % 2) * (w / 2) + (w % 2) * (h / 2);
		ans += (h % 2) * (w % 2);
	}


	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	double n=1.0*read()/3;
   	printf("%.8lf\n",n*n*n);
    return 0;
}

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


#define INFTY  200006;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> f(n),pe(n);
	int ans1=0, ans2=0;
	rep(i,m){
		int p;
		string s;
		cin >> p >> s;
		p--;
		if(s[0] == 'A') f[p] = 1;
		if(f[p] == 0 && s[0] == 'W') pe[p]++;
	}
	rep(i,n){
		if(f[i] == 1){
			ans1++;
			ans2+= pe[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[1005];
int main(){
	cin>>n;
	repn(i,n) cin>>a[i];
	ll so=0,se=0;
	repn(i,n){
		if(a[i]<0) continue;
		if(i%2 == 1) so+=a[i];
		else se+=a[i];
	}
	if(so == 0 && se == 0){
		ll mx = -1e18; int v = -1;
		repn(i,n){
			if(mx < a[i]){
				mx = a[i];
				v = i;
			}
		}
		cout<<mx<<endl;
		cout<<n-1<<endl;
		for(int i=1;i<v;i++) puts("1");
		int zan = n-v+1;
		for(int i=v+1;i<=n;i++) printf("%d\n",zan--);
		return 0;
	}
	cout<<max(so,se)<<endl;
	vector<int>ans;
	if(so == max(so,se)){
		vector<int>use;
		repn(i,n){
			if(a[i]<0) continue;
			if(i%2 == 1) use.pb(i);
		}
		for(int i=1;i<use[0];i++){
			ans.pb(1);
		}
		for(int i=1;i<use.size();i++){
			int dif = 1+(1+use[i]-use[i-1]);
			dif /= 2;
			while(dif != 1){
				ans.pb(dif--);
			}
		}
		int zan = n-use[use.size()-1]+1;
		for(int i=0;i<n-use[use.size()-1];i++){
			ans.pb(zan--);
		}
		printf("%d\n",ans.size());
		rep(k,ans.size())printf("%d\n",ans[k]);
	}
	else{
		vector<int>use;
		repn(i,n){
			if(a[i]<0) continue;
			if(i%2 == 0) use.pb(i);
		}
		for(int i=1;i<use[0];i++){
			ans.pb(1);
		}
		for(int i=1;i<use.size();i++){
			int dif = 1+(1+use[i]-use[i-1]);
			dif /= 2;
			while(dif != 1){
				ans.pb(dif--);
			}
		}
		int zan = n-use[use.size()-1]+1;
		for(int i=0;i<n-use[use.size()-1];i++){
			ans.pb(zan--);
		}
		printf("%d\n",ans.size());
		rep(k,ans.size())printf("%d\n",ans[k]);
	}
}

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

int main(void){
    int n, w, h;
    cin >> n >> w >> h;
    
    vector<pair<int, int> > height, width;
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        width.emplace_back(x - z, -1);
        width.emplace_back(x + z, 1);
        height.emplace_back(y - z, -1);
        height.emplace_back(y + z, 1);
    }
    
    sort(width.begin(), width.end());
    sort(height.begin(), height.end());
    
    bool can1 = true, can2 = true;
    int f1 = 0, f2 = 0;
    if (width[0].first > 0) can1 = false;
    if (width[width.size() - 1].first < w) can1 = false;
    for (int i = 0; i < width.size(); i++) {
        if (width[i].second == -1) f1++;
        else f1--;
        if (f1 == 0 && i != width.size() - 1) can1 = false;
    }
    if (height[0].first > 0) can2 = false;
    if (height[height.size() - 1].first < h) can2 = false;
    for (int i = 0; i < height.size(); i++) {
        if (height[i].second == -1) f2++;
        else f2--;
        if (f2 == 0 && i != height.size() - 1) can2 = false;
    }
    
    //for (int i = 0; i < width.size(); i++) cout << width[i].first << " "<<width[i].second << endl;
    //for (int i = 0; i < height.size(); i++) cout << height[i].first << " "<<height[i].second << endl;
    
    if (can1 || can2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
}



Measured memory_bytes: 6276
#include <stdio.h>
int arr[3];
int visit[3];
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	bool isok=true;
	while(M--){
		int s,c;
		scanf("%d %d",&s,&c);
		if(visit[s-1]) isok&=arr[s-1]==c;
		visit[s-1]=1;
		arr[s-1]=c;
	}
	if(!isok){
		printf("-1");
		return 0;
	}
	for(int i=0;i<N;i++){
		if(N>1&&i==0){
			if(visit[i]&&arr[i]==0){
				printf("-1");
				return 0;
			}
			else printf("%d",visit[i]?arr[i]:1);
		}
		else{
			printf("%d",visit[i]?arr[i]:0);
		}
	}
}

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

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

    vector<int> d(N);
    vector<bool> checked(N);

    rep(i,N){
        cin >> d.at(i);
    } 

    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    
    cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    vll l(n); REP(i,n) cin>>l[i];
    VSORT(l);
    if (2 * l[n-1] < accumulate(ALL(l),0LL)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, w_max = map(int, input().split())
X = []
for _ in range(n):
    X.append(list(map(int, input().split())))

W = [0] * (w_max + 1)

for i in range(len(W)):
    for x in X:
        xv, xw = x[0], x[1]
        if i - xw >= 0:
            W[i] = max(W[i], W[i - xw] + xv)

print(max(W))


Measured memory_bytes: 5916
def solve(A, N):
    ret = 0
    while max(A) > N-1:
        for i in range(N):
            if A[i] > N-1:
                t = A[i]//N
                for j in range(N):
                    if j == i:
                        A[j] -= t*N
                        continue
                    A[j] += t
                ret += t
    return ret
N = int( input())
A = list( map( int, input().split()))
ans = 0
for i in range(N):
    if A[i] > N-1:
        t = A[i]//N
        for j in range(N):
            if j == i:
                A[j] -= t*N
                continue
            A[j] += t
        ans += t
for i in range(N):
    if A[i] > N+1:
        t = A[i]//(N+1)
        if A[i] - t*(N+1) <= N-1:
            t -= 1
        A[i] -= t*(N+1)
        ans += t*(N+1)
print( ans + solve(A,N))


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll n,m,k,u;
ll p,q;

class dijkstra{
  public:
	struct edge{ ll to, cost;};
	ll V;
	vector<vector<edge> > G;
	vector<ll> d;
	dijkstra(ll nv){
		nv += 10;
		d = vector<ll>(nv); 
		V = nv;
		G = vector<vector<edge> >(nv);
	}
		
	void run(ll s){
		priority_queue<P, vector<P>, greater<P> > que;
		fill(d.begin(), d.end(), LLONG_MAX);
		d[s] = 0;
		que.push(P(0, s));

		while(!que.empty()){
			P p = que.top(); que.pop();
			ll v = p.second;
			if(d[v] < p.first) continue;
			for (ll i = 0;i < G[v].size();i++){
				edge e = G[v][i];
				if(d[e.to] > d[v] + e.cost){
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to],e.to));
				}
			}
		}
	}
};

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

	cin >> n >> m >> k >> u;
	cin >> p >> q;

	ll s[100005]; memset(s,-1,sizeof(s)); //-1:正常 それ以外：ゾンビからの距離
	queue<ll> que;
	vector<ll> edge[100005];
	
	for (ll i = 0;i < k;i++){
		ll tmp; cin >> tmp; tmp--;
		s[tmp] = 0;
		que.push(tmp);
	}

	for (ll i = 0;i < m;i++){
		ll a,b; cin >> a >> b;
		a--; b--;
		edge[a].push_back(b); edge[b].push_back(a);
	}

	while(que.size()){
		ll now = que.front(); que.pop();
		for (ll i = 0;i < edge[now].size();i++){
			ll next = edge[now][i];
			if(s[next] == -1){
				s[next] = s[now]+1;
				que.push(next);
			}
		}
	}

	dijkstra D(n);

	for (ll i = 0;i < n;i++){
		for (ll j = 0;j < edge[i].size();j++){
			ll next = edge[i][j];
			if(next == n-1){
				D.G[i].push_back({next,0});
			}else if(s[next] == -1 || s[next] > u){
				D.G[i].push_back({next,p});
			}else if(s[next] != 0){
				D.G[i].push_back({next,q});
			}
		}
	}

	D.run(0);

	cout << D.d[n-1] << endl;

	return 0;

}



Measured memory_bytes: 24908
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int n;
	cin >> n;
	PRI(lcm(n, 2));
	return 0;
}

Measured memory_bytes: 3624