akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        deque<bool> d;
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++){
            if(s[i]=='B'){
                if(d.size())
                    d.pop_back();
            }
            else{
                d.pb(s[i]-'0');
            }
        }
        while(d.size()){
            cout<<d.front();
            d.pop_front();
        }
        cout<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] n = new int[10];
		for(int i = 0; i < 10; i++){
			n[i] = sc.nextInt();
		}
		Arrays.sort(n);
		for(int i = 9; i >= 7; i--){
			System.out.println(n[i]);
		}
	}
}



Measured memory_bytes: 26440
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int k, a, b, c, bit[20];
int main(){
	a=read(), b=read(), c=read();
	k=read();
	bit[0]=1;
	for (int i=1;i<=10;i++) bit[i]=bit[i-1]<<1;
	for (int i=0;i<=k;i++)
		if (a<b*bit[i] && b*bit[i]<c*bit[k-i]){
			puts("Yes");
			return 0;
		}
	puts("No");
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define min(a, b) ( (a) < (b) ? (a) : (b) )
#define max(a, b) ( (a) > (b) ? (a) : (b) )
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define Repeat_Forever for (;;)
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))
#define ENDL cout << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector<ll> vll;

template <class T>
const bool is_impar(T x) {return (bool) (x & 1);}

int n;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    if (n <= 999)
        cout << "ABC";
    else cout << "ABD";
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
#include<algorithm>
#include<string>
#include<vector>
using namespace std;


int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int arr[n+1][m+1];

    for(int i=0; i<= n; ++i)
    {
        for(int j=0; j<=m; ++j)
        {
            if(i==0||j==0)
            {
                arr[i][j] = 0;
            }
            else
            {
                if(s[i-1] == t[j-1])
                {
                    arr[i][j] = 1 + arr[i-1][j-1];
                }
                else
                {
                    arr[i][j] = max(arr[i-1][j], arr[i][j-1]);
                }
            }
        }
    }
    string ans = "";
    int i = n, j = m;
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans=s[i-1]+ans;
            i--;
            j--;
        }
        else
        {
            if(arr[i-1][j] > arr[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }


    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[114514];
void f_init(int n) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
int a[100010];
int ans, cnt;
signed main() {
	scanf("%lld", &n);
	rep(i, n) {
		scanf("%lld", &a[i]);
		if (a[i]) cnt += a[i];
		else {
			ans += cnt / 2;
			cnt = 0;
		}
	}
	ans += cnt / 2;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;

const char *opchr = "+-*";

int eval(int lhs, int op, int rhs) {
    switch(op) {
        case 0: return lhs+rhs;
        case 1: return lhs-rhs;
        case 2: return lhs*rhs;
    }
    return 0;
}

int main() {
    while(true) {
        int ns[4];
        for(int i = 0; i < 4; ++i) cin >> ns[i];
        if(!ns[0] && !ns[1] && !ns[2] && !ns[3]) break;

        sort(ns, ns+4);
        do {
            for(int pat = 0; pat < 27; ++pat) {
                int oppos[6] = {0};
                oppos[3] = oppos[4] = oppos[5] = 1;
                do {
                    int opn = 0;
                    int div = 1;
                    stack<int> s;
                    stack<string> hist;
                    for(int i = 0; i < 4; ++i) {
                        s.push(ns[i]);
                        string numstr;
                        numstr += ns[i]+'0';
                        hist.push(numstr);
                        for(int j = 0; j < i; ++j)
                            if(oppos[opn+j]) {
                                if(s.size() < 2) goto next_patperm;
                                int lhs = s.top(); s.pop();
                                int rhs = s.top(); s.pop();
                                s.push(eval(lhs, pat/div%3, rhs));
                                string lhse = hist.top(); hist.pop();
                                string rhse = hist.top(); hist.pop();
                                hist.push("(" + lhse + opchr[pat/div%3] + rhse + ")");
                                div *= 3;
                            }
                        opn += i;
                    }
                    if(s.top() == 10) {
                        cout << hist.top() << endl;
                        goto next;
                    }
next_patperm:
                    ;
                } while(next_permutation(oppos, oppos+6));
            }
        } while(next_permutation(ns, ns+4));
        cout << 0 << endl;
next:
        ;
    }
    return 0;
}

Measured memory_bytes: 932
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]

n,m=map(int,input().split())
uf=UnionFind(n+1)
for _ in range(m):
    a,b=map(int,input().split())
    uf.Unite(a,b)
ans=0
for i in range(n):
    ans=max(ans,uf.Count(i))
print(ans)

Measured memory_bytes: 14508
import math
A,B,H,M = map(int,input().split())
time = H*60+M
theta1 = 2*math.pi*time/(12*60)
theta2 = 2*math.pi*time/60

ax,ay = A*math.cos(theta1),A*math.sin(theta1)
bx,by = B*math.cos(theta2),B*math.sin(theta2)

dist = (ax-bx)**2+(ay-by)**2
dist = math.sqrt(dist)
print(dist)

Measured memory_bytes: 9512
# -*-coding:utf-8
#????????????????????°

import fileinput

def main():

    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))

        number = tokens[0]
        ans = 0
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if((i+j+k+l) == number):
                            ans += 1

        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7624
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    IOS;
    ll n,a,b;
    cin >> n >> a >> b;
    if(a+b-1>n||a*b<n){
        put(-1);
        return 0;
    }
    vector<ll> res(n);
    if(b==1){
        if(a==n){
            REP(i,n){
                res[i] = i+1;
            }
        }else{
            put(-1);
            return 0;
        }
    }else{
        ll t = (n-a)/(b-1);
        REP(i,t){
            REP(j,b){
                res[i*b+j] = (i+1)*b-j;
            }
        }
        ll k = n-t*b;
        REP(i,k-(a-t)){
            res[b*t+i] = n-i;
        }

        REP(i,a-t){
            res[b*t+k-(a-t)+i] = t*b+1+i;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 4608
def euc_core(a,b):
    mod = a % b

    return b, mod

def euc(a,b):
    a_i = a
    b_i = b
    while True:
        if b_i == 0:
            break
        a_i, b_i = euc_core(a_i, b_i)
    
    return a_i


a,b = map(int, input().split())

if a < b :
    ai = a
    a = b
    b = ai

print(euc(a,b))



Measured memory_bytes: 5596
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	p,q,r,s = map(int,input().split())
	n = int(input())
	pickable_1l = min(p*4,q*2,r,p*2+q)
	if(pickable_1l * 2 < s):
		print(n*pickable_1l)
	else:
		print(n//2*s + pickable_1l * (n%2))


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 63596
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

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

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	ll cnt = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			for(int k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]){
					ll x = a[i];
					ll y = a[j];
					ll z = a[k];
					vector<ll> b(3);
					b[0] = x;
					b[1] = y;
					b[2] = z;
					sort(ALL(b));
					if (b[2] <(b[1] + b[0])){
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3632
import math
from collections import defaultdict
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
          n /= i
          table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    dd = defaultdict(int)
    n = int(input())
    pri = factorization(n)
    res = 0
    i  = len(pri)-1
    ans = 0

    for i in pri:
        k = i[1]
        i=1
        tmp=2
        cnt = 0
        while i<=k:
            i+=tmp
            tmp+=1
            cnt+=1
        ans+=cnt
    if len(pri)==1 and pri[0][1]==1:
        ans=1
    if n==1:
        ans = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9752
from collections import deque
k=int(input())

que=deque([1,2,3,4,5,6,7,8,9])
for _ in range(k):
    x=que.popleft()
    if x%10!=0:
        que.append(x*10+x%10-1)
    que.append(x*10+x%10)
    if x%10!=9:
        que.append(x*10+x%10+1)
print(x)

Measured memory_bytes: 18888
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, a[100010], b[100010];
ll calc() {
	//puts("b:");
	//for(int i=1; i<=n; i++) printf("%d ", b[i]); puts("");
	ll sum = 0;
	for(int i=1; i<n; i++)
		sum += abs(b[i] - b[i+1]);
	return sum;
}
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	sort(a+1, a+n+1);
	ll res;
	if(n % 2 == 0) {
		for(int i=1; i<=n/2; i++) {
			b[i*2-1] = a[n/2-i+1];
			b[i*2] = a[n-i+1];
		}
		res = calc();
	} else {
		for(int i=1; i<=n/2; i++) {
			b[i*2-1] = a[n/2+1+i];
			b[i*2] = a[n/2+1-i];
		}
		b[n] = a[n/2+1];
		res = calc();
		for(int i=1; i<=n/2; i++) {
			b[i*2-1] = a[n/2+1-i];
			b[i*2] = a[n/2+1+i];
		}
		b[n] = a[n/2+1];
		res = max(res, calc());
	}
	printf("%lld", res);
	return 0;
}

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


int main(void) {


    double A,B; cin>>A>>B;

    for (double i = 1; i <= 10000; ++i) {
        double eight = floor(i*0.08);
        double ten = floor(i*0.1);
        if((eight==A) && (ten==B)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

    return 0;
}

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

using namespace std;

int N, A, B, sum, cnt;
string s, ans[101010];

int main() {
  cin >> N >> A >> B >> s;

  for (int i = 0; i < N; i++) {
    if (s[i] == 'a') {
      if (sum < A + B) {
        sum++;
        ans[i] = "Yes";
      }
    } else if (s[i] == 'b') {
      if (sum < A + B && cnt < B) {
        sum++;
        cnt++;
        ans[i] = "Yes";
      }
    }

    if (ans[i] != "Yes") ans[i] = "No";
  }

  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

int main(){
    string s;
    int k;
    cin >> s >> k;

    for(int i = 0; i < s.length(); i++){
        int distToA = ('z' - s[i] + 1) % 26;
        if(distToA <= k){
            s[i] = 'a';
            k -= distToA;
        }
    }

    k %= 26;
    for(int i = 0; i < k; i++){
        if(s[s.length()-1] == 'z')  s[s.length()-1] = 'a';
        else                        s[s.length()-1]++;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;


 
/*
string fs(string str1, string str2)
{    if (str1.length() > str2.length())
        swap(str1, str2);
      string str = "";
    int n1 = str1.length(), n2 = str2.length();
    int diff = n2 - n1;
      int carry = 0;
      for (int i=n1-1; i>=0; i--)
    {
 
        int sum = ((str1[i]-'0') +
                   (str2[i+diff]-'0') +
                   carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      for (int i=n2-n1-1; i>=0; i--)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      if (carry)
        str.push_back(carry+'0');
      reverse(str.begin(), str.end());
 
    return str;
}*/
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second<y.second;}
bool f2(pll &x,pll &y){return x.first>y.first;}
bool f3(ll &x,ll &y){
    return x>y; 
    }

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()


//include<bits/stdc++.h>


int main()
{ fastio;
//freopen("input.txt", "r", stdin); 
//freopen("output.txt", "w", stdout);
ll n,k;cin>>n>>k;
ll x=n/k;
ll ans=1e18+4;
forl(i,-2,2){
    ll h=x+i;
    ll y=h*k;
    y=abs(y-n);
    ans=min(ans,y);

}
cout<<ans;

return 0;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll n;
       cin>>n;
       ll h[n];
       rep(i,0,n) cin>>h[i];
       ll ans=1, mx=h[0];
       rep(i,1,n)
       {
              if(h[i]>=mx) ans++;
              mx = max(mx, h[i]);
       }
       cout<<ans;
}


int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int n,x;
int ans = 0;
void dfs(int x,int y){
    if(y%x == 0){
        ans += 2*y - x;
        return;
    }else{
        ans += 2*(y/x)*x;
        dfs(y%x,x);
    }
}
signed main(){
    cin >> n >> x;
    ans = n;
    
    if(2*x == n){
        cout << 3*x << endl;
        return 0;
    }
    if(2*x < n){
        dfs(x,n-x);
    }else{
        dfs(n-x,x);
    }
    
    cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1e17
#define ninf -1e17
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n, w;
ll wt[105], val[105];
ll dp[105][100005];
ll compute(ll i, ll cur)
{
    if(cur>w) return ninf;
    if(i==n) return 0;
    if(dp[i][cur]!=-1) return dp[i][cur];
    ll ans = ninf;
    ans = MAX2( ans, val[i] + compute(i+1, cur+wt[i]));
    ans = MAX2(ans, compute(i+1, cur));
    return dp[i][cur] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>w;
    ll i, j;
    FOR0(i, n)
    {
        cin>>wt[i]>>val[i];
        FOR0(j, w+1) dp[i][j] = -1;
    }
    //cout<<inf<<" "<<ninf<<endl;
    cout<<compute(0, 0);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t n = 0, a = 0, b = 0;
  cin >> n >> a >> b;
  
  if (a <= 0) {
    cout << 0 << endl;
    return 0;
  }
  if (a >= n) {
    cout << n << endl;
    return 0;
  }
  
  int64_t ans = 0;
  if (a + b <= n) {
    ans = a * (n / (a + b));
    if (n % (a + b) <= a) {
      ans += n % (a + b);
    }
    else {
      ans += a;
    }
  }
  else {
    ans = a;
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
from collections import deque
n = int(input())
A=[int(input()) for _ in range(n)]
q=deque()
for a in A:
    i=bisect_left(q,a)
    if not i:
        q.appendleft(a)
    else:
        q[i-1]=a
print(len(q))

Measured memory_bytes: 53864
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Score = Tuple!(long, "p", long, "c");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    foreach (i; iota(n))
        a[i] -= (i + 1);
    a.sort();
    auto b = a[n / 2];
    foreach (ref e; a)
        e -= b;
    a.map!(a => abs(a)).sum.writeln();
}

Measured memory_bytes: 10992
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
cnt = 1
passengers = [T[0]]

for i in range(1, N):
    if T[i] - passengers[0] <= K and len(passengers) < C:
        passengers.append(T[i])
    else:
        cnt += 1
        passengers = [T[i]]

print(cnt)

Measured memory_bytes: 8276
#include<iostream>
#include<algorithm>
using namespace std;
int a[110];
int main(){
  int b,c=0,d=0;
  cin>>b;
  for(int i=0;i<b;i++){
    cin>>a[i];
    sort(a,a+b);
    reverse(a,a+b);
  }
  for(int i=0;i<b;i++){
    if(i%2==0){
      c+=a[i];
    }
    else
      d+=a[i];
  }
  cout<<c-d<<endl;
}


Measured memory_bytes: 256
<?php

    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    
    $ans = 1;
    $prev = $a[0];
    $c = 0;
    $tmp = 0;
    for($i=1;$i<$n;$i++){
        $tmp = $c;
        if($c==0){
            if($a[$i]>$prev) $tmp = 1;
            if($a[$i]<$prev) $tmp = -1;
        }
        if($c>0){
            if($a[$i]<$prev){
                $ans++;
                $tmp = 0;
            }
        }
        if($c<0){
            if($a[$i]>$prev){
                $ans++;
                $tmp = 0;
            }
        }
        $prev = $a[$i];
        $c = $tmp;
    }
    echo $ans;
?>

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

int main(){
    vector<int>posi(5);
    int k;
    for(int i=0;i<5;i++)cin>>posi.at(i);
    cin>>k;
    bool can=true;
    sort(posi.begin(),posi.end());
    if(posi.at(4)-posi.at(0)>k)   can=false;
    cout<<(can? "Yay!":":(")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll>A(X),B(Y),C(Z),D,ans;
    rep(i,X)cin >> A[i];
    rep(i,Y)cin >> B[i];
    rep(i,Z)cin >> C[i];
    sort(ALL(A),greater<>());
    sort(ALL(B),greater<>());
    sort(ALL(C),greater<>());
    rep(i,X)rep(j,Y){
        D.push_back(A[i]+B[j]);
    }
    sort(ALL(D),greater<>());
    D.resize(3000);
    rep(i,D.size())rep(j,Z){
        ans.push_back(D[i]+C[j]);
    }
    sort(ALL(ans),greater<>());
    rep(i,K)cout << ans[i] << endl;
}

Measured memory_bytes: 43240
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n; string s; cin >> n >> s;
    int ans = -INF;
    FOR(i,1,n){
        string a = s.substr(0,i);
        string b = s.substr(i,n-i+1);
        set<int> st; int tmp = 0;
        REP(j,a.size()) st.insert(a[j]);
        REP(j,b.size()) if(st.count(b[j])){tmp++; st.erase(b[j]);}
        chmax(ans,tmp);
    }
    out(ans);

    return 0;
}

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

/* 
The read function reads a string according to each one. 
*/
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")
}

//main function
fn main() {
    let n: String = read();
    let m: String = read();
    if n==m{
	println!("H");
    }else {
	println!("D");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=500 +10 , M= 2e6 + 10, dx[4] =  {1,-1,0,0}, dy[4]= {0,0,1,-1};

bool vis[M];
int n, m, p[M],pn=0;
LL a[N][N], b[N][N];
void PrimeMap(){
	pn =0 ; int n = 2e6  , k = sqrt(1e5+0.5);
	memset(vis, 0 , sizeof(vis));
	for (int i=2; i <= k; ++i)	if ( !vis[i] ) 
		for (int j=i+i; j<=n; j+=i) vis[j] = true;
	
	for (int i=2; i<=n; ++i)	if ( !vis[i] )
		p[ pn++] = i;
}


int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d", &n );
	PrimeMap();
	
	for (int i=0; i<n; ++i){
		for (int j=0; j<n; ++j){
			int s= (i+j)>>1, d=(i-j)>>1;
			#ifdef che
			debug("(x-y)=%d, d=%d\n", i-j, d);
			#endif
			if ( (i^j)&1 ) printf("%d ", p[s+1]*p[d+n+(n>>1)+1]);
				else
			printf("%lld ",1ll*p[s+1]*p[s]*p[d+n+(n>>1)+1]*p[d+n+(n>>1)]+1);
			
		}
		puts("");
	}
	
	scanf("%d", &n);
	
	return 0;
}

Measured memory_bytes: 10880
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	if (N%M == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << N*M - N << endl;
	return 0;
}

Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<pair<ll, ll>> prime_factorize(ll N) {
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
template<typename T>
T factorial(T a){
  if(a == 2) return 2;
  return a * (factorial(a-1));
}

int main(){
    ll H;
    cin >> H;
    ll count = 0;
    while(H != 0){
        H /= 2;
        count++;
    }
    ll sum = 0;
    for(int i = 0; i <= count - 1; i++){
        sum += pow(2, i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
const int maxn = 100010;
const double EPS = 1e-6;
using namespace std;
int main()
{
	string s;
	cin>>s;
	string ans="";
	for(int i=0;i<sz(s);i+=2){
		ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 512
//07/03/2020
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");

#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

stack<char>shamone;
queue<char>pisone;

int main(){
    _fastio
    string s;

    cin>>s;
    ll t;
    cin>>t;
    ll cnt=0;
    while(t--){
        ll ty;
        cin>>ty;
        if(ty==1){
            cnt++;
        }
        else{
            ll f;
            cin>>f;
            char ch;
            cin>>ch;
            if(f==1){
                if(cnt%2){
                    pisone.push(ch);
                }
                else{
                    shamone.push(ch);
                }
            }
            else{
                if(cnt%2){
                   // s=ch+s;
                   shamone.push(ch);
                }
                else{
                    //s+=ch;
                    pisone.push(ch);
                }
            }
        }
    }

    string s1="";
    while(!shamone.empty()){
        s1+=shamone.top();
        shamone.pop();
    }
    string s2="";
    while(!pisone.empty()){
        s2+=pisone.front();
        pisone.pop();
    }

    s1+=s;
    s1+=s2;


    if(cnt%2){
        reverse(s1.begin(),s1.end());
    }

    cout<<s1<<endl;



    return 0;
}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  for (int i = 0; i < sz(s); ++i) {
    if (i % 2 == 0) cout << s[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
#define SEGMAX 131072
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, c, ans=0;

	cin>>n>>c;

	vll x(n), v(n), vsum(n+1, 0), vinv(n+1, 0), vsummax(n+1), vinvmax(n+1);

	rep(i, n) cin>>x[i]>>v[i];

	rep(i, n) vsum[i+1]=vsum[i]+v[i];

	repr(i, 1, n+1) vsum[i]-=x[i-1];

	reprev(i, n) vinv[i]=vinv[i+1]+v[i];

	rep(i, n) vinv[i]-=(c-x[i]);

	
	rep(i, n+1){
		if(ans<vsum[i]) ans=vsum[i];
		if(ans<vinv[i]) ans=vinv[i];
	}

	if(n<=0){
		rep(i, n){
			rep(j, n){
				if(i<j){
					ll temp=vsum[i+1]+vinv[j]-x[i];
					if(ans<temp) ans=temp;

					temp=vsum[i+1]+vinv[j]-(c-x[j]);
					if(ans<temp) ans=temp;
				}
			}
		}
		cout<<ans<<endl;
	}else{
		ll max1=0;
		rep(i, n+1){
			if(max1<vsum[i]){
				max1=vsum[i];
			}
			vsummax[i]=max1;
		}
		rep(i, n){
			ll temp=vinv[i]+vsummax[i]-(c-x[i]);
			if(ans<temp) ans=temp;
		}


		max1=0;
		reprev(i, n+1){
			if(max1<vinv[i]){
				max1=vinv[i];
			}
			vinvmax[i]=max1;
		}
		repr(i, 1, n+1){
			ll temp=vsum[i]+vinvmax[i]-x[i-1];
			if(ans<temp) ans=temp;
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
	int w,a,b;
	int ar,br;
	int ans;
	cin>>w>>a>>b;
	ar = a+w;
	br=b+w;
	if(max(abs(ar-b),abs(br-a))<2*w)
	{
		ans=0;
	}else{
		ans=min(abs(br-a),abs(b-ar));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
i,j,k,m,t,a[100];main(n){while(scanf("%d%d",&n,&m),n|m){memset(a,0,100);for(i=0;i<n*m;scanf("%d",&t),a[i++%m]+=t);n=m;while(n--){for(t=i=0;i<m;++i)t=t<a[i]?a[k=i]:t;printf("%d%c",k+1,n?32:10),t=a[k]=0;}}}

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

vector<int> d;
vector<vector<pair<int, int>>> path;

void dfs(int x, int s){
  s %= 2;
  d[x] = s;

  for(auto next : path[x]){
    if(d[next.first] == -1) dfs(next.first, s + next.second);
  }
}


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

  d.resize(n);
  path.resize(n);

  for(int i=0; i<n-1; ++i){
    d[i] = -1;
    int u, v, w; cin >> u >> v >> w;
    --u; --v;
    path[u].push_back(make_pair(v, w));
    path[v].push_back(make_pair(u, w));
  }
  d[n-1] = -1;

  dfs(0, 0);

  for(int i=0; i<n; ++i){
    cout << d[i] << endl;
  }
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  deque<char> D;
  for(int i=0; i<S.size(); i++){
    D.push_back(S.at(i));
  }
  int rev = 0;
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int t;
    cin >> t;
    if(t == 1){
      rev++;
    }
    else{
      int x;
      cin >> x;
      char y;
      cin >> y;
      if((x == 1 && rev %2 == 0) || (x == 2 && rev %2 == 1)){
        D.push_front(y);
      }
      else{
        D.push_back(y);
      }
    }
  }
  
  if(rev %2 == 0){
    while(D.size()){
      cout << D.front();
      D.pop_front();
    }
  }
  else{
    while(D.size()){
      cout << D.back();
      D.pop_back();
    }
  }
  cout << endl;
}

Measured memory_bytes: 896