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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<int> vec;
  vec.push_back(0);

  reps(i, 1, n) {
    int a;
    cin >> a;
    vec.push_back(a);
  }

  vec.push_back(0);

  vector<int> upcum(n+10);
  vector<int> downcum(n+10);

  vector<int> diff(n+10);
  for (int i = 1; i < vec.size()-1; ++i) {
    diff[i] = abs(vec[i+1] - vec[i-1]);
  }

  for (int i = 1; i < vec.size(); ++i) {
    upcum[i] = upcum[i-1] + abs(vec[i-1] - vec[i]);
  }

  for (int i = vec.size()-2; i >= 0; --i) {
    downcum[i] = downcum[i+1] + abs(vec[i+1] - vec[i]);
  }

  for (int i = 1; i < vec.size()-1; ++i) {
    cout << diff[i] + upcum[i-1] + downcum[i+1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <stdlib.h>

int sort_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){

	int n,k,min=-1;

	scanf("%d %d",&n,&k);

	int h[n];
	
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}

	qsort(h,n,sizeof(int), sort_int);

	for(int i=0;i<n-(k-1);i++){
		if(min==-1 || min>h[i+(k-1)]-h[i]){
			min=h[i+(k-1)]-h[i];
		}
	}

	printf("%d",min);
}

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

const int md = 998244353;
const int N = 105;

map< vector<bool>, int > f;

vector<bool> get(int l, int r, vector<bool> &v) {
	vector<bool> ret;
	for (int i = l; i <= r; ++i) ret.push_back(v[i]);
	return ret;
}

int dp(vector<bool> v) {
	int n = v.size();
	if (n == 0) return 1;
	if (f.find(v) != f.end()) return f[v];

	int &ret = f[v];

	// the encoding string starts with a '0' or '1'
	vector<bool> nv = v;
	nv.erase(nv.begin());
	ret = (v[0] + 1) * dp(nv);
	ret -= (ret >= md) ? md : 0;

	// the encoding string starts with a bracket '('
	for (int len = 1; len <= n; ++len) {
		// [0...len - 1][len...2 * len - 1]...
		vector<bool> cur = get(0, len - 1, v);

		for (int repeat = 2; repeat * len <= n; ++repeat) {
			// update cur
			for (int j = (repeat-1) * len; j < repeat * len; ++j) {
				cur[j - (repeat-1) * len] = (cur[j - (repeat-1) * len] & v[j]);
			}

			ret += 1LL * dp(cur) * dp(get(repeat * len, n - 1, v)) % md;
			ret -= (ret >= md) ? md : 0;
		}
	}

	return ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string S; cin >> S;
	
	vector<bool> s;
	for (int i = 0; i < S.size(); ++i) s.push_back(S[i] - '0');

	cout << dp(s) << endl;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int mo = 1e9 + 7;

ll T, n, k;

int get_mnb(ll l, ll r) {
    int res = 0;
    for(int i = 60; i >= 0; --i) {
        if((l >> i & 1) == (r >> i & 1)) 
            res += (l >> i & 1);
        else {
            res += bool (l & ((1ll << i) - 1)); 
            break;
        }
    }
    return res;
}

vector<pll> temp;
std::map<vector<ll>, vector<pll>> mp;
std::map<vector<ll>, vector<pll>> :: iterator it;

void out (vector<ll> x) {
    for(auto v : x) printf("%lld ", v);
    printf("\n");
}
void out (vector<pll> x) {
    for(auto v : x) printf("(%lld, %lld) ", v.fst, v.snd);
    printf("\n");
}

void calc(int x, ll tims) {
    vector<ll> b;
    if(tims < 0) return;

    for(int i = 0; i < n; ++i) b.pb(temp[i].snd - (i <= x));
    
    std::sort(b.begin(), b.end());
    if(b[0] < 0) return;

    for(int i = n-1; i > 0; --i) { b[i] -= b[i-1]; }
    ll t = b[0]; b[0] = 0;

    tims = std::min(tims, t);
    mp[b].pb(mp(t - tims, t));
}

vector<ll> a;

int main() {

        read(n), read(k); 
        temp.resize(n), a.resize(n);

        for(int i = 0; i < n; ++i) read(a[i]);
        std::sort(a.begin(), a.end());

        mp.clear();

        for(int i = 0; i <= 60; ++i) {

            ll bits = (1ll << i) - 1;
            for(int j = 0; j < n; ++j) temp[j] = mp(a[j] & bits, a[j] >> i);

            std::sort(temp.begin(), temp.end());

            ll lst = 0;
            for(int j = 0, nxt = 0; j < n; j = nxt + 1) {
                nxt = j;
                while(nxt < n-1 && temp[nxt + 1].fst == temp[j].fst) ++ nxt;

                calc(j-1, k - i - get_mnb(lst, temp[j].fst));
                lst = temp[j].fst + 1;
            }
        }

        int ans = 0;
        for(it = mp.begin(); it != mp.end(); ++ it) {
            // out(it -> fst);
            // out(it -> snd);

            temp = it -> snd;
            std::sort(temp.begin(), temp.end());

            ll l = temp[0].fst, r = temp[0].snd;

            for(int i = 1; i < (int) temp.size(); ++i) {

                if(temp[i].fst <= r) {
                    chkmax(r, temp[i].snd);
                } else {
                    ans = (ans + (r - l + 1) % mo) % mo;
                    l = temp[i].fst;
                    r = temp[i].snd;
                }
            }
            ans = (ans + (r - l + 1) % mo) % mo;
        }
        printf("%d\n", ans);
    

    return 0;
}


Measured memory_bytes: 16512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

/*
AC
自分自身とのxorは0
*/

ll a,b,ans=0,a2=0;

ll xor_sum(ll s){
	ll sum=0;
	rep(i,40){
		bool ok=false;
		ll x=(ll)1<<i;
		if(i==0){//最下位だけ個別処理（塊の大きさが2の倍数でないため）
			if((s+1)/2%2==1)ok=true;
		}else if((s/x)%2 == 1 && ((s+1)%x)%2 == 1){
			ok=true;
		}
		if(ok)sum+=x;
	}
	return sum;
}

int main(void){
	cin>>a>>b;
	cout<<(xor_sum(b)^xor_sum(a-1))<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (isEven(a) || isEven(b)) {
                System.out.println("Even");
            } else {
                System.out.println("Odd");
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }

    public static boolean isEven(int num) {
        return num % 2 == 0;
    }
}

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

int main(){
  string w;
  cin >> w;
  map<char,int> m;
  bool flag=true;
  for(auto c : w){
    if(m.count(c)){
      m.at(c)++;
    }else{
      m[c]=1;
    }
  }
  for(auto p : m){
    if(p.second%2!=0){
      flag=false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n, k, q;

	while(scanf("%d%d%d", &n, &k, &q)==3)
	{
		vi s(n+1, k-q);
		vi a(q+1);

		for(int i=1;i<=q;i++)
		{
			scanf("%d", &a[i]);
			s[a[i]]++;
		}
		for(int i=1;i<=n;i++)
		{
			printf("%s\n", (s[i]>0)?"Yes":"No");
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define MAX 100000

int array[MAX];

int partition(int,int);

int main(){

  int n, i, ans;

  scanf("%d", &n);

  for( i=0; i<n; i++){
    scanf("%d", &array[i]);
  }

  ans = partition(0,n-1);

  for( i=0; i<ans; i++){
    printf("%d ", array[i]);
  }

  printf("[%d] ", array[ans]);

  for( i=ans+1; i<n-1; i++){
    printf("%d ", array[i]);
  }

  printf("%d\n", array[n-1]);

  return 0;
}

int partition(int p, int r){

  int x, i, j, tmp;

  x = array[r];
  i = p-1;

  for( j=p; j<r; j++){
    if( array[j] <= x ){
      i++;
      tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
  }

  tmp = array[i+1];
  array[i+1] = array[r];
  array[r] = tmp;
  
  return i+1;
}

Measured memory_bytes: 988
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    char s[201];
    scanf("%s", s);
    int n=strlen(s);
    n -= 2;
    while(1){
        int f=1;
        rep(i, 0, n/2){
            if(s[i] != s[i+n/2]){
                f = 0;
            }
        }
        if(f){
            printf("%d", n);
            break;
        }
        n -= 2;
    }

    return 0;
}

Measured memory_bytes: 128
N, A, B, K = map(int, input().split())
mod = 998244353
f_table = [1] * (N+1)
inverse_table = [0] * (N+1)

def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return f_table[n] * inverse_table[r] * inverse_table[n-r] % mod


for i in range(2, N + 1):
    f_table[i] = (f_table[i-1] * i) % mod
inverse_table[N] = pow(f_table[N], mod-2, mod)
for i in range(N, 0, -1):
    inverse_table[i-1] = (inverse_table[i] * i) % mod

res = 0
for a in range(0, N+1):
    b = (K - A*a) // B
    if (K - A * a) % B == 0 and 0 <= b <= N:
        res += cmb(N, a) * cmb(N, b) % mod
print(res % mod)

Measured memory_bytes: 26740
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[1010][1010];
vector<pair<int,int> > pc[5];
int dp[6][1010];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<5;i++)pc[i].clear();
		int sr,sc,gr,gc;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='S'){sr=i;sc=j;}
			else if(str[i][j]=='G'){gr=i;gc=j;}
			else if(str[i][j]!='.'){
				pc[str[i][j]-'1'].push_back(make_pair(i,j));
			}
		}
		int ret=999999999;
		int at=0;
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++)for(int k=0;k<1010;k++)dp[j][k]=999999999;
			for(int j=0;j<pc[(i+1)%5].size();j++){
				dp[0][j]=ABS(pc[(i+1)%5][j].first-sr)+ABS(pc[(i+1)%5][j].second-sc);
			}
			for(int j=0;j<3;j++){
				for(int k=0;k<pc[(i+j+1)%5].size();k++){
					for(int l=0;l<pc[(i+j+2)%5].size();l++){
						dp[j+1][l]=min(dp[j+1][l],dp[j][k]+ABS(pc[(i+j+2)%5][l].first-pc[(i+j+1)%5][k].first)+ABS(pc[(i+j+2)%5][l].second-pc[(i+j+1)%5][k].second));
					}
				}
			}
			int tmp=999999999;
			for(int j=0;j<pc[(i+4)%5].size();j++)tmp=min(tmp,dp[3][j]+ABS(pc[(i+4)%5][j].first-gr)+ABS(pc[(i+4)%5][j].second-gc));
			if(ret>tmp){ret=tmp;at=i;}
		}
		if(ret>99999999)printf("NA\n");
		else printf("%d %d\n",at+1,ret);
	}
}

Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    
    if((a%3==0) || (b%3==0) || ((a+b)%3==0)) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

using namespace std;

int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if (x > y) {
		int t = x;
		x = y;
		y = t;
		t = a;
		a = b;
		b = t;
	}

	int ans = y * c * 2;
	ans = min(ans, x * c * 2 + (y - x) * b);
	ans = min(ans, a * x + b * y);
	cout << ans << endl;

	return 0;
}

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

using ll = long long;
// #define int long long
using P = pair<int, int>;
using PP = pair<P, int>;  //<<y,x>,distance>

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

#define MAX 55
int H,W;

bool g[MAX][MAX];
int d[MAX][MAX];
bool visited[MAX][MAX];

int bfs_finding_goal(int start_h, int start_w) {
  queue<PP> q;
  PP qt = PP(P(start_h, start_w),0);
  q.push(qt);
  while(!q.empty()) {
    qt = q.front();
    int curr_x = qt.first.second;
    int curr_y = qt.first.first;
    int curr_d = qt.second;
    q.pop();
    for(int dy = -1; dy <= 1; ++dy) {
      for(int dx = -1; dx <= 1; ++dx) {
        if(!dy && !dx) continue;  // 自分の位置
        if(abs(dy)+abs(dx) == 2) continue; // 斜め移動

        int next_x = curr_x + dx;
        int next_y = curr_y + dy;
        int next_d = curr_d + 1;

        // 範囲外
        if(next_x < 0 || next_x >= W) continue;
        if(next_y < 0 || next_y >= H) continue;
        if(next_x == W-1 && next_y == H-1) return next_d; // 目的のマスについた

        // 通れないまたはすでに到達済み
        if(!g[next_y][next_x]) continue;
        if(visited[next_y][next_x]) continue;
        q.push(PP(P(next_y,next_x),next_d));
        visited[next_y][next_x] = true;
      }
    }
  }
  return -1;
}

/***** MAIN *****/
signed main() {
  cin >> H >> W;
  int white_count = 0;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      g[h][w] = (c == '.');
      if(g[h][w]) ++white_count;
    }
  }
  int distance = bfs_finding_goal(0,0);
  if(distance == -1) {
    cout << -1;
  } else {
    int ans = white_count - distance - 1;
    cout << ans;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	max := max(nums...)
	min := min(nums...)
	sum := sum(nums...)

	fmt.Printf("%d %d %d\n", min, max, sum)
}

func max(vars ...int) int {
	var max = math.MinInt64
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func min(vars ...int) int {
	var min = math.MaxInt64
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func sum(vars ...int) int {
	var sum int

	for _, i := range vars {
		sum = sum + i
	}
	return sum
}



Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int N, Q, ma;
  vector<int> v;

  cin >> N >> Q;
  Rep(i, N) {
    int c; cin >> c;
    ma = max(ma, c);
    v.pb( c );
  }

  sort( All(v) );

  while( Q-- ) {
    int q, cnt = 1, ans = 0;

    cin >> q;
    while( 1 ) {
      int p = q * cnt;
      ans = max(ans, (*(lower_bound( All(v), p )-1)) % q);
      cnt++;
      if( p >= ma ) break;
    }

    cout << ans << endl;
  }

}

Measured memory_bytes: 4836
#define REP(i, n) for (int i = 0;i<(int)(n);i++)
#define rep(i, n) REP(i, n)
#define REPI(i, a, n) for(int i=int(a);i<int(b);i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

typedef long long ll;

#include <bits/stdc++.h>

using namespace std;


int main(){
    std::cin.tie(0);

    int d,n;
    cin >>d>>n;
    if(n==100)n++;
    rep(i,d)n*=100;
    
    cout<<n<<endl;
}

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

using namespace std;

typedef map<string, priority_queue<int, vector<int>, greater<int> > > Book; 

int main()
{

    int page;
    string word;
    Book book;

    while(cin >> word >> page)
    {
        book[word].push(page);
    }

    for(Book::iterator it = book.begin(); it != book.end(); it++)
    {
        cout << it->first << endl;
        while(!(it->second.empty()))
        {
            cout << it->second.top();
            cout << (it->second.size() == 1 ? '\n' : ' ');
            it->second.pop();
        }
    }

}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    while (n > 0) {
        if (n % 10 == 9)
        {
            cout << "Yes\n";
            return 0;
        } else {
            n /= 10;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main() {
   fast();
  long long n,p;
  cin>>n>>p;
  long long d=sqrt(p);
  unordered_map<long long int,long long int> m;
 
  while(p%2==0){
      p=p/2;
      m[2]++;
  }
  long long l=p;
  for(long long i=3;i<=sqrt(l);i++){
    while(l%i==0){
      l=l/i;
      m[i]++;
    }
  }
  if(l>2){
    m[l]++;
  }
  long long ans=1;
  for(auto i:m){
    long long t=(i.second)/n;
    long long a=i.first;
    ans*=binpow(a,t);
  }
  cout<<ans<<"\n";
   




}

Measured memory_bytes: 3652
h, n = gets.split.map &:to_i

cost = {}

n.times{
	a, b = gets.split.map &:to_i
	if cost[a] == nil || cost[a] > b then
		cost[a] = b
	end
}

total = Array.new(10001, 1000000000)
total[0] = 0

(1..10000).each{ |x|
	cost.each{ |k, v|
		temp = nil
		if x >= k then
			temp = total[x - k] + v
		else
			temp = v
		end
		
		if temp < total[x] then
			total[x] = temp
		end
	}
	
	if h == x then
		puts total[x]
		exit
	end
}


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

int main(){

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

  int64_t sum=0;
  for(int i=0;i<N;++i){
    sum ^= a[i];
  }

  for(int i=0;i<N;++i){
    int64_t ans=sum^a[i];
    cout<<ans<<" ";
  }


}


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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

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

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

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

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    long a, b, c;
    foreach (i; 0 .. N)
    {
        long cnt;
        while (~A[i] & 1)
        {
            A[i] >>= 1;
            cnt++;
        }
        a += cnt == 0;
        b += cnt == 1;
        c += 2 <= cnt;
    }
    bool z = a - 1 <= c;
    bool x = b % 2 == 0 || a == c;
    writeln(z && x ? "Yes" : "No");
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll ans = 0;
  ll cnt = 0;
  for (ll i = 0; i < 3; i++) {
    if (S[i] == 'R') cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	map<string, int> vote;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		vote[S]++;
	}
	int maxVote = 0;
	for (auto itr = vote.begin(); itr != vote.end(); itr++) {
		maxVote = max(maxVote, itr->second);
	}
	for (auto itr = vote.begin(); itr != vote.end(); itr++) {
		if (itr->second == maxVote) {
			cout << itr->first << endl;
		}
	}

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  int v;
  int a=0;
  int k=1;
  int j=1;
  for(int i=0;i<n;i++){
    cin>>v;
    a+=v%2;
    k*=3;
  }
  for(int i=0;i<(n-a);i++)j*=2;
  cout<<k-j<<endl;
}


Measured memory_bytes: 256
N = gets.to_i
As = gets.split(' ').map(&:to_i)
total_length = As.inject(&:+)
half_length = total_length / 2.0
length_from_start = 0
if N == 2
  puts (As[0] - As[1]).abs
  exit
end
As.each_with_index do |a, i|
  length_from_start += a
  if length_from_start == half_length
    puts 0
    break
  elsif length_from_start > half_length
    mid_point = i
    length_to_end = As[(i + 1)..(N - 1)].inject(&:+)
    shorter, longer = [length_from_start - a, length_to_end].min, [length_from_start - a, length_to_end].max
    puts ((shorter + a) - longer).abs
    break
  end
end

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

using Lint=long long;

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

   Lint ans=accumulate(a.begin(),a.end(),0LL)-(Lint)N*(N+1)/2;
   cout<<ans<<endl;
   return 0;
}



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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    map<int, int> b;
    REP(i, n)
    {
        result += b[i - a[i]];
        b[i + a[i]]++;
    }


    cout << result << endl;
    return 0;
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#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 p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N, M;
  cin >> N >> M;

  vector<ll> buckets(N, 0);
  rep(i, M){
    ll a = il() - 1;
    ll b = il() - 1;
    buckets[a]++;
    buckets[b]++;
  }

  rep(i, N){
    if (buckets[i]%2==1){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

}

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

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod	%1000000007
#define FOR(I,N) for(I=0;I<N;++I)

int main()
{
	ll n,i,j;
	cin>>n;
	ld p[n+1];
	FOR(i,n)
		cin>>p[i+1];
	ld dp[n+1][n+1];
	dp[0][0]=0;
	dp[1][0]=(1-p[1]);
	dp[1][1]=p[1];
	for(i=2;i<=n;++i)
	{
		for(j=0;j<=i;++j)
		{
			if(j==i)
				dp[i][j] = dp[i-1][j-1] * p[i];
			else if(j!=0)
				dp[i][j]= dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
			else
				dp[i][j] = dp[i-1][j] * (1-p[i]);
		}
	}
	ld ans=0;
	for(i=(n/2+1);i<=n;++i )
		ans+=dp[n][i];
	cout<<fixed << setprecision(10)<<ans;	
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < n; ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long next_subset(unsigned long long subset){
	unsigned long long tem = subset + (subset & -subset);
	unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

inline void solve(){
	int n;
	ll t,ans=1;
	cin>>n;
	rep(i,n){ cin>>t; ans=lcm(ans,t); }
	cout<<ans;
	return;
}

inline void input(){
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}





Measured memory_bytes: 256
using System;

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            var array = input.Split(' ');
            var numberOfMan = int.Parse(array[0]);
            var moneyOfTrainPerMan = int.Parse(array[1]);
            var moneyOfTaxi = int.Parse(array[2]);

            var moneyOfTrain = moneyOfTrainPerMan * numberOfMan;

            if (moneyOfTaxi < moneyOfTrain)
            {
                Console.WriteLine(moneyOfTaxi);
            }
            else
            {
                Console.WriteLine(moneyOfTrain);
            }
        }
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll K;
    cin >> K;
    REP(i, K) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < N - 1; i++)
  {
    if (a[i] <= x)
    {
      ans++;
      x -= a[i];
    }
  }
  if (a[N - 1] == x)
    ans++;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

ll n;
vector<ll> s[300001];

int main(void) {
	ll m,tmp,ans=0;
	cin >> n;
	
	for (ll i = 0; i < n; i++) {
		cin >> m;
		for (ll j = 0; j < m; j++) {
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	
	priority_queue<ll> q;
	for (ll i = n - 1; i >= 0; i--) {
		for (ll j = 0; j < s[i].size(); j++) {
			q.push(s[i][j]);
		}
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19392
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a[3][3],b[3][3];
	memset(b,0,sizeof(b));
	for(int i=0;i<3;i++)
	 for(int h=0;h<3;h++)
	    cin>>a[i][h];
	int n,m;
	cin>>n;
	while(n--)    
	{
		cin>>m;
		for(int i=0;i<3;i++)
		 for(int h=0;h<3;h++)
		  if(a[i][h]==m)
		   b[i][h]=1;
	}
	int r1=b[0][0]+b[0][1]+b[0][2];
	int r2=b[1][0]+b[1][1]+b[1][2];
	int r3=b[2][0]+b[2][1]+b[2][2];
	int r4=b[0][0]+b[1][0]+b[2][0];
	int r5=b[0][1]+b[1][1]+b[2][1];
	int r6=b[0][2]+b[1][2]+b[2][2];
	int r7=b[0][0]+b[1][1]+b[2][2];
	int r8=b[0][2]+b[1][1]+b[2][0];
	if(r1==3||r2==3||r3==3||r4==3||r5==3||r6==3||r7==3||r8==3)
	 cout<<"Yes";
	else
	 cout<<"No"; 
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  vpll p(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    p.emplace_back(a,b);
  }
  reverse(all(p));
  
  UnionFind uf(n);
  
  ll tmp=n*(n-1)/2;
  vll ans;
  ans.push_back(tmp);
  rep(i,m-1){
    ll a=p[i].first, b=p[i].second;
    if(!uf.isSame(a,b)) tmp-=uf.size(a)*uf.size(b);
    ans.push_back(max(tmp,0LL));
    uf.connect(a,b);
  }
  reverse(all(ans));
  for(auto e: ans){
    cout<<e<<endl;
  }
  
}

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

int main(void){
    string s;
    cin >> s;
    vector<int> v(4);
    for(int i=0; i<4; i++){
        v.at(i) = stoi(s.substr(i,1));
    }
    
    for(int bit=0b0000; bit<=0b1111; bit++){
        vector<int> u(4);
        vector<char> op(4);
        u.at(0) = v.at(0);
        for(int i=1; i<4; i++){
            if(bit & (1<<i)){
                op.at(i) = '-';
                u.at(i) = (-1)*v.at(i);
            }else{
                op.at(i) = '+';
                u.at(i) = v.at(i);
            }
        }
        if(accumulate(u.begin(), u.end(), 0) == 7){
            cout << v.at(0) << op.at(1) << v.at(1) << op.at(2) << v.at(2) << op.at(3) << v.at(3) << "=7" << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  ll H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1;
    return 0;
  }
  if (H % 2 == 1 && W % 2 == 1) cout << (H*W+1)/2;
  else cout << (H*W)/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod LLONG_MAX
#define mod1 998244353
#define Mmax 1000005
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
bool comp(pair<li,pair<li,li>>a,pair<li,pair<li,li>>b)
{
  if(a.first<b.first)
  return 1;
  else if(a.first>b.first)
  return 0;
  else
  {
    return a.second.first<b.second.first;
  }
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=(ans%mod)*(x%mod)%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
li modInverse(li n)
{
    return mpow(n, mod-2);
}

li nCrModPFermat(li n, li r,li x,li y,li z)
{
   // Base case
   if (r==0)
      return 1;
    // li fac[n+1];
    // fac[0] = 1;
    // for (int i=1 ; i<=n; i++)
    //     fac[i] = fac[i-1]*i%mod;
    return (x* modInverse(y) % mod *modInverse(z) % mod) % mod;
}
void bfs(vector<li>v[],li visit[],li s,li ans[])
{
  deque<li>q;
  q.push_back(s);
  visit[s]=1;
  while(!q.empty())
  {
    li x=q.front();
    q.pop_front();
    for(auto i=v[x].begin();i!=v[x].end();i++)
    {
      if(!visit[*i])
      {
        q.push_back(*i);
        visit[*i]=1;
      }
    }
  }
}
void buildtree(int*tree,int*arr,int start,int end,int treeNode)
{
  if(start<end)
  {
    int mid=start+(end-start)/2;
    buildtree(tree,arr,start,mid,2*treeNode);
    buildtree(tree,arr,mid+1,end,2*treeNode+1);
    tree[treeNode]=tree[2*treeNode]+tree[2*treeNode+1];
  }
}
void update(int*tree,int*arr,int start,int end,int pos,int val,int treeNode)
{
  if(start==end)
  tree[treeNode]=val;
  else
  {
    int mid=start+(end-start)/2;
    if(pos<=mid)
    update(tree,arr,start,mid,pos,val,2*treeNode);
    else
    update(tree,arr,mid+1,end,pos,val,2*treeNode+1);
    tree[treeNode]=tree[2*treeNode]+tree[2*treeNode+1];
  }
}

void dfs(vector<li>v[],li visit[],li s,li c[],li ans[],map<li,li>*m,li pred[])
{
    visit[s]=1;
     (*m)[c[s]]++;
    for(auto i=v[s].begin();i!=v[s].end();i++)
      {
        if(!visit[*i])
        {pred[*i]=s;
           dfs(v,visit,*i,c,ans,m,pred);
        }
      }
      if((*m)[c[pred[s]]]==1)
    ans[s]=(*m).size()-1;
    else
    ans[s]=(*m).size();
}
vector<li>factor(li n)
{
  vector<li>v;
  if(n%2==0)
  {
    while(n%2==0)
    {n/=2;
    v.push_back(2);
    }
  }
  for(li i=3;i<=sqrt(n);i+=2)
  {
    if(n%i==0)
    {
      while(n%i==0)
      {n/=i;
      v.push_back(i);
      }
    }
  }
  if(n>1)
  v.push_back(n);
  return v;
}
int main()
{
// li t,i,j;
// cin>>t;
// while(t--)
// {
//
//   cout<<endl;
// }
string s,t;
cin>>s>>t;
if(s==t.substr(0,t.size()-1))
cout<<"Yes";
else
cout<<"No";
return 0;
}


Measured memory_bytes: 3616
n = input()
s = list(map(int,input().split()))
Alice = []
Bob = []
for i in range(len(s)):
    if i % 2 == 0:
        Alice.append(max(s))
        s.remove(max(s))
    else:
        Bob.append(max(s))
        s.remove(max(s))
print(sum(Alice) - sum(Bob))

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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define ALL(c)         (c).begin(), (c).end()

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

	vector<int> a(N);
	for (auto& n : a) cin >> n;

	auto minmax_pair = minmax_element(ALL(a));
	auto min_value   = *minmax_pair.first;
	auto max_value   = *minmax_pair.second;

	int ans = INT_MAX;
	if (min_value == max_value) {
		ans = 0;
	} else {
		FOR (v, min_value, max_value) {
			int cost = 0;
			for (auto n : a) cost += pow(v - n, 2);
			ans = min(ans, cost);
		}
	}

	cout << ans << endl;
}

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

const int N_MAX = 2010;
char C[N_MAX][N_MAX];

int h, w;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
        }
    }

    UnionFind uf1(h * w), uf2(h * w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++){
            if(C[i][j] == '.' and C[i][j + 1] == '.'){
                int now = i * w + j;
                uf1.unite(now, now + 1);
            }
        }
    }

    for(int i = 0; i < w; i++){
        for(int j = 0; j < h - 1; j++){
            if(C[j][i] == '.' and C[j + 1][i] == '.'){
                int now = j * w + i;
                uf2.unite(now, now + w);
            }
        }
    }

    map<int, int> mp1, mp2;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '.'){
                int now = i * w + j;
                
                int r1 = uf1.root(now);
                mp1[r1] = -uf1.par[r1];

                int r2 = uf2.root(now);
                mp2[r2] = -uf2.par[r2];
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '#') continue;
            int cnt = 0;
            int now = i * w + j;
            int r1 = uf1.root(now);
            cnt += -uf1.par[r1];
            int r2 = uf2.root(now);
            cnt += -uf2.par[r2];

            // cout << i << ' ' << j << ' ' << -uf1.par[r1] << ' ' << -uf2.par[r2] << endl;
            cnt--;
            ans = max(ans, cnt);
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 120320
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 2e5+12;
//indexed_set s;

int a;

int main() {

    NoType;

    cin >> a;
    cout << a + a*a + a*a*a;

return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  string S;cin>>S;
  bool a=false,b=false,c=false;
  rep(i,3){
    if(S[i]=='a')a=true;
    else if(S[i]=='b')b=true;
    else if(S[i]=='c')c=true; 
  }
  if(a&&b&&c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
}


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

const int V = 100001;

int N, x[V], y[V];
vector<int> G[V * 2];
bool vis[V*2];
vector<int> cnt(2);

void dfs(int v){
    if(vis[v])  return;
    vis[v] = true;
    cnt[v/V]++;
    for(auto i : G[v])  dfs(i);
}

int main(void){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> x[i] >> y[i];
    
    for(int i=0;i<N;i++){
        y[i] += V;
        G[ x[i] ].push_back(y[i]);
        G[ y[i] ].push_back(x[i]);
    }
    
    long long ans = 0;
    for(int i=0;i<V*2;i++){
        if(vis[i])  continue;
        cnt = vector<int>(2);
        dfs(i);
        ans += (long long)cnt[0] * cnt[1];
    }
    
    ans -= N;
    cout << ans << endl;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
	double h;
	int a;
	cin >> h >> a;
	cout << ceil(h/a) << endl;
	return 0;
}

Measured memory_bytes: 256
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int r, g, b, n;
  scanf("%d%d%d%d", &r, &g, &b, &n);

  int ans = 0;
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      int t = i * r + j * g;
      if (n >= t && (n - t) % b == 0) ans++;
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256