akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define NUM 20000
int main(void)
{
	int a[NUM];
	int b[NUM];
	char op[NUM];
	int i,j;

	for (i = 0; i < NUM; i++){
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if (op[i] == '?')break;
	}

	for (j = 0; j < NUM; j++){
		if (op[j] == '?')break;
		switch (op[j])
		{
		case '+':
			printf("%d\n", a[j] + b[j]);
			break;
		case '-':
			printf("%d\n", a[j] - b[j]);
			break;
		case '*':
			printf("%d\n", a[j] * b[j]);
			break;
		case '/':
			printf("%d\n", a[j] / b[j]);
			break;
		default:
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<algorithm>

#define INF 1<<28

using namespace std;

int n, m[100][100], M[100][2];

int Multi(int a, int b) {
	if (m[a][b] != INF) return m[a][b];
	else if (b - a == 1) m[a][b] = M[a][0] * M[a][1] * M[b][1];
	else {
		for (int i = 1; i < b - a - 1; i++) {
			m[a][b] = min(m[a][b], Multi(a, a + i) + Multi(a + i + 1, b) + M[a][0] * M[a + i][1] * M[b][1]);
		}
		m[a][b] = min(m[a][b], Multi(a, b - 1) + M[a][0] * M[b][0] * M[b][1]);
		m[a][b] = min(m[a][b], Multi(a + 1, b) + M[a][0] * M[a][1] * M[b][1]);
	}
	return m[a][b];
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> M[i][0] >> M[i][1];
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) m[i][j] = INF;
	}
	cout << Multi(0, n - 1) << endl;
}


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

typedef long long ll;
const ll MOD=1000000007;

ll modpow(ll x,ll k){
	if(k==0)return 1;
	ll ret=modpow(x,k/2);
	ret*=ret; ret%=MOD;
	if(k%2==1){
		ret*=x; ret%=MOD;
	}
	return ret;
}

int main(){
	static ll n;
	static ll a[100010];
	scanf("%lld",&n);
	for(int i=0;i<=n;i++)scanf("%lld",&a[i]);
	
	static int cnt[100010]={};
	for(int i=0;i<=n;i++)cnt[a[i]]++;
	int t=0;
	for(int i=1;i<=n;i++)if(cnt[i]==2)t=i;
	ll s=0;
	for(int i=0;i<=n;i++)if(a[i]==t){s+=i;break;}
	for(int i=n;i>=0;i--)if(a[i]==t){s+=n-i;break;}
	
	ll x=1,y=1;
	for(int i=1;i<=n+1;i++){
		x*=n+1-i+1; x%=MOD;
		if(i>=2)y*=s-i+2; y%=MOD;
		x*=modpow(i,MOD-2); x%=MOD;
		if(i>=2)y*=modpow(i-1,MOD-2); y%=MOD;
		printf("%lld\n",(x+MOD-y)%MOD);
	}
}



Measured memory_bytes: 2432
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll a = inl(), b = inl();
        if (a == b) cout << 2 * a << endl;
        else if (a > b) cout << a + a - 1 << endl;
        else cout << b + b - 1 << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] A = new int[N];
    int[] order = new int[N];
    StringBuilder sb = new StringBuilder();
    for(int i=0;i<N;i++){
      order[Integer.parseInt(sc.next())-1] = i+1;
    }
    sb.append(order[0]);
    for(int i=1;i<N;i++){
      sb.append(" "+order[i]);
    }
    System.out.print(sb.toString());
    System.out.flush();
  }
}


Measured memory_bytes: 48492
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

struct Node {
	int key;
	Node* left;
	Node* right;
	Node* par;
};

struct binarySearchTree {
	Node* root;

	binarySearchTree() {
		root = NULL;
	}

	void insert(int key);
	void inorderTreeWalk(Node* node);
	void preorderTreeWalk(Node* node);
	bool find(Node* node, int key);
};

void binarySearchTree::insert(int key) {
	Node* z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->left = z->right = z->par = NULL;

	if (root == NULL) {
		root = z;
		return;
	}

	Node* y = NULL;
	Node* x = root;

	while (x != NULL) {
		y = x;
		if (x->key>key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	z->par = y;
	if (y->key>key) {
		y->left = z;
	}
	else {
		y->right = z;
	}
	return;
}

void binarySearchTree::inorderTreeWalk(Node* node) {
	if (node != NULL) {
		inorderTreeWalk(node->left);
		cout << " " << node->key;
		inorderTreeWalk(node->right);
	}
	return;
}

void binarySearchTree::preorderTreeWalk(Node* node) {
	if (node != NULL) {
		cout << " " << node->key;
		preorderTreeWalk(node->left);
		preorderTreeWalk(node->right);
	}
	return;
}

bool binarySearchTree::find(Node* node, int key) {
	if (node == NULL) {
		return 0;
	}
	else if (node->key == key) {
		return 1;
	}
	else if (node->key>key) {
		return find(node->left, key);
	}
	else {
		return find(node->right, key);
	}
}

int main(void) {
	int n, x, i;
	string s;
	binarySearchTree tree;

	cin >> n;

	for (i = 0;i<n;i++) {
		cin >> s;
		if (s[0] == 'i') {
			cin >> x;
			tree.insert(x);
		}
		else if (s[0] == 'p') {
			tree.inorderTreeWalk(tree.root);
			cout << endl;
			tree.preorderTreeWalk(tree.root);
			cout << endl;
		}
		else {
			cin >> x;
			if (tree.find(tree.root, x)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 21912
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
typedef long long ll;
typedef double db;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
//start!
const int MAX_N=1e3+5;
int main()
{
	char s[MAX_N]; ss(s+1);
	int len=strlen(s+1);
	printf("%s",s+1);
	if(s[len]=='s') puts("es");
	else puts("s");
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

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

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

#include <boost/functional/hash.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<int64_t>>& adjs, vector<int64_t>& g, int64_t v) {
    for (auto u : adjs[v]) {
        if (g[u] >= 0) {
            continue;
        }

        g[u] = g[v];
        dfs(adjs, g, u);
    }
}

int main() {
    int64_t n, k, l;
    cin >> n >> k >> l;

    vector<vector<int64_t>> road(n), rail(n);
    for (auto i : irange(0L, k)) {
        int64_t p, q;
        cin >> p >> q;
        --p;
        --q;
        road[p].push_back(q);
        road[q].push_back(p);
    }
    for (auto i : irange(0L, l)) {
        int64_t p, q;
        cin >> p >> q;
        --p;
        --q;
        rail[p].push_back(q);
        rail[q].push_back(p);
    }

    vector<int64_t> g1(n, -1), g2(n, -1);
    for (auto i : irange(0L, n)) {
        if (g1[i] < 0) {
            g1[i] = i;
            dfs(road, g1, i);
        }
        if (g2[i] < 0) {
            g2[i] = i;
            dfs(rail, g2, i);
        }
    }

    unordered_map<pair<int64_t, int64_t>, int64_t,
                  boost::hash<std::pair<int64_t, int64_t>>>
            m;
    for (auto i : irange(0L, n)) {
        m[make_pair(g1[i], g2[i])]++;
    }

    for (auto i : irange(0L, n)) {
        cout << m[make_pair(g1[i], g2[i])] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 29640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  ll l = 0, r = 0;
  ll ans = 0;
  EACH(v, s) {
    if (r > 0 && v == '<') {
      ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2;
      r = 0;
      l = 1;
    } else if (v == '<') {
      l++;
    } else {
      r++;
    }
  }
  ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

int main(){
  string s;
  int a=0,b=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  for(int i=a;i<s.size();i++){
    if(s[i]=='Z'){
      b=i;
    }
  }
  cout<<b-a+1<<endl;
}
      
      


Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;
    int N = str.size();

    string target_str = "keyence";
    string target_rev = "ecneyek";

    int valid_cnt = 0;

    for (int i = 0; i < N; i++) {
        if (str[i] == target_str[i]) {
            valid_cnt++;
        } else {
            break;
        }
    }

    int remain_cnt = 7 - valid_cnt;

    for (int j = 0; j < remain_cnt; j++) {
        if (target_rev[j] != str[N - 1 - j]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import(
  "fmt"
  "strings"
)

func main() {
  var s string
  fmt.Scan(&s)
  
  ans := "Yes"
  for i, char := range strings.Split(s, "") {
    i++
    if (i % 2 == 0 && char == "R") || (i % 2 != 0 && char == "L") {
      ans = "No"
      break
    }
  }
  fmt.Println(ans)
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,s=0,sum=0;
  cin>>n;
  
ll a[n];
for(int i=0;i<n;i++)
{
  cin>>a[i];
  s+=a[i];
}
ll avg=s%n>n/2?s/n+1:s/n;

for(int i=0;i<n;i++)
{
sum+=((avg-a[i])*(avg-a[i]));
}
cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/

int n,arr[100009];

int main()
{
    //freopen("input_file_name.in","r",stdin);
    //freopen("output_file_name.out","w",stdout);
    scanf("%d",&n);
    REP(i,1,n)scanf("%d",&arr[i]);
    sort(arr+1,arr+n+1);
    if(arr[n]-arr[1]>1)
    {
        printf("No\n");
        return 0;
    }
    if(arr[n]==arr[1])
    {
        if(arr[1]>n/2 && arr[1]!=n-1)
        {
            printf("No\n");
        }
        else printf("Yes\n");
        return 0;
    }
    int cnt=0;
    REP(i,1,n)
    {
        if(arr[i]==arr[1])cnt++;
    }
    arr[n]-=cnt;
    int temp=arr[n];
    n-=cnt;
    if(temp>n/2|| temp<=0 || n<=1)
    {
        printf("No\n");
    }
    else printf("Yes\n");
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 200010;

int n, a[MAX];

void push_word(stack<pii> &st, int c, int L){
    if(L==0) return;
    else if(!st.empty() && st.top().fi==c) st.top().se+=L;
    else st.emplace(c, L);
}

bool check(int m){
    if(m==0) return false;
    stack<pii> st;
    rep(i, n){
        if(i==0) push_word(st, 0, a[0]);
        else if(a[i]>a[i-1]){
            push_word(st, 0, a[i]-a[i-1]);
        }
        else{
            int len=a[i-1];
            while(len-st.top().se>=a[i]){
                len-=st.top().se;
                st.pop();
            }
            while(!st.empty() && st.top().fi+1==m){
                len-=st.top().se;
                st.pop();
            }
            if(len==0) return false;
            pii p=st.top(); st.pop();
            if(len>a[i]){
                int l=len-a[i];
                push_word(st, p.fi, p.se-l-1);
                push_word(st, p.fi+1, 1);
            }
            else{
                push_word(st, p.fi, p.se - 1);
                push_word(st, p.fi + 1, 1);
                push_word(st, 0, a[i]-len);
            }
        }
    }
    return true;
}

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]);
    int low=0, high=n;
    while(high-low>1){
        int mid=(high+low)/2;
        (check(mid)?high:low)=mid;
    }
    printf("%d\n", high);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B;

int main()
{
  std::cin >> A >> B;

  if( (A-B)&1 )
    std::cout << "IMPOSSIBLE" << std::endl;
  else
    std::cout << (A+B)/2 << std::endl;

  return 0;
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;

int h[200500];
int a[200500];

long long tree[800500];

void update(int v, int l, int r, int a, long long b) {
    if (l == r - 1) {
        tree[v] = b;
        return;
    }
    int m = (l + r) >> 1;

    if (a < m)
        update(v + v + 1, l, m, a, b);
    else
        update(v + v + 2, m, r, a, b);

    tree[v] = max(tree[v + v + 1], tree[v + v + 2]);
}

long long get(int v, int l, int r, int a, int b) {
    if (r <= a || b <= l)
        return 0;

    if (a <= l && r <= b)
        return tree[v];

    int m = (l + r) / 2, vv1 = v + v + 1;

    return max(get(vv1, l, m, a, b), get(vv1 + 1, m, r, a, b));
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    forn(i, n) cin >> h[i];
    forn(i, n) cin >> a[i];

    long long ans = 0;

    forn(i, n) {
        long long sum = a[i] + get(0, 0, n, 0, h[i]);
        update(0, 0, n, h[i], sum);
        ans = max(ans, sum);
    }

    cout << ans;
    return 0;
}

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

int main() {
  int left = 0, right, top, bottom = 0;
  int n;
  cin >> right >> top >> n;

  for(int i = 0; i < n; i++ ) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) {
      left = max(left, x);
    }
    else if(a == 2) {
      right = min(right, x);
    }
    else if(a == 3) {
      bottom = max(bottom, y);
    }
    else if(a == 4) {
      top = min(top, y);
    }
  }
  int area = (right-left) * (top-bottom);
  if(left >= right or top <= bottom) cout << 0 << endl;
  else cout << area << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  bool ok = true;
  if (n < 5) { ok = false; }
  reverse(s.begin(), s.end());
  vector<string> cands = { "dream", "dreamer", "erase", "eraser" };
  for (int i = 0; i < 4; ++i) {
    reverse(cands[i].begin(), cands[i].end());
  }
  for (int i = 0; ok and i < n; ) {
    if (i + 5 > n) {
      ok = false;
      break;
    }
    string p = s.substr(i, 3);
    int ix = -1;
    if (p == "mae") { ix = 0; }
    else if (p == "rem") { ix = 1; }
    else if (p == "esa") { ix = 2; }
    else if (p == "res") { ix = 3; }
    else {
      ok = false;
      break;
    }
    int j = 0;
    while (j < (int)cands[ix].size() and i + j < n and s[i + j] == cands[ix][j]) {
      ++j;
    }
    if (j != (int)cands[ix].size()) { ok = false; }
    i += cands[ix].size();

  }
  printf("%s\n", ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
int a[N];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,greater<int>());
    ll sum=a[1];
    int k=n-2;
    int x=k/2;
    int y=k%2;
    for(int i=2;i<=x+1;i++) sum+=2*a[i];
    if(y){
        sum+=a[x+2];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4388
import sys
sys.setrecursionlimit(10**6)

class Union_find:
    
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rank=[0]*(n+1)
    
    def find_root(self,x):# 頂点xの根を見つける
    
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.find_root(self.root[x])
            return self.root[x]
    
    def unite(self,x,y):#頂点xと頂点yを繋ぐ辺追加
    
        x=self.find_root(x)
        y=self.find_root(y)
    
        if x==y:
            return 
        elif self.rank[x]>self.rank[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1
    
    def same(self,x,y):#頂点xと頂点yが連結であるか
        return self.find_root(x)==self.find_root(y)
    
    def count(self,x):#頂点xが属する木のサイズ
        return -self.root[self.find_root(x)]

n,m=map(int,input().split())
graph=Union_find(n+1)
ans=[]
now=(n*(n-1))//2
a=[list(map(int,input().split())) for _ in range(m)]

for i in reversed(range(m)):
    ans.append(now)
    if not graph.same(a[i][0],a[i][1]):
        now-=graph.count(a[i][0])*graph.count(a[i][1])
    graph.unite(a[i][0],a[i][1])

for i in reversed(ans):
    print(i)

Measured memory_bytes: 34248
import java.util.*;

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

        int A = stdIn.nextInt();
        int B = stdIn.nextInt();
        int C = 0;

        if(A == 1){
            if(B==2) C = 3;
            if(B==3) C = 2;
        }else if(A == 2){
            if(B==3) C = 1;
            if(B==1) C = 3;
        }else if(A == 3){
            if(B==1) C = 2;
            if(B==2) C = 1;
        }else{
            System.out.print("Error");
        }
        
        System.out.print(C);

    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,m;

int main(){
	cin >> n >> m;
	
	if(n*2<=m) cout << n+(m-2*n)/4 << endl;
	else cout << m/2 << endl;
	return 0;
}


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

int main(){
	int N, Q;
	cin >> N >> Q;
	int Ans[N - 1];
	char S_n, S_n1;
	int Ans_count = 0;
  	int l, r;
	for(int i = 0;i < N - 1;i++){
		Ans[i] = 0;
	}
	cin >> S_n;
	for(int i = 0;i < N - 1;i++){
		cin >> S_n1;
		if(S_n == 'A' && S_n1 == 'C'){
			Ans[i] = Ans[i - 1] + 1;
		}else{
          Ans[i] = Ans[i - 1];
        }
		S_n = S_n1;
	}
	for(int i = 0;i < Q;i++){
		cin >> l >> r;
		cout << Ans[r - 2] - Ans[l - 2] << endl;
		Ans_count = 0;
	}
	
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/


int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll > v;
    for(ll i=0;i<n;i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    ll ans=0;
    for(ll i=0;i<k;i++)
    {

        if(i>=n) break;
        ans+=v[i];
    }
    cout << ans;
}


Measured memory_bytes: 3624
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = -1
for i in range(len(a)):
    if i == (len(a)-1):
        tmp = (a[0]+k) - a[i]
        
    else:
        tmp = a[i+1] - a[i]
    if tmp > ans:
        ans = tmp
        
print(k-ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

int _find(vector<string> &arr,int n){
    set<string> s;
    if(n==0){return 1;}
    s.insert(arr[0]);
    int lastCh=arr[0].back();
    for(int i=1;i<n;i++){
        if(s.count(arr[i])){
            return false;
        }
        if(arr[i][0]!=lastCh){
            return false;
        }
        s.insert(arr[i]);
        lastCh=arr[i].back();
    }
    return 1;
}

int T;
double temperature(double h){
    return T - h*0.006;
}
void solve(){
    
    int n;
    cin>>n;
    // int T,A;
    double A;
    cin>>T>>A;
    
    int idx=0;
    double minD=INT_MAX;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(abs(temperature(h) - A) <=minD){
            idx=i+1;
            minD=abs(temperature(h) - A) ;
        }
    }
    cout<<idx<<endl;
}




int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3760
import java.util.*;
class Main{
	public static void main(String[]args){
    	Scanner in = new Scanner(System.in);
      	int a = in.nextInt(), b = in.nextInt();
      	String x = "", y = "";
      	for(int i = 0; i < a ;i++)
          x+=b;
      	for(int i = 0 ; i< b;i++)
          y+=a;
      	if(Integer.parseInt(x)>Integer.parseInt(y))
          System.out.println(x);
      	else
          System.out.println(y);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n, minv, maxv=-1000000000;
    cin >> n;
    cin >> minv;
    for (int i=1; i<n; i++) {
        int k;
        cin >> k;
        maxv = max(maxv, k-minv);
        minv = min(minv, k);
    }
    cout << maxv << endl;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 a,b;
    cin >> a >> b;
    string c = "";
    string d = "";
    rep(i,b) {
        c += a+'0';
    }
    rep(i,a) {
        d += b+'0';
    }
    if(c<=d) cout << c << endl;
    else cout << d << endl;
}

Measured memory_bytes: 3596
import math

A, B = map(int, input().split())
mi = math.floor(min(A/8*100, B*10))
ma = math.ceil(max(A/8*100, B*10))

result = -1

for i in range(mi,ma+1):
    if i*8//100 == A and i//10 == B:
        result = i
        break

print(result)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import numpy as np
import math
import re
n = int(input())
a = input()
a = re.split(" ",a)

max = 0
min = 10**9
for i in range(n):
    if(int(a[i]) > max):
        max = int(a[i])
    if(int(a[i]) < min):
        min = int(a[i])
print(max - min)

Measured memory_bytes: 12500
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl A(N), B(N), D(N); REP(i, N) cin >> A[i]; REP(i, N) cin >> B[i];
    ll sum = 0, cnt = 0;
    REP(i, N){
        D[i] = A[i] - B[i];
        if(D[i] < 0){
            cnt++;
            sum += abs(D[i]);
        }
    }
    if(sum == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(D.begin(), D.end(), greater<ll>());
    
    ll ans = cnt;
    REP(i, N){
        if(D[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        sum -= D[i];
        ans++;
        if(sum < 0) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2940
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"549
817
715
603"# => "1152",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        mut s: chars,
    }
    s.sort();
    s.dedup();

    if s.len() == 3 {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b, c;

signed main(){
	cin >> a >> b >> c;
	cout <<max((int)0, c - (a - b) )<< endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String).chars().collect::<Vec<_>>();

    let n = s.len();
    let mut odd = 0;
    let mut even = 0;
    let mut res = vec![0; n];

    for i in 0..n {
        if s[i] == 'R' {
            std::mem::swap(&mut odd, &mut even);
            odd += 1;
        } else {
            res[i] += even;
            res[i-1] += odd;
            odd = 0;
            even = 0;
        }
    }
    for i in (0..n).rev() {
        if s[i] == 'L' {
            std::mem::swap(&mut odd, &mut even);
            odd += 1;
        } else {
            res[i] += even;
            res[i+1] += odd;
            odd = 0;
            even = 0;
        }
    }
    for i in 0..n {
        print!("{} ", res[i]);
    }
    println!("");
}


Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  char c; cin >> c;
  if (c == 'A') cout << 'T' << endl;
  if (c == 'T') cout << 'A' << endl;
  if (c == 'G') cout << 'C' << endl;
  if (c == 'C') cout << 'G' << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N+1,0);
  int MAXL = (N+1)*2 + 10;
  
  for(int i=0;i<N;i++)cin >> A[i+1];
    
    
    vector<int> temp(N+1,0);
  while(K){
    vector<int> B(MAXL+10,0);
      
    for(int i=1;i<=N;i++){
      int sub1 = (i - A[i])*2 - 1;
      if(sub1<0)sub1=0;
      int sub2 = (i + A[i])*2 + 1;
      if(sub2>MAXL-2)sub2=MAXL-2;
      B.at(sub1)++;
      B.at(sub2+1)--;
    }
      
    for(int i=1;i<MAXL;i++){
      B.at(i)+=B.at(i-1);
    }
      
    for(int i=0;i<N;i++)A.at(i+1)=B.at((i+1)*2);
      
      if(temp==A)break;
      temp=A;
    K--;
      /*
      cout << "-----------" << endl;
      for(int i=0;i<N;i++)cout << A[i+1] << " ";
      cout << endl;*/
      
  }
    
    
    
    
    for(int i=0;i<N;i++)cout << A[i+1] << " ";
  cout << endl;
}

Measured memory_bytes: 6432
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (llong (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using llong = long long;


llong n;
llong a[1000005];
llong p[10005];
bool x[1000005];
bool table[1000005];

void build() {
    p[0] = 2;
    int idx = 1;

    for (int i = 3; i < 1005; i += 2) {
        if (!table[i]) {
            p[idx++] = i;
            for (int j = i + i; j < 1005; j += i) table[j] = true;
        }
    }
};

int main() {
    build();

    cin >> n;
    repeat(i, n) cin >> a[i];

    llong v = a[0];
    repeat(i, 1, n) {
        v = gcd(v, a[i]);
    }

    bool f = true;
    for (int i = n - 1; i >= 0; i--) {
        llong vs = a[i];
        llong j = 0;

        while (vs > 1 && p[j] > 0) {
            if (vs % p[j] == 0) {
                if (x[p[j]]) f = false;
                x[p[j]] = true;
            }
            while (vs % p[j] == 0) {
                vs /= p[j];
            }
            j++;
        }

        if (vs > 1) {
            if (x[vs]) f = false;
            x[vs] = true;
        }
    }

    if (f) {
        cout << "pairwise coprime" << endl;
    }
    else if (v == 1) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "not coprime" << endl;
    }

    return 0;
};


Measured memory_bytes: 12232
#include <bits/stdc++.h>
#define lint long long
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define to_stirng to_string
#define INF 10000000000
using namespace std;

// cout << fixed << setprecision(12)

int main(){
  lint H,W,K,x1,y1,x2,y2;
  cin >> H >> W >> K >> x1 >> y1 >> x2 >> y2;
  
  vector<vector<lint> > hasu(H+2, vector<lint>(W+2));
  vector<vector<lint> > kaki(H+2, vector<lint>(W+2, INF));
  
  for(lint i=0; i<=H+1; i++){
    hasu[i][0] = true;
    hasu[i][W+1] = true;
  }
  for(lint j=0; j<=W+1; j++){
    hasu[0][j] = true;
    hasu[H+1][j] = true;
  }
  for(lint i=1; i<=H; i++){
    for(lint j=1; j<=W; j++){
      char c;
      cin >> c;
      if(c=='@') hasu[i][j] = true;
      else hasu[i][j] = false;
    }
  }
  
  kaki[x1][y1] = 0;
  
  queue<pair<lint,lint> > next;
  next.push(MP(x1,y1));
  
  while(!(next.empty())){
    pair<lint, lint> tmp = next.front();
    lint x0 = tmp.first;
    lint y0 = tmp.second;
    lint kaki0 = kaki[x0][y0];
    next.pop();
    for(lint i=1; i<=K; i++){
      lint u = x0+i;
      lint v = y0;
      if(kaki[u][v] <= kaki0) break; //chokudai
      if(hasu[u][v]) break;
      else if(kaki[u][v] > kaki0 + 1){
        kaki[u][v] = kaki0 + 1;
        next.push(MP(u,v));
      }
    }
    for(lint i=1; i<=K; i++){
      lint u = x0-i;
      lint v = y0;
      if(kaki[u][v] <= kaki0) break; //chokudai
      if(hasu[u][v]) break;
      else if(kaki[u][v] > kaki0 + 1){
        kaki[u][v] = kaki0 + 1;
        next.push(MP(u,v));
      }
    }
    for(lint i=1; i<=K; i++){
      lint u = x0;
      lint v = y0+i;
      if(kaki[u][v] <= kaki0) break; //chokudai
      if(hasu[u][v]) break;
      else if(kaki[u][v] > kaki0 + 1){
        kaki[u][v] = kaki0 + 1;
        next.push(MP(u,v));
      }
    }
    for(lint i=1; i<=K; i++){
      lint u = x0;
      lint v = y0-i;
      if(kaki[u][v] <= kaki0) break; //chokudai
      if(hasu[u][v]) break;
      else if(kaki[u][v] > kaki0 + 1){
        kaki[u][v] = kaki0 + 1;
        next.push(MP(u,v));
      }
    }
  }
  
  // cout << hasu[3][1] << endl;
  
  /*
  for(lint i=1; i<=H; i++){
    for(lint j=1; j<=W; j++){
      cout << hasu[i][j] << ' ';
    }
    cout << endl;
  }
  */
  
  if(kaki[x2][y2] == INF) cout << "-1" << endl;
  else cout << kaki[x2][y2] << endl;
}
     
      
      


Measured memory_bytes: 57916
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#import numpy as np
import bisect
from collections import deque

def main():
	n=II()
	A=[II() for _ in range(n)]

	Q=deque([A[0]])
	#print(Q)
	for i in range(1,n):
		if A[i]<=Q[0]:
			Q.appendleft(A[i])
		else:
			a=bisect.bisect_left(Q,A[i])
			Q[a-1]=A[i]
	print(len(Q))








if __name__ == "__main__":
	main()

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

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    s = set()
    for _ in range(n):
        s.add(read(str))
    print(len(s))


if __name__ == "__main__":
    main()


Measured memory_bytes: 30964