akhauriyash/Code-Regression huggingface dataset:
a = gets.chomp.to_s

if (a.match("A?KIHA?BA?RA?")) then
	a.sub!(/A?KIHA?BA?RA?/,"AKIHABARA")
	if a == "AKIHABARA" then
		puts "YES"
	else
		puts "NO"
	end
else
	puts"NO"
end


Measured memory_bytes: 14428
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

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

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

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [usize; n],
    }
    aa.sort();

    use std::collections::HashMap;
    let mut map = HashMap::new();
    for &a in aa.iter() {
        *map.entry(a).or_insert(0) += 1;
    }

    aa.reverse();
    let mut ans = 0;
    for a in aa {
        let next = a.next_power_of_two();
        let mut rem = next - a;
        if rem == 0 {
            if map[&a] < 2 {
                continue;
            }
            rem = a;
        }
        if !map.contains_key(&rem) {
            continue;
        }
        if map[&rem] == 0 || map[&a] == 0 {
            continue;
        }

        ans += 1;
        *map.get_mut(&a).unwrap() -= 1;
        *map.get_mut(&rem).unwrap() -= 1;
    }
    puts!("{}\n", ans);
}


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

typedef long long ll;
const int maxn=100010;
ll n;
ll a[maxn];
ll sum, base, b[maxn], k;

int main(){

	scanf("%lld", &n); base=1ll*n*(n+1)>>1;
	for(int i=1;i<=n;i++) scanf("%lld", &a[i]), sum+=a[i];
	if(sum%base){ puts("NO"); return 0; }
	k=sum/base;
	for(int i=1;i<n;i++) b[i]=a[i+1]-a[i]; b[n]=a[1]-a[n];
	// for(int i=1;i<=n;i++) printf("%lld ", b[i]); puts("");
	ll tot=0;
	for(int i=1;i<=n;i++){
		ll d=k-b[i];
		if(d<0){ puts("NO"); return 0; }
		if(d%n){ puts("NO"); return 0; }
		tot+=d/n;
	}
	if(tot==k) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 1792
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.map!(x=>(x-'0').to!int).array;
  auto op = ['-', ' ', '+'];
  
  a:foreach (op1; iota(-1, 2, 2)) {
    foreach (op2; iota(-1, 2, 2)) {
      foreach (op3; iota(-1, 2, 2)) {
        auto sum = n[0] + op1 * n[1] + op2 * n[2] + op3 * n[3];
        if (sum == 7) {
          writeln(n[0], op[op1+1] , n[1], op[op2+1], n[2], op[op3+1], n[3], "=7");
          break a;
        } 
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    //入力
    ll N; 
    cin >> N;
    //ll a[100010][3];    //あまり、a[n]のnを大きくするとエラーなので注意
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    //dpテーブル
    //ll dp[100010][3];
    //初期条件、初期化は既に終わっている

    //遷移
    for (ll i = 0;i<N;i++) {
        for (ll j = 0;j<3;j++) {
            for (ll k = 0;k<3;k++) {
                if (j==k) continue;
                chmax(dp[i+1][k],dp[i][j] + a[i][k]);
            }
        }
    }
    ll ans = max(dp[N][0],dp[N][1]); //dp[i] はi日目なので注意,
    ans = max(ans,dp[N][2]);         //N日目はN-1でなく、dp[N]なので注意
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}
 
Node find(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k < u->key){ 
    return find(u->left,k);
  }
  else { 
    return find(u->right,k);
  }
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
Node treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){ y=z;}//zが子を持たないか、子を1つ持つ場合は入力節点のz
  else {y= treeSuccessor(z);}//zが子を2つ持つ場合はzの次節点
  if(y->left!=NIL){//yの子xを決める
    x=y->left;//yに左の子があれば、xはyの左の子
  }
  else {
    x=y->right;//yに左の子がなければ、xはyの右の子
  }
  if(x!=NIL){ x->parent=y->parent;}//xの親を設定する
  if(y->parent==NIL){ root=x;}
  else if(y==y->parent->left){
    y->parent->left=x;
  }//yがその親の左の子ならば、pの左の子をxとする
  else{
    y->parent->right=x;
  }//yがその親の右の子ならば、pの右の子をxとする
  if(y!=z){//zの次節点が削除された場合
    z->key=y->key;//yのデータをzにコピーする
  }
    return y;
}
 
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  //printf("%d\n",x->key);
  while(x!=NIL){//親を設定
    y=x;
    if(z->key < x->key){ 
      x=x->left;
    }//左の子へ移動
    else x=x->right;//右の子へ移動
  }
  z->parent=y;
  if(y==NIL){ 
    root = z;
  }
  else if(z->key < y->key){
    y->left=z;
  }//zをyの左の子にする
  else y->right=z;//zをyの右の子にする
}
 
void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
 
int main(){
  
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);
  root=NIL;
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
vector < int > v[100005],post;
int a,b;
int odw[100005];
int dp[100005];
int out=0;
void dfs1(int node)
{
	odw[node]=1;
	for(auto it: v[node])
		if(!odw[it])
			dfs1(it);
	post.push_back(node);
}
int main(){
	cin>>n>>m;
	for(int i=0;m>i;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
	}
	for(int i=1;n>=i;i++)
		if(!odw[i])
			dfs1(i);
	for(int i=0;n>i;i++)
	{
		int node=post[i];
		int wynik=0;
		for(auto it: v[node])
			wynik=max(wynik,dp[it]+1);
		dp[node]=wynik;
		out=max(dp[node],out);
	}
	cout<<out;
return 0;
}


Measured memory_bytes: 9080
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 1000000007;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE],B[SIZE],C[SIZE];string s;
LL solve(){
	cin >> N;
	LL ans=1;
	B[0]=3;
	REP(i,N){
		cin >> A[i];
		A[i]++;
		ans*=B[A[i]-1]-B[A[i]];
		ans%=p;
		B[A[i]]++;
	}
	cout << ans << endl;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 21504
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,P;
    R(A,P);
    W((A*3+P)/2);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>  // sort, 二分探索(lower_bound)など
#include <cmath>      // pow, logなど
#include <complex>    // 複素数
#include <deque>      // 両端アクセスのキュー
#include <iostream>   // 入出力
#include <iterator>
#include <map>
#include <numeric>  // iota(整数列の生成), gcd, lcm
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>  // 順序保持しないmap
#include <unordered_set>  // 順序保持しないset
#include <utility>        // pair
#include <vector>

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()
#define MAX(x) *max_element(ALL(x))  // 最大値を求める
#define MIN(x) *min_element(ALL(x))  // 最小値を求める

using namespace std;
typedef long long ll;

constexpr int INF      = 1e9;
constexpr int MOD      = 1000000007;
constexpr size_t MAX_N = 110000;

int memo[MAX_N];

// 貰うDPでの解法 --- memo[n]に遷移を集める
int main() {
  size_t N;
  cin >> N;

  for (int& v : memo) {
    v = N;
  }
  memo[0] = 0;

  for (size_t n = 1; n <= N; ++n) {
    for (size_t pow6 = 1; pow6 <= n; pow6 *= 6) {
      memo[n] = min(memo[n], memo[n - pow6] + 1);
    }
    for (size_t pow9 = 1; pow9 <= n; pow9 *= 9) {
      memo[n] = min(memo[n], memo[n - pow9] + 1);
    }
  }

  cout << memo[N] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
 
 
//  5
//  0 1 2 3 4
int main(){
    int res[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << res[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc067.contest.atcoder.jp/tasks/arc067_b>
問題文============================================================
 東西方向にのびる直線上に、N 個の町があります。 町には、西から順に 1 から N までの番号がついています。
 直線上には座標が設定されていて、東に行くほど座標が大きくなります。 町 i の座標は Xi です。
 
 あなたは今、町 1 にいて、これからほかの全ての町を訪れたいです。 移動する手段は次の 2 種類あります。
 
 直線上を歩いて移動する。 東西どちらに歩いても、1 移動する度に疲労度が A 上がります。
 
 好きな場所へテレポートする。 テレポートをすると、移動した距離によらず疲労度が B 上がります。
 
 この 2 種類の移動を繰り返して全ての町を最適に回った時、疲労度の上昇値の合計の最小値がいくつになるか求めてください。
 
=================================================================

解説=============================================================

 これは簡単
 街は順番に昇順に並んでいるのでそのまま順番に訪れて行ったほうがいい
 また、テレポートするなら初めから次の街に行ったほうがいいので
 順番に街と街の間を 歩いて or テレポート
 のどちらが疲労度が小さくなるかを見て行けばよい
 
================================================================
*/
ll solve(){
    ll N,A,B; cin >> N >> A >> B;
    vector<ll> X(N); for(auto &in:X) cin >> in;
    ll res = 0;
    for(int i = 0; i < N-1;i++){
        res += min(A*(X[i+1]-X[i]),B);
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int fr[3]; //reordered
vector<pii> ord;

vi mf(string s) {
	vi cnt(3);

	rep(i, s.size()) {
		++cnt[s[i] - 'A'];
	}

	rep(i, 3) ord.eb(cnt[i], i);
	sort(ALL(ord));
	rep(i, 3) fr[i] = ord[i].fi;

	vi res;

	rep(i, s.size()) {
		int c = s[i] - 'A';
		rep(j, 3) {
			if (ord[j].se == c) {
				res.pb(j);
			}
		}
	}

	return res;
}

void out(vi v) {
	string s;
	rep(i, v.size()) {
		s.pb('A' + ord[v[i]].se);
	}
	cout << s << endl;
}

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

	rep(i, in.size()) {
		if (i == 0 || s.back() != in[i]) {
			s.pb(in[i]);
		}
	}

	vi vec = mf(s);
	//cout << fr[0] << ", " << fr[1] << ", " << fr[2] << endl;

	int n = vec.size();
	vi skip(n);

	rep(i, n) if (vec[i] == 2 && fr[2] > fr[1]) {
		if (i == 0 || i == n - 1 || vec[i-1] != vec[i+1]) {
			skip[i] = 1;
			--fr[2];
		}
	}
/*
	puts("modified");
	cout << fr[0] << ", " << fr[1] << ", " << fr[2] << endl;

	if (fr[1] == fr[2]) {
		dump("same");
	}
*/
	vector<vi> parts;
	vi cur;

	rep(i, vec.size()) if (!skip[i]) {
		if (vec[i] != 0) {
			cur.pb(vec[i]);
		} else {
			parts.pb(cur);
			cur.clear();
		}
	}
	parts.pb(cur);
	//dump(parts);

	if (parts.size() == 1) {
		cout << "" << endl;
		return 0;
	}

	n = (int)parts.size();
	vi erased0(n);
	vi erasedbl(n);

	rep(i, parts.size()) {
		if (i > 0 && parts[i-1] == vi{2}) {
			if (fr[1] < fr[2]) {
				if (i > 0) {
					erased0[i-1] = 1;
					--fr[0];
				}
				erasedbl[i-1] = 1;
				--fr[2];
			}
		}
	}

/*
	puts("modified2");
	cout << fr[0] << ", " << fr[1] << ", " << fr[2] << endl;
*/

	vi ans;
	bool frt = 1;

	rep(i, parts.size()) {
		if (i && !erased0[i-1]) {
			ans.pb(0);
			frt = 0;
		}

		if (!erasedbl[i]) {
			int mini = frt ? 2 : 3;
			while (parts[i].size() >= mini) {
				if (fr[1] > fr[0] && fr[2] > fr[0]) {
					--fr[1]; --fr[2];
					parts[i].pop_back();
					parts[i].pop_back();
				} else {
					break;
				}
			}
			for (int &x : parts[i]) {
				ans.pb(x);
			}
		}
	}

	if (fr[1] > fr[0]) {
		int sz = ans.size();
		if (ans[sz-1] != 0 && ans[sz-2] != 0) {
			ans.pop_back();
			ans.pop_back();
		}
	}

	out(ans);
	return 0;
}

Measured memory_bytes: 42528
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

ll pair_num(ll x){
    ll n = 0;
    for (int i = 0; i < 31; i++) {
        if (x & (1 << i)) {
            n = i;
        }
    }

    return (ll)pow(2, n+1) - x;
}


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

    // vector<ll> ball(N);
    // for (int i = 0; i < N; i++) {
    //     cin >> ball[i];
    // }

    map<ll,ll> num_ball;
    for (int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        num_ball[A]++;
    }

    vi num_cand;
    for (auto itr = num_ball.begin(); itr != num_ball.end(); itr++) {
        num_cand.push_back(itr->first);
    }
    sort(all(num_cand));
    reverse(all(num_cand));

    ll ans = 0;
    // for (auto itr = num_ball.begin(); itr != num_ball.end(); itr++){
    for (int i = 0; i < (int)num_cand.size(); i++){
        if (num_ball[num_cand[i]] > 0) {
            if (num_cand[i] == pair_num(num_cand[i])) {
                ans += num_ball[num_cand[i]] / 2;
                num_ball[num_cand[i]] = num_ball[num_cand[i]] % 2;
            } else {
                int min_num = min(num_ball[num_cand[i]], num_ball[ pair_num(num_cand[i])]);
                ans += min_num;
                num_ball[num_cand[i]] -= min_num;
                num_ball[ pair_num(num_cand[i]) ] -= min_num;
            }
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 25972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

  int size;
  int matrix[10][10];

  int sum_row,sum_column,sum;
  char line[200];
  char* p;

  int i,j;
  char c;

  
  while(1) {

    scanf("%d",&size);
    c=getchar();

    if(size==0) break;

    for(i=0;i<size;i++) {

      fgets(line,sizeof(line),stdin);
      line[strlen(line)-1]='\0';

      p=strtok(line," ");
      matrix[i][0]=atoi(p);

      for(j=1;j<size;j++) {
	p=strtok(NULL," ");
	matrix[i][j]=atoi(p);
      }

    }

    for(i=0;i<size;i++) {
     
      sum_row=0;

      for(j=0;j<size;j++) {

	printf("%5d",matrix[i][j]);

	sum_row+=matrix[i][j];

      }

      printf("%5d\n",sum_row);
    }

    sum=0;

    for(j=0;j<size;j++) {

      sum_column=0;

      for(i=0;i<size;i++) {

	sum_column+=matrix[i][j];

      }

      sum+=sum_column;

      printf("%5d",sum_column);
    }

    printf("%5d\n",sum);

  }

  return 0;

}

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

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++){
    int a;
    cin >> a;
    sum += a;
  }
  if (sum <= N)
    cout << N - sum << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
struct edge {int x,y; };
int N;
int T[100001];
edge Z[100001];

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

  cin >> N;
  T[0] = 0;
  Z[0].x = 0;
  Z[0].y = 0;
  for(int i=1; i<=N; i++){
    cin >> T[i];
    cin >> Z[i].x >> Z[i].y;
  }
  rep(i, N){
    int diff = abs(Z[i+1].x-Z[i].x) + abs(Z[i+1].y-Z[i].y);
    if (abs(T[i+1] - T[i]) < diff) {
      cout << "No" << "\n";
      return 0;
    }
    if ((abs(T[i+1] - T[i]) - diff)%2==1){
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  vector<bool> v(n, true);
  rep(i, n) { cin >> h[i]; }
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] <= h[b]) v[a] = false;
    if (h[b] <= h[a]) v[b] = false;
  }

  ll ans = 0;
  rep(i, n) if (v[i]) ans++;
  cout << ans << endl;

  return 0;
}


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

class Dice{
public:
    int f[6];
    
    Dice(){};
    
    void role(int w,int x,int y,int z){
        int v = f[w];f[w] = f[x];f[x] = f[y];f[y] = f[z];f[z] = v;
    }
    void roleS(){role(0,4,5,1);}
    void roleE(){role(0,3,5,2);}
    void check(char s){
        if (s == 'S')roleS();
        else if (s == 'E') roleE();
        else if (s == 'W') for(int i = 0; i < 3; i++) roleE();
        else if (s == 'N') for(int i = 0; i < 3; i++) roleS();
    }
};

int main(){
    Dice d;
    string str;
    for(int i = 0; i < 6; i++) cin >> d.f[i];
    cin >> str;
    for(int i = 0; i < str.size(); i++) d.check(str[i]);
    cout << d.f[0] << endl;
    return 0;
}


Measured memory_bytes: 3220
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
point = -1
min_diff = 10000
for i in range(n):
    diff = abs(t - h[i] * 0.006 - a)
    if min_diff > diff:
        point = i + 1
        min_diff = diff
print(point)

Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n,m;
char a[1100][1100] ;
int mem[1100][1100];

ll dp(int i, int j){
if(i == n || j== m) return 0;
if(i == n-1 && j==m-1) return 1;
if(mem[i][j] != -1) return mem[i][j];
long long ret = 0 ,ret1 = 0;
if(j < m - 1 && a[i][j+1] !='#'){
    ret = dp(i,j+1);
}

if(i < n-1 && a[i+1][j] != '#'){
    ret1 = dp(i+1,j);
}
return mem[i][j] = ((ret %mod) + (ret1%mod))%mod;
}


int main()
{
  cin>>n>>m;
  for(int i=0; i<n; i++)
  for(int j=0; j< m; j++){
    cin>>a[i][j];

  }
  memset(mem,-1,sizeof(mem));
  cout<<dp(0,0)%mod;

}


Measured memory_bytes: 6144
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
    n = int(input().strip())
    v = input().strip()
    ans = 0
    dp = [[0] * (n+1) for _ in range(n+1)]
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if v[i] == v[j]:
                dp[i][j] = dp[i+1][j+1] + 1
                ans = max(ans, min(abs(i-j), dp[i][j]))
    print(ans)
    # print(dp)
if __name__ == '__main__':
    main()


Measured memory_bytes: 232072
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int N, M, l, r, lmax = 1, rmin = 10e+5;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    lmax = max(l, lmax);
    rmin = min(r, rmin);
  }
  cout << max(0, rmin - lmax + 1) << endl;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back

//transform(s.begin(), s.end(), s.begin(), ::tolower); //to convert a string entirely to lower case

//toupper(s[i]) or tolower(s[i]) // converting a character to upper or lower case

//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


//vec.insert(v.begin(),value)   -> to insert a value in the vector at the begin

// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);

//covert integer to string :  to_string(integer)

bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    string x = "";
    ll ac = 0, wa = 0, tle = 0, re = 0;
    for(ll i = 0; i<n; i++)
    {
        cin >> x;
        if(x == "AC")
            ++ac;
        else if (x == "WA")
            ++wa;
        else if(x == "TLE")
            ++tle;
        else
            ++re;            
    }
    cout << "AC " << "x " << ac << endl;
    cout << "WA " << "x " << wa << endl;  
    cout << "TLE " << "x " << tle << endl;  
    cout << "RE " << "x " << re << endl;  

    return 0;
}   

Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
pre = -100
for i in range(n):
  ans += b[a[i] - 1]
  if pre == a[i] - 1:
    ans += c[pre - 1]
  pre = a[i]
print(ans)

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

int main(void)
{
    ll a;
    long double b;
    cin >> a >> b;
    long double ret = a * b;
    cout << (ll)ret << endl;
}


Measured memory_bytes: 3724
def main():
    a = 0
    i = 0
    s = []
    u = []
    l = raw_input()
    for c in l:
        if c == '\\':
            s.append(i)
        elif c == '/' and len(s) > 0:
            j = s.pop()
            t = i - j
            a += t
            while len(u) > 0 and u[-1][0] > j:
                t += u.pop()[1]
            u.append((j, t))
        i += 1
    u.insert(0, (0, len(u)))

    print(a)
    print(' '.join(map(lambda x: str(x[1]), u)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 6968
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

typedef struct{
  short x,y;
  int cost;
  short ch;
}mouse;


mouse t;
short cx,cy,nx,ny,ch,nch,h,w,n;
int cost;

main(){
  scanf("%d%d%d",&h,&w,&n);
  short maxch[h][w];
  char ku[h][w];
  
  rep(i,h)scanf("%s",ku[i]);


  rep(i,h)rep(j,w){
    if(ku[i][j]=='S')cx=i,cy=j;
    maxch[i][j]=-1;
  }

  queue<mouse> Q;

  Q.push((mouse){cx,cy,0,0});
  maxch[cx][cy]=0;

  while(!Q.empty()){
    //cout<<Q.size()<<endl;
    t=Q.front();Q.pop();
    cx=t.x,cy=t.y,cost=t.cost;
    ch=t.ch;

    rep(i,4){
      nx=cx+dx[i],ny=cy+dy[i];
      if(nx<0 || nx>=h || ny<0 || ny>=w || ku[nx][ny]=='X')continue;
	 nch=ch;
	 if(ku[nx][ny]<='9' && ku[nx][ny]>='1' && ku[nx][ny]-'0'==t.ch+1){
	   nch=ch+1;
	 }

	 if(maxch[nx][ny]>=nch)continue;
	 if(nch==n){
	   printf("%d\n",cost+1);
	   return 0;
	 }
	 maxch[nx][ny]=nch;
	 Q.push((mouse){nx,ny,cost+1,nch});
    }
  }
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    int L;
    while( cin >> s >> L, L ){
        while( s.size() < L ) s += '0';

        int mi, ma, i = 0;
        map<int, int> mp;
        mp[stoi( s )] = i++;
        while( 1 ){
            sort( ALL( s ) );
            mi = stoi( s );
            reverse( ALL( s ) );
            ma = stoi( s );

            if( mp.find( ma - mi ) != mp.end() ){
                cout << mp[ma - mi] << " " << ma - mi << " " << i - mp[ma - mi] << endl;
                break;
            }
            mp[ma - mi] = i++;
            s = to_string( ma - mi );
            while( s.size() < L ) s += '0';

        }
    }
}


Measured memory_bytes: 3240
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

#define int ll

signed main() {
  int p,q,r;
  std::cin >> p >> q >> r;
  int sum = p+q+r;
  int min = std::min(sum-p,sum-q);
  min = std::min(min,sum-r);
  std::cout << min << ENDL;
  return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for sum_w in range(W + 1):
        if sum_w - weight[i] >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i]
                                   [sum_w - weight[i]] + value[i])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])

print(dp[N][W])


Measured memory_bytes: 120684
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;


struct LowLink
{
    const vector<vector<int>> graph;
    int N;
    vector<int> ord, low;
    vector<bool> used;
    vector<vector<int>> bridge;
    vector<int> articulation; 
    LowLink(vector<vector<int>>_graph): graph(_graph)
    {
        N = graph.size();
    };

    void dfs(int now, int &k, int par)
    {
        used[now] = true;
        ord[now] = k++;
        low[now] = ord[now];
        bool is_art = false;
        int cnt = 0;
        for (auto next: graph[now])
        if (next != par)
        {
            if (!used[next])
            {
                ++cnt;
                dfs(next, k, now);
            }
            
            is_art |= ~par and ord[now] <= low[next];
            low[now] = min(low[now], low[next]);
            if (ord[now] < low[next]) bridge.push_back({now, next});
        }
        is_art |= par == -1 and cnt>1;
        if (is_art) articulation.push_back(now);
    }

    void build()
    {
        ord.assign(N, -1);
        low.assign(N, -1);
        used.assign(N, false);

        int k=0;
        rep(i, 0, N)
        if (!used[i])
            dfs(i, k, -1);
    }
};


int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    rep(i, 0, M)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    LowLink lowlink(graph);
    lowlink.build();

    cout << lowlink.bridge.size() << endl;
    return 0;
}

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

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

  int sum = 0, A = 0, B = 0;

  for (int i = 1; i < N + 1; i++) {
    for (int j = i; j < K; j *= 2) B++;
    A = max(A, B);
    sum += 1 << (A - B);
    B = 0;
  }

  double ans = (double) sum / (N * (1 << A));

  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
int n;
int a[200009];
int b[200009];
vector<int> ans;
int ar1[400009];
int ar2[400009];
int lps[400009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i)
        cin >> b[i];
    
    for(int i = 0; i < n; ++i){
        ar1[i] = a[i]^a[(i+1)%n];
        ar2[i] = b[i]^b[(i+1)%n];
    }
    for(int i = 0; i < n; ++i)
        ar1[i+n] = ar1[i];
    int m = n;
    n = 2*n-1;
    int i = 1;
    int len = 0;
    while(i < m){
        if(ar2[i] == ar2[len]){
            ++len;
            lps[i] = len;
            ++i;
        }
        else if(len == 0)
            ++i;
        else
            len = lps[len-1];
    }
    i = 0;
    int j = 0;
    while(i < n){
        if(ar1[i] == ar2[j]){
            ++i;
            ++j;
        }
        if(j == m){
            ans.pb(i-j);
            j = lps[j-1];
        }
        else if(ar1[i] != ar2[j]){
            if(j == 0)
                ++i;
            else
                j = lps[j-1];
        }
    }
    for(auto u : ans)
        cout << u << " " << (b[0]^a[u]) << "\n";
}   

Measured memory_bytes: 9844
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int a,b;
  cin>>a>>b;
  for(int i=1;i<=5000;i++){
    
    int x=i*0.08;
    int y=i*0.1;
    if(x==a&&y==b){
      cout<<i<<endl;
      return 0;
    }
    
  }
  cout<<-1<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<bool> VB;

int main() {
  int N;
  cin >> N;
  VL ts;
  VL as;
  for (int i = 0; i < N; i++) {
    ll t;
    cin >> t;
    ts.push_back(t);
  }
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    as.push_back(a);
  }

  VB exact_ts;
  VB exact_as;

  exact_ts.push_back(true);
  for (int i = 0; i < N-1; i++) {
    exact_ts.push_back(ts[i] < ts[i+1]);
  }
  for (int i = 0; i < N-1; i++) {
    exact_as.push_back(as[i] > as[i+1]);
  }
  exact_as.push_back(true);


  ll res = 1;
  const ll M = 1e9+7;
  for (int i = 0; i < N; i++) {
    ll p = 0;
    bool e_t = exact_ts[i];
    bool e_a = exact_as[i];
    ll t = ts[i];
    ll a = as[i];
    if (e_t) {
      if (e_a) {
        if (t == a) p = 1;
      } else {
        if (t <= a) p = 1;
      }
    } else {
      if (e_a) {
        if (a <= t) p = 1;
      } else {
        p = min(a, t);
      }
    }

    res *= p;
    res %= M;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for (ll i = 0; i < N; i++) {
        cin >> L[i];
    }
    ll ans = 0;
    sort(ALL(L));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if(i == j) continue;
            ans += upper_bound(ALL(L), L[i] + L[j] - 1) - lower_bound(ALL(L), abs(L[i] - L[j]) + 1);
            if(L[i] >= abs(L[i] - L[j]) + 1 && L[i] <= L[i] + L[j] - 1) ans--;
            if(L[j] >= abs(L[i] - L[j]) + 1 && L[j] <= L[i] + L[j] - 1) ans--;
        }
    }
    ans = ans / 6;
    printf("%lld\n", ans);

}

Measured memory_bytes: 3708
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int a[] = new int[10];
		for(int i = 0; i < 10; ++ i)a[i] = in.nextInt();
		Arrays.sort(a);
//		int x = 0;
//		int y = 0;
//		int z = 0;
//		for(int  i = 0; i < 10; ++ i){
//			int t = in.nextInt();
//			if(t < x){
//				if(t < y && t > z) z = t;
//				if(t > y){ z= y;y = t;}
//			}else{
//				z = y;
//				y = x;
//				x = t;
//			}
//			
//		}
		System.out.println(a[9] + "\n" + a[8] + "\n" + a[7]); 
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
const int sz = 200000;
vector<int>g[sz];
bool used[sz];
pii res[sz];
int deg[sz];
int cnt;
set<pii>st;
void ae(int a,int b){
    g[a].emplace_back(b);
    g[b].emplace_back(a);
}
void dfs(int s, int p){
    used[s] = true;
    for(int x: g[s]){
        if(x == p)continue;
        if(!used[x]){
            dfs(x,s);
        }else if(s < x){
            res[cnt++] = pii(s,x);
            deg[s]++;
        }
    }
    if(p == -1)return;
    if(deg[s] & 1){
        res[cnt++] = pii(s, p);
        deg[s]++;
    }else{
        res[cnt++] = pii(p, s);
        deg[p]++;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(m & 1){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--,b--;
        ae(a,b);
    }
    dfs(0,-1);
    for(int i = 0; i < m; i++){
        cout << res[i].first + 1 << " " << res[i].second + 1 << "\n";
    }
}

Measured memory_bytes: 15616
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s, t; cin >> s >> t;
    rep(i, 26) {
        char c = 'a' + i;
        string u = s + c;
        if(u == t) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a = 0, b, ans = 0, pp = 0, qq = 0;
  //string s;
  cin >> n;
  vector<int> p(n), q(n), v(n);
  rep(i, n) cin >> p.at(i);
  rep(i, n) cin >> q.at(i);
  rep(i, n) v.at(i) = i + 1;
  do{
    a++;
    if(v == p) pp = a;
    if(v == q) qq = a;
    if(pp != 0 && qq != 0) break;
  }while(next_permutation(v.begin(),v.end())); 
  
  //vector<int> v(n), c(n);
  //if(1) {}
  cout << abs(pp - qq) << endl;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if ( n > m ) n = m;
  vector<int> l;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    l.push_back(a);
  }
  sort(l.begin(), l.end());
  vector<int> d_l;
  for (int i = 0; i < m - 1; i++) {
    d_l.push_back(l[i + 1] - l[i]);
  }
  sort(d_l.begin(), d_l.end());

  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += d_l[m - 2 - i];
  }
  int l_last = l[m - 1] - l[0];
  cout << l_last - sum << endl;
  return 0;
}

Measured memory_bytes: 1400