akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    vector<int> edge[N+1];
    queue<int> que;
    int dist[N+1];
    int Mdist;
    bool used[N+1];
    fill_n(used, N+1, false);
    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dist[1] = 0;
    Mdist = 0;
    int pos = 1;
    que.push(1);
    used[1] = true;
    while(!que.empty()){
        int i = que.front();
        que.pop();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(!used[k]){
                used[k] = true;
                que.push(k);
                dist[k] = dist[i]+1;
                if(dist[k] > Mdist){
                    pos = k;
                    Mdist = dist[k];
                }
            }
        }
    }
    dist[pos] = 0;
    Mdist = 0;
    que.push(pos);
  	fill_n(used, N+1, false);
    used[pos] = true;
    while(!que.empty()){
        int i = que.front();
        que.pop();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(!used[k]){
                used[k] = true;
                que.push(k);
                dist[k] = dist[i]+1;
                if(dist[k] > Mdist){
                    Mdist = dist[k];
                }
            }
        }
    }
    if(Mdist%3 == 1) cout << "Second" << endl;
    else cout << "First" << endl;
}

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

using ld=long double;
using P=complex<ld>;
const long double eps=1e-9;

ld cross(P a, P b) { return a.real()*b.imag()-a.imag()*b.real(); }

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}


int main()
{
    int n; cin>>n;
    vector<P> p(n);
    for(int i=0; i<n; ++i) {
        int x, y; cin>>x>>y;
        p[i]=P(x, y);
    }

    auto c=min_ball(begin(p), end(p));
    printf("%.9f\n", sqrt((double)c.second));
}


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

int main() {
  int n;
  cin >> n;
  unordered_map<int, int> count;
  for (int ni = 0; ni < n; ni++) {
    int a;
    cin >> a;
    count[a]++;
  }
  int answer = 0;
  for (auto it = count.begin(); it != count.end(); it++) {
    int num = it->first;
    int cnt = it->second;
    if (cnt >= num) {
      answer += cnt - num;
    } else {
      answer += cnt;
    }
  }
  cout << answer << endl;
  return 0;
}

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

using namespace std;
using ll=long long;
const int N = 5555; 
const int Z = 2555;
ll dp[55][N];

void solve() {
    int n, A;
    cin >> n >> A;
    dp[0][Z] = 1;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        x -= A;
        memcpy(dp[i+1], dp[i], sizeof dp[i+1]);
        for (int j = 0; j < N; j++) {
            if (j+x < 0 || j+x >= N) continue;
            dp[i+1][j+x] += dp[i][j];
        }
    }
    ll res = dp[n][Z] - 1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using Graph = vector<vector<pair<int, int>>>;

constexpr int MOD = 1000000007;

void bfs(const Graph& G, vi& d, int i) {
    int n = G.size();

    vector<bool> seen(n, false);
    queue<int> q;
    rep(i, 0, n) { d[i] = INT_MAX; }

    d[i] = 0;
    q.push(i);
    seen[i] = true;

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto u : G[v]) {
            if (!seen[u.first]) {
                seen[u.first] = true;
                d[u.first] = d[v] + u.second;
                q.push(u.first);
            }
        }
    }
}

int calc(const Graph& G) {
    int n = G.size();
    vi d(n);

    bfs(G, d, 0);

    int x = 0, maxd = 0;
    rep(i, 0, n) {
        if (d[i] != INT_MAX && maxd < d[i]) {
            maxd = d[i];
            x = i;
        }
    }
    bfs(G, d, x);

    maxd = 0;
    rep(i, 0, n) {
        if (d[i] != INT_MAX && maxd < d[i]) { maxd = d[i]; }
    }
    return maxd;
}

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

    int n;
    cin >> n;

    Graph G(n);
    rep(i, 0, n - 1) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
        G[t].emplace_back(s, d);
    }

    cout << calc(G) << endl;

    return 0;
}


Measured memory_bytes: 9784
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = cin.next;
        int cnt = -1;
        long ans = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'W')
            {
                cnt++;
                ans += i - cnt;
            }

        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13140
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--) 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    ll m=1e6+1;
    ll c[m+1]={0},i,j,k=1,f,n;
    vector<ll>v[m+1];
    for(i=2;i<=1e6;i++){
        if(c[i]==0){
            for(j=2;j*i<=1e6;j++){
                v[i*j].pb(i);
                c[j*i]=1;
            }
            v[i].pb(i);
        }
    }
    map<ll,ll>m1;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>j;
        for(auto it:v[j]){
            m1[it]++;
            if(m1[it]>=2)
            k=0;
        }
        if(i==1)
        f=j;
        else
        f=__gcd(f,j);
    }
    if(k==1)
    cout<<"pairwise coprime";
    else
    {
        if(f==1)
        cout<<"setwise coprime";
        else
        cout<<"not coprime";
    }
}

Measured memory_bytes: 86364
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<vector<pair<ll,ll> > > Graph(100100);
vector<ll>dist(100100);
vector<bool>visited(100100,false);
void dfs(ll from,ll distance){
    dist[from] = distance;
    //cerr << "visit" << from << endl;
    visited[from] = true;
    REP(i,Graph[from].size()){
        if(!visited[Graph[from][i].first]){
            dfs(Graph[from][i].first,distance+Graph[from][i].second);
        }
    }
}

int main(){
    int n;
    cin >> n;
    REP(i,n-1){
        ll a,b,c;
        cin >> a >> b  >>c;
        a--;b--;
        Graph[a].push_back(make_pair(b,c));
        Graph[b].push_back(make_pair(a,c));
    }
    int q,k;

    cin >> q >> k;
    k--;
    vector<ll>x(q),y(q);
    REP(i,q){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
    }
    dfs(k,0);
    REP(i,q){
        cout << dist[x[i]]+dist[y[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 17164
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 998244353;

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		--b;
		ans = (ans * a) % MOD;
	}
	return ans;
}

const int MX = 510000;

ll fc[MX * 2];
ll bfc[MX * 2];

ll cnk(int n, int k) {
	return fc[n] * bfc[k] % MOD * bfc[n - k] % MOD;
}

int main() {
	fc[0] = 1;
	bfc[0] = 1;
	for (int i = 1; i < 2 * MX; ++i) {
		fc[i] = (fc[i - 1] * i) % MOD;
		bfc[i] = pw(fc[i], MOD - 2) % MOD;
	}
	for (int i = 1; i < 2 * MX; ++i)
		fc[i] = (fc[i - 1] * i) % MOD;
	int n, m;
	cin >> n >> m;
	if (n < m)
		swap(n, m);
	ll go = 0;
	for (int i = 1; i <= m; ++i) {
		go = (go + cnk(i * 2, i) * cnk(n - i + m - i, n - i)) % MOD;
	}
	go = (go * pw(2, MOD - 2)) % MOD;
	go = go * pw(cnk(n + m, m), MOD - 2) % MOD;
	go = (go + n) % MOD;
	cout << go << "\n";
	return 0;
}




Measured memory_bytes: 16128
<?php
    $num_problem = trim(fgets(STDIN));
    $time = explode(" ",trim(fgets(STDIN)));
//    var_dump($time);
    $num_drink = trim(fgets(STDIN));
    for($i=0;$i<$num_drink;$i++){
        list($target_prob_num,$modified_time) = explode(" ",trim(fgets(STDIN)));
        $dif = $modified_time - $time[$target_prob_num-1];
 //       var_dump($time);
        echo array_sum($time) + $dif;
        echo PHP_EOL;
    }
?>  

Measured memory_bytes: 3704
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],2);
  var oddlist = {};
  var evenlist = {};
  for(var i = 0; i < N; i++){
    //偶奇が一致するところだけ関係する
    if(i % 2 == 0){
       if(oddlist[list[i]] == null){
     	  oddlist[list[i]] = 1;
    	}else{
    	   	oddlist[list[i]]++;
    	}
    }else{
       if(evenlist[list[i]] == null){
     	  evenlist[list[i]] = 1;
  	  }else{
   	  	 evenlist[list[i]]++;
  	  }
    }
  }
  
  var output = 0;
  var oddSet = Object.keys(oddlist);
  var evenSet = Object.keys(evenlist);
  if(oddSet.length == 1 && evenSet.length == 1){
    if(evenSet[0] == oddSet[0]){
       myout(N/2);
    	return;
    }else{
       myout(0);
      return;
    }
    
  }
  var tmp = 0;
  var lastSelect = "";
  oddSet.sort(function(a,b){
  	return oddlist[b] - oddlist[a];
  });
  evenSet.sort(function(a,b){
  	return evenlist[b] - evenlist[a];
  });
  
  if(oddSet[0] == evenSet[0]){
    var mae = 10000000;
    var ato = 10000000;
     if(oddSet[1] != null){
        mae = (N / 2 - oddlist[oddSet[1]]) + (N / 2 - evenlist[evenSet[0]]);
     }
     if(evenSet[1] != null){
        ato = (N / 2 - oddlist[oddSet[0]]) + (N / 2 - evenlist[evenSet[1]]);
     }
    output = Math.min(mae,ato);
  }else{
     output = (N / 2 - oddlist[oddSet[0]]) + (N / 2 - evenlist[evenSet[0]]);
  }
  myout(output);
  
}
Main(myin());


Measured memory_bytes: 36072
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

ll n, m, l;
vvector<pll> road;
vvector<ll> anses;

int func(int start, int target){
	vector<int> high(n+1, -1);
	vector<char> used(n+1, false);
	vector<int> ntarget;
	vector<int> reses(n+1, 1000);
	ntarget.push_back(start);
	high[start]=l;
	priority_queue<pll> pq;
	rep(j, n){
		if(ntarget.empty())break;
		foreach(j, ntarget){
			if(high[j]>=0){
				if(used[j])continue;
				used[j]=true;
				pq.emplace(l, j);
				high[j]=l;
			}
		}
		ntarget.clear();

		while(pq.size()){
			pll d = pq.top();
			pq.pop();
			if(high[d.second]!=d.first)continue;
			foreach(i, road[d.second]){
				int nf = d.first - i.second;
				if(high[i.first]>=nf)continue;
				reses[i.first]=min(reses[i.first], j);
				high[i.first]=nf;
				pq.emplace(nf, i.first);
				ntarget.push_back(i.first);
			}
		}
	}
	repa(i, n+1){
		if(reses[i]==1000)anses[start][i]=-1;
		else anses[start][i]=reses[i];
	}
	return anses[start][target];

}

int main(){
	cin >> n >> m >> l;
	road.resize(n+1);
	anses.resize(n+1, vector<ll>(n+1, -2));
	rep(i, m){
		ll a, b, c;
		cin >> a >> b >> c;
		road[a].emplace_back(b, c);
		road[b].emplace_back(a, c);
	}
	int q;
	cin >> q;
	rep(i, q){
		int a, b;
		cin >> a >> b;
		if(anses[a][b]==-2)func(a, b);
		cout << anses[a][b] << endl;
	}

	return 0;
}



Measured memory_bytes: 4648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
  cout << (m1 != m2) << '\n';
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }

  vector<string> res(0);
  for (int i = 0; i < h; i++) {
    bool flag = false;
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '#') {
        flag = true;
        break;
      }
    }
    if (flag) {
      res.push_back(grid[i]);
    }
  }
  h = res.size();

  vector<string> res2(0);
  for (int j = 0; j < w; j++) {
    bool flag = false;
    for (int i = 0; i < h; i++) {
      if (res[i][j] == '#') {
        flag = true;
        break;
      }
    }
    if (flag) {
      string t = "";
      for (int i = 0; i < h; i++) {
        t += res[i][j];
      }
      res2.push_back(t);
    }
  }
  w = res2.size();
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << res2[j][i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
const MAX_N: usize = 100000;

fn main() {
    let mut sc = Scanner::new();

    let mut is_prime = vec![true; MAX_N + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for p in 2..(MAX_N + 1) {
        if !is_prime[p] {
            continue;
        }
        let mut cur = p * 2;
        while cur <= MAX_N {
            is_prime[cur] = false;
            cur += p;
        }
    }

    let mut is_liked = vec![false; MAX_N + 1];
    for n in 3..(MAX_N + 1) {
        if n % 2 == 1 && is_prime[n] && is_prime[(n + 1) / 2] {
            is_liked[n] = true;
        }
    }
    let mut sum = vec![0; is_liked.len() + 1];
    for i in 0..is_liked.len() {
        sum[i + 1] = sum[i] + if is_liked[i] { 1 } else { 0 };
    }

    let q: usize = sc.read();
    for _ in 0..q {
        let l: usize = sc.read();
        let r: usize = sc.read();
        println!("{}", sum[r + 1] - sum[l]);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (1e6) + 322;
const int inf = (int)(2e9);
const int mod = (int)(1e9) + 7; // check modulo

void solve() {
    int ac = 0, wa = 0, re = 0, tle = 0;
    int n; cin >> n;
    for(int i = 1; i <=  n; ++i) {
        string s; cin >> s;
        if (s == "WA") wa++;
        if (s == "TLE") tle++;
        if (s == "RE")  re++;
        if (s == "AC") ac++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
        solve();
//    }
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <math.h>

int main(void)
{
	char s[100000];
	int i,cnt[2]={0};
	scanf("%s",s);
	
	for(i=0;i<strlen(s);i++){
		cnt[s[i] - '0']++;
	}
	printf("%d\n",(int)fmin(cnt[0],cnt[1])*2);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int t[5];
  char c;
  while(cin>>t[0]>>c>>t[1]>>c>>t[2]>>c>>t[3]>>c>>t[4]){
    int same[14]={0};
    int a = 0;
    int b = 0;
    bool role = false;
    for(int i=0;i<5;i++) same[t[i]]++;
    for(int i=0;i<14;i++){
      if(same[i]>1&&a==0) a = same[i];
      else if(same[i]>1&&b==0) b = same[i];
    }
    for(int i=1;i<11;i++){
      int h = i+4;
      if(h==14) h = 1; 
      if(same[i]==1&&same[i+1]==1&&same[i+2]==1&&same[i+3]==1&&same[h]==1){ cout << "straight" << endl;
	role = true;}
    }
    if(!role){
      if(a==4) cout << "four card" << endl;
      else if(a==3&&b==2||a==2&&b==3) cout << "full house" << endl;
      else if(a==3) cout << "three card" << endl;
      else if(a==2&&b==2) cout << "two pair" << endl;
      else if(a==2) cout << "one pair" << endl;
      else cout << "null" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[11];
		int hz = 0;
		for(int i=1; i<=10; i++){
			h[i] = sc.nextInt();
		}
		for(int i=9; i>=1; i--){
			for(int j=1; j<=i; j++){
				if(h[j] <= h[j+1]){
					hz = h[j+1];
					h[j+1] = h[j];
					h[j] =hz;
				}
			}
		}
		for(int i=1; i<=3; i++){
			System.out.println(h[i]);
		}
	}
}

Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  ll sumA=0, sumB=accumulate(all(A), 0LL);
  ll ans = longinf;
  rep(i, n-1) {
    sumA += A[i];
    sumB -= A[i];
    ans = min(abs(sumA-sumB), ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define DIVISOR 1000000007
#define BUF_SIZE 10

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

#define NUM_MAX 1000

int main(void) {
    int num = get_int();
    static int map[NUM_MAX+1];

    int i;
    for(i = 2; i <= num; i++) {
        int n = i;
        int div = 2;
        while(n>1) {
            if(n%div) { // cannot devide
                div++;
                continue;
            }
            map[div]++;
            n = n / div;
        } 
    }

    uint64_t ans = 1;
    for(i = 2; i <= num; i++) {
        ans = (ans * (map[i]+1))%DIVISOR;
    }
    printf("%d\n", (int)ans);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i <= 100; i++) {
    bool flag = 1, flag2 = 1;
    for (int j = 0; j < n; j++) {
      if (x - i == p[j]) {
        flag = 0;
      }
      if (x + i == p[j]) {
        flag2 = 0;
      }
    }
    if (flag) {
      cout << x - i << '\n';
      return 0;
    }
    if (flag2) {
      cout << x + i << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3640
N = int(input())
a = list(map(int,input().split()))
A = a.sort()
array = list(set(a))
array.sort()
sum = 0
n = 0
for i in range(len(array)):
    cnt = 0
    for j in range(n,len(a)):
        if array[i] == a[j]:
            cnt += 1
        else:
            break
    n += cnt
    if cnt >= array[i]:
        sum += cnt - array[i]
    else:
        sum += cnt
print(sum)

Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v)  (v).begin() (v).end()


void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    std::vector<ll> r(n + 1);
    for(int i = 1; i <= n; i++)
        r[i] = r[i - 1] + (s[i - 1] == 'R');
    ll ans = 1e9, cur, curm;
    for(int i = 0; i <= n; i++)
    {
        ll rd = r[n]-r[i];
    
        ll wh = (i - r[i]);
        cur = min(rd, wh);
        curm = rd + wh;
        curm -= 2 * cur;
        // cout << i << " " << r[i] << " " << rd << " " << wh << curm + cur << endl;
        ans = min(ans, curm + cur);
    }
    cout << ans;

}



int main()
{


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

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

}

Measured memory_bytes: 5184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  string a = s.substr(0, 2);
  string b = s.substr(2);
  int A = stoi(a);
  int B = stoi(b);
  if(A > 0 && A <= 12 && B > 0 && B <= 12){
    cout << "AMBIGUOUS" << endl;
  }else if(B > 0 && B <= 12){
    cout << "YYMM" << endl;
  }else if(A > 0 && A <= 12){
    cout << "MMYY" << endl;
  }else{
    cout << "NA" << endl;
  }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    vector<int> a(2);
    REP(i, 2) cin >> a[i];
    int ans = 0;

    REP(i, 2) {
        if(a[i] == 1) {
            ans += 300000;
        } else if(a[i] == 2) {
            ans += 200000;
        } else if(a[i] == 3){
            ans += 100000;
        }
    }

    if(a[0] == 1 && a[1] == 1) {
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void) {
    string s;
    int K;
    cin >> s >> K;
    size_t N = s.size();
    set<string> st;
    for(int i=0; i<N; i++) {
        for(int j=1; i+j<=N && j<=K; j++) {
            st.insert(s.substr(i, j));
        }
    }
    auto itr = st.begin();
    cout << *next(itr, K-1) << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int n, k;
	int l[50];
	
	cin >> n >> k;
	REP(i, n) scanf("%d", l + i);
	sort(l, l + n, greater<int>());
	
	int sum = 0;
	REP(i, k) sum += l[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
ld n , d;
vector<vector<ld>> x(n,vector<ld>(d));

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ss = s.size();
    vector<vector<int>> a(3);
    for(int i=0;i<ss;i++){
        if(s.at(i)=='R') a.at(0).emplace_back(i);
        if(s.at(i)=='G') a.at(1).emplace_back(i);
        if(s.at(i)=='B') a.at(2).emplace_back(i);
    }
    ll ans = 0;

    for(int i=0;i<=n-3;i++){
        for(int j=i+1;j<=n-2;j++){
            int r = 0, g = 0 , b = 0;
            if(s.at(i)=='R' || s.at(j)=='R') r = 1;
            if(s.at(i)=='G'||s.at(j)=='G') g = 1;
            if(s.at(i)=='B'||s.at(j)=='B') b = 1;
            if(r+g+b<=1) continue;
            if(r==0){
                auto it = lower_bound(a.at(0).begin(),a.at(0).end(),(j+1));  
                ans += (int)(a.at(0).size()) - (it - a.at(0).begin());
                if(j+(j-i)<n  && s.at(j+(j-i)) == 'R') ans--;  
            }
            if(g==0){
                auto it = lower_bound(a.at(1).begin(),a.at(1).end(),(j+1));  
                ans += (int)(a.at(1).size()) - (it - a.at(1).begin());
                if(j+(j-i)<n && s.at(j+(j-i)) == 'G') ans--;  
            }
            if(b==0){
                auto it = lower_bound(a.at(2).begin(),a.at(2).end(),(j+1));  
                ans += (int)(a.at(2).size()) - (it - a.at(2).begin());
                if(j+(j-i)<n && s.at(j+(j-i)) == 'B') ans--;  
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
###############################################
#                                             #
#   author: raghav_0901 (Raghav Dalmia)       #
#   updated on: 15-08-2020,  5:33:12 pm IST   #
#                                             #
###############################################


from math import *


def _in():
    arr = [int(x) for x in input().split(' ')]
    return arr[0] if len(arr) == 1 else arr


if __name__ == "__main__":
    s = input()
    if(s == "RRR"):
        print(3)
    else:
        if(s[:2] == "RR"):
            print(2)
        elif(s[1:] == "RR"):
            print(2)
        else:
            if(s.count("R") > 0):
                print(1)
            else:
                print(0)


Measured memory_bytes: 9068
using System;
class Program
{
    static void Main(string[] args)
    {
        char[] str = Console.ReadLine().ToCharArray();
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[1]);
            int b = int.Parse(line[2]);
            if (line[0] == "print")
            {
                string answer = "";
                for (int j = a; j <= b; j++)
                {
                    answer += str[j].ToString();
                }
                Console.WriteLine(answer);
            }
            else if (line[0] == "replace")
            {
                char[] p = line[3].ToCharArray();
                for (int j = a; j <= b; j++)
                {
                    str[j] = p[j-a];
                }
            }
            else
            {
                char tmp;
                for (int j = a,jend = a+(b-a)/2,reverseCount = b; j <= jend; j++)
                {
                    tmp = str[j];
                    str[j] = str[reverseCount];
                    str[reverseCount] = tmp;
                    reverseCount--;
                }
            }
        } Console.ReadLine();
    }
}

Measured memory_bytes: 5912
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut s = read_as_string().chars().collect::<Vec<char>>();
    s.sort();

    if s[0] == 'a' && s[1] == 'b' && s[2] == 'c'{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n;
bool uab[101];

int main(void)
{
    cin >> n;
    vector<pair<int, int>> ab;
    vector<pair<int, int>> cd;
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());

    rep(i, n)
    {
        int c, d;
        cin >> c >> d;
        cd.push_back(make_pair(c, d));
    }
    sort(cd.begin(), cd.end());

    int res = 0;

    rep(i, n)
    {
        int cand = -1;
        int ymax = -inf;

        rep(j, n)
        {
            if (uab[j])
                continue;

            if (ab[j].first > cd[i].first)
                continue;

            if (ab[j].second > cd[i].second)
                continue;

            if (ymax > ab[j].second)
                continue;

            cand = j;
            ymax = ab[j].second;
        }

        if (cand >= 0)
        {
            uab[cand] = true;
            //cout << i << " - " << cand << endl;
            //cout << ab[cand].first << ab[cand].second << endl;
            //cout << cd[i].first << cd[i].second << endl;
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    char st[20+1];
    char *pt;

    scanf("%s", st);
    for (pt=st; *pt!='\0'; pt++) ;
    for (pt--; pt!=st; pt--) printf("%c", *pt);
    printf("%c\n", *pt);
    return 0;
}

Measured memory_bytes: 968
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
a = RI()

ls_x = []
x = 0
for i in range(n):
    x += a[i]
    ls_x.append(x)    

S = sum(a)

m = INF
for i in range(n-1):
    x = ls_x[i]
    y = S - x
    m = min(m,abs(x-y))
print(m)

Measured memory_bytes: 108208
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define _CRT_DISABLE_PERFCRIT_LOCKS

#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>	
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <thread>
#include <cassert>

using namespace std;

#define ll long long
#define ull unsigned long long
typedef int hv;
#define double long double
#define make(type, x) type x; cin>>x	
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int, int>
#define PPII pair<PII, int>
#define M7 1000000007ll
#define M9 1000000009ll
#define MFFT 998244353ll 
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define outv(a) for(auto& x: a) cout << x << ' ';

int cnt_d(int num) {
	int cnt = 0;
	while (num) {
		num /= 10;
		cnt++;
	}
	return cnt;
}


void Solve() {
	make(int, n);
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (cnt_d(i) & 1) ans++;
	}
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef _SUPER_DEFINE
	auto F1 = freopen("input.txt", "r", stdin);
	auto F2 = freopen("output.txt", "w", stdout);
	if (F1 == NULL || F2 == NULL) return 0;
	if (sizeof(int) != 8) cout << "NO LONG!!!\n";
	Solve();
	fflush(stdout);
	while (!cin.eof()) {
		string s = "_";
		do getline(cin, s);
		while (!cin.eof() && !s.empty());
		if (cin.eof()) break;
		FOR(2) cout << endl;
		Solve();
		fflush(stdout);
	}
	fclose(F1), fclose(F2);
#else
	Solve();
#endif
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n; cin>>n; string s; int a=0,b=0,c=0,d=0;
  for(int i=0;i<n;i++)
  {
      cin>>s;
      if(s[0]=='A'){a++;}
      if(s[0]=='W'){b++;}
      if(s[0]=='T'){c++;}
      if(s[0]=='R'){d++;}
  }
  
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;

#define MAX_N 500

vector<string> ans_list;

int n;

string S = "ixcm";

int trans(string str1){
  int k = 0;
  int mode = 0;
  int num1 = 0;
  for(int i = 0; i < str1.length(); i++){
    if(mode == 0 && str1[i] >= '2' && str1[i] <= '9'){
      k = str1[i] - '0';
      mode = 1;
    }
    else if(mode == 0){
      for(int j = 0; j < 4; j++){
	if(S[j] == str1[i]){
	  num1 += pow(10, j);
	  break;
	}
      }
    }
    else{
      mode = 0;
      for(int j = 0; j < 4; j++){
	if(S[j] == str1[i]){
	  num1 += k * pow(10, j);
	  break;
	}
      }
    }
  }
  return num1;
}

int main(){

  cin >> n;

  while(n > 0){
    n--;
    string str1, str2;
    cin >> str1 >> str2;

    int num1 = 0, num2 = 0;

    num1 = trans(str1);
    num2 = trans(str2);

    int num3 = num1+num2;
    
    string ans;

    for(int num = 3; num >= 0; num--){
      int p = pow(10, num);
      int pp = num3/p;
      if(pp == 1){
	ans += S[num];
	num3 %= p;
      }
      else if(pp > 1){
	ans += ('0' + pp);
	ans += S[num];
	num3 %= p;
      }
    }

    ans_list.push_back(ans);

  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    ll N; cin>>N;
    ll sum=0;
    for (int i = 1; i <= N; ++i) {
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
using namespace std;

const int N = 2e5;
char a[N*3+3];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",a+1); for(int i=1; i<=n; i++) a[i] -= 65;
	int tag = 0,hd = 1,tl = n;
	for(int i=1; i<=n+n; i++)
	{
		if((a[hd]^tag)==0) {a[hd]^=1;}
		else {tag^=1; hd++; tl++; a[tl] = tag;}
		if(i==m) {for(int j=hd; j<=tl; j++) printf("%c",(a[j]^tag)+65); return 0;}
	}
	if((n&1)&&(m&1)) {a[hd]^=1;}
	for(int i=hd; i<=tl; i++) printf("%c",(a[i]^tag)+65);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    vector<vector<pair<intl, intl> > > v(n);
    rep(i,n){
        cin >> a[i];
        v[i].resize(a[i]);
        rep(j,a[i]){
            intl x,y;
            cin >> x >> y;
            v[i][j] = mp(x,y);    
        }
    }
    intl mi = 0;
    for(intl i = 0; i < (1 << n); i++){
        bool f = true;
        rep(j,n){
            if(!(i & (1 << j)))continue;
            //debug(j);
            rep(k,a[j]){
                if(!!(i & (1 << (v[j][k].first - 1))) != v[j][k].second){
                    //cout << bitset<4>(i) << " "<< j << " " << k <<endl;
                    //cout << v[j][k].first - 1 << ":" << v[j][k].second << endl;
                    //cout << bitset<3>(i) << " " << bitset<3>(1 << (v[j][k].first - 1)) << " " << v[j][k].second << " " << !!(i & (1 << (v[j][k].first - 1))) <<  endl;
                    f = false;
                }
            }
        }
        intl cnt = __builtin_popcount(i);
        if(f)mi = max(mi,cnt);
        //cout << bitset<8>(i) << ":" << f << endl;
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

accum=[0]
for i in range(N):
    accum.append(accum[i]+a[i])

accum.remove(0)
#print(accum)
S=accum[-1]
lst=[]
for i in range(N-1):
    lst.append(abs(S-accum[i]*2))
print(min(lst))

Measured memory_bytes: 88520
def f():
    a = list(map(int, input().split()))
    if a[0] <= a[1]:
        print(a[0]+1)
        return
    b = a[2]-a[1]
    print(((a[0]-a[1]+1)//2)*b+(a[0]-a[1]+1)%2+a[1] if b > 2 else a[0]+1)
f()

Measured memory_bytes: 3060
A, B, C, X, Y = map(int,input().split())
AB = 2*C*max(X,Y)
AandB = A*X + B*Y
if X > Y:
    ABandAandB = 2*C*min(X,Y)+(X-Y)*A
else:
    ABandAandB = 2*C*min(X,Y)+(Y-X)*B
print(min(AB,AandB,ABandAandB))

Measured memory_bytes: 3064