akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  string S;
  cin >> S;
  int64_t Q;
  cin >> Q;
  vector<int64_t> query(Q);
  for(int i=0; i<Q; i++){
    cin >> query[i];
    query[i]--;
  }
  vector<int64_t> ans(Q);
  vector<vector<int64_t>> DM(Q,vector<int64_t>(3,0)); //Dの数、Mの数、DMの数
  for(int i=0; i<N; i++){
    if(S[i] == 'D'){
      for(int j=0; j<Q; j++){
        DM[j][0]++;
      }
    }
    if(S[i] == 'M'){
      for(int j=0; j<Q; j++){
        DM[j][1]++;
        DM[j][2] += DM[j][0];
      }
    }
    if(S[i] == 'C'){
      for(int j=0; j<Q; j++){
        ans[j] += DM[j][2];
      }
    }
    for(int j=0; j<Q; j++){
      if(i - query[j] >= 0){
        int x = i - query[j];
        if(S[x] == 'D'){
          DM[j][0]--;
          DM[j][2] -= DM[j][1];
        }
        if(S[x] == 'M'){
          DM[j][1]--;
        }
      }
    }
  }
  
  for(int i=0; i<Q; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <math.h>
// #include <stdlib.h>

int main(void) {
    double r;
    scanf("%lf", &r);

    double area = M_PI * pow(r, 2);
    double cirfer = M_PI * 2 * r; 

    printf("%.6f %.6f\n", area, cirfer);
    return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  string ans = "Three";
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if(s == "Y") {
      ans = "Four";
      break;
    }
  }

  cout << ans << endl;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<N;i++){
        cin>>B.at(i);
    }
    for(int i=0;i<N-1;i++){
        cin>>C.at(i);
    }

    int sum=B.at(N-1);
    for(int i=0;i<N-1;i++){
        if(A.at(i)==A.at(i+1)-1){
            sum+=C.at(A.at(i)-1);
        }
        sum+=B.at(i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
/*input
3 6
1 4 3
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 5050
#define INF 0x3f3f3f3f

int n , k , x[MAX] , pre[MAX] , all = 0;
bitset<MAX> fr[MAX] , ba[MAX];
int query(int ql , int qr){
	if(qr < 0) return 0;
	if(ql <= 0) return 1;
	ql = max(ql , 1LL);
	return pre[qr] - pre[ql - 1] > 0;
}
int32_t main(){
	IOS;
	cin >> n >> k;
	REP(i , 1 , n + 1) cin >> x[i] , all += x[i];
	if(all < k) return cout << n << endl , 0;
	fr[0][0] = ba[n + 1][0] = 1;
	REP(i , 1 , n + 1) fr[i] = fr[i - 1] | (fr[i - 1] << x[i]);
	RREP(i , n , 1)    ba[i] = ba[i + 1] | (ba[i + 1] << x[i]);
	pre[0] = 1;
	int ans = 0;
	REP(i , 1 , n + 1){
		int ql = k - x[i] , qr = k - 1 , ok = 1;
		REP(j , 1 , k + 1) pre[j] = pre[j - 1] + ba[i + 1][j];
		REP(j , 0 , k + 1){
			if(fr[i - 1][j] && query(ql - j , qr - j)) ok = 0;
		}
		// if(ok == 1) cout << i << endl;
		ans += ok;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
// 2016-12-06
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	const int c[4] = {10, 50, 100, 500};
	int n, a[4];
	bool l = false;
	while (cin >> n, n) {
		int m = 0;
		for (int i = 0; i < 4; i++) {
			cin >> a[i];
			m += a[i] * c[i];
		}
		m -= n;
		int b[4];
		for (int i = 3; i >= 0; i--) {
			b[i] = m / c[i];
			m %= c[i];
		}
		if (l) {
			cout << endl;
		}
		l = true;
		for (int i = 0; i < 4; i++) {
			if (b[i] < a[i]) {
				cout << c[i] << ' ' << a[i] - b[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題164

            string[] line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[0]);
            int b = int.Parse(line[1]);
            int c = int.Parse(line[2]);
            int d = int.Parse(line[3]);

            //高橋の攻撃必要回数
            int e;
            if (c%b == 0)
            {
                e = c / b;
            }
            else
            {
                e = c / b + 1;
            }

            int f;
            if (a % d == 0)
            {
                f = a / d;
            }
            else
            {
                f = a / d + 1;
            }


            if (e <= f)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


    }
}


Measured memory_bytes: 27500
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

int main(void) {
	uint32_t N, X;
	uint32_t m[100];
	uint32_t min = UINT32_MAX;
	uint32_t sum = 0;

	scanf("%"PRIu32" %"PRIu32, &N, &X);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32"\n", &(m[idx]));
		if (m[idx] < min) {
			min = m[idx];
		}
		sum += m[idx];
	}
	scanf("%"PRIu32, &(m[N - 1]));
	if (m[N - 1] < min) {
		min = m[N - 1];
	}
	sum += m[N - 1];

	printf("%"PRIu32, N + (X - sum)/min);

	return 0;
}


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

const int MAXN = 1000005;

int k;
bool vis[MAXN];

int main(){
	scanf("%d", &k);
	
	int u = 7 % k, i = 1;
	while(u != 0){
		if(vis[u])break;
		vis[u] = true;
		
		u = (u * 10 + 7) % k;
		i++;
	}
	
	if(u == 0){
		printf("%d\n", i);
	}else{
		printf("-1\n");
	}
	
	return 0;
}


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

int main(){
  int n, cnt = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    while(a % 2 == 0){
      cnt++;
      a /= 2;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
    int n;cin>>n;
    int s[n];
    rep(i,n)cin>>s[i];
    sort(s,s+n);
    int ans = 0;
    rep(i,n)ans+=s[i];
    if(ans%10 !=0){
        cout<<ans<<endl;
        return 0;
    }
    else{
        rep(i,n)if(s[i]%10 !=0){
            ans-=s[i];
            cout<<ans<<endl;
            return 0;
        }
    }
  cout<<0<<endl;
	return 0;
}



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

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


	vector<vector<int>> a(100, vector<int>(2));



	for (int i = 0; i < n; i++) {
		cin >> a.at(i).at(0) >> a.at(i).at(1);
	}
	

	for (int i = 0; i < n-2; i++) {
		if (a[i][0] == a[i][1] && a[i + 1][0] == a[i + 1][1] && a[i + 2][0] == a[i + 2][1]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3616
import sys
import math

n, m, l = map(int, raw_input().split())

A = [[0 for i in xrange(m)] for j in xrange(n)]
B = [[0 for i in xrange(l)] for j in xrange(m)]

for i in xrange(n):
    A[i] = map(int, raw_input().split())

for i in xrange(m):
    B[i] = map(int, raw_input().split())

for i in xrange(n):
    for j in xrange(l):
        sm = 0
        for k in xrange(m):
            sm += A[i][k] * B[k][j]

        sys.stdout.write(str(sm))
        if j < l-1:
            sys.stdout.write(" ")
    print

Measured memory_bytes: 6932
n = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
ans = 0
for i in range(n):
    s1 = min(A[i], B[i])
    ans += s1
    B[i] -= s1
    A[i] -= s1
    s2 = min(A[i+1], B[i])
    ans += s2
    B[i] -= s2
    A[i+1] -= s2
    
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++) {
    if (T.at(i) == '?'){
      T.at(i) = 'D';
    }
  }
  cout << T << endl;
}



Measured memory_bytes: 3700
def main():
    S = input()
    num = S.count('S')
    if num==3:
        print('0')
    if num==2: 
        print('1')
    if num==1:
        if S[1]=='S':
            print('1')
        else:
            print('2')
    if num==0:
        print('3')
        


if __name__ == "__main__":
    main()


Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<set<Int> > G(n);
  for(Int i=0;i<m;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace(b);
    G[b].emplace(a);    
  }
  
  for(Int i=0;i<n;i++){
    if(G[i].size()&1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
  for(Int i=0;i<n;i++){
    if(G[i].size()>=6u){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  Int cnt=0;
  for(Int i=0;i<n;i++)
    cnt+=(G[i].size()-2)/2;
  
  if(cnt>=3){
    cout<<"Yes"<<endl;
    return 0;
  }

  if(cnt<=1){    
    cout<<"No"<<endl;
    return 0;
  }


  // cnt == 2
  vector<Int> vs;
  for(Int i=0;i<n;i++)
    if(G[i].size()==4u) vs.emplace_back(i);

  assert(vs.size()==2u);
  Int x=vs[0],y=vs[1];
  for(Int i=0;i<n;i++){
    if(i==x||i==y) continue;
    Int a=*G[i].begin();
    Int b=*G[i].rbegin();
    assert(G[a].count(i)&&G[b].count(i));
    G[i].clear();
    
    G[a].erase(i);
    G[b].erase(i);
    G[a].emplace(b);
    G[b].emplace(a);
  }
  
  cout<<(G[x].count(x)?"Yes":"No")<<endl;  
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
    
 int n,ct=0;
 cin>>n;
 Vec v(n);
 for(int i=0;i<n;i++){
    cin>>v[i];
 }
 for(int i=0;i<n;i+=2){
   if(v[i]%2==1){
       ct++;
   }
 }
 cout<<ct<<endl;
}
 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    cout << (double)(N - N / 2) / (double)N << endl;

    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    int a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sort(a, a + n);
    int idx = -1;
    lli sum = 0;
    for (int i = 0; i + 1 < n; ++i) {
      sum += a[i];
      unless (2 * sum >= a[i + 1]) {
        idx = i;
      }
    }
    if (idx == -1) {
      cout << n << endl;
      continue;
    } else {
      int cnt = 0;
      each (i, a) cnt += (a[idx] < i);
      cout << cnt << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 640
import numpy as np
import math
#from decimal import *
#from numba import njit

#@njit
def main():
    A,B,H,M = map(int, input().split())
    # 時
    h = H + M/60
    # 時針の角度
    hr = (h%12)/12 * 2*math.pi
    # 分
    m = M/60
    # 分針の角度
    mr = m * 2*math.pi

    C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(hr-mr))
    print(C)

main()


Measured memory_bytes: 27180
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

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

  int count = 1;
  vector<int> a;
  s.push_back('-');
  bool tf = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1]) {
      count++;
      tf = true;
    } else {
      a.push_back(count);
      count = 1;
      tf = false;
    }
  }
  if (tf) a.push_back(count);

  vector<int> t(a.size() + 1, 0);  // s[0] = 0 になる
  for (int i = 0; i < a.size(); i++) t[i + 1] = t[i] + a[i];

  for (int i = 0; i < k * 2 + 1000000; i++) {
    t.push_back(t[t.size() - 1]);
  }
  int res = 0;
  if (s[0] == '0') {
    // 0から始まるとき
    for (int i = 0; i < t.size(); i += 2) {
      if (i + k * 2 >= t.size() - 1) continue;
      if (i - 1 < 0) {
        res = max(res, t[i + k * 2]);
        continue;
      }
      res = max(res, t[i + k * 2] - t[i - 1]);
    }
  } else {
    for (int i = 1; i < t.size(); i += 2) {
      if (i + k * 2 >= t.size() - 1) continue;
      if (i - 1 < 0) {
        res = max(res, t[i + k * 2]);
        continue;
      }
      res = max(res, t[i + k * 2] - t[i - 1]);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 8964
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int N,i;
    i=0;
    cin>>N;
    while(N>1){
        if(N%3==0){
            N=N/3;
        }else{
            N=N/3+1;
        }
        i++;
    }
    cout<<i<<endl;
}



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

using namespace std;

int num[200005];

bool check(int n,int m,int s) {
  int r=0,d1=2*n;
  for(int i=2*n;i>0;i--) {
  	while (r<2*n&&num[r+1]+num[i]<=s) r++;
  	if (!r) d1=min(d1,i-1); else d1=min(d1,r+i-1);
  }
  r=0;
  int d2=2*n;
  for(int i=2*n;i>0;i--) {
  	while (r<2*n&&num[r+1]+num[i]<=s+m) r++;
  	if (!r) d2=min(d2,i-1);
    else if (r<2*n) d2=min(d2,r+i-2*n);
  }
  int l=2*n+1,d3=1;
  for(int i=1;i<=2*n;i++) {
  	while (l>1&&num[l-1]+num[i]>=m) l--;
	if (l>2*n) d3=max(d3,i+1); else d3=max(d3,l+i-2*n); 
  }
  for(int i=0;i<=2*n;i+=2)
    if (i<=d1&&i+1<=d2&&i+1>=d3) return 1;
  return 0;
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=2*n;i++) scanf("%d",&num[i]);
  sort(num+1,num+2*n+1);
  int l=0,r=0;
  for(int i=1;i<=n;i++) r=max(r,(num[i]+num[2*n-i+1])%m);
  while (l<r) {
  	int mid=((l+r)>>1);
  	if (check(n,m,mid)) r=mid; else l=mid+1;
  }
  printf("%d\n",l);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  ll cnt=0;
  for(ll i=0;i<n;i++) {
    if(a[i]!=b[i])cnt++;
  }
  if(cnt<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))

cnt = 0
for x in t:
    l = 0
    r = n
    while l<r:
        mid = (l+r)//2
        if s[mid]!=x:
            if s[mid]<x:
                l = mid + 1
            else:
                r = mid
        else:
            cnt += 1
            break
print(cnt)


Measured memory_bytes: 16712
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

class State
{
public:
  int x, y, dir, cost;
  State(int xx = 0, int yy = 0, int d = 0, int c = 0)
    :x(xx), y(yy), dir(d), cost(c) {}
  bool operator < (const State& st) const
  {
    return this->cost > st.cost;
  }
};

int main()
{
  const int INF = 1 << 30;

  int w, h;
  while (scanf("%d %d", &w, &h) != EOF) {
    if (w == 0 && h == 0)
      break;

    vector<vector<int> > field(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j)
	scanf("%d", &field[i][j]);
    }

    vector<int> c(4);
    for (int i = 0; i < 4; ++i)
      scanf("%d", &c[i]);

    State next;
    priority_queue<State> que;
    que.push(State(0, 0, 0, 0));
    vector<vector<vector<int> > > cost(h, vector<vector<int> >(w, vector<int>(4, INF)));
    vector<vector<vector<int> > > visited(h, vector<vector<int> >(w, vector<int>(4, 0)));
    while (!que.empty()) {
      State st = que.top();
      que.pop();

      if (st.x == w-1 && st.y == h-1) {
	printf("%d\n", st.cost);
	break;
      }

      if (visited[st.y][st.x][st.dir] || cost[st.y][st.x][st.dir] < st.cost)
	continue;

      visited[st.y][st.x][st.dir] = 1;
      for (int i = 0; i < 4; ++i) {
	next.dir = (st.dir+i) % 4;
	next.cost = st.cost;
	if (field[st.y][st.x] != i)
	  next.cost += c[i];
	next.x = st.x + dx[next.dir];
	next.y = st.y + dy[next.dir];

	if (next.x < 0 || next.x >= w || next.y < 0 || next.y >= h)
	    continue;

	if (cost[next.y][next.x][next.dir] > next.cost) {
	  cost[next.y][next.x][next.dir] = next.cost;
	  que.push(next);
	}
      }
    }

  }
  return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if ( A == B && B != C){
    cout << "Yes" << endl;
  }
  else if ( A != B && B == C){
    cout << "Yes" << endl;
  }
  else if ( A != B && A == C){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

int main() {
    int N; cin >> N;
    if (N/100 == 7 || (N/10)%10 == 7 || N%10 == 7) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int s[n];
  int sum=0;
  for(int i=0;i<n;i++) {
    cin>>s[i];
    sum+=s[i];
  }
  if(sum%10!=0) cout<<sum<<endl;
  else{
    int ans=0;
    for(int i=0;i<n;i++){
      if((sum-s[i])%10!=0) ans=max(ans,sum-s[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e2+5;

char grid[MAXN][MAXN];
int R, C;
int dp[MAXN][MAXN];

bool valid(int r, int c){
    return 0<=r && r<R && 0<=c && c<C;
}

int solve(int r, int c){
    if(dp[r][c] != -1) return dp[r][c];
    int ret = -1, ret2 = -1;
    if(valid(r+1, c)) ret = (grid[r][c] != grid[r+1][c]) + solve(r+1,c);
    if(valid(r, c+1)) ret2 = (grid[r][c] != grid[r][c+1]) + solve(r,c+1);
    if(ret == -1 && ret2 == -1) return dp[r][c] = 0;
    if(ret == -1) return dp[r][c] = ret2;
    if(ret2 == -1) return dp[r][c] = ret;
    return dp[r][c] = min(ret, ret2);
    
}

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ms(dp, -1);
    rii(R, C);
    FOR(i,0,R) scanf("%s", grid[i]);
    int ans = solve(0,0);
    ans += (grid[0][0] == '#');
    ans += (grid[R-1][C-1] == '#');
    printf("%d\n", ans / 2);
    

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, w;
};
  

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

	vector<vector<Edge>> g(k);

	REP(i, k) {
		g[i].push_back({ i,(i + 1) % k, 1 });
		g[i].push_back({i, (i * 10) % k, 0});
	}

	priority_queue<pii, vector<pii>, greater<>> pq;
	pq.push({1, 1});

	vector<int> al(k, -1 );
	
	while (pq.size()) {
		pii cur = pq.top();
		pq.pop();

		if (al[cur.second] != -1) continue;
		al[cur.second] = cur.first;

		for (auto itr : g[cur.second]) {
			pq.push({ itr.w + cur.first,itr.to});
		}

	}

	cout << al[0] << endl;

	return 0;
}

Measured memory_bytes: 7284
N = int(input())
S = input()
a = [int(s)-1 for s in S]


from collections import defaultdict

r = 1
d = defaultdict(int)
while 2**r  <= N:
  for i in range(1,N):
    if i*(2**r) <= N:
      d[i*(2**r)] += 1
    else:
      break
  r+=1

def calc(list_of_int):
  # 1と0で構成されているとする
  length = len(list_of_int)
  res = list_of_int[0]
  
  keisu = 0
  for i,r in zip(list_of_int[1:], range(N-1)):
    keisu += d[N-r-1]-d[r+1]
    res = (res + ((2 if keisu>0 else 1)*i) )% 2
  return res

if 1 in a:
  print(calc(a))
else:
  print(calc(list(map(lambda x:x//2,a)))*2)

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

int main(){
  long int n, k;
  cin >> n >> k;
  if(k>=n){
    cout << 0 << endl;
    return 0;
  }
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  long long ans=0;
  rep(i,n-k){
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4016
package main
 
import (
    "fmt"
)
 
func main() {
  var s string
  fmt.Scan(&s)
  c := 0
  if s[:1] == "1" {
    c += 1
  }
  if s[1:2] == "1" {
    c += 1
  }
  if s[2:] == "1" {
    c += 1
  }
  fmt.Printf("%d\n", c)
}

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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }

int xxx(int x) {
  int sum = 0;
  while (x > 0) {
    sum += (x % 10);
    x /= 10;
  }
  return sum;
}

int main() {
  // 入力
  int N;
  cin >> N;
  
  // 計算
  int min = INT_MAX;
  for (int a = 1; a < N; a++) {
    int b = N - a;
    int t = xxx(a) + xxx(b);
    if (t < min) {
      min = t;
    }
  }
  
  // 出力
  println(min);
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N;
    cin >> N;

    for(ll i=N; ; i++)
    {
        ll temp = i;

        ll cur = 0;
        ll prev = temp%10;
        ll flag = 0;
        while(temp)
        {
            cur = temp%10;
            if(cur!=prev)
            {
                flag = 1;
                break;
            }
            prev = cur;
            temp/=10;
        }

        if(!flag)
        {
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int n;
string S;
int main(){
    cin >> S;
    n = S.size();
    int zero = 0;
    int one = 0;

    for(int i = 0; i < n; i++){
        if(S[i] == '0') zero++;
        else one++;
    }
    cout << min(one,zero)*2 << endl;
}



Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int w,n;
vector< pair<int,int> > v;

int** GetArray(int w,int h){
	int** pt = new int*[w];
	for(int i=0;i<w;i++){
		pt[i] = new int[h];
		for(int j=0;j<h;j++){
			pt[i][j] = 0;
		}
	}
	return pt;
}

void DeleteArray(int** pt,int w){
	for(int i=0;i<w;i++){
		delete[] pt[i];
	}
	delete[] pt;
}

int main(){
	int setno = 1;
	int a,b;
	while(scanf("%d",&w) != EOF){
		if(w == 0){break;}
		scanf("%d",&n);
		printf("Case %d:\n",setno);
		//printf("n:%d,w:%d\n",n,w);
		v.clear();
		v.push_back(make_pair(0,0));
		for(int i=0;i<n;i++){
			scanf("%d,%d",&a,&b);
			v.push_back(make_pair(a,b));
		}
		int** dp = GetArray(n + 1,w + 1);
		for(int j=0;j<=w;j++){
			//printf("j:%d\n",j);
			dp[0][j] = 0;
		}
		for(int i=1;i<=n;i++){
			for(int j=0;j<=w;j++){
				//printf("%d:%d\n",i,j);
				if(j < v[i].second){
					dp[i][j] = dp[i-1][j];
				}else{
					dp[i][j] = max(dp[i-1][j] , dp[i-1][j-v[i].second] + v[i].first);
				}
			}
		}
		int ans = dp[n][w];
		int answ = -1;
		for(int i=0;i<=w;i++){
			if(dp[n][i] == ans){
				answ = i;
				break;
			}
		}
		printf("%d\n%d\n",ans,answ);
		DeleteArray(dp,n + 1);
		setno++;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int n,m,a;
int main(void)
{
	int x[1000],y[1000],z[1000],i;
	scanf("%d %d",&n,&m);
	a=n/2;
	a=n-a;
	for(i=0;i<m;i++) scanf("%d %d",&x[i],&y[i]);
	for(i=0;i<m;i++){
		if(x[i]>a) x[i]=abs(x[i]-n)+1;
		if(y[i]>a) y[i]=abs(y[i]-n)+1;
		if(x[i]>a&&y[i]>a){
			if(x[i]<y[i]) z[i]=y[i]%3;
			else z[i]=x[i]%3;
		}
		else{
			if(x[i]>y[i]) z[i]=y[i]%3;
			else z[i]=x[i]%3;
		}
	}
	for(i=0;i<m;i++){
		if(z[i]!=0) printf("%d\n",z[i]);
		else  printf("%d\n",z[i]+3);
	}
	return 0;
}


Measured memory_bytes: 2776
#include <cstdio>
using namespace std;

int p[100002];

int main(){
  int N, K; scanf("%d%d", &N, &K);

  long long ans = 0;

  for(int s = 0, r = N - 1; r >= K; r--){
    s += p[N - r] + (N - r) / (r + 1) + 1; ans += s;
    for(int i = 0; i <= N; i += r + 1) p[i]++;
  }

  if(K == 0) ans -= N;

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

char grid[2002][2002];
int H[2002][2002] = {0,};
int W[2002][2002] = {0,};

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

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int start = j;
            int cnt = 0;
            while(j<w && grid[i][j]=='.'){
                j++;
                cnt++;
            }
            for(int k = start; k < j; k++){
                W[i][k] = cnt;
            }
        }
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            int start = j;
            int cnt = 0;
            while(j<h && grid[j][i]=='.'){
                j++;
                cnt++;
            }
            for(int k = start; k < j; k++){
                H[k][i] = cnt;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, H[i][j]+W[i][j]);
        }
    }
    cout << max(ans-1,0) << endl;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	long s; cin>>s;
	long m=s/60; s%=60;
	long h=m/60; m%=60;
	cout<<h<<":"<<m<<":"<<s<<endl;
}

Measured memory_bytes: 3112
import sys
from collections import defaultdict

n, v = map(int, sys.stdin.readline().split())
a = tuple(map(int, sys.stdin.readline().split()))
b = tuple(map(int, sys.stdin.readline().split()))
c = tuple(map(int, sys.stdin.readline().split()))
d = tuple(map(int, sys.stdin.readline().split()))
mp = defaultdict(int)
for val1 in c:
    for val2 in d:
        mp[val1 + val2] += 1
print(sum(mp[v - val1 - val2] for val1 in a for val2 in b))


Measured memory_bytes: 179128
#include "bits/stdc++.h"

#define INF 99999999
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

struct Edge
{
	int s, t, w;
	Edge(int s,int t,int w):s(s),t(t),w(w){}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return w != e.w ? w < e.w : (s != e.s ? s < e.s : t < e.t);
	}
};


struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

struct Rectangle
{
	ll h;
	int p;
	Rectangle(ll h,int p):h(h),p(p){}
};

ll h[100000];

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

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

	stack<Rectangle> rs;

	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (rs.empty())
		{
			rs.push(Rectangle(h[i], i));
		}
		else
		{
			if (rs.top().h < h[i])
			{
				rs.push(Rectangle(h[i], i));
			}
			else if (rs.top().h>h[i])
			{
				int tp = i;
				while (!rs.empty() && rs.top().h>h[i])
				{
					Rectangle tr = rs.top();
					rs.pop();
					ans = max(ans, tr.h*(i - tr.p));
					tp = tr.p;
				}
				rs.push(Rectangle(h[i], tp));
			}
		}
	}

	while (!rs.empty())
	{
		Rectangle tr = rs.top();
		rs.pop();
		ans = max(ans, tr.h*(N - tr.p));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5232
A,B,C,X,Y = map(int,input().split())
ans=0


if A+B > C*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)


Measured memory_bytes: 9172
#include <iostream>

int main(int argc, char const* argv[])
{
    int A, B, ans = 0;
    std::cin >> A >> B;
    for (int i = 0; i < 2; ++i) {
        if (B <= A) {
            ans += A--;
        } else {
            ans += B--;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int keta(int n) {
    int res = 0;
    while(n>0){
        if(n%2==1){
            res ++;
            n --;
        }
        n /=2;
    }
    return res;
}

int solve(int n,int x){
    if(n==0) return x;
    int ppcnt=keta(n);
    n %= ppcnt;
    x ++;
    return solve(n,x);
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<char> a(n);
    rep(i,n) cin>>a[i];
    int ppcnt=0;

    rep(i,n) if(a[i]=='1') ppcnt ++;

    if(ppcnt==0){
        rep(i,n) cout<<1<<endl;
        return 0;
    }

    vector<int> up(n+1,0),down(n+1,0),cul(n+1,0);
    vector<P> two(n+1);
    int nowup=1,nowdown=1;
    for(int i=n-1;i>=0;i--){
        two[i]=P(nowup,nowdown);
        int num=a[i]-'0';
        up[i] =up[i+1]+num*nowup;
        down[i]= down[i+1]+nowdown*num;
        up[i] %=(ppcnt+1);
    if(ppcnt!=1)    down[i] %=(ppcnt-1);
        nowup *=2;
        nowup %=ppcnt+1;
        nowdown *=2;
    if(ppcnt!=1)    nowdown %=ppcnt-1;
    }

    rep(i,n){
        int num=0;
        if(a[i]=='1'){
            num=down[0];
            num -=two[i].second;
            if(num<0) num +=ppcnt-1;
        }
        else{
            num=up[0];
            num +=two[i].first;
            num %=(ppcnt+1);
        }
        if(ppcnt==1 && a[i]=='1') cout<<0<<endl;
        else cout<<solve(num,1)<<endl;
    }
}/*
./problem.exe
*/

Measured memory_bytes: 7420
k=int(input())
x= list(map(int, input().split()))
ans=0
karikime=0
for i in range(k-1):
    if x[i]>=x[i+1]:
        karikime+=1
    else:
        ans=max(ans,karikime)
        karikime=0
    if i==k-2:
        ans=max(ans,karikime)
print(ans)

Measured memory_bytes: 14252
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

A,B,C,K = parseMap(split(readline()))

ans = 0
if A + B > K
    println(min(A,K))
else
    ans += A
    ans -= K - (A + B)
    println(ans)
end

Measured memory_bytes: 161904
#include <iostream> //cin,cout
#include <fstream> //input.txtの入力
#include <vector> //vector
#include <map> //map
#include <algorithm> //next_permutation

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  vector<int>P(N),Q(N);

  for(int i=0;i<N;i++) cin>>P.at(i),P.at(i)--;
  for(int i=0;i<N;i++) cin>>Q.at(i),Q.at(i)--;

  map<vector<int>,int> ord;
  int iter=0;

  vector<int>V(N);
  for(int i=0;i<N;i++) V.at(i)=i;

  do{
    ord[V]=iter++;
  }while(next_permutation(V.begin(),V.end()));

  cout<<abs(ord[P]-ord[Q])<<endl;

}


Measured memory_bytes: 5248
from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
c = int(stdin.readline())
u = a+b-c 
y = 3*c - a - b
all = u + c + y 
w = all - a - c 
z = all - y - w 
x = all - a - u 
v = all - b - c 
print a,b,y 
print x,c,z 
print u,v,w 

Measured memory_bytes: 2692
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }


	void solve() {
		IOS;
		string s, t;
		cin >> s >> t;
		if (s.size() + 1 == t.size()) {
			bool flag = true;
			REP(i, s.size()) {
				if (s[i] != t[i]) {
					flag = false;
				}
			}
			if (flag) {
				put("Yes");
				return;
			}
		}
		put("No");
	}
} // namespace idaten


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


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  int64 t= *(int64 *)a-*(int64 *)b;
  return t==0?0:t<0?-1:1;
}

void fill(int64 *c,int64 *a,int64 *b,int n){
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      c[i*n+j]=a[i]+b[j];
    }
  }
  qsort(c,n*n,sizeof(int64),cmp);
  return;
}

void run(void){
  int n;
  int64 v;
  scanf("%d%lld",&n,&v);
  int64 a[1000];
  int64 b[1000];
  int i;
  for(i=0;i<n;i++) scanf("%lld",a+i);
  for(i=0;i<n;i++) scanf("%lld",b+i);
  int64 *ab=(int64 *)malloc(sizeof(int64)*1000000);
  fill(ab,a,b,n);
  int64 c[1000];
  int64 d[1000];
  for(i=0;i<n;i++) scanf("%lld",c+i);
  for(i=0;i<n;i++) scanf("%lld",d+i);
  int64 *cd=(int64 *)malloc(sizeof(int64)*1000000);
  fill(cd,c,d,n);

  int64 ans=0;
  int l=0;
  int r=n*n-1;
  while(l<n*n && r>=0){
    int64 t=ab[l]+cd[r];
    if(t==v){
      int c1=0;
      while(l+c1<n*n && ab[l+c1]==v-cd[r]) c1++;
      int c2=0;
      while(r-c2>=0 && cd[r-c2]==v-ab[l]) c2++;
      ans+=(int64)c1*c2;
      l+=c1;
      r-=c2;
    } else if(t<v){
      l++;
    } else {
      r--;
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}



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

long long ceilDiv(long long a, long long b) {
	return (a - 1) / b + 1;
}

int main(void) {
	using namespace std;
	long long N, A, B;
	cin >> N >> A >> B;
	vector<long long> hs;
	for(int i = 0; i < N; ++i) {
		int h;
		cin >> h;
		hs.push_back(h);
	}
	sort(hs.begin(), hs.end());
	long long M = hs.back();
	int L = 0;
	int R = ceilDiv(M, B) + 1;
	const long long INF = 1e15;
	long long result = INF;
	while(R - L > 1) {
		int m = (R + L) / 2; //魔法の使用回数
		long long count = 0; //どれだけ余分に使う必要があるか
		for(int i = 0; i < N; ++i) {
			if(m * B < hs[i]) {
				count += ceilDiv(hs[i] - m * B, A - B);
			}
		}
		if(result == INF) result = count;
		if(m < count) {
			L = m;
		} else {
			R = m;
			result = m;
		}
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
ll h,w;
cin >> h >> w;
if(w == 1 || h == 1){
  cout << 1 << endl;
}
else cout << (h*w+1)/2 << endl;
}


Measured memory_bytes: 3600
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	auto path = new bool[][]('I'+1, 'I'+1);
	foreach (i; 'A'..'I'+1) {
		if ((i - 'A') % 3) path[i][i-1] = 1;
		if ((i - 'A') % 3 != 2) path[i][i+1] = 1;
		if ((i - 'C') > 0) path[i][i-3] = 1;
		if ((i - 'G') < 0) path[i][i+3] = 1;
	}
	foreach (line; stdin.byLine) {
		auto str = line.chomp;
		char pre = str[0];
		bool f;
		foreach (c; str[1..$]) {
			if (!path[pre][c]) {
				f = 1;
				break;
			}
			pre = c;
		} 
		if (!f) str.writeln;
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 


#define M 100010


int main(){
	IOS;
	tihs;

	
	ll n;cin>>n;
	ll cnt[n+1]={0};
	rep(i,0,n-1){
		ll x;cin>>x;
		cnt[x]++;
	}
	rep(i,1,n+1)cout<<cnt[i]<<"\n";
	return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastio 	ios::sync_with_stdio(false);cin.tie(NULL)
#define printvector(vec) for(auto &v: vec){cout<<v<<" | ";}cout<<"\n";
template<typename T> ostream& operator<<(ostream &s,vector<T> vec){for(auto &v: vec){s<<v<<" ";}s<<"\n";return s;}
template<typename T> void print(T v){cout<<v<<" ";}
template<typename T, typename... Args> void print(T first, Args... args){cout<<first<<" ";print(args...);}

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	x-=a;
	x=x%b;
	cout<<x;
}

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

using namespace std;

int main(void)
{
	long long s;
	cin >> s;
	if (s != 1e18)
	{
		long long x1, x2, y1, y2;
		x1 = 1e9, y1 = 1;
		y2 = s / x1 + 1;
		x2 = 1e9 - (s % x1);
		cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	}
	else
	{
		cout << "0 0 1000000000 0 0 1000000000" << endl;
	}
	return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll a,b,h; cin >> a >> b >> h;
    out((a+b)*h/2);
}

Measured memory_bytes: 3604
n = int(input())
hps = list(map(int, input().split()))
m = min(hps)
def gojo(a, b):
  if b == 0:
    return a
  else:
    return gojo(b, a % b)
res = m
for hp in hps:
  res = gojo(max(res, hp),min(res, hp))
print(res)

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

using namespace std;

const int MOD = 1e9 + 7;


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

    int w, a , b;
    cin >> w >> a >> b;

    if (b > a + w) {
        cout << b - a - w;
    } else cout << max(a - b - w, 0);

    return 0;
}


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

int main(){
    int N, D;
    cin >> N >> D;
    int x[N][D];
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> x[i][j];
        }
    }
    int count = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int norm = 0;
            for(int k=0; k<D; k++){
                int dif = 0;
                dif = abs(x[i][k] - x[j][k]);
                norm += dif*dif;
            }
            for(int k=0; k<=norm; k++){
                if(k*k == norm) count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256