akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  Dooloper
*    created: 06.06.2020 07:41:25
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>


using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<bool> eratosthenes(int n){
    vector<bool> ret(n + 1, true);

    ret[0] = false;
    ret[1] = false;
    for (int i = 2; i*i < ret.size(); i++)
    {
        if(ret[i]){
            for (int j = 2; j * i < ret.size(); j++){
                ret[i * j] = false;
            }
        }
    }

    return ret;
}

int main() {
    cin.tie(0);
    int N;
    cin >> N;
    vector<bool> prime = eratosthenes(100000000);
    int a;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if(prime[a])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int h, w, k;
	while(1){
		cin >> h >> w;
		if ( h == 0 && w == 0 ) break;
		
		for (int i = 1; i <= h; i++) {
			for ( int j = 1; j <= w; j++ ){
				k = ( i + j ) % 2;
				if ( k == 0 ) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define vii vector < pii >
#define viii vector < piii >
#define vll vector <ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

const int N = 10010;
int n, m;
vi dp((1 << 13 + 10), - 1);
vi arr(1010);
vector <vi >  a(1010);
bool mark[1010];
int ak[1010];


int f(int bitmask){
    if(bitmask == 0){
        return 0;
    }

    if(dp[bitmask] != -1 ) return dp[bitmask];

    int ans = INT_MAX;
    int aux;
    forn(i, m){
        if(mark[i] || !(ak[i]&bitmask)) continue;
        aux = bitmask;
        for(auto x:a[i]){
            if(bitmask&(1 << x))
                bitmask = bitmask^(1 << x);
        }
        mark[i] = true;
        ans = min(ans, arr[i] + f(bitmask));
        mark[i] = false;
        bitmask = aux;
    }
    return dp[bitmask] = ans;
}


int32_t main(){
//    ios::sync_with_stdio(0),cin.tie(0);	
    int k, ax, aux = 0;
    scanf("%lld%lld",&n,&m);
    forn(i, m){
        scanf("%lld%lld",&arr[i],&ax);
        ak[i] = 0;
        forn(j, ax){
            scanf("%lld",&k);
            aux = aux | (1 << k);
            ak[i] = ak[i] | (1 << k);
            a[i].pb(k);
        }
    }

    memset(mark, 0, sizeof mark);

    int bitmask = 0;
    rep(i, 1, n + 1){
        bitmask = bitmask|(1 << i);
    }

    if(aux != bitmask){
        cout << -1 << endl;
        return 0;
    }
    int ans =  f(bitmask);

    if(ans >= INT_MAX){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<long,long>
#define pil pair<int,long>
#define pli pair<long,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    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;
}
const double PI=3.14159265358979323846264338327950288419716939;
int main(){
    double R;
   scanf("%lf",&R);
   printf("%lf\n",2*PI*R);
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n, x, t;
    cin >> n >> x >> t;
    ll cur = 0, time = 0;
    while(cur < n) {
        cur += x;
        time += t;
    }
    cout << time << "\n";
}   

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<long double> A(N),B(N);
  for(int i=0;i<N;i++) cin >> A[i] >> B[i];

  long double ave = 0;
  for(int i=0;i<N-1;i++){
    for(int j=i;j<N;j++){
      ave += 2*sqrt(pow(A[i]-A[j],2) + pow(B[i]-B[j],2))/N;
    }
  }
  
  cout << setprecision(10) << ave << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cout << v[i] << ' ';
	}
	cout << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
	int n,m,k; cin >> n>>m>>k;
	UnionFind uf(n);
	vector<int> follow(n,0);
	int a,b;
	Rep(m){
		cin >> a >> b;
		uf.unite(--a, --b);
		follow[a]++;
		follow[b]++;
	}
	vector<int> ans(n);
	rep(i,n){
		ans[i] = uf.size(i) - follow[i] - 1;
	}
	Rep(k){
		cin >> a >> b;
		if(uf.same(--a,--b)){
			ans[a]--;
			ans[b]--;
		}
	}
	print(ans);
}

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

Measured memory_bytes: 22096
package main

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

const MOD = 1000000007

func lib_Combination(n, r int) (int, error) {
	if n < r {
		return 0, fmt.Errorf("r(%d) is larger than n(%d)", r, n)
	}
	if n == r {
		return 1, nil
	}
	rRangeFac, err := lib_RangeFactorial(n, r)
	if err != nil {
		return 0, fmt.Errorf("failed in Combination: %v", err)
	}
	rFac, err := lib_Factorial(r)
	if err != nil {
		return 0, fmt.Errorf("failed in Combination: %v", err)
	}
	return rRangeFac / rFac, nil
}
func lib_CountInt(values []int) map[int]int {
	m := map[int]int{}
	for _, value := range values {
		m[value]++
	}
	return m
}
func lib_Factorial(n int) (f int, err error) {
	if n > 20 {
		return 0, fmt.Errorf("too large Factorical n: %d", n)
	}
	f = 1
	for i := 2; i <= n; i++ {
		f = f * i
	}
	return
}
func lib_ModMul(a, b, mod int) int {
	return (a % mod) * (b % mod) % mod
}
func lib_ModSum(a, b, mod int) int {
	return ((a % mod) + (b % mod)) % mod
}
func lib_MustCombination(n, r int) int {
	_v0, _err := lib_Combination(n, r)
	if _err != nil {
		panic(_err)
	}
	return _v0
}
func lib_RangeFactorial(n, num int) (f int, err error) {
	f = 1
	for i := 0; i < num; i++ {
		f *= n - i
	}
	return
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var K int
	scanner.Scan()
	K, _ = strconv.Atoi(scanner.Text())
	A := make([]int, N-1-0+1)
	for i := 0; i < N-1-0+1; i++ {
		scanner.Scan()
		A[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, K, A))
}
func solve(N int, K int, A []int) int {
	inNum := 0
	for j := 1; j < len(A); j++ {
		for i := 0; i < j; i++ {
			if A[i] > A[j] {
				inNum++
			}
		}
	}
	inSum := lib_ModMul(inNum, K, MOD)
	if K == 1 {
		return inSum
	}
	m := lib_CountInt(A)
	list := make([]int, 2000+5, 2000+5)
	for a, num := range m {
		for i := 1; i < a; i++ {
			list[i] = lib_ModSum(list[i], num, MOD)
		}
	}
	per := 0
	for _, a := range A {
		per = lib_ModSum(per, list[a], MOD)
	}
	return (inSum + lib_ModMul(per, lib_MustCombination(K, 2), MOD)) % MOD
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n){
	
	int ans = 0;
	for(int i = 0; i <= 9; ++i){
		for(int j = 0; j <= 9; ++j){
			for(int k = 0; k <= 9; ++k){
				for(int l = 0; l <= 9; ++l){
					if(i + j + k + l == n){
						ans++;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
	
	}
	
	return 0;
}

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

fn main() {
    let s = scan!();
    let p = s.matches('p').count();
    println!("{}", s.len() / 2 - p)
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
    int a,b,c,y,n;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF){
        y=n=0;
        for(int i=1;i<=10;i++){
            if(i==a||i==b||i==c)continue;
            if(a+b+i>20)n++;
            else y++;
        }
        if(y>n)printf("YES\n");
        else printf("NO\n");
    }
}

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

int main() {
    int n;
    int a[110];
    
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    sort(a, a + n, greater<int>());
    
    int a_sum = 0, b_sum = 0;
    
    for(int i = 0; i < n; ++ i){
        if(i % 2 == 0) a_sum += a[i];
        else b_sum += a[i];
    }
    
    cout << a_sum - b_sum << endl;
}

Measured memory_bytes: 256
#include "cstdio"
#include "algorithm"

int A[100004];
int g;
int gcd (int x,int y)
{
    return y==0?x:gcd(y,x%y);
}
int main()
{
    int n,k;
    while (scanf ("%d%d",&n,&k) != EOF)
    {
        for (int i=0;i<n;i++)
        {
            scanf ("%d",&A[i]);
        }
        g = A[0];
        for (int i=1;i<n;i++)
        {
            g = gcd(g,A[i]);
        }
        std::sort(A,A+n);
        if (A[n-1] < k)
        {
            printf ("IMPOSSIBLE\n");
            continue;
        }
        for (int i=0;i<n;i++)
        {
            if (k%g == A[i]%g)
            {
                printf ("POSSIBLE\n");
                break;
            }
            if (i==n-1)
            {
                 printf ("IMPOSSIBLE\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
import Data.List.Split
import Data.List

main = do
        str <- getLine
        times <- getLine
        let nums = map (read) (splitOn " " str) :: [Int]
        let times' = read times :: Int
        let res = iterate multiToMax nums
        let ans = res !! times'
        putStrLn $ show (sum ans)

multiToMax list = (x * 2) : rest
        where
                sorted = sortBy (\x y -> compare y x) list
                x = head sorted
                rest = tail sorted

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

import sys
# from IPython import embed

args = sys.argv
if len(args) == 2:
  import IPython

def embed():
  if len(args) == 2:
    sys.stdin = open('/dev/tty')
    IPython.embed()


N, K, Q = map(int, input().split(" "))

A = []
for i in range(0, Q):
  A.append(int(input()))

wins = [0] * N
for i in A:
  wins[i - 1] = wins[i - 1] + 1

embed()

for i in range(0, N):
  score = K - Q + wins[i]
  if score > 0:
    print("Yes")
  else:
    print("No")


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

ll recurse(ll day, ll wht, vector<vector<ll>>& arr, vector<vector<ll>>& dp) {
    ll n = arr[0].size();
    if (day == n-1) {
        return arr[wht][day];
    }

    if (dp[wht][day] != -1) {
        return dp[wht][day];
    }

    ll cost = arr[wht][day] + max(
        recurse(day+1, (wht+1)%3, arr, dp),
        recurse(day+1, (wht+2)%3, arr, dp)
    );

    dp[wht][day] = cost;
    return cost;


}

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n;
    cin >> n;
    vector<vector<ll>> inp (3, vector<ll> (n));
    vector<vector<ll>> dp(3, vector<ll>(n, -1));
    for (ll i = 0; i < n; i++) {
        cin >> inp[0][i];
        cin >> inp[1][i];
        cin >> inp[2][i];
    }



    cout << max(
        recurse(0, 0, inp, dp),
        max(
            recurse(0, 1, inp, dp),
            recurse(0, 2, inp, dp)
        )
    ) << endl;




    
    return 0;
}

Measured memory_bytes: 15088
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, K; cin >> N >> K;
    vector<vector<ll>> HB(2*K, vector<ll>(2*K, 0));
    vector<vector<ll>> MB(2*K+1, vector<ll>(2*K+1, 0));
    ll ma = 0;
    rep(i,N) {
        ll x, y; char c; cin >> x >> y >> c;
        if (c == 'W') x += K; // WならKずらすことでBと同様に演算可能に
        x %= 2 * K;
        y %= 2 * K;
        HB[x][y]++;
    }
    // 二次元累積和
    for(ll i=1;i<=2*K;i++) for(ll j = 1; j<=2*K; j++) {
        MB[i][j] += MB[i][j-1] + HB[i-1][j-1];
    }
    for(ll j=0;j<=2*K;j++) for(ll i = 1; i<=2*K; i++) {
        MB[i][j] += MB[i-1][j];
    }

    for (ll i = 0; i <= K; i++) {
        for (ll j = 0; j <= K; j++) {
            ll cnt = 0;
            ll B1, B2, B3, B4, B5;
            B1 = MB[i][j];
            B2 = MB[i][2*K] - MB[i][j+K];
            B3 = MB[i+K][j+K] - MB[i][j+K] - MB[i+K][j] + MB[i][j];
            B4 = MB[2*K][j] - MB[i+K][j];  
            B5 = MB[2*K][2*K] - MB[i+K][2*K] - MB[2*K][j+K] + MB[i+K][j+K];
            cnt = B1 + B2 + B3 + B4 + B5;
            ma = max(ma, cnt);
            B1 = MB[i][j+K] - MB[i][j];
            B2 = MB[i+K][j] - MB[i][j];
            B3 = MB[i+K][2*K] - MB[i][2*K] - MB[i+K][j+K] + MB[i][j+K];
            B4 = MB[2*K][j+K] - MB[i+K][j+K] - MB[2*K][j] + MB[i+K][j];
            cnt = B1 + B2 + B3 + B4;
            ma = max(ma, cnt);
        }
    }
    cout << ma << endl;
}


Measured memory_bytes: 66036
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];
int n;

void preParse(int u);
void inParse(int u);
void postParse(int u);

int main(){
  int i,p,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    T[i].p=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&p,&l,&r);
    T[p].l=l;
    T[p].r=r;
    if(l!=NIL)T[l].p=p;
    if(r!=NIL)T[r].p=p;
  }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

void preParse(int u){
  if (u==NIL){
    return;
  }
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}
void inParse(int u){
  if(u==NIL){
    return;
  }
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}
void postParse(int u){
  if(u==NIL){
    return;
  }
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}



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

int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;

    rep(i, 0, N){
        if(s.substr(i) == t.substr(0, N-i)){
            cout << N+i << endl;
            return 0;
        }
    }
    cout << 2*N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
    ll n,k;cin>>n>>k;
    vvi v(200005);
    vi a(n);
    rep(i,n){
        cin>>a[i];
        v[a[i]].pb(i);
    }
    ll now=0,c=1;
    while(now!=n){
        auto it=lower_bound(all(v[a[now]]),now+1);
        if(it==v[a[now]].end()){
            it=v[a[now]].begin();
            c++;
        }
        now=*it+1;
    }
  	now=0;
    k%=c;
  if(k==0)return 0;
    while(k>0){
        auto it=lower_bound(all(v[a[now]]),now+1);
        if(it==v[a[now]].end()){
            it=v[a[now]].begin();
            k--;
            if(k==0)break;
        }
        now=*it+1;
    }
    vi ans;
    ans.pb(a[now]);
    now++;
    while(now<n){
        auto it=lower_bound(all(v[a[now]]),now+1);
        if(it==v[a[now]].end()){
            ans.pb(a[now]);
            now++;
        }
        else now=*it+1;
    }
    rep(i,ans.size()){
        if(i)cout<<' ';
        cout<<ans[i];
    }
}

Measured memory_bytes: 17140
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　var n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            var sa = s.Split(' ');
            int[] ia = new int[n];
            for(int i = 0;i < ia.Length; i++)
            {
                ia[i] = int.Parse(sa[i]);
            }

            int total = 0;
            for(int i = 0;i < ia.Length; i++)
            {
                total += ia[i];
            }
            int ave = (int)Math.Round((double)total / ia.Length);

            int diff_total = 0;

            for (int i = 0; i < ia.Length; i++)
            {
                diff_total += (int)Math.Pow((ia[i] - ave), 2);
            }

            Console.WriteLine(diff_total);
        }
 }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define maxn 100100
using namespace std;

int len;

char s1[maxn],s2[maxn];

int main(){
	scanf("%s",s1);
	len=strlen(s1);
	for(int i=0;i<len;i++){
		if(s1[i]=='p') s2[i]='q';
		else if(s1[i]=='q') s2[i]='p';
		else if(s1[i]=='b') s2[i]='d';
		else if(s1[i]=='d') s2[i]='b';
	}
	for(int i=0;i<len;i++){
		if(s1[i]!=s2[len-1-i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 512
N = int(input())
S = input()

east = [0] ## east[i]: (N-i)番目の人より東にいる人で、東を向いている人数, len=(N+1)
west = [0] ## west[i]: (i-1)番目の人より西にいる人で、西を向いている人数, len=(N+1)
for i in range(N-1):
  east.append(east[-1] + (S[N-i-1] == 'E'))
  west.append(west[-1] + (S[i] == 'W'))
  
ans = N
for i in range(N):
  cost = east[N-i-1] + west[i]
  ans = min(ans, cost)
  
print(ans)
  

Measured memory_bytes: 27116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    vll b;
    for(auto&& e:mp){
        if(e.second >= 2){
            b.emplace_back(e.first);
        }
        if(e.second >= 4){
            b.emplace_back(e.first);
        }
    }
    reverse(ALL(b));
    if(SZ(b) <= 1){
        cout << 0 << endl;
    }else{
        cout << b[0]*b[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 7296
n=int(input())
A=[100]*(10**5+4)
A[0]=0
B=[1,6,6**2,6**3,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5]
for i in range(1,n+2):
  A[i]=min(A[i-B[j]] for j in range(12))+1
print(A[n])

Measured memory_bytes: 3828
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main(){
      
  fastio();
  int n,m,i,j;
  cin>>n>>m;

  vi dis;
  for(i=0;i<n;i++)
  {
  	int x;
  	cin>>x;
  	dis.pb(abs(x-m));
  }
  int g=dis[0];
  for(i=0;i<dis.size();i++)
  {
  	g=gcd(g,dis[i]);
  }
  cout<<g;
  return 0;
}

Measured memory_bytes: 892
import numpy as np

H,W = list(map(int,input().split()))

#print(H,W)

dot=[]
for h in range(H):
    d=input().strip()
    if '#' in d:
        dot.append(list(d))
    
#print(dot)
dot = np.array(dot).T

dot2=[]
for d in range(len(dot)):
    if '#' in dot[d]:
        dot2.append(dot[d])

dot2 = np.array(dot2).T

#print(dot2)

for h in range(len(dot2)):
    print("".join(dot2[h]))

Measured memory_bytes: 14444
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 2005, INF = 1e9;
const ll Mod = 1e9 + 7;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n, k;
ll C[N][N];

void Init() {
	C[0][0] = 1;
	rep (i, 1, 2000)
		rep (j, C[i][0] = 1, i) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
			// if (i == 2 && j == 1)
				// cout << C[i][j] << endl;
		}
}

int main() {
	Init();
	n = read<int>(), k = read<int>();
	int x = n - k + 1, y = k - 1;
	rep (i, 1, k) {
		printf("%lld\n", C[x][i] * C[y][i - 1] % Mod);
	}
	return 0;
}



Measured memory_bytes: 30080
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N;
vector<int> b(110);
bool f = 0;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
int main() {
    cin >> N;
    vector<int> v;
    for (int i = 1; i <= N; ++i) cin >> b[i];
    bool f = 1;
    while(f) {
        f = 0;
        for (int i = N; i > 0 && !f; --i) {
            if (b[i] == i) {
                remove(b, i);
                v.push_back(i);
                f = 1;
            }
        }
    }
    if ((int)v.size() == N) for (int i = N-1; i >= 0; --i) cout << v[i] << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

// dijkstra
struct edge{int to; ll cost;};

struct dijkstra {
    int V;
    vll d;
    vector<vector<edge>> G;

    dijkstra(int n) {init(n);} 

    void init(int n) {
        V = n;
        G.resize(V);
        d.resize(V);
        rep(i,V) d[i] = inf_l;
    }

    void add_edge(int s, int t, ll cost) {
        s--; t--;
        edge e;
        e.to = t; e.cost = cost;
        G[s].push_back(e);
    }

    void run(int s) {
        s--;
        priority_queue<P, vector<P>, greater<P>> q;
        d[s] = 0;
        q.push(P(0,s));
        while (!q.empty()) {
            P p = q.top(); q.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (auto e: G[v]) {
                if (chmin(d[e.to],d[v]+e.cost)) {
                    q.push(P(d[e.to],e.to));
                }
            }
        }
    }
};

int main() {
    int n; cin >> n;
    dijkstra dj(n);
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        ll c; cin >> c;
        dj.add_edge(a,b,c);
        dj.add_edge(b,a,c);
    }
    int q, k; cin >> q >> k;
    dj.run(k);
    rep(i,q) {
        int x, y; cin >> x >> y;
        x--; y--;
        cout << dj.d[x] + dj.d[y] << endl;
    }
}

Measured memory_bytes: 11120
Z = input("").split()
N = int(Z[0])
D = int(Z[1])
count = 0
 
while(N):
    Z1 = input("").split()
    X = int(Z1[0])
    Y = int(Z1[1])
  
    d = (X**2 + Y**2)**0.5
  
    if d<=D:
        count += 1
    N = N -1
print(count)

Measured memory_bytes: 9648
N=int(input())
alice=0
bob=0
l_n=list(map(int,input().split()))
l_n.sort(reverse=True)
for i in range(N):
    if i % 2 == 0:
        alice+=l_n[i]
    else:
        bob+=l_n[i]
print(abs(alice-bob))

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> t(N);
  string X;
  for (int i = 0; i<N;i++) {
    cin >> S.at(i) >> t.at(i);
  }
  
  cin >> X;
  
  int ans = 0;
  
  bool check = false;
  
  for (int i = 0;i < N;i++) {
    if (check) {
      ans += t.at(i);
    }
    if (S.at(i) == X) {
      check = true;
    }
  }
  cout << ans << endl;
    
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include<cmath>
    typedef long long ll;
    using namespace std;
    const double PI = acos(-1.0);

    int main(){
        int n,m;
        int sum=0;
        cin>>n>>m;
        int a[m];
        for(int i=0; i<m;i++){
            cin>>a[i];
            sum+=a[i];
        }
        if(sum<=n){
            cout<<n-sum;}
           else{
            cout<<"-1";
           }





    }

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

int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for(int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);

  int counter = 0;
  for(int i = 0; i < N; i++) {
    if(x - a[i] >= 0) {
      counter++;
      x -= a[i];
    }
    else break;
    if(i == N - 1 && x > 0) counter--;
  }

  cout << counter << endl;
}


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

using namespace std;

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

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

	vector<long long > sum(N);
	sum[0] = a[0];
	for (int i = 1; i < N; i++)
	{
		sum[i] = sum[i - 1] + a[i];
	}

	long long ans = (long long)1e14;
	for (int i = 0; i < N - 1; i++) {
		ans = min(ans, abs(sum[i] - (sum[N - 1] - sum[i])));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int N, M;
bool possible; 
long long int INF = 1e18; 
long long int A[100010][2];
vector<pair<int, long long int>> E[100010]; 
void dfs(int V, int pm){
	for(int i = 0; i < E[V].size(); i++){
		long long int a = A[E[V].at(i).first][1-pm]; 
		if(a != INF && a != E[V].at(i).second - A[V][pm]){
			possible = false; return;
		}
		else if(a == E[V].at(i).second - A[V][pm]) continue; 
		else if(a == INF){
			A[E[V].at(i).first][1-pm] = E[V].at(i).second - A[V][pm]; 
			dfs(E[V].at(i).first, 1-pm);
		}
	}
}
int main(){
	cin >> N >> M; 
	for(int i = 0; i < M; i++){
		int u, v;
		long long int s; 
		cin >> u >> v >> s; 
		E[u].push_back(pair<int, long long int>(v, s)); 
		E[v].push_back(pair<int, long long int>(u, s)); 
	}
	for(int i = 1; i <= N; i++){
		A[i][0] = INF; A[i][1] = INF; 
		//各頂点に1次の係数が\pm1の1次式を対応させる．衝突したら方程式を解く．
	}
	A[1][0] = 0; //1次式xを対応させ，他を連鎖的に求める． 
	possible = true; 
	dfs(1, 0); 
	long long int exact = INF; 
	for(int i = 1; i <= N; i++){
		if(A[i][0] != INF && A[i][1] != INF && A[i][0] % 2 != A[i][1] % 2){
			possible = false; break; 
		}
		else if(A[i][0] != INF && A[i][1] != INF && A[i][0] % 2 == A[i][1] % 2){
			exact = (A[i][1] - A[i][0]) / 2; break; 
		}
	}  
	if(exact != INF){
		for(int j = 1; j <= N; j++){
			if(A[j][0] != INF && A[j][1] != INF 
				&& (A[j][1] - A[j][0] != 2 * exact || A[j][0] + A[j][1] <= 0)){
				possible = false; break; 
			}
		}
	}
	if(!possible) cout << 0 << endl; 
	else if(exact != INF) cout << 1 << endl; 
	else{
		long long int const1 = 1e17; long long int const2 = 1e17; 
		for(int i = 1; i <= N; i++){
			if(A[i][0] != INF) const1 = min(const1, A[i][0]); // x+const1 > 0
			if(A[i][1] != INF) const2 = min(const2, A[i][1]); // const2-x > 0
		}
		cout << max((long long) 0, const2 + const1 - 1) << endl; 
	}
}

Measured memory_bytes: 21504
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    string tmp;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s<t) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  string s;
  cin >> s;
  vector<bool> flag(s.size(), false);
  vector<string> elems = {"dream", "dreamer", "erase", "eraser"};
  rep(i, elems.size()) {
    if (s.substr(0, elems[i].size()) == elems[i]) {
      flag[elems[i].size() - 1] = true;
    }
  }
  rep(i, s.size()) {
    rep(j, elems.size()) {
      if (i >= elems[j].size() && flag[i - elems[j].size()] &&
          s.substr(i - elems[j].size() + 1, elems[j].size()) == elems[j]) {
        flag[i] = true;
      }
    }
  }
  if (flag[s.size() - 1]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    ca = 3 ** N
    co = 1
    for x in A:
        if x % 2 == 0:
            co *= 2
        else:
            co *= 1
    return ca - co


print(solve())


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

using ll =long long;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    
    vector<ll> resl(n+1,0);
    {
    auto nega=a;
    vector<ll> time4(n);
    vector<int> par(n);
    auto leq=[&](int lhs,int rhs){
        if(time4[lhs]<time4[rhs]){
            return nega[lhs]<=(1LL<<((time4[rhs]-time4[lhs])*2))*nega[rhs];
        }
        else{
            return nega[lhs]*(1LL<<((time4[lhs]-time4[rhs])*2))<=nega[rhs];
        }
    };
    
    for(int i=0;i<n;i++){
        //update resl[i+1]
        resl[i+1]=resl[i]+1;
        nega[i]*=-2;
        int p=i;
        while(p>0 && !leq(p-1,p)){
            int pre=time4[p-1];
            while(!leq(p-1,p)){
                time4[p-1]++;
            }
            int plus_cnt=time4[p-1]-pre;
            resl[i+1]+=2*plus_cnt*(p-par[p-1]);
            if(p-1!=par[p-1]) time4[par[p-1]]+=plus_cnt;
            p=par[p-1];
        }
        par[i]=p;
    }


    
 





    }
    
    vector<ll> resr(n+1);
    {
        auto nega=a;
        reverse(nega.begin(),nega.end());
        for(int i=0;i<n;i++) nega[i]=-nega[i];
        
    vector<ll> time4(n);
    vector<int> par(n);
    auto leq=[&](int lhs,int rhs){
        if(time4[lhs]<time4[rhs]){
            return nega[lhs]<=(1LL<<((time4[rhs]-time4[lhs])*2))*nega[rhs];
        }
        else{
            return nega[lhs]*(1LL<<((time4[lhs]-time4[rhs])*2))<=nega[rhs];
        }
    };
    
    for(int i=0;i<n;i++){
        //update resl[i+1]
        resr[i+1]=resr[i];
        int p=i;
        while(p>0 && !leq(p-1,p)){
            int pre=time4[p-1];
            while(!leq(p-1,p)){
                time4[p-1]++;
            }
            int plus_cnt=time4[p-1]-pre;
            resr[i+1]+=2*plus_cnt*(p-par[p-1]);
            if(p-1!=par[p-1]) time4[par[p-1]]+=plus_cnt;
            p=par[p-1];
        }
        par[i]=p;
    }

    }
    

    ll res=1e15;
    for(int i=0;i<=n;i++){
        res=min(res,resr[i]+resl[n-i]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 10936
#include <cstdio>

using namespace std;

int main(){

    int a[2], r, buffer;

    r = 100000;

    scanf("%d %d", &a[0], &a[1] );

    if( a[0] < a[1] ){

        buffer = a[0];
        a[0] = a[1];
        a[1] = buffer;

    }

    while( r > 0 ){

        r = a[0] % a[1];

        a[0] = a[1];
        a[1] = r;

    }
    
    printf("%d\n", a[0] );

    return 0;

}

Measured memory_bytes: 2756
using System;
using System.Linq;

namespace abc_049_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[1]++;
            for (int i = 0; i < a[0]; i++) { string a1 = Console.ReadLine();Console.WriteLine(a1);Console.WriteLine(a1); }
        }
    }
}

Measured memory_bytes: 2904
#include<iostream>

int calc(int X) {
  if(X >= 2000) return 1;
  int c = X/100;
  if(100*c <= X && X <= 105*c) return 1;
  return 0;
}

int main() {
  int X; std::cin >> X;
  std::cout << calc(X) << std::endl;
  return 0; 
} 


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;

    // 変えるべきもののindexを保管
    vector<ll> ng;
    vector<ll> p(N); rep(i, N){
        cin >> p.at(i);
        if (p.at(i) == (i + 1)){
            ng.push_back(i);
        }
    }
    ll i = 0;
    ll ans = 0;
    while (i < ng.size()){
        // 連続しておかしい場合，一気に塗り替えられる
        if ((i + 1) < ng.size() && (ng.at(i) + 1) == ng.at(i + 1)){
            i += 2;
        } else {
            i += 1;
        }
        ans++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 2168
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    string S, T;
    cin >> S;
    cin >> T;
    if (T.substr(0, T.size() - 1) == S)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <cstring>
#include <cstdio>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
std::map<int, int> arr; 
int a[105], b[105], w[105][105], na, nb, from[105]; 
bool vis[105]; 
inline bool chk(int n)
{
	if (n <= 1)
		return false; 
	for (int i = 2; i * i <= n; i++)
	{
		if (!(n % i))
			return false; 
	}
	return true; 
}
bool dfs(int u)
{
	for (int v = 0; v < nb; v++)
	{
		if (vis[v] || !w[u][v])
			continue; 
		vis[v] = true; 
		if (-1 == from[v] || dfs(from[v]))
		{
			from[v] = u; 
			return true; 
		}
	}
	return false; 
}
int main()
{
	// freopen("ARC080-F.in", "r", stdin); 
	int n, ans = 0; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		int x; 
		scanf("%d", &x); 
		arr[x] ^= 1; 
		arr[x + 1] ^= 1; 
	}
	for (auto it : arr)
	{
		if (it.second)
			(it.first & 1 ? a[na++] : b[nb++]) = it.first; 
	}
	for (int i = 0; i < na; i++)
	{
		for (int j = 0; j < nb; j++)
			w[i][j] = chk(my_abs(a[i] - b[j])); 
	}
	memset(from, -1, sizeof(from)); 
	for (int i = 0; i < n; i++)
	{
		memset(vis, false, sizeof(vis)); 
		ans += dfs(i); 
	}
	printf("%d\n", ans + ((na - ans) / 2 + (nb - ans) / 2) * 2 + (na - ans & 1) * 3);
	return 0; 
}


Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
li=[]
gc = lcm(c,d)
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int R[200000],n,i,j,minv,maxv;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&R[i]);
  }
  maxv = R[1] - R[0];
  minv = R[0];
  for(j=1; j<n; j++){
    if(maxv < (R[j]-minv)) maxv = R[j]-minv;
    if(minv > R[j]) minv = R[j];
  }
  printf("%d\n",maxv);

  return 0;
}



Measured memory_bytes: 2548
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    ll count = 0;
    ll pre = s[0];
    for(long i = 1; i < s.length(); ++i) {
        if (pre != s[i]) {
            pre = s[i];
            count ++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
def rm_s(h):
	for hai in set(h):
		if (hai in h) and (hai+1 in h) and (hai+2 in h):
			if len(h) == 3: return 1
			h1 = h[:]
			for i in range(3): h1.remove(hai+i)
			return is_hora(h1)
	else: return 0
		
def rm_k(h):
	for hai in set(h):
		if h.count(hai) >= 3:
			if len(h) == 3: return 1
			h1 = h[:]
			for i in range(3): h1.remove(hai)
			return is_hora(h1)
	else: return 0
	
def is_hora(h):
	return rm_s(h) or rm_k(h)
	
while True:
	try:
		h = map(int, raw_input())
		ans = []
		for add in range(1,10):
			if h.count(add) <= 3:
				h1 = h[:]+[add]
				for d in set(h1):
					if 2 <= h1.count(d):
						h1 = h[:]+[add]
						h1.remove(d);h1.remove(d)
						if is_hora(h1):
							ans.append(add)
							break
		print " ".join(map(str, sorted(ans))) if len(ans) > 0 else 0
	except:
		break

Measured memory_bytes: 4280
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long

int n;
vector<string> ans;

void dfs(int dep, char cur, string s) {
  if(dep == n) {
    ans.push_back(s);
    return ;
  }
  for(char ch = 'a'; ch < cur; ch++) {
    dfs(dep + 1, cur, s + ch);
  }
  dfs(dep + 1, cur + 1, s + cur);
}
int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  dfs(0, 'a', "");
  sort(ans.begin(), ans.end());  
  for (auto s : ans) {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 7796
#include <iostream>
#include <string>

int main(){
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::string c = s.substr(0,n/2);
  if(s == c+c)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}
  

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("");
		String[] t = sc.nextLine().split("");
		sc.close();
		int size = s.length;
		int count = 0;
		for (int i = 0; i < size; i++) {
			if (!s[i].equals(t[i])) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 57576
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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<_>>()
    };

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

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }
    let mut count = 0;
    for a in 0..a + 1 {
        for b in 0..b + 1 {
            for c in 0..c + 1 {
                if 500 * a + 100 * b + 50 * c == x {
                    count += 1
                }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int a[233333],b[233333],A[233333],B[233333],n,tmp,t1,t2,ans=0;
long long bb[32];
inline int in(){  
    int W=1,X=0;  
    char Ch=0;  
    while(!isdigit(Ch)){  
        if(Ch=='-') W=-1;  
        Ch=getchar();  
    }  
    while(isdigit(Ch))  
        X=(X<<3)+(X<<1)+(Ch^'0'),Ch=getchar();  
    return X*W;  
}

inline void out(long long X,char *S){    
    if(X<0) putchar('-'),X=-X;    
    if(X>9)  out(X/10,"");    
    putchar(X%10+'0');    
    printf(S);    
}  

inline void getbits(){
	bb[0]=1;
	for(int i=1;i<=32;i++)
		bb[i]=bb[i-1]<<1;
}

int main(){
	n=in();
	for(int i=1;i<=n;i++)	
		a[i]=in();
	for(int i=1;i<=n;i++)
		b[i]=in();
	getbits();
	for(int i=0;i<30;i++){
		for(int j=1;j<=n;j++)
			A[j]=a[j]%bb[i+1],B[j]=b[j]%bb[i+1];
		sort(B+1,B+n+1);
		tmp=0;
		for(int j=1;j<=n;j++){
			t1=lower_bound(B+1,B+n+1,bb[i+1]-A[j])-lower_bound(B+1,B+n+1,bb[i]-A[j]);
			t2=lower_bound(B+1,B+n+1,bb[i+2]-A[j])-lower_bound(B+1,B+n+1,bb[i+1]+bb[i]-A[j]);
			tmp+=t1+t2;
			tmp&=1;
		}
		ans+=1ll*bb[i]*tmp;
	}
	out(ans,"");
}

Measured memory_bytes: 3328