akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	int count;
	cin >> count;

	string s;
	cin >> s;

	if (s.length() <= count) {
		cout << s << endl;
	} else {
		cout << s.substr(0, count) << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60

long long chose2(long long x){
    return x*(x-1)/2;
}

int main(){
    long long N,K;
    cin >> N >> K;
    vector<long long>H(N,0);
    for(long long i=0;i<N;i++){
        cin >> H[i];
    }

    sort(H.begin(),H.end(), greater<int>());
    K=min(K,N);
    for(long long i=0;i<K;i++){
        H[i]=0;
    }

    long long ans=0;
    for(long long i=0;i<N;i++){
        ans+=H[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long H;
    long W;
    long count =0;
    cin >> H >> W;
    if(H ==1 || W ==1){
        cout << 1 <<endl;
    }
    else{
    if(H%2==1 && W%2==1){
        count += (H/2 + 1) * (W/2+1) + (H/2) * (W/2);
        
    }else if(H%2 == 0 && W%2 == 1){
        count += H/2*(W);
    }else if(H%2==1 && W%2==0){
        count += (H/2+1) * W/2 + (H/2) * W/2;
      }
    else{
        count += (H/2)*(W);
    }
    cout << count << endl;
    }    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  double X[N];
  int i;
  for(i=0; i<N; i++)
    cin >> X[i];

  double sum = 0;
  double min_num;
  for(i=0; i<N; i++)
    sum += X[i];
  
  min_num = sum/(double)N;
  if( (int)(min_num*10)%10 <5)
    min_num = (int)min_num;
  else
    min_num = (int)min_num + 1;

  int ans = 0;
  for(i=0; i<N; i++)
    ans += (int)(X[i]-min_num)*(X[i]-min_num);

  cout << ans << endl;

    
  return 0;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    cout << (a[x] == a[y] ? "Yes": "No" ) << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  }
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    sum=sum+A.at(i);
  }
  
  int juko=sum/(4*M);
  
  if(sum-juko*(4*M)==0){
    juko=juko;
  }
  else{
    juko=juko+1;
  }
  
  int count=0;
  
  for(int i=0;i<N;i++){
    if(A.at(i)>=juko){
      count++;
    }
  }
  
  if(count>=M){
    cout << "Yes" << endl;
  }
  else if(count<M){
    cout << "No" << endl;
  }
}
    


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

string ss[110];

int main()
{
	ios::sync_with_stdio(false);
	
	int n,l;
	cin>>n>>l;
	
	for(int i=0;i<n;i++)
		cin>>ss[i];
	
	sort(ss,ss+n);
	
	for(int i=0;i<n;i++)
		cout<<ss[i];
	
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,r;
long long a[200002],b[200002],k;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>m>>k;
  for(int i=1;i<=n;i++)
    cin>>a[i],a[i]=min(k+1,a[i]+a[i-1]);
  for(int i=1;i<=m;i++)
    cin>>b[i],b[i]=min(k+1,b[i]+b[i-1]);
  a[n+1]=b[m+1]=k+1;
  n=m=0;
  long long c=k;
  while(a[n+1]<=c)
    n++;
  r=n;
  while(n>=0)
  { while(a[n]+b[m]<=k)
       r=max(r,n+m),m++;
    n--;
  }
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 6724
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl
#define MAXN 100002

int main(){
	

    ll n;
    cin>>n;
    pair< pair<string, ll>, ll > p[n];
    string s;
    ll m;
    for(ll i=0; i<n; i++){
    	cin>>s>>m;
    	m = m*(-1);
    	p[i] = make_pair(make_pair(s, m), i+1);
    }
    sort(p, p+n);

    for(ll i=0; i<n; i++){
    	cout<<p[i].second<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n;
int black=0,white=0;
vector<int>vec[100001];
int color[100001];
queue<int>q;
int main()
{
    cin>>n;
    for(int i=0; i<n-1; i++)
    {
        int x,y;
        cin>>x>>y;
        vec[x-1].push_back(y-1);
        vec[y-1].push_back(x-1);
    }
    q.push(0);
    q.push(n-1);
    color[0]=1;
    color[n-1]=2;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        if(color[u]==1)
            black++;
        if(color[u]==2)
            white++;
        for(int i=0;i<vec[u].size();i++)
        {
            int v=vec[u][i];
            if(color[v])
                continue;
            color[v]=color[u];
            q.push(v);
        }
    }
    if(black>white)
        cout<<"Fennec"<<endl;
    else
        cout<<"Snuke"<<endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	
	string s;
	stack<char> st;
	
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i] == 'B'){
			if(st.empty()){
				continue;
			}
			st.pop();
			continue;
		}
		st.push(s[i]);
	}
	vector<char> v;
	while(!st.empty()){
		v.push_back(st.top());
		st.pop();
	}
	
	for(int i=v.size()-1;i>=0;i--){
		cout<<v[i];
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]

ans = 0
for i in range(H+1):
    for j in range(W+1):
        for row in itertools.combinations([x for x in range(H)], i):
            for column in itertools.combinations([x for x in range(W)], j):
                tmp = 0
                for tr in range(H):
                    for tc in range(W):
                        if tr in row:
                            continue
                        if tc in column:
                            continue
                        if c[tr][tc] == '#':
                            tmp += 1
                if tmp == K:
                    ans += 1
print(ans)

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



int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    sort(p.begin(),p.end());
    int ans=p[n/2]-p[n/2-1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
// ALDS1_6_D: Minimum Cost Sort

use std::cmp::min;

fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn scan_vec<T: std::str::FromStr>() -> Vec<T> {
    let s: String = scan();
    s.split_whitespace().map(|a| T::from_str(a).ok().unwrap()).collect()
}

fn solve(a: &Vec<usize>, n: usize, ss: usize) -> usize {
    let mut ans: usize = 0;
    let mut b = a.clone();
    let mut v = vec![false; a.len()];
    let mut t = vec![0; 10001];
    b.sort();
    for i in 0..n {
        t[b[i]] = i;
    }
    for i in 0..n {
        if v[i] {
            continue;
        }
        let mut cur: usize = i;
        let mut s: usize = 0;
        let mut m: usize = 10001;
        let mut an: usize = 0;
        loop {
            v[cur] = true;
            an += 1;
            let vv = a[cur];
            m = min(m, vv);
            s += vv;
            cur = t[vv];
            if v[cur] {
                break;
            }
        }
        ans += min(s + (an - 2) * m, m + s + (an + 1) * ss)
    }
    ans
}

fn main() {
    let n: usize = scan();
    let a: Vec<usize> = scan_vec();
    let mut s: usize = 10001;
    for i in 0..n {
        s = min(s, a[i]);
    }
    let ans = solve(&a, n, s);
    println!("{}", ans);
}


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

bool xDP[8010][8010] = { false };
bool yDP[8010][8010] = { false };

int main() {
	string S;
	int rl = 0;
	cin >> S;
	int ss = S.size(), F = 0, cnt = 0;
	vector<int> RL, UD;
	int i = 0;
	bool jud = 0;
	while (i < ss) {
		if (S[i] == 'T')break;
		i++;F++;
	}
	i++;
	int RLz = 0, UDz = 0, RLs = 0, UDs = 0;

	while (i < ss) {
		if (S[i] == 'F')
			cnt++;
		else {
			if (cnt) {
				if (rl) {
					RL.push_back(cnt);
					RLz++;RLs += cnt;
				}
				else {
					UD.push_back(cnt);
					UDz++;UDs += cnt;
				}
				cnt = 0;
			}
			rl = 1 - rl;
		}
		i++;
	}
	if (cnt) {
		if (rl) {
			RL.push_back(cnt);
			RLz++;RLs += cnt;
		}
		else {
			UD.push_back(cnt);
			UDz++;UDs += cnt;
		}
	}
	int x, y;
	cin >> x >> y;
	x = abs(F - x), y = abs(y);
	if ((RLs -= x) % 2) {
		cout << "No" << endl;
		return 0;
	}
	RLs /= 2;
	if (RLz == 0) {
		if (RLs) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		xDP[0][0] = xDP[0][RL[0]] = true;
		for (int j = 1;j < RLz;j++) {
			for (int k = 0;k <= RLs;k++) {
				if (k == 0)
					xDP[j][k] = true;
				if (k >= RL[j] && xDP[j - 1][k - RL[j]])
					xDP[j][k] = true;
				if (xDP[j - 1][k])
					xDP[j][k] = true;
			}
		}
		if (!xDP[RLz - 1][RLs]) {
			cout << "No" << endl;
			return 0;
		}
	}

	if ((UDs -= y) % 2) {
		cout << "No" << endl;
		return 0;
	}
	UDs /= 2;
	if (UDz == 0) {
		if (UDs) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		yDP[0][0] = yDP[0][UD[0]] = true;
		for (int j = 1;j < UDz;j++) {
			for (int k = 0;k <= UDs;k++) {
				if (k == 0)
					yDP[j][k] = true;
				if (k >= UD[j] && yDP[j - 1][k - UD[j]])
					yDP[j][k] = true;
				if (yDP[j - 1][k])
					yDP[j][k] = true;
			}
		}
		if (!yDP[UDz - 1][UDs]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 34048
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int N;
vector<int> dp(100000, INF);
vector<vector<int>> g(100000);

int dfs(int cur, int pre)
{
    if (g[cur].size() == 0)
    {
        return dp[cur] = 0;
    }
    vector<int> dis;
    for (auto v : g[cur])
    {
        if (v == pre)
            continue;
        dis.push_back(dfs(v, cur));
    }
    sort(dis.rbegin(), dis.rend());
    int res = 0;
    for (int i = 1; i <= (int)dis.size(); i++)
    {
        res = max(res, dis[i-1] + i);
    }
    return dp[cur] = res;
}

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

    cin >> N;
    for (int i = 1; i < N; i++)
    {
        int a;
        cin >> a;
        a--;
        g[a].push_back(i);
    }
    cout << dfs(0, -1) << endl;
}


Measured memory_bytes: 17024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let u: Vec<char> = read::<String>().chars().collect();
    let mut z = 0;
    let mut o = 0;
    for i in u {
        if i == '0' {
            z+=1;
        } else {
            o+=1;
        }
    }
    println!("{}", if o < z { o } else { z } * 2);
}

Measured memory_bytes: 4352
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
s = input()
t = input()
k = gcd(n,m)
l = n*m//k

for i in range(0,l,l//k):
        if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:
                print(-1)
                exit()
print(l)

Measured memory_bytes: 10268
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod = 1e9+7;	

int solve()
{
	ll n,ans=0;cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	vi pow_2(61,1);
	rep(i,1,61) pow_2[i]=(pow_2[i-1]*2)%mod;
	rep(i,0,61)
	{
		vi cnt(2,0);
		rep(j,0,n) cnt[((a[j]>>i)&1)]++;
		rep(j,0,n)
		{
			ans = ans+(cnt[!((a[j]>>i)&1)]*pow_2[i])%mod;
			if(ans>=mod) ans-=mod;
			cnt[((a[j]>>i)&1)]--;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll r,d,x; cin >>r>>d>>x;

    for (int i = 0; i < 10; i++) {
        x = r*x - d;
        cout << x << endl;
    }
    
    return 0;
}





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

int main() {
  int n, q;
  std::cin >> n;
  std::vector<int> s(n);
  for (int i = 0; i < n; ++i)
    std::cin >> s.at(i);
  std::cin >> q;
  std::vector<int> t(q);
  for (int i = 0; i < q; ++i)
    std::cin >> t.at(i);

  std::set<int> st;
  for (auto i : s)
    for (auto j : t)
      if (i == j)
        st.insert(i);

  std::cout << st.size() << std::endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;

  vector<int> L(n);
  rep(i, 0, n) cin >> L[i];
  sort(L.begin(), L.end());

  ll ans = 0;
  rep(b, 0, n) {
    rep(a, 0, b) {
      int ab = L[a] + L[b];
      int ng = lower_bound(L.begin(), L.end(), ab) - L.begin();
      int ok = b + 1;
      ans += ng - ok;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
long long lcm(long long a, long long b)
{
   return a /gcd(a, b)*b;
}
signed main(){
    int N; cin>>N;
    vector<long long> T(N); REP(i,N) cin>>T[i];
    long long ans = 1;
    REP(i,N){
        ans = lcm(ans,T[i]);
    }
    Out(ans);
}


Measured memory_bytes: 256
n = int(input())
graph =[]
time = 0
for i in range(n-1):
    c,s,f = map(int,input().split())
    graph.append([i,c,s,f])

def shortest_path(start,end,times):
    if start == end:
        return times
    elif times<=graph[start][2]:
        times = (graph[start][2]+graph[start][1])
        return shortest_path(start+1,end,times)
    elif times%graph[start][3]==0:
        times += (graph[start][1])
        return shortest_path(start+1,end,times)
    else:
        times = times+graph[start][3]-times%graph[start][3]+graph[start][1]
        return shortest_path(start+1,end,times)


for i in range(n):
    print(shortest_path(i,n-1,0))

Measured memory_bytes: 9400
import java.io.*;
import java.util.Scanner;
 
class Element {
    Element next;
    Element prev;
    int key;
    Element(int a) {
        key = a;
    }
}
  
class DoubleyLinkedList {
    Element head;
    DoubleyLinkedList() {
        head = new Element(-1);
        head.next = head;
        head.prev = head;
    }
      
    void insert(int key) {
        Element e = new Element(key);
        e.next = head.next;
        e.prev = head;
        e.next.prev = e;
        head.next = e;
    }

    void delete(int key) {
        for (Element e = head.next; e != head; e = e.next) {
            if (e.key == key) {
                e.prev.next = e.next;
                e.next.prev = e.prev;
                break;
            }
        }
    }

    void deleteFirst() {
        Element e = head.next;
        e.next.prev = head;
        head.next = e.next;
    }
    
    void deleteLast() {
        Element e = head.prev;
        e.prev.next = head;
        head.prev = e.prev;
    }
      
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Element e = head.next; e != head; e = e.next) {
            sb.append(e.key);
            sb.append(' ');
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append('\n');
        return sb.toString();
    }
}
  
public class Main {
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
  
        DoubleyLinkedList list = new DoubleyLinkedList();
        for (int i = 0; i < n; i++) {
            String[] line = br.readLine().split(" ");
            if (line[0].equals("insert")) {
                list.insert(Integer.parseInt(line[1]));
            } else if (line[0].equals("delete")) {
                list.delete(Integer.parseInt(line[1]));
            } else if (line[0].equals("deleteFirst")) {
                list.deleteFirst();
            } else if (line[0].equals("deleteLast")) {
                list.deleteLast();
            }
        }
        System.out.print(list.toString());

    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
string S;

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

  if (N % 2 != 0){
    No(); return 0;
  }

  for (int i = 0; i < N / 2; i++){
    if (S[i] != S[i + N / 2]){
      No(); return 0;
    }
  }
  Yes();

  return 0;
}


Measured memory_bytes: 3636
def main():
  from heapq import heapify,heappush,heappop
  n,m,*a=[-int(i)for i in open(0).read().split()]
  heapify(a)
  for _ in range(-m):heappush(a,0--heappop(a)//2)
  print(-sum(a))
main()

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

int main()
{
	int a, b;

	cin >> a >> b;

	if( (a % 2) == 0 || (b % 2) == 0 ) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<vector>
using namespace std;
const int N=2000,inf=0x3f3f3f3f;
int n,val[N+1];
vector<int>e[N+1];
int siz[N+1],dis[N+1],f[N+1];
int res=inf;
void dfs(int u,int fa)
{
	siz[u]=val[u],dis[u]=0;
	int maxn=0;
	for(int v:e[u]) {
		if(v==fa) {
			continue;
		}
		dfs(v,u);
		siz[u]+=siz[v],dis[u]+=dis[v];
		if(dis[v]>=dis[maxn]) {
			maxn=v;
		}
	}
	if(maxn) {
		if(dis[u]>=dis[maxn]*2) {
			f[u]=dis[u]/2;
		} else {
			f[u]=dis[u]-dis[maxn]+min(f[maxn],(dis[maxn]*2-dis[u])/2);
		}
	} else {
		f[u]=0;
	}
	if(fa) {
		dis[u]+=siz[u];
	}
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		char c=getchar();
		while(!isdigit(c)) {
			c=getchar();
		}
		val[i]=c-'0';
	}
	for(int i=1,u,v;i<n;++i) {
		scanf("%d%d",&u,&v);
		e[u].push_back(v),e[v].push_back(u);
	}
	for(int i=1;i<=n;++i) {
		dfs(i,0);
		if(!(dis[i]&1)&&(f[i]>=dis[i]/2)) {
			res=min(res,dis[i]/2);
		}
	}
	printf("%d\n",res==inf?-1:res);
	return 0;
}

Measured memory_bytes: 3504
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
#define gc() getchar_unlocked()
//#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int  tr['T'+1];
char f[33554432];

int main()
{
	int n, k, c;

	tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
	n = in();
	while (n--) {
		if (gc() == 'i') {
			k = 7; while (--k) gc();
			k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
			f[k] = 1;
		} else {
			k = 5; while (--k) gc();
			k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
			puts(f[k]? "yes": "no");
		}
	}
	return 0;
}



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

int main(void)
{
  int r, c, i, j, count, lastcount;
  int map[101][101] = {};
  cin >> r >> c;
  for (i = 0; i < r; i++){
    for (j = 0; j < c; j++) cin >> map[i][j];
  }
  for (i = 0; i < r; i++){
    count = 0;
    for (j = 0; j < c; j++){
      count += map[i][j];
      cout << map[i][j] << " ";
    }
    cout << count << endl;
  }
  lastcount = 0;
  for (j = 0; j < c; j++){
    count = 0;
    for (i = 0; i < r; i++){
      count += map[i][j];
    }
    lastcount += count;
    cout << count << " ";
  }
  cout << lastcount << endl;
  return 0;
}

Measured memory_bytes: 1208
n=int(input())



ans=[[] for i in range(10)]


for i in range(n):
    if i==0:
        ans[i].append(["a",1])
    else:
        for moji,index in ans[i-1]:
            for plus in range(index):
                new=moji+chr(plus+97)
                ans[i].append([new,index])
            new=moji+chr(index+97)
            ans[i].append([new,index+1])

for a,b in ans[n-1]:
    print(a)

Measured memory_bytes: 28024
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N,Z,W;
	SINT32 ans;
	cin >> N>>Z>>W;

	vector <SINT32> DATA(N);

	rep(i,0,N) {	
		cin >> DATA[i];
	}

	if (N == 1) {
		ans = ABS(DATA[0] - W);
	} else {
		ans = MAX(ABS(DATA[N-1] - W),ABS(DATA[N-1]-DATA[N-2]));
	}


	cout << ans << endl;

	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
while True:
    N,I,J = map(int,input().split())
    if N == 0:
        break
    L = [I]*N
    for i in range(N-2,-1,-1):
        if L[i+1]<=2**(i+1):
            L[i] = 2**(i+1) - L[i+1] + 1
        else:
            L[i] = L[i+1] - 2**(i+1)
    ans = ""
    for i in range(N):
        if L[i] > 2**i:
            if J <= 2**(N-i-1):
                ans = ans+"R"
            else:
                ans = ans+"L"
                J -= 2**(N-i-1)
        else:
            if J <= 2**(N-i-1):
                J = 2**(N-1-i)-J+1
                ans = ans + "L"
            else:
                J -= 2**(N-i-1)
                J = 2**(N-1-i)-J+1
                ans = ans + "R"
    print(ans)



Measured memory_bytes: 5608
x, n = map(int, input().split())
if(n == 0):
    print(x)
elif(n == 1):
    if(n == x):
        print(x - 1)
    else:
        print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    p2 = map(lambda a: a - x, p)
    ps = sorted(p2, key=abs)
    q = list(range((-1) * n, n))
    qs = sorted(q, key=abs)
    for i in range(n):
        if(ps[i] != qs[i]):
            print(qs[i] + x)
            break
    else:
        print(x + qs[n])

Measured memory_bytes: 62004
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const int MODD = 998244353;
const ll LLINF = 1e18;


int coun[100001];
vector<int> rec;

int main(){
	ll n, x, m;
	cin >> n >> x >> m;
	
	ll now = x;
	coun[now]++;
	bool flg = false;
	rec.push_back(now);
	for (int i = 1; i < n; i++){
		now = now * now % m;
		if (coun[now] == 2){
			flg = true;
			break;
		}
		coun[now]++;
		rec.push_back(now);
	}

	if (flg == true){
		ll before = 0;
		ll loop = 0;
		ll loop_size = 0;
		ll start_id = 0;
		for (int i = 0; i < rec.size(); i++){
			if (rec[i] == rec[rec.size()-1]){
				start_id = i;
				break;
			}
			before += rec[i];
		}
		for (int i = start_id; i < rec.size()-1; i++){
			loop_size++;
			loop += rec[i];
		}
		if (loop == 0) cout << before << endl;
		else{
			n -= start_id;
			ll ans = before + n/loop_size*loop;
			for (int i = start_id; i < start_id+n%loop_size; i++){
				ans += rec[i];
			}
			cout << ans << endl;
		}
	}else{
		ll ans = 0;
		for (int i = 0; i < n; i++){
			ans += rec[i];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int m; cin >> m;
    vector<ll> d(m),c(m);
    ll k = 0, s = 0;
    rep(i,m){
        cin >> d[i] >> c[i];
        k += c[i];
        s += d[i]*c[i];
    }    
    cout << k - 1 + (s - 1) / 9 << endl;
}

Measured memory_bytes: 3328
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]

left = []
right = []
for i in 1..M do
  left[i-1] = lines[i][0]
  right[i-1] = lines[i][1]
end

left.sort!.reverse!
right.sort!

ans = right[0] - left[0] + 1
if ans < 0 then
  puts 0
else
  puts ans
end

Measured memory_bytes: 23656
#pragma GCC optimize("Ofast")
#include <stdio.h>

main()
{
    int n,k; scanf("%d%d",&n,&k);
    int ary[1<<18];
    int que[1<<18];
    int que2[1<<18];
    int *beg=que,*end=que;
    int *beg2=que2,*end2=que2;
    int sorted=0;
    int ans=0;

    for(int i=0; i<n; ++i)
    {
        scanf("%d",ary+i);
        int flag=0;

        if(i>=k)
        {
            if(*beg==i-k) ++beg;
            else flag=1;

            if(*beg2==i-k) ++beg2;
        }

        while(beg!=end && ary[*(end-1)]>ary[i])
        {
            --end;
        }
        *end++=i;

        while(beg2!=end2 && ary[*(end2-1)]<ary[i]) --end2;
        if(beg2!=end2) flag=1;
        *end2++=i;

        if(i==k-1) flag=1;
        else if(i<k-1) flag=0;

        if(end-beg==k)
        {
            flag=0;
            sorted=1;
        }

        if(flag)
        {
            ans++;
            // printf("%d\n",i);
        }
    }

    ans+=sorted;
    printf("%d\n",ans);
}


Measured memory_bytes: 2944
n = gets.to_i
a = []
b = []
c = []
n.times do
  params = gets.split.map(&:to_i)
  a << params[0]
  b << params[1]
  c << params[2]
end

dp = Array.new(n) { Array.new(3, 0) }
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

1.upto(n - 1) do |i|
  dp[i][0] = [dp[i - 1][1], dp[i - 1][2]].max + a[i]
  dp[i][1] = [dp[i - 1][0], dp[i - 1][2]].max + b[i]
  dp[i][2] = [dp[i - 1][0], dp[i - 1][1]].max + c[i]
end

puts [dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]].max


Measured memory_bytes: 13724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < sz(s); i++){
        s[i] = 'x';
    }
    cout << s;
    return 0;
}


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

int main() {
  deque<char> S;
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    S.push_back(s[i]);
  }
  int Q;
  cin >> Q;
  bool rev = false;
  for(int i = 0; i < Q;i++){
    int q;
    cin >> q;
    if(q == 1){
      if(rev){
        rev = false;
      }
      else{
        rev = true;
      }
    }
    else{
      int F;
      char C;
      cin >> F >> C;
      if(F == 1){
        if(rev == false){
          S.push_front(C);
        }
        else{
          S.push_back(C);
        }
      }
      else{
        if(rev == false){
          S.push_back(C);
        }
        else{
          S.push_front(C);
        }
      }
    }
  }
  if(!rev){
    for(int i = 0;i < S.size();i++){
      cout << S[i];
    }
  }
  else{
    for(int i =  S.size() -1;i >= 0;i--){
      cout <<S[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 896
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* search(int key) {
    struct Node *x = note->next;
    while(x != note && x->key != key ) {
        x = x-> next;
    }
    return x;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
   
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
void deleteKey(int key) {
    deleteNode(search(key));
}
   
void printList() {
    struct Node *x;
    x = note->next;
    int i = 0;
    while(1) {
        if (x == note) break;
        if(i++ > 0) printf(" ");
        printf("%d", x->key);
        x = x->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( order[6] == 'F') {
                    deleteFirst();
                }else if(order[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    printList();
    return 0;
}

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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a<=0) {
    cout << "delicious" << endl;
  }
  else if(b-a>0 && b-a <= x ){
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

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

#define INF (1<<18)



int main() {
    ll n,y;
    cin>>n>>y;

    rep(i,n+1){
        rep(j,n+1){
            ll k = n - i -j;
            if(k<0) continue;
            ll sum = i*10000 + j*5000 + k*1000;
            if(sum == y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }

    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func solve() {
	n, m := getInt(), getInt()
	bulbs := make([][]int, m)
	for i := range bulbs {
		k := getInt()
		bulbs[i] = make([]int, k)
		for j := range bulbs[i] {
			bulbs[i][j] = getInt() - 1
		}
	}
	ps := getIntSlice(m)

	ans := 0
	for bit := 0; bit < (1 << uint(n)); bit++ {
		ok := true
		for i, switches := range bulbs {
			cnt := 0
			for _, sw := range switches {
				if (bit & (1 << uint(sw))) > 0 {
					cnt++
				}
			}
			if cnt%2 != ps[i] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include <stdio.h>

#define MAX_N (105)
#define INF (10000)
int G[MAX_N][MAX_N];
int N;

int dist[MAX_N];
bool arrived[MAX_N];

int prim()
{
    int ret = 0;
    for ( int i = 0; i < N; i++ ) {
	arrived[i] = false;
	dist[i] = INF;
    }

    dist[0] = 0;

    while ( true ) {
	int min_dist = INF;
	int u = 0;
	for ( int i = 0; i < N; i++ ) {
	    if ( !arrived[i] && dist[i] < min_dist ) {
		min_dist = dist[i];
		u = i;
	    }
	}
	
	if ( min_dist == INF ) break;

	ret += dist[u];
	arrived[u] = true;

	for ( int i = 0; i < N; i++ ) {
	    if ( !arrived[i] && (G[u][i] != -1) && (dist[i] > G[u][i]) ) {
		dist[i] = G[u][i];
	    }
	}
    }

    return ret;
}

int main()
{
    int ans = 0;
    scanf("%d", &N);

    for ( int i = 0; i < N; i++ ) {
	for ( int j = 0; j < N; j++ ) {
	    scanf("%d", &G[i][j]);
	}
    }

    ans = prim();

    printf("%d\n", ans);

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;

  unordered_map<string, int> ans;
  for(int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    ans[s]++;
  }
  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;

  
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3656
n = int(input())
a = list(map(int, input().split()))

four = 0
two = 0
other = 0
for i in a:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1
    else:
        other += 1

ans = 'No'
other += two % 2
if four + 1 >= other:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define M_PI 3.1415926535897932384626433832795
using namespace std;
using LL = int64_t;
using ULL = int64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
//#define DEBUG

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  const double h_angle = M_PI * 2.0 * ((h / 12.0) + (m / 720.0));
  const double m_angle = M_PI * 2.0 * m / 60.0;

  const double h_x = cos(h_angle) * a;
  const double h_y = sin(h_angle) * a;
  const double m_x = cos(m_angle) * b;
  const double m_y = sin(m_angle) * b;
  
  const double d = sqrt((h_x - m_x) * (h_x - m_x) +
                        (h_y - m_y) * (h_y - m_y));
  cout << setprecision(20) << d << endl;

  #ifdef DEBUG
  cout << a << endl;
  cout << b << endl;
  cout << h << endl;
  cout << m << endl;
  cout << h_angle << endl;
  cout << m_angle << endl;
  cout << h_x << endl;
  cout << h_y << endl;
  cout << m_x << endl;
  cout << m_y << endl;
  cout << h_x - m_x << endl;
  cout << h_y - m_y << endl;
  #endif
}



Measured memory_bytes: 4160
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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

	int A, B; cin >> A >> B;
	print(max({ A*B,A - B,A + B }));
 }



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define M 1000000007
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)

//--------------------------------------------------------------

void Main(){
  set<string> st;
  map<char,vi> mp;
  string s;
  cin>>s;
  int k;
  cin>>k;
  rep(i,s.length()){
    mp[s[i]].push_back(i);
  }
  for(auto m:mp){
    for(auto v:m.second){
      st.insert(s.substr(v,1));
      if(v-1+2 < s.length()) st.insert(s.substr(v,2));
      if(v-1+3 < s.length()) st.insert(s.substr(v,3));
      if(v-1+4 < s.length()) st.insert(s.substr(v,4));
      if(v-1+5 < s.length()) st.insert(s.substr(v,5));
    }
    if(st.size()>=k) break;
  }
  cout<<*(next(st.begin(),k-1))<<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}
int cnt=0,ans=0,x,y,i;
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
     cnt=0;
    while (n % 2 == 0)  
    {  
        cnt++;
        n = n/2;  
    }  
    //cout<<cnt<<" "<<"2"<<endl;
    cnt=cnt*2;
    x=sqrt(cnt);
    for(i=0;i<=x;i++)
    if((i*(i+1))<=(cnt))
    y=i;
  
    ans+=y;
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
         
        cnt=0;
        while (n % i == 0)  
        {  
           cnt++;
            n = n/i;  
        }  
        cnt=cnt*2;
        x=sqrt(cnt);
        y=0;
        for(int j=1;j<=x+1;j++)
        if((j*(j+1))<=(cnt))
        y=j;
        ans+=y;
        // cout<<cnt<<" "<<i<<endl;
    }  
  
    
    if (n > 2)  
        ans++;
}  
  
void solve()
{ 
  int n;cin >> n;
  primeFactors(n);
  cout<<ans;
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 3700