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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int calc(int n, int a, int b, vector<int> v)
{
	int result = 0;
	rep(i, n)
	{
		if (i % 2 == 0)
		{
			if (v[i] != a)
				result += 1;
		}
		else if (i % 2 == 1)
		{
			if (v[i] != b)
				result += 1;
		}
	}

	return result;
}

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

	vector<mpint> a(N);
	rep(i, N) {
		cin >> a[i];
	}

	mpint total = 1;
	rep (i, N) {
		total *= a[i];
		if (total > mpint(1e18)) {
			break;
		}
	}

	bool is_zero = false;
	rep (i, N) {
		if (a[i] == 0) is_zero = true;
	}

	if (is_zero) {
		total = 0;
	} else {
		if (total > mpint(1e18)) {
			total = -1;
		}
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 6572
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if(k <= a) {
		cout << k << endl;
	} else if(k <= a + b) {
		cout << a << endl;
	} else {
		cout << a - (k - a - b) << endl;
	}
}

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


ans=[0 for i in range(n)]
ans[0]=0



check=a[0]
for i in range(1,n):
  if a[i]>=check:
    ans[i]=0
    check=a[i]
  else:
    ans[i]=check-a[i]

print(sum(ans))

Measured memory_bytes: 102044
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define lli long long int
#define pii pair<lli,lli>
#define f first
#define sE second
lli n,x,y,t,mod=1e9+7,ans=0; 
int main() { 
    fast
    string s;
    lli a,b;
    cin>>n>>a>>b;
    cout<<a*(n/(a+b))+min(a,n%(a+b))<<endl;
        
} 

Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RI(a, b);
  PI((a + b + 1) / 2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    ll ans=0;
    for(int i = 0; i < n; i++) {
        int a;cin >> a;
        ans += a-1;
    }
    cout<<ans << endl;

    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  VI l(m),r(m);
  rep(i,m){
    cin >> l[i] >> r[i];
  }
  
  int left=0, right=n+1;
  rep(i,m){
    left = max(left, l[i]);
    right = min(right, r[i]);
  }
  
  cout << max(0, (right-left+1)) << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    string s; cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long can_div_c = floor((long double)b / c) - ceil((long double)a / c) + 1;
  long long can_div_d = floor((long double)b / d) - ceil((long double)a / d) + 1;
  long long cd = c * d / __gcd(c, d);
  long long can_div_cd = floor((long double)b / cd) - ceil((long double)a / cd) + 1;

  cout << (b - a + 1) - (can_div_c + can_div_d - can_div_cd) << endl;
  return 0;
}

Measured memory_bytes: 256
D,G = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(D)]
ans = 0
 
for i in range(2**D):
	point = 0
	count = 0
	for j in range(D):
		if (i>>j)&1:
			point += 100*(j+1)*X[j][0]+X[j][1]
			count += X[j][0]
	if 	G > point:
		for k in range(D)[::-1]:
			if (i>>k)&1==0:
				if (G-point) <= 100*(k+1)*(X[k][0]):
					count += (G-point-1) // (100*(k+1)) +1
					break
				else:
					count = 10**5
					break
	if ans == 0 or count < ans:
		ans = count
 
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int i, n, a[100], min=1000000001, max=0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
    if(min>a[i]) min = a[i];
    if(max<a[i]) max = a[i];
  }

  printf("%d\n", max -min);

  return (0);
}


Measured memory_bytes: 1712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		
		int n = sc.nextInt();
		
		int a[]= new int[n];
		int ans=0;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        int min = a[0];
        
        for(int i=1; i<n; i++){
            if (min > a[i]){
                ans++;
                min = a[i];
            }
        }
		

        System.out.println(ans+1);
	}
}

Measured memory_bytes: 61080
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int w, h;
ll p[100010], q[100010];

ll solve() {
    vector<P> c;
    for (int i = 0; i < w; i++) c.push_back(make_pair(p[i], 0));
    for (int i = 0; i < h; i++) c.push_back(make_pair(q[i], 1));
    sort(ALL(c));

    int t = w + h;
    int cw = 0, ch = 0;
    ll res = 0;
    for (int i = 0; i < t; i++) {
        P p = c[i];
        if (p.second == 0) {
            res += p.first * (h + 1 - ch);
            cw++;
        } else {
            res += p.first * (w + 1 - cw);
            ch++;
        }
    }
    return res;
}

void input() {
    cin >> w >> h;
    for (int i = 0; i < w; i++) cin >> p[i];
    for (int i = 0; i < h; i++) cin >> q[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 303;

int H, W, K;
bool cake[MAX][MAX];
int result[MAX][MAX];

int has_b_in_line(int h) {
    REP (w, W) if (cake[h][w]) return true;
    return false;
}

void solve() {
    int count_b = 0; // いちごの数

    REP (h, H) {
        if (has_b_in_line(h)) {
            count_b++;
            bool fst = true;
            REP (w, W) {
                if (cake[h][w]) {
                    if (!fst) count_b++;
                    fst = false;
                }
                result[h][w] = count_b;
            }
        }
    }

    int first_line = 0;
    while (result[first_line][0] == 0) first_line++;

    REP (h, H) {
        int l = h;
        if (h < first_line) l = first_line;
        else {
            while (result[l][0] == 0) l--;
        }

        REP (w, W) {
            cout << result[l][w] << " ";
        }
        cout << "\n";
    }
}

int main() {
    cin >> H >> W >> K;
    REP (h, H) {
        string s; cin >> s;
        REP (w, W) cake[h][w] = (s[w] == '#');
    }
    solve();
}

Measured memory_bytes: 1152
#include <iostream>
  
using namespace std;
  
typedef unsigned long long ull;
  
int main()
{
    ull t[45] = { 1, 1 };
    for( int i=2; i<45; ++i )
        t[i] = t[i-1] + t[i-2];
    ull n;
    cin >> n;
    cout << t[n] << endl;
}

Measured memory_bytes: 1156
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}


Measured memory_bytes: 35792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int A, B, K;
int main() {
    while (cin >> A >> B >> K) {
        set<int> res;
        for (int i = A; i < A+K; ++i) if (i <= B) res.insert(i);
        for (int j = B; j > B-K; --j) if (j >= A) res.insert(j);
        EACH(it, res) {
            cout << *it << endl;
        }
    }
}




















    
    
    
    
    
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long d;
  cin>>n>>d;
  int cnt=0;
  for(int i=0;i<n;i++){
    long long x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];

int main(){
    cin >> s;
	n = strlen(s);
	for(i=0;i<n;i++){
		if(s[i] == 'W'){
			ans += m;
		}else{
			m += 1;
		}
	}
	p(ans);
	
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define div 1e9+7
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;
int main(){
	int n,m;
	cin>>n>>m;
	int a[m];
	int sum=0;
	rep(i,m){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
		puts(-1);
	else
		puts(n-sum);
	
}


Measured memory_bytes: 3624
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> ss(n); cin >> ss;
    vector<int> ts(m); cin >> ts;
    vector<int> dp[2] = {vector<int>(m + 1, 1), vector<int>(m + 1)};
    // vector<vector<int>> dp(2, vector<int>(m + 1, 1));
    for(int i = 0; i < n; i++){
        int i1 = i & 1, i2 = !i1;
        dp[i2][0] = 1;
        for(int j = 0; j < m; j++){
            int& num = dp[i2][j + 1];
            num = dp[i2][j] + dp[i1][j + 1] - dp[i1][j];
            if(num >= M){
                num -= M;
            }else if(num < 0){
                num += M;
            }
            if(ss[i] == ts[j]){
                num += dp[i1][j];
                if(num >= M){
                    num -= M;
                }
            }
        }
    }
    printde(dp);
    cout << dp[n & 1][m] << '\n';
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		String s = sc.next();
		System.out.println(s.substring(0, s.length()-8));
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
	static long ans = 1;
	static int n, k;
	static int mod = 1000000007;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		k = Integer.parseInt(sa[1]);
		Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;

			List<Integer> list1 = map.get(a);
			if (list1 == null) {
				list1 = new ArrayList<Integer>();
				map.put(a, list1);
			}
			list1.add(b);

			List<Integer> list2 = map.get(b);
			if (list2 == null) {
				list2 = new ArrayList<Integer>();
				map.put(b, list2);
			}
			list2.add(a);
		}
		br.close();
		map.put(-1, new ArrayList<Integer>());

		if (n == 1) {
			System.out.println(k);
			return;
		}

		int[] cnt = new int[100005];
		dfs(map, 0, -1, 2, cnt);
		System.out.println(ans);
	}

	static void dfs(Map<Integer, List<Integer>> map, int c, int p, int dep, int[] cnt) {
		int x = Math.min(cnt[dep - 2], 1) + Math.min(cnt[dep - 1], 1) + cnt[dep] + cnt[dep + 1];
		int y = Math.max(k - x, 0);
		ans *= y;
		ans %= mod;
		cnt[dep]++;

		List<Integer> list = map.get(c);
		for (int i : list) {
			if (i != p) {
				dfs(map, i, c, dep + 1, cnt);
			}
		}
		dep--;
		cnt[dep + 2] = 0;
	}

	static long power(long x, long n) {
		if (n == 0) {
			return 1;
		}
		int mod = 1000000007;
		long val = power(x, n / 2);
		val = val * val % mod;
		if (n % 2 == 1) {
			val = val * x % mod;
		}
		return val;
	}
}


Measured memory_bytes: 81408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b==1)
		cout<<0<<endl;
	else
		for(int i=1;;i++){
			if((i*a-(i-1))>=b){
				cout<<i<<endl;
				break;
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#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>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	string s, t;

	cin >> s >> t;

	SORT(s);
	SORT(t);
	reverse(t.begin(), t.end());
	// debug(s);
	// debug(t);

	if (s < t)
		cout
			<< "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



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

int n, m;

int main(){
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    
    for (int i = - 1; i <= n; i++){
        for (int j = i + 1; j <= n; j++){
            if (n - j + i + 1 <= k){
                int tmp = 0;
                vector<int> tmp_v;
                
                if (i >= 0 && i < n){
                    for (int k = 0; k <= i; k++){
                        tmp_v.push_back(v[k]);
                        tmp += v[k];
                    }
                }
                if (j < n){
                    for (int k = j; k < n; k++){
                        tmp_v.push_back(v[k]);
                        tmp += v[k];
                    }
                }
                sort(tmp_v.begin(), tmp_v.end());
                
                if (tmp_v.size() > 0){
                    int num = min((int)tmp_v.size(), k - (int)tmp_v.size());
                    for (int s = 0; s < num; s++){
                        if (tmp_v[s] < 0) tmp -= tmp_v[s];
                    }
                }
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}








Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	int a, b;
	string s;
public:
	B()
	{
		cin >> a >> b >> s;
	}

	bool check()
	{
		if (s[a] != '-')
			return false;

		REP(i, a)
			if (s[i] < '0' || s[i] > '9')
				return false;

		for(int i{a+1}; i < SZ(s); i++)
			if (s[i] < '0' || s[i] > '9')
				return false;

		return true;
	}

	void solve()
	{

		if (check())
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
#include <stack>
#include <cmath>
using namespace std;

#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 llong long long

int main() {
  int a[4],b[4];
  while(scanf("%d %d %d %d %d %d %d %d", a, a+1, a+2, a+3, b, b+1, b+2, b+3) != EOF) {
    int hit = 0;
    int blow = 0;
    REP(i,4) if(a[i] == b[i]) hit++;
    REP(i,4) {
      REP(j,4) {
	if(i != j && a[i] == b[j]) blow++;
      }
    }
    printf("%d %d\n",hit, blow);
  }
  return 0;
}

Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int n;
string s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>s;
	vector<vector<int>> pref(n,vector<int>(3));
	for(int i=0;i<n;++i){
		if(s[i]=='R') s[i]='0';
		else if(s[i]=='G') s[i]='1';
		else s[i]='2';
		if(!i){
			pref[i][s[i]-'0']=1;
		}
		else{
			pref[i][0]=pref[i-1][0];
			pref[i][1]=pref[i-1][1];
			pref[i][2]=pref[i-1][2];
			++pref[i][s[i]-'0'];
		}
	}
	ll ans=0;
	for(int i=2;i<n;++i){
		for(int j=1;j<i;++j){
			if(s[i]==s[j]) continue;
			int findd=3-(s[i]-'0'+s[j]-'0');
			int diff=(i-j);
			int minus=1;
			if(j-diff<0){
				minus=0;
			}
			else if(s[j-diff]-'0'!=findd) minus=0;
			ans+=(pref[j-1][findd])-minus;
			//~ cout<<findd<<" (find) "<<ans<<endl;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3772
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long M = 1_000_000_007;

    List<Integer> factors = new ArrayList<>();
    factors.add(0);
    for (int i = 1; i * i <= N; i++) {
      int j = N / i;
      factors.add(i);
      if (j != i) factors.add(j);
    }
    Collections.sort(factors);

    int F = factors.size() - 1;
    long[][] dp = new long[K][F + 1];
    for (int i = 1; i <= F; i++) {
      dp[0][i] = factors.get(i);
    }
    for (int i = 1; i < K; i++) {
      for (int j = 1; j <= F; j++) {
        dp[i][j] = dp[i][j - 1];
        dp[i][j] += dp[i - 1][F - j + 1] * (factors.get(j) - factors.get(j - 1)) % M;
        if (dp[i][j] >= M) dp[i][j] -= M;
      }
    }

    System.out.println(dp[K - 1][F]);
  }
}


Measured memory_bytes: 83412
def main():
	A, B = map(int, input().split())
	ans = 0
	for i in range(A, B+1):
		copy_i = str(i)
		add = 1
		for j in range(len(copy_i)//2):
			if copy_i[j] != copy_i[-j-1]:
				add = 0
				break
		ans += add
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
# coding: utf-8
N = int(input())
mins, maxs = [], []
for i in range(N):
    a, b = map(int, input().split())
    mins.append(a)
    maxs.append(b)
mins.sort()
maxs.sort()
if N % 2 == 0:
    mincn = (mins[N//2-1] + mins[N//2])
    maxcn = (maxs[N//2-1] + maxs[N//2])
else:
    mincn = mins[N//2]
    maxcn = maxs[N//2]
print(maxcn - mincn + 1)

Measured memory_bytes: 25520
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// 15:20-15:35 WA

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int sx,sy,tx,ty;
LL A[MAX_N];
void solve() {
  int dx=tx-sx,dy=ty-sy;
  string res=string(dy,'U')+string(dx,'R')+"U"+string(dx+1,'L')+string(dy+1,'D')+"R";
  res+=string(dx,'R')+string(dy,'U')+"R"+string(dy+1,'D')+string(dx+1,'L')+"U";
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>sx>>sy>>tx>>ty;
  solve();
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    ans = min(n * a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;
int n,m,t;
int main()
{
	map<int,int> a,b;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&t);
		a[t]++;
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d",&t);
		b[t]++;
	}
	for(auto i:b)
		if(a[i.first]<i.second){puts("NO");return 0;}
	puts("YES");
	return 0;
}


Measured memory_bytes: 18944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        StringBuilder sb = new StringBuilder(S);
        int ans = 0;
        for (int i=0;i<S.length();i++) {
            String S_tmp = sb.substring(i);
            int[] z = z_algo(S_tmp);
            // System.out.println(Arrays.toString(z));
            for (int j=1;j<S.length()-i;j++) {
                if (j>=z[j]) {
                    ans = Math.max(ans,z[j]);
                }
            }
        }
        System.out.println(ans);
    }

    public static int[] z_algo(String S) {
        int N = S.length();
        int[] A = new int[N];
        A[0] = N;
        int i = 1;
        int j = 0;
        while (i < N) {
            while (i+j < N && S.charAt(j) == S.charAt(i+j)) {
                j++;
            }
            A[i] = j;
            if (j==0) {
                i++;
                continue;
            }
            int k=1;
            while (i+k < N && k+A[k] < j) {
                A[i+k] = A[k];
                k++;
            }
            i += k;
            j -= k;
        }
        return A;
    }
}

Measured memory_bytes: 47376
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
int x[maxn],y[maxn];

int main(int argc, char const *argv[])
{
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		int a,b;
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		int ans=0;
		for(int i=0;i<m;i++){
			scanf("%d %d",&a,&b);
			if(a==1) x[b]=1;
			if(b==n) y[a]=1;
			// if(a==1&&b==n){
			// 	ans=1;
			// }
		}
		if(!ans){
			for(int i=1;i<=n;i++){
				if(x[i]&&y[i]){
					ans=1;
					break;
				}
			}
		}
		if(ans){
			printf("POSSIBLE\n");
		}
		else{
			printf("IMPOSSIBLE\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1792
//どうしてもフェネちゃん VS きすけくん にしたかった..........

/*  include  */
#include <cstdio>
#include <vector>
/*  using namespace  */
using namespace std;

/*  local var  */
vector<int> グラフ[100005];
int フェネック[100005];	
int きすけ[100005];
/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)

/*  typedef  */
typedef long long ll;

/*  function  */
void dfs(int マス,int 前回いた場所,int 距離差,int f)
{
	/*  距離差の設定  */
	if(f)フェネック[マス]=距離差;
	else きすけ[マス]=距離差;
	loop(i,グラフ[マス].size()){
		/*  前回いた場所でなければ行ってないので行く  */
		if(グラフ[マス][i] != 前回いた場所 ) dfs(グラフ[マス][i],マス,距離差+1,f);
	}
}

/*  main program  */
int main()
{	
	int マス数;
	int 連結A,連結B;
	int フェネちゃんが塗れるマス数=0;

	scanf("%d",&マス数);

	loop(i,マス数-1){
		scanf("%d %d",&連結A,&連結B);
		連結A--,連結B--;		 //連結A 連結Bの数を一つ減らし、0からマス数-1の数で表現
		グラフ[連結A].push_back(連結B);	 //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
		グラフ[連結B].push_back(連結A);	 //上記同様。「BからAへの辺を追加して無向グラフにする」
	}

	dfs(0,-1,0,1);			 //フェネちゃんはマス0からスタート。スタートなので前回いたところは -1 とする。 距離差はもちろん0
	dfs(マス数-1,-1,0,0);		 //上記同様。ただし きすけくんはマス数-1の数からのスタートなので マス数-1からスタートする。
	loop(i,マス数){
		 //フェネちゃんは先手だから「自分がiマス目に到着する手数が相手の手数"以下"であれば良い。」
		(フェネック[i]<=きすけ[i])?フェネちゃんが塗れるマス数++:フェネちゃんが塗れるマス数--;
	}
	/*後は塗った数が同数であった場合、フェネちゃんが塗れなくなるためきすけくんの勝利とすればよい。*/
	printf("%s\n",(フェネちゃんが塗れるマス数>0)?"Fennec":"Snuke");
	
}


Measured memory_bytes: 12800
/* Author rumoisen */
/* created 2018/11/17 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no() { cout << "No" << endl;exit(0);}
void yes() { cout << "Yes" << endl;exit(0);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  int a[52], b[52];
  REP(i, m){
      cin >> a[i] >> b[i];
  }
  vector<int> vec(n);
  for (int i = 0; i < m;i++){
    for (int j = 0; j < n; j++){
      if(a[i]==j+1||b[i]==j+1)
        vec[j]++;
    }
  }
  for (int i = 0; i < n; i++ ){
    cout << vec[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int compare = compare(A, B);
            System.out.println(compare == 0 ? "EQUAL" : compare > 0 ? "GREATER" : "LESS");
        }
    }

    private static int compare(String a, String b) {
        if (a.length() < b.length()) {
            return -1;
        }
        if (a.length() > b.length()) {
            return 1;
        }
        int N = a.length();
        for (int i = 0; i < N; i++) {
            if (a.charAt(i) < b.charAt(i)) {
                return -1;
            }
            if (a.charAt(i) > b.charAt(i)) {
                return 1;
            }
        }
        return 0;
    }
}


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

int main()
{
	string s;
	int q;
	cin >> s >> q;
	bool isForward = true;
	string forth, back;

	auto appendElem = [&](string elem, int which)
	{
		if (which == 1)
		{
			if (isForward)
			{
				forth += elem;
			}
			else
			{
				back += elem;
			}
		}
		else
		{
			if (isForward)
			{
				back += elem;
			}
			else
			{
				forth += elem;
			}
		}
	};

	for (int i=0; i<q ; i++)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			isForward = !isForward;
		}
		else
		{
			int which;
			string e;
			cin >> which >> e;
			appendElem(e, which);
		}
	}
	string ans;
	reverse(forth.begin(), forth.end());
	ans = forth + s + back;
	
	if (!isForward) reverse(ans.begin(), ans.end());

	cout << ans << endl;

}


Measured memory_bytes: 1348
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>

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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string str;
	for(int i = 0; i < 4; i++) {
		char c;
		std::cin >> c;
		str += c;
	}
	std::sort(str.begin(), str.end());
	std::cout << (str == "1479" ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
from queue import Queue
n,q = map(int,input().split())
names = []
times = []
for _ in range(n):
  data = list(map(str,input().split()))
  names.append(data[0])
  times.append(int(data[1]))

names_queue = Queue()
times_queue = Queue()
for i in range(n):
  names_queue.put(names[i])
  times_queue.put(times[i])
#print("---------")
time = 0
i = 0
ret = {}
while True:
  if times_queue.empty():
    break
  d = times_queue.get()
  n = names_queue.get()
# print("%s %d" %(n,d))
# print(d)
  if d-q <= 0:
    time += d
    ret[n] = time
  else:
    times_queue.put(d-q)
    names_queue.put(n)
    time += q
#print("--------")
for key,value in ret.items():
  print("%s %d" %(key,value))



Measured memory_bytes: 16560
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	qsort(a, 3, sizeof(int), cmpint);
	if ((a[0] + a[1] + a[2]) % 2 == (3 * a[2]) % 2) {
		printf("%d\n", (a[2] - a[0] + a[2] - a[1]) / 2);
	} else {
		printf("%d\n", (a[2] - a[0] + a[2] - a[1]) / 2 + 2);
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	ans += min(N, M / 2);
	M -= ans * 2;
	ans += M / 4;
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys


def distance(p1, p2):
    x1, y1 = p1
    x2, y2 = p2
    return abs(x2 - x1) + abs(y2 - y1)


H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())

P = [None] * (H * W + 1)
P[0] = (0, 0)
for i in range(H):
    for j in range(W):
        P[A[i][j]] = (i, j)

S = [0] * (H * W + 1)
for i in range(1, H * W + 1):
    pi = max(0, i - D)
    S[i] = S[pi] + distance(P[pi], P[i])

ans = []
for q in sys.stdin.readlines():
    L, R = map(int, q.split())
    # ans.append(S[R] - S[L])
    print(S[R] - S[L])

# print(*ans, sep='\n')


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

using namespace std;

int main()
{
    int a, b, bt = 0;
    double t;

    cin >> a >> b >> t;

    t += 0.5;

    while(1)
    {
        if(t >= a)
        {
            t -= a;
            bt += b;
        }
        else
            break;

    }

    cout << bt << endl;

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	ll N;
	cin >> N;
	string ans = "";
	int t = 1;
	int n = N % 26;
	if (n == 0) { n += 26; }
	ans += ('a' + n - 1);
	N -= n;
	N /=26;
	while (N>0) {
		int n = N % 26;
		if (n == 0) { n += 26; }
		ans += ('a' + n - 1);
		N -= n;
		N /= 26;
	}
	reverses(ans);
	ce(ans)
    return 0;
}



Measured memory_bytes: 3600
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int m=stoi(s+t);
    for(int i=0;i<=100100;i++){
        if(m==i*i){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

class Dijkstra{
private:
    struct edge { int to, cost;};
    vector< vector<edge> > g;
    vvi ee;
    vector<int> prever;
    int n;
public:
    Dijkstra(){};
    Dijkstra(int size){
        n = size;
        g.resize(n);
        ee = vvi(n,vi(n,0));
    }

    vi dist;

    void add_edge(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        ee[a][b]++;
        g[a].push_back(e1);
    }

    void calc(int s){
        priority_queue< pii, vector<pii>, greater<pii> > q;
        int n = g.size();
        dist = vi (n, INF);
        dist[s] = 0;
        q.push(pii(0, s));
        prever = vector<int>(n,-1);

        while(!q.empty()){
            pii p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue; //更新されていたら何もしない
            for(int i = 0; i < g[v].size(); i++){
                edge e = g[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    prever[e.to] = v;
                    q.push(pii(dist[e.to], e.to));
                }
            }
        }
    }

    vector<int> get_path(int t){ //頂点tへの最短路
        vector<int> path;
        for(; t != -1;t=prever[t]){
            path.push_back(t);
        }
        reverse(path.begin(), path.end());
        return path;
    }

    void solve(){
        int mi = INF;
        vi ans;
        rep(i,n){
            calc(i);
            rep(j,n)if(ee[j][i] && dist[j] < INF){
                int len = dist[j]+1;
                if(len < mi){
                    mi = len;
                    ans = get_path(j);
                }
            }
        }
        if(mi == INF){
            cout << -1 << endl;
        }else{
            cout << ans.size() << endl;
            rep(i,ans.size())cout << ans[i]+1 << endl;
        }

    }

};



signed main(void) {
    int n,m;
    cin >> n >> m;
    Dijkstra dij(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        dij.add_edge(a,b,1);
    }
    dij.solve();
}


Measured memory_bytes: 8192