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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    vector<ll> V(N);
    REP(i, N) cin >> V[i];
    ll target = 1;
    ll sum = 0;
    ll ans1 = 0;
    REP(i, N) {
        ll nsum = sum + V[i];
        // debug(nsum);
        if (i) target = (ll) -1 * (sum / abs(sum));
        if (nsum == 0) {
            ans1 += abs(target - nsum); 
            sum = target;
        } else {
            ll nsign = nsum / abs(nsum);
            // debug(nsign);
            if (nsign == target) {
                sum = nsum;
                // continue;
            } else {
                ans1 += abs(target - nsum);
                sum = target;
            }
        }

    }
    target = -1;
    sum = 0;
    ll ans2 = 0;
    REP(i, N) {
        ll nsum = sum + V[i];
        // debug(nsum);
        if (i) target = (ll) -1 * (sum / abs(sum));
        if (nsum == 0) {
            ans2 += abs(target - nsum); 
            sum = target;
        } else {
            ll nsign = nsum / abs(nsum);
            // debug(nsign);
            if (nsign == target) {
                sum = nsum;
                // continue;
            } else {
                ans2 += abs(target - nsum);
                sum = target;
            }
        }
    }
    cout << min(ans1, ans2) << endl;

}

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

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:22:07:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n;
    cin>>n;
    cout<<(n*(n-1))/2;
    return 0;
}





















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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000


ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2;i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
	ll res;
	res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
	return res;
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<ll>fact(MAX+1), ifact(MAX+1);
  getfact(fact, ifact);
  ll n,m,k;
  cin>>n>>m;
  vector<ll>a(n);
  for(ll i=0;i<n;i++) cin>>a[i];
  sort(all(a));
  ll res = 0;
  for(ll i=m-1;i<n;i++)
  {
    res = (res + (a[i] * ncr(i, m-1, fact, ifact)) % MOD) % MOD;
  }
  for(ll i=0;n-i>=m;i++)
  {
    res = ((res - (a[i] * ncr(n-i-1, m-1, fact, ifact)) % MOD) + MOD) % MOD;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;

// computational complexity : O(E*logV)

struct edge{
    int to;
    long long int cost;
};

int V,E;// number of (vertices, edges)
vector<vector<edge>> graph;
vector<long long int> d;// shortest distances

void Dijkstra(int s){// s = starting point
    priority_queue<
        pair<long long int, int>// temporarily keeping (shortest distance, vertex)
        , vector<pair<long long int, int>>, greater<pair<long long int, int>>// shorter ones first
    > pq;

    // initialize (INF)
    for(int i=0; i<V; i++){
        d[i] = INF;
    }
    d[s] = 0;
    pq.push({0,s});

    // search
    pair<long long int, int> current;// (shortest-distance confirmed, vertex)
    while(!pq.empty()){
        current = pq.top(); pq.pop();

        int v = current.second;
        if(d[v] < current.first){
            continue;// ignore (not the shortest path)
        }
        // else (need to check)
        for(edge e : graph[v]){// adjacent nodes
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;// update minimum cost
                pq.push({d[e.to], e.to});
            }
        }
    }
}

int main(){
    cin >> V >> E;
    graph.resize(V);
    d.resize(V);
    for(int i=0; i+1<V; i++){
        graph[i+1].push_back({i,0});
    }

    for(int i=0; i<E; i++){
        int l, r, c;
        cin >> l >> r >> c;
        l -= 1;
        r -= 1;
        graph[l].push_back({r,c});
    }

    Dijkstra(0);// starting from s
    if(d[V-1] != INF) cout << d[V-1] << endl;
    if(d[V-1] == INF) cout << -1 << endl;
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<i32> l(k), r(k);
    for (i32 i = 0, d = 0; i < k; i++) {
        while (s[d] == 'x') d++;
        l[i] = d;
        d += c + 1;
    }
    for (i32 i = k-1, d = n-1; i >= 0; i--) {
        while (s[d] == 'x') d--;
        r[i] = d;
        d -= c + 1;
    }

    for (i32 i = 0; i < k; i++) {
        if (l[i] == r[i]) cout << l[i] + 1 << endl;
    }
}


Measured memory_bytes: 4996
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = reader.readLine().split(" ");
        int r = Integer.parseInt(arr[0]);
        int d = Integer.parseInt(arr[1]);
        int x = Integer.parseInt(arr[2]);
        for (int i = 0; i < 10; i++) {
            x = r * x - d;
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 20948
//PLUS ULTRA
//one who sits atop all the clans : Lion's Sin Escanor 

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

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

	bool safe[101];
	memset(safe  , true , sizeof(safe));
	int d , inp;

	forn(i,0,k){
		 cin >> d;
		forn(j,0,d){
			cin >> inp;
			safe[inp] = false; 

		}
	}

	int cnt = 0;

	forn(i,1,n+1){

		if(safe[i])cnt++;

	}

	cout << cnt << "\n";
    
        


}

int main(){
    SPEED;

    solve();


    return 0;
}
      
       


Measured memory_bytes: 3652
'use strict'

function Main(input) {
    const tape = input.split('\n')[0].split('');
    const result = []

    for (const v of tape) {
        if (v === 'B') {
            result.pop();
        } else {
            result.push(v);
        }
    }

    console.log(result.join(''));
}

// input
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
// AOJ 0363 Loading
// 2018.2.11 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

char b[20002];
int dp[20002][16];

int main()
{
	int h, n, x, y;
	int i, h1, ans;
	
	h = in(), n = in(), h1 = h-1;
	while (n--) {
		x = in();
		b[in()] |= 1 << x;
	}
	
	for (y = 0; y < h1; y++) {
		if (!b[y] && !b[y+1]) {
			if (dp[y+1][15] < dp[y][x]+2) dp[y+1][15] = dp[y][0]+2;
		}
		
		for (x = 0; x < 16; x++) {
			if (dp[y+1][0] < dp[y][x]) dp[y+1][0] = dp[y][x];

			for (i = 0; i < 3; i++) {
				int mask = 3 << i;
				if (!(x & mask) && !(b[y] & mask) && !(b[y+1] & mask)) {
					if (dp[y+1][mask] < dp[y][x]+1) dp[y+1][mask] = dp[y][x]+1;
				}
			}
		}
	}
	
	ans = 0, i = 16; while (i--) if (ans < dp[h1][i]) ans = dp[h1][i];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2376
#include<bits/stdc++.h>
#include<numeric>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

// 最大公約数のll版
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	return b == 0 ? a : gcd(b, a % b);
}

// 最小公倍数のll版
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

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

	ll N, M;
	cin >> N >> M;

	string S, T;
	cin >> S >> T;

	ll g = gcd(N, M);
	ll l = lcm(N, M);

	ll index = 0;
	while (true){
		if(S[index/M] != T[index/N]){
			//cout << index << endl;
			cout << "-1" << endl;
			return 0;
		}
		else{
			index += l;
			if(index/M >= N || index/N >= M){
				cout << l << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0;i<N;i++){
			W = in.readLine();
			A[i]=Integer.parseInt(W);
			B[i]=Integer.parseInt(W);
		}

		Arrays.sort(B);

		for(int i=0;i<N;i++){
			int indx = Arrays.binarySearch(B, A[i]);
			if(indx ==N-1){
				System.out.println(B[indx-1]);
			}else {
				System.out.println(B[N-1]);
			}
		}
	}

}


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

int32_t main()
{
    int d,g;
    cin>>d>>g;

    vector<array<int,2>> s(d);
    for(int i=0;i<d;i++)
    cin>>s[i][0]>>s[i][1];
     int ans=INT_MAX;
    for(int i=0;i<(1<<d);i++)
    {
        int left=-1,sum=0,count=0;
        for(int j=0;j<d;j++)
        {
            if((i>>j)&1)
                sum+=100*(j+1)*s[j][0]+s[j][1],count+=s[j][0];
            else
            left=j;
        }
        if(sum<g)
        {
            int c=100*(left+1);
            int need=(g-sum+c-1)/c;
            if(need>=s[left][0])
            continue;
            count+=need;
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;



}

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

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

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

    vector<int> ans(n);
    while(b.size() != 0){
        bool flag = false;
        for(int i=b.size()-1; i>=0; i--){
            if(b[i] == i+1){
                ans.push_back(b[i]);
                b.erase(b.begin() + i);
                flag = true;
                break;
            }
        }
        if(flag == false){
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(),ans.end());
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<pair<ll, ll>> XL(N);
    vll X(N), L(N);
    rep(i, N) {
        ll x, l;
        cin >> x >> l;
        XL[i] = make_pair(x + l, x - l);
    }
    sort(XL.begin(), XL.end());
    ll max_start = -INF;
    ll max_end = -INF;
    ll ans = 0;
    rep(i, N) {
        if (max_end <= XL[i].second) {
            max_end = XL[i].first;
            ans++;
        }
    }
    //ll ans = 0;
    //set<int> starts, ends;
    //
    //rep(i, N) {
    //    ll x, l;
    //    l = XL[i].first;
    //    x = XL[i].second;
    //    auto eit = ends.upper_bound(x - l);
    //    auto sit = starts.upper_bound(x - l);
    //   
    //    if (eit == ends.end()) {
    //        starts.insert(x - l);
    //        ends.insert(x + l);
    //        ans++;
    //        continue;
    //    }
    //    if (sit == starts.end()) continue;
    //    if (*eit < *sit) continue;
    //    eit = ends.upper_bound(x + l);
    //    auto sit2 = starts.lower_bound(x + l);
    //    if (sit2 == starts.end()) continue;
    //    if (*sit == *sit2) {
    //        starts.insert(x - l);
    //        ends.insert(x + l);
    //        ans++;
    //    }

    //    
    //    else {
    //        int eidx = *eit;
    //        auto sit = starts.upper_bound(x - l);
    //        int sidx = *sit;
    //        if(sidx < eidx)
    //        if (*sit > x + l) continue;
    //        ans++;
    //        ends.insert(x + l);
    //        starts.insert(x - l);
    //    }
    //}

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  bool OK = true;
  for (int i=0; i<S.size(); i++) {
    if (i%2==0) {
      if (S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
        OK = false;
        break;
      }
    }
    else if (S[i]!='L'&&S[i]!='U'&&S[i]!='D') {
      OK = false;
      break;
    }
  }
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

rest = 0
for i in range(N):
    A[i] -= B[i]
    if A[i] < 0:
        A[i+1] += A[i]
        A[i] = 0
        if A[i + 1] < 0:
            A[i+1] = 0

print(sum(A_orig)-sum(A))


Measured memory_bytes: 24256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef vector<int>	vi;
#define FAST_IO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	int i,n,x=0,ans=0;
	cin >> n ;
	int a,b;
	for(i=0;i<n;i++){
	    cin >> a >> b;
	    if(a==b){
	        x++;
	        if(x>2)ans=1;
	    }
	    else{
	        x=0;
	    }
	}
	if(ans==1)cout << "Yes" << endl;
	else cout << "No" << endl;
}

int32_t main()
{
	FAST_IO;
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
#define int i64
int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  for (auto &e: a) cin >> e.first >> e.second;
  int ans = n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) if (i != j) {
      int y = a[i].second - a[j].second;
      int x = a[i].first - a[j].first;
      if (x == 0 && y == 0) continue;
      set<pair<int,int>> st(ALL(a));
      int cur = 0;
      while (!st.empty()) {
        cur++;
        auto pt = *st.begin();
        st.erase(st.begin());
        int cx = pt.first + x, cy = pt.second + y;
        while (st.count({cx, cy})) {
          st.erase({cx, cy});
          cx += x; cy += y;
        }
        cx = pt.first - x, cy = pt.second - y;
        while (st.count({cx, cy})) {
          st.erase({cx, cy});
          cx -= x; cy -= y;
        }
      }
      uin(ans, cur);
    }
  }
  kek(ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    long long int N;
    cin>>N;
    string a[N];
    int count1=0, count2=0, count3=0, count4=0;
    
    for(int i=0; i<N; i++)
    {
        cin>>a[i];
    }
    
    for(int i=0; i<N; i++)
    {
        if(a[i]=="AC")
        {
            count1++;
        }
        else if(a[i]=="WA")
        {
            count2++;
        }
        else if(a[i]=="TLE")
        {
            count3++;
        }
        else if(a[i]=="RE")
        {
            count4++;
        }
        
    }

   cout<<"AC x "<<count1<<endl<<"WA x "<<count2<<endl<<"TLE x "<<count3<<endl<<"RE x "<<count4<<endl;
    return 0;
}


Measured memory_bytes: 6712
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
string str;

int main(){
    while(cin >> str){
        reverse(str.begin(), str.end());
        cout << str << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

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

void run_test() {
	int n; cin >> n;
    map<string, int> m;
    rep(i, n) {
        string s; cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3592
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		if(a1+a2+a3>21) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}

	}
	public static long calc(int n,int c) {
		long ans = 1;
		for(int i =1;i<n+1;i++) {
			ans = (ans * i)%1000000007;
		}
		ans = ans * reverse(c)%1000000007;

		return ans*reverse(n-c)%1000000007;
	}
	public static long reverse(int c) {
		long divider =1;
		for(int i =1;i<c+1;i++) {
			divider = (divider * i)%1000000007;
		}
		long dividerholder=divider;
		for(int i=1;i<10000;i++) {
			divider = divider*dividerholder%1000000007;
		}
		long dividerholder2 = divider;
		for(int i=1;i<100000;i++) {
			divider = divider*dividerholder2%1000000007;
		}
		for(int i=0;i<5;i++) {
			divider = divider*dividerholder%1000000007;
		}
		return divider;
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n;
vector<int> A(1<<20);

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n;
  for(int i = 0;i < n;i++) {
      cin>>A[i];
  }
  sort(A.begin(), A.begin()+n);
  if(A[n-1]-A[0] > 1) {
      cout<<"No"<<endl;
      return 0;
  }

  if(A[n-1] == A[0]) {
      if(A[0]+1 == n || n >= 2*A[0]) {
          cout<<"Yes"<<endl;
      } else {
          cout<<"No"<<endl;
      }
      return 0;
  }

  int x = 0, y = 0;
  for(int i = 0;i < n;i++) {
      if(A[i] == A[0]) x++;
      else y++;
  }

  if(x >= A[n-1]) {
      cout<<"No"<<endl;
      return 0;
  }

  if(y >= 2*(A[n-1]-x)) {
      cout<<"Yes"<<endl;
  }

  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    long long A[N+1];
    for(long long i=0;i<N+1;i++){
        cin>>A[i];
    }
    long long B[N];
    for(long long i=0;i<N;i++){
        cin>>B[i];
    }
    long long ans=0;
    for(long long i=0;i<N;i++){
        ans+=min(A[i],B[i]);
        if(A[i]<B[i]){
            ans+=min(A[i+1],B[i]-A[i]);
            A[i+1]-=min(A[i+1],B[i]-A[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5168
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (N == 1 && A != B) {
			System.out.println(0);
			return ;
		}
		
		if (A>B) {
			System.out.println(0);
			return ;
		}
		
		long temp = N-2;
		
		System.out.println(temp*B-temp*A+1);
	}
	
}


Measured memory_bytes: 35804
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int cas=0;
  int anskati=0;
  int ansomo;
  int w,n;
  int kati[1111],omo[1111];
  int memo[1111][1111];
  while(1){
    cas++;
    anskati=0;
    cin>>w;
    if(w==0) break;
    cin>>n;
    for(int i=0;i<=w;i++){
      memo[0][i]=0;
    }
    for(int i=0;i<n;i++){
      char a;
      cin>>kati[i]>>a>>omo[i];
    }
    cout<<"Case "<<cas<<':'<<endl;
    
    for(int i=1;i<=n;i++){
      for(int j=1;j<=w;j++){
	if(j<omo[i-1]){
	  memo[i][j]=memo[i-1][j];
	}else{
	  memo[i][j]=max(memo[i-1][j],memo[i-1][j-omo[i-1]]+kati[i-1]);
	}
      }
    }
    for(int i=0;i<=w;i++){
      if(memo[n][i]>anskati){
	anskati=memo[n][i];
	ansomo=i;
      }
    }
    cout<<anskati<<endl;
    cout<<ansomo<<endl;
    
  }
}

Measured memory_bytes: 5512
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		int result = Integer.MAX_VALUE;		
		Scanner scanner = new Scanner(System.in);		
		int total = scanner.nextInt();
		int burnd = scanner.nextInt();
		int zeroIdx = 0;
		
		List<Integer> point = new ArrayList<Integer>();
		boolean zeroFalg = false;
		for(int i = 0; i < total; i++) {
			int idx = scanner.nextInt();
			if(idx < 0) {
				zeroIdx++;
			}
			if(idx == 0) {				
				zeroFalg = true;
				continue;
			}
			point.add(idx);
		}
		
		if(zeroFalg) {
			total--;
			burnd--;
		}
		
		int firstIdx = zeroIdx - burnd < 0 ? 0 : zeroIdx - burnd ;
		int lastIdx =  zeroIdx + burnd - 1 >= total? total - 1 :  zeroIdx + burnd - 1;
		
		int nums = total > zeroIdx ? zeroIdx + 1:zeroIdx;
		
		if(burnd == 0) {
			result = 0;
		}else {
			for(int i = firstIdx; i < nums; i++) {			
				int totalLeft = 0;
				int totalRight = 0;
				int nextIdx = i + burnd - 1;
				
				if(nextIdx > lastIdx) {
					break;
				}
				
				if(i < zeroIdx) {
					totalLeft = Math.abs(point.get(i));
				}				
				
				if(nextIdx >= zeroIdx) {
					totalRight = point.get(nextIdx);
				}
				
				
				result =Math.min(result,  Math.min(2*totalLeft + totalRight, totalLeft + 2*totalRight));
			}		
		}
		

		System.out.println(result);

	}

}


Measured memory_bytes: 60956
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int A[3][3];
	int B[3][3];
	rep(i, 3) rep(j, 3) B[i][j] = 0;
	rep(i, 3) rep(j, 3) cin >> A[i][j];
	int N;
	cin >> N;
	int b;
	rep(i, N)
	{
		cin >> b;
		rep(i, 3) rep(j, 3) if(A[i][j]==b) B[i][j] = 1;
	}

	int flag, judge=0;
	rep(i, 3)
	{
		flag = B[0][i] + B[1][i] + B[2][i];
		if(flag==3) judge = 1;
	}
	rep(i, 3)
	{
		flag = B[i][0] + B[i][1] + B[i][2];
		if(flag==3) judge = 1;
	}
	if(B[0][0]+B[1][1]+B[2][2] == 3) judge = 1;
	if(B[0][2]+B[1][1]+B[2][0] == 3) judge = 1;

	if(judge==0) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}


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

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);
        var ary = ToIntArray(input.ReadLine(), n);

        Array.Sort(ary);
        long c = 0;

        for(int i=n-1; i>=0; i--) {
            if (k > 0) {
                k--;
                continue;
            } else {
                c += ary[i];
            }
        }

        return c;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

class Main {

    // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long W;
        W = sc.nextLong();
        long[] w = new long[(int)(N)];
        long[] v = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                w[i] = sc.nextLong();
                v[i] = sc.nextLong();
        }
        solve(N, W, w, v);
    }

    static void solve(long N, long W, long[] w, long[] v){
        long[] dp = new long[(int)(W+1)];

        for (int i = 1; i <= N; i++){
            for (int j = (int)(W); j >= w[i-1]; j--){
                dp[j] = Math.max(dp[j], dp[j-(int)w[i-1]] + v[i-1]);
            }
        }

        System.out.print(dp[(int)W]);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    FOR(i, 0, 16)if (s[i] != t[i])++ans;
    cout << ans << "\n";
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	vector<ll> d(N); rep(i, N)cin >> d[i];

	sort(ALL(d));
	reverse(ALL(d));

	ll ans = 1;
	for (int i = 1; i < N; i++) {
		if (d[i] < d[i - 1]) ans++;
	}

	cout << ans << endl;
}

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

int n, k;
vector<int> d;
vector<vector<int>> a;

void input(){
    cin >> n >> k;
    d.resize(k);
    a.resize(k, vector<int>());
    for(int i = 0; i < k; i++){
        cin >> d[i];
        a[i].resize(d[i]);
        for (int j = 0; j < d[i]; j++){
            cin >> a[i][j];
        }
    }
}

void solve(){
    int ans = 0;
    for(int i = 1; i <= n; i++){
        bool have = false;
        for(auto v : a){
            for(auto p : v){
                if (p == i){
                    have = true;
                }
            }
        }
        if (!have){
            ans++;
        }
    }
    cout << ans << endl;
}


int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> P2;
P2 p[8];
int d[2<<10][101][101];
int INF=1<<29;
vector<int> v[101];
int n,m,e,s,g,r;

int dijkstra(int t) {
  queue<P> que;
  for(int i=0; i<n; i++) {
    for(int j=0; j<=r; j++) {
      if(d[t][i][j]!=INF) {
	que.push(P(i,j));
      }
    }
  }
  while(!que.empty()) {
    int x=que.front().F,c=que.front().S;que.pop();
    if(d[t][s][0]>d[t][x][c]+1) {
      d[t][s][0]=d[t][x][c]+1;
      que.push(P(s,0));
    }
    if(c==r) continue;
    for(int i=0; i<v[x].size(); i++) {
      int y=v[x][i];
      int k=-1;
      for(int j=0; j<e; j++) {
	if(p[j].F==y && !(t&(1<<j))) k=j;
      }
      if(k<0) {
	if(d[t][y][c+1]>d[t][x][c]+1) {
	  d[t][y][c+1]=d[t][x][c]+1;
	  que.push(P(y,c+1));
	}
      } else {
	if(d[t|(1<<k)][y][c+1]>d[t][x][c]+1) {
	  d[t|(1<<k)][y][c+1]=d[t][x][c]+1;
	}
      }
    }
    for(int i=0; i<e; i++) {
      if(t&(1<<i)) {
	P pp=p[i].S;
	if(x==pp.F || x==pp.S) {
	  int y=(pp.F==x)?pp.S:pp.F;
	  int k=-1;
	  for(int j=0; j<e; j++) {
	    if(p[j].F==y && !(t&(1<<j))) k=j;
	  }
	  if(k<0) {
	    if(d[t][y][c+1]>d[t][x][c]+1) {
	      d[t][y][c+1]=d[t][x][c]+1;
	      que.push(P(y,c+1));
	    }
	  } else {
	    if(d[t|(1<<k)][y][c+1]>d[t][x][c]+1) {
	      d[t|(1<<k)][y][c+1]=d[t][x][c]+1;
	    }
	  }
	}
      }
    }
  }
  int ans=INF;
  for(int i=0; i<=r; i++) ans=min(ans,d[t][g][i]);
  return ans;
}

int main() {
  for(int t=0; t<(1<<10); t++) {
    for(int i=0; i<101; i++) {
      for(int j=0; j<101; j++) d[t][i][j]=INF;
    }
  }
  cin >> n >> m >> e >> s >> g >> r;
  for(int i=0; i<m; i++) {
    int x,y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for(int i=0; i<e; i++) {
    cin >> p[i].S.F >> p[i].S.S >> p[i].F;
    if(p[i].F==s) d[1<<i][s][0]=0;
  }
  d[0][s][0]=0;
  int ans=INF;
  for(int t=0; t<(1<<e); t++) ans=min(ans,dijkstra(t));
  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 42292
from numpy import *
A = (10**5+1)*[1]
B = (10**5+1)*[0]

for i in range(2,int(10**2.5)+1):
  if A[i]==1:
    for j in range(2*i,10**5+1,i):
      A[j] = 0

for n in range(3,10**5+1):
  if A[n] and A[(n+1)//2]:
    B[n]+=1

B = cumsum(B)
for q in range(int(input())):
  l,r = map(int,input().split())
  print(B[r]-B[l-1])

Measured memory_bytes: 29852
import Control.Applicative

max3 :: Int -> Int -> Int -> Int
max3 a b c = max (max a b) c

solve :: Int -> Int -> Int
solve a b = max3 add sub mul
    where add = a + b
          sub = a - b
          mul = a * b


main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    putStrLn $ show (solve a b)

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int counter = 0;
  bool y = true;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'o') ++counter;
  }

  if (counter + 15 - s.length() >=8 ) std::cout << "YES" << endl;
  else std::cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))

int N;
int A[100010];
int B[100010], C[100010];
int sum = 0;

int main()
{
	cin >> N;

	bool ap = true;
	bool am = true;

	REP(i, N) {
		cin >> A[i];
		sum += A[i];
		if (A[i] >= 0) am = false;
		else if (A[i] <= 0) ap = false;
	}
	sort(A, A + N);
	int ma = A[N - 1];
	int mi = A[0];

	
	

	REP(i, N - 1) {
		if (A[i] < 0 || i == 0) {
			sum -= A[i] * 2;
		}
		else {
			break;
		}
	}
	cout << sum << endl;

	for (int i = 1; i < N - 1; i++) {
		if (A[i] >= 0) {
			cout << mi << " " << A[i] << endl;
			mi -= A[i];
		}
		else {
			cout << ma << " " << A[i] << endl;
			ma -= A[i];
		}
	}
	cout << ma << " " << mi << endl;

}

Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int num=sc.nextInt();
		int tmp[] = new int[num];
		for(int i=0; i<num; i++) {
			tmp[i]=sc.nextInt();
		}
        System.out.println(Arrays.toString(tmp).replaceAll("[,\\[\\]]", ""));
		for(int j=1;j<tmp.length;j++) {

			int key = tmp[j];
			int i=j-1;
			while(i>=0&&tmp[i]>key) {
				tmp[i+1] =tmp[i];
				i--;
			}
			tmp[i+1]=key;
            System.out.println(Arrays.toString(tmp).replaceAll("[,\\[\\]]", ""));
		}
	}
}


Measured memory_bytes: 31444
#include<stdio.h>
int main(){
    int i, q, x1, y1, x2, y2, x3, y3, x4, y4;
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d%d%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1)==0)puts("2");
        else if((y2-y1)*(y4-y3)+(x2-x1)*(x4-x3)==0)puts("1");
        else puts("0");
    }
    return 0;
}

Measured memory_bytes: 584
n = int(input())
sl = sorted([''.join(sorted(input())) for _ in [0]*n])
count = 0
while len(sl)>1:
  i = 1
  flag = True
  while flag:
    if sl[-1] == sl[-(i+1)]:
      i += 1
      if i == len(sl):
        flag=False
    else:
      flag = False
  if i>1:
    count += i*(i-1)//2
  del sl[-i:]
  flag=True
print(count)


Measured memory_bytes: 11204
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int a,b,c;

int main(){
    cin >> a >> b >> c;
    if(a==b&&b==c){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int MAX_N=2e5+1;
int n,a1e,a1v=0,a2v=0;
int a[MAX_N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  cin>>n;
  rep(i,n) cin>>a[i];
  a1e=max_element(a,a+n)-a;
  rep(i,n){
    if(i!=a1e) a2v=max(a2v,a[i]);
  }
  a1v=a[a1e];
  rep(i,n){
    if(i==a1e) cout<<a2v<<endl;
    else cout<<a1v<<endl;
  }
  return 0;
}


Measured memory_bytes: 2432
unittest
{
	assert( [ "3 7", "9 3 4" ].parse.expand.solve == "POSSIBLE" );
	assert( [ "3 5", "6 9 3" ].parse.expand.solve == "IMPOSSIBLE" );
	assert( [ "4 11", "11 3 7 15" ].parse.expand.solve == "POSSIBLE" );
	assert( [ "5 12", "10 2 8 6 4" ].parse.expand.solve == "IMPOSSIBLE" );
}



import std.algorithm;
import std.conv;
import std.numeric : gcd;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// 最大値と最大公約数を取得
	auto r = as.reduce!( max, gcd );
	if( k <= r[ 0 ] && k % r[ 1 ] == 0 ) return "POSSIBLE";
	else                                 return "IMPOSSIBLE";
}


Measured memory_bytes: 4664
import java.util.Scanner;

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

		String str = sc.next();

		String[] strs = str.split("");

		long temp = 0;
		long answer = 0;
		for(int i=0; i<(1<<strs.length-1); i++) {
			temp = Integer.parseInt(strs[0]);
			for(int j=0; j<strs.length-1; j++) {
				if((1&(i>>j)) == 1) {
					answer += temp;
					temp = 0;
				}
				temp = temp*10 + Integer.parseInt(strs[j+1]);
			}
			answer += temp;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23252
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long a[]=new long[n];
    for(int i=0;i<n;i++)
    a[i]=sc.nextLong();
    long sum=0;
    for(int i=1;i<n;i++)
    {
      if(a[i]<a[i-1])
      {
        sum+=a[i-1]-a[i];
        a[i]=a[i-1];
      }
    }
    System.out.println(sum);
  }
}
    

Measured memory_bytes: 61508