akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

/* 計算 O(1) */
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll N, M;
  cin >> N >> M;

  map<ll, ll> p = prime_factor(M);
  mint ans = 1;
  COMinit();
  for (auto iter = p.begin(); iter != p.end(); iter++) {
    int Fi = iter->fi;
    int Se = iter->se;
    ans *= COM(Se + (N - 1), Se);
  }
  cout << ans.x << endl;
}

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



//int main(){
// int a[10];
// for(int i=0;i<10;i++){
//  cin>>a[i];
// }
// sort(a,a+10);
// for(int i=9;i>6;i--)
//  cout<<a[i]<<endl;
//return 0;
//}


//int main(){
//	int a,b,ans;
//	while(cin>>a>>b){
//		a+=b;
//		ans=1;
//		while(a/10){
//			a/=10;
//			ans++;
//			}
//		cout<<ans<<endl;
//	}
//	return 0;
//}

int main(){
	int n,a[3];
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)
			cin>>a[j];
		sort(a,a+3);
		cout<<((a[0]*a[0]+a[1]*a[1]-a[2]*a[2])?"NO":"YES")<<endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int check(string s, char c){
    bool uniq(true), excl(true);
    REP(i, s.length()){
        if(s[i] == c) excl = false;
        else uniq = false;
    }
    return 2*uniq + excl;
}

int main(){
    string S; cin >> S;
    if(S.size() != 26){
        VB used(26, false);
        REP(i, S.size()) used[S[i] - 'a'] = true;
        cout << S;
        REP(i, 26){
            if(!used[i]){
                cout << char('a' + i) << endl;
                return 0;
            }
        }
    }
    char prv('a' - 1); int idx(26);
    RREP(i, 25){
        if(S[i] < prv) break;
        prv = S[i]; idx = i;
    }
    if(!idx){
        cout << -1 << endl; return 0;
    }
    char a(S[idx-1]), b('z');
    FOR(i, idx, 26){
        if(S[i] > a) chmin(b, S[i]);
    }
    REP(i, idx-1) cout << S[i];
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.String;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.next();
            if (str.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int x = sc.nextInt();
                str = str.substring(x) + str.substring(0, x);
            }
            System.out.printf("%s\n", str);
        }
    }
}


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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> M, P;
  int64_t m = 0;
  int64_t p = 0;
  int64_t zero = 0;
  for(int i = 0; i < N; i++) {
    int64_t a;
    cin >> a;
    if(a > 0) {
      P.push_back(a);
      p++;
    }
    else if(a < 0) {
      M.push_back(a);
      m++;
    }
    else {
      zero++;
    }
  }
  if(K <= m * p) {
    sort(M.begin(), M.end());
    sort(P.begin(), P.end());
    int64_t L = P.at(p - 1) * M.at(0);
    int64_t R = 0;
    bool start = true;
    while(R - L > 1) {
      int64_t x = (R + L) / 2;
      if(start) {
        x = L;
      }
      int64_t keep = 0;
      int64_t count = 0;
      bool judge = false;
      // 積がx以下のペアを数える
      for(int64_t i = 0; i < p; i++) {
        for(int64_t j = keep; j < m; j++) {
          if(P.at(i) * M.at(j) > x) {
            count += j;
            keep = j;
            break;
          }
          if(j == m - 1) {
            count += m * (p - i);
            judge = true;
            break;
          }
        }
        if(judge) {
          break;
        }
      }
      if(start && count >= K) {
        cout << L << endl;
        return 0;
      }
      if(count >= K) {
        R = x;
      }
      else {
        L = x;
      }
      start = false;
    }
    cout << R << endl;
  }
  else if(K <= m * p + zero * (m + p) + zero * (zero - 1) / 2) {
    cout << 0 << endl;
    return 0;
  }
  else {
    K -= m * p + zero * (m + p) + zero * (zero - 1) / 2;
    sort(P.begin(), P.end());
    sort(M.begin(), M.end());
    reverse(M.begin(), M.end());
    // 積がx以下のペアを数える
    int64_t L = 0;
    int64_t R = 0;
    if(m > 1) {
      R = M.at(m - 1) * M.at(m - 2);
    }
    if(p > 1) {
      R = max(R, P.at(p - 1) * P.at(p - 2));
    }
    while(R - L > 1) {
      int64_t x = (R + L) / 2;
      int64_t keep1 = p - 1;
      int64_t keep2 = m - 1;
      bool judge1 = false;
      bool judge2 = false;
      int64_t count = 0;
      for(int64_t i = 0; i < p; i++) {
        for(int64_t j = keep1; j >= 0; j--) {
          if(i == j) {
            continue;
          }
          if(P.at(i) * P.at(j) <= x) {
            count += j + 1;
            if(j >= i) {
              count--;
            }
            keep1 = j;
            break;
          }
          if(j == 0) {
            judge1 = true;
            break;
          }
        }
        if(judge1) {
          break;
        }
      }
      for(int64_t i = 0; i < m; i++) {
        for(int64_t j = keep2; j >= 0; j--) {
          if(i == j) {
            continue;
          }
          if(M.at(i) * M.at(j) <= x) {
            count += j + 1;
            if(j >= i) {
              count--;
            }
            keep2 = j;
            break;
          }
          if(j == 0) {
            judge2 = true;
            break;
          }
        }
        if(judge2) {
          break;
        }
      }
      count /= 2;
      if(count >= K) {
        R = x;
      }
      else {
        L = x;
      }
    }
    cout << R << endl;
  }
}

Measured memory_bytes: 5192
#include<stdio.h>

int main() {
	int N;
	int ans;

	while (1) {
		if (scanf("%d", &N) == EOF)break;
		ans = 0;
		for (int i = 1; i < 600 / N; i++) {
			ans += i * N*i*N*N;
		}
		printf("%d\n", ans);
	}


	return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main()
{
    ll n, p;
    scanf("%lld%lld", &n, &p);
    if(n==1) {printf("%lld\n", p); return 0;}
    ll ans = 1ll;
    ll cur = 2ll;
    bool f = true;
    while(true) {
        ll tmp = 1ll;
        for(int i=0; i<n; i++) {
            tmp *= cur;
            if(tmp > p) {f=false; break;}
        }
        if(p % tmp == 0) ans = cur;
        if(!f) break;
        ++cur;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
const double PI = acos(-1);
using namespace std;
int main()
{
  long int n,a;
  cin>>n>>a;
  int flag=0;
  if((n>=1 && n<=9) && (a>=1 && a<=9))
  cout<<a*n;
  else
  cout<<"-1";

    
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int count = 0;
        for (int i = 0; i < n-1; i++) {
            if (i+1 == p[i]) {
                int tmp = p[i];
                p[i] = p[i+1];
                p[i+1] = tmp;
                count++;
            }
        }
        if (p[n-1] == n) count++;

        System.out.println(count);
    }
}

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

int main() {
    string str;
    cin>>str;
    
    int m=0;
    
    string ans ="hi";
    
    for(int i=0;i<6;i++){
        if(ans == str){
            cout<<"Yes"<<endl;
            m=1;
          break;
        }
        ans = ans + "hi";
    }
    
    if(m==0) cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int k,x;
int main(){
	k=rd(),x=rd();
	rep(i,x-k+1,x+k-1) rt(i),pc(' ');
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e6+5;
/*
ll f(ll x, ll n){
    ll r=1;
    while(n>0){
        if(n&1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;
}

ll fact[N],ifact[N];
void build(){
    fact[0]=1;
    fact[1]=1;
    for(ll i=2;i<N;i++)
    fact[i]=(fact[i-1]*i)%mod;
    fr(i,0,N)
    ifact[i]=f(fact[i],mod-2);
}
ll C(ll n, ll r){
    if(r==0)
    return 1;
    ll ans=fact[n];
    ans=(ans*ifact[r])%mod;
    ans=(ans*ifact[n-r])%mod;
    return ans;
}
vector<vector<ll> > matmul(vector<vector<ll> > v1,vector<vector<ll> > v2){
    vector<vector<ll> > v(6,vector<ll>(6,0));
    fr(i,0,6){
        fr(j,0,6){
            fr(k,0,6)
            v[i][j]=(v[i][j]+ v1[i][k]*v2[k][j])%mod;
        }
    }
    return v;
}
vector<vector<ll> > matf(ll n){
    vector<vector<ll> >z={
    {1,1,1,1,1,1},
    {1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0}},
    r={{1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0},
    {0,0,0,0,0,1}};

    while(n>0){
        if(n&1){
            r=matmul(r,z);
        }
        z=matmul(z,z);
        n/=2LL;
    }
    return r;
}*/
void solve(){
    ll n;
    cin>>n;
    string s="";
    while(n>0){
        int x=n%26LL;
        if(x==0)
        x=26;
        n=(n-x)/26LL;
        s+='a'+x-1;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e18 + 7;
const int maxn = 3e3 + 10;
const int maxq = 5e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;


int dp[maxn][maxn];
pair<int,int> path[maxn][maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string z1,z2;
    cin>>z1>>z2;
    string s="",t="";
    s+=" ";
    s+=z1;
    t+=" ";
    t+=z2;
    for(int i=1;i<s.size();i++){
        for(int j=1;j<t.size();j++){
            if(s[i]==t[j]){
                dp[i][j] = dp[i-1][j-1]+1;
                path[i][j]={i-1,j-1};
            }
            else{
                if(dp[i-1][j]>dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                    path[i][j] = {i-1,j};
                }else{
                    dp[i][j] = dp[i][j-1];
                    path[i][j] = {i,j-1};
                }
            }
        }
    }
    string rre = "";
    string re = "";
    int i = s.size()-1,j=t.size()-1;
    while(i>0 && j>0){
        int x = path[i][j].first;
        int y = path[i][j].second;
        if(x==(i-1) && y==(j-1)){
            rre+=s[i];
        }
        i = x;
        j = y;
    }
    for(int z=rre.size()-1;z>=0;z--){
        re +=(rre[z]);
    }
    cout<<re<<endl;
    return 0;
}


Measured memory_bytes: 106368
# -*- coding: utf-8 -*-
# モジュールのインポート
import collections

# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for q in range(Q):
    B_q, C_q = list(map(int, input().split()))
    B.append(B_q)
    C.append(C_q)

# 求解処理
S = sum(A)
counter_A = collections.Counter(A)
for b, c in zip(B, C):
    S += (c - b) * counter_A[b]
    # 結果出力
    print(S)
    # カウンターの更新
    counter_A[c] += counter_A[b]
    counter_A[b] = 0


Measured memory_bytes: 30028
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<tuple<string, int, int>> S(n);
	for (int i = 0; i < n; i++)
	{
		string city;
		int score;
		cin >> city >> score;

		get<0>(S[i]) = city;
		get<1>(S[i]) = -score;
		get<2>(S[i]) = i+1;
	}
	sort(all(S));
	for (int i = 0; i < n; i++)
		cout << get<2>(S[i]) << endl;
}



Measured memory_bytes: 256
N, k = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans = 0
already = set()
for i in range(len(T)):
    t_now = T[i]
    point = 0
    if t_now == "r":
        point = P
    elif t_now == "p":
        point = S
    else:
        point = R

    if i >= k:
        t_before = T[i - k]
        if t_now == t_before and (i - k) not in already:
            point = 0
            already.add(i)
    ans += point
    # print(point)
print(ans)

Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int>>;

int N;
string s;

int main(){
    cin >> s;
    if(s == "AAA") cout << "No";
  else if(s == "BBB") cout << "No";  
  else cout << "Yes";
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int S[12][1000];

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

  int H, W, K;
  cin >> H >> W >> K;

  string s;
  rep(i, H){
    cin >> s;
    rep(j, W){
      if(s[j] == '0'){
        S[i][j] = 0;
      }else{
        S[i][j] = 1;
      }
    }
  }

  int ans = H * W * 10;

  for(int bit = 0; bit < (1 << H); bit++){
    
    set<int> kyokai;
    for(int i = 0; i < H-1; i++){
      int a, b;
      if(bit & (1<<i)){
        a = 1;
      }else{
        a = 0;
      }
      if(bit & (1<<(i+1))){
        b = 1;
      }else{
        b = 0;
      }
      if(a != b){
        kyokai.insert(i);
      }
    }
    kyokai.insert(H-1);
    int Nblock = kyokai.size();
    vector<int> sum_white(Nblock);
    
    vector<int> sum_cur(Nblock);
    rep(i, Nblock){
      sum_white[i] = 0;
      sum_cur[i] = 0;
    }

    int cnt_line = 0;
    bool ok1 = true;
    for(int j = 0; j < W; j++){
      // まず、該当のところ
      int ind = 0;
      int sum_= 0;
      for(int i = 0; i < H; i++){
        if(S[i][j] == 1){
          sum_++;
        }
        if(kyokai.find(i) != kyokai.end()){
          sum_cur[ind] = sum_;
          sum_ = 0;
          ind++;
        }
      }
      
      for(int i = 0; i < Nblock; i++){
        if(sum_cur[i] > K){
          ok1 = false;
          break;
        }
      }

      bool ok = true;

      for(int i = 0; i < Nblock; i++){
        if(sum_cur[i] + sum_white[i] > K){
          ok = false;
          break;
        }
      }

      if(ok){
        for(int i = 0; i < Nblock; i++){
          sum_white[i] += sum_cur[i];
          sum_cur[i] = 0;
        }
      }else{
        cnt_line++;

        for(int i = 0; i < Nblock; i++){
          sum_white[i] = sum_cur[i];
          sum_cur[i] = 0;
        }
      }
    }
    if(ok1){
      chmin(ans, (Nblock-1) + cnt_line);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}else if(a==b){
		printf("a == b\n");
	}else{
		printf("a > b\n");
	}
	
	
	return 0;
}



Measured memory_bytes: 2060
n = int(input())
arr = list(map(int, input().split(' ')))

start = 0 
end = n-1

s = e = 0
while start <= end:
    if s >= e:
        e += arr[end]
        end -= 1
    else:
        s += arr[start]
        start += 1

print(abs(s - e))


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(){
	string m[3];
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		string w = "NA";
		for(int i=0;i<3;i++){
			if(m[i][0] == m[i][1] && m[i][0] == m[i][2])
				if(m[i][0] != '+')w = m[i][0];
			if(m[0][i] == m[1][i] && m[0][i] == m[2][i])
				if(m[0][i] != '+')w = m[0][i];
		}
		if(m[0][0] == m[1][1] && m[0][0] == m[2][2])
			if(m[0][0] != '+')w = m[0][0];
		if(m[0][2] == m[1][1] && m[0][2] == m[2][0])
			if(m[0][2] != '+')w = m[0][2];
		
		std::cout << w << std::endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int n,a,cnt;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a=read();
		if(i%2 && a%2)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}
/*

*/


Measured memory_bytes: 3164
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");


signed main(){
    FASTER;
    int A,B;cin>>A>>B;
    int gcd=__gcd(A,B);
    int GCD=gcd;
    int ans=1;
    for(int i=2;i<=sqrt(GCD);i++){
        int flg=0;
        while(gcd%i==0){
            flg=1;
            gcd/=i;
        }
        ans+=flg;
    }
    if(gcd!=1)ans++;
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

struct node{ //update add, query max
	int s,e,m;
	ll val=0,lazy=0;
	node *l,*r;
	
	node (int _s,int _e){
		s=_s,e=_e,m=s+e>>1;
		
		if (s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	
	void propo(){
		if (lazy){
			val+=lazy;
			
			if (s!=e){
				l->lazy+=lazy;
				r->lazy+=lazy;
			}
			
			lazy=0;
		}
	}
	
	void update(int i,int j,ll k){
		if (s==i && e==j) lazy+=k;
		else{
			if (j<=m) l->update(i,j,k);
			else if (m<i) r->update(i,j,k);
			else l->update(i,m,k),r->update(m+1,j,k);
			
			l->propo(),r->propo();
			val=max(l->val,r->val);
		}
	}
	
	ll query(int i,int j){
		propo();
		
		if (s==i && e==j) return val;
		else if (j<=m) return l->query(i,j);
		else if (m<i) return r->query(i,j);
		else return max(l->query(i,m),r->query(m+1,j));
	}
}*root=new node(0,200005);

int n,k;
vector<int> s[200005];
vector<ii> e[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	
	int a,b,c;
	rep(x,0,k){
		cin>>a>>b>>c;
		s[a].push_back(c);
		e[b+1].push_back(ii(a-1,-c));
	}
	
	ll ans=0;
	
	rep(x,1,n+1){
		for (auto &it:s[x]) root->update(0,x-1,it);
		for (auto &it:e[x]) root->update(0,it.fi,it.se);
		
		ll curr=root->query(0,x-1);
		//cout<<curr<<endl;
		root->update(x,x,curr);
		ans=max(ans,curr);
	}
	
	cout<<ans<<endl;
}


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

using namespace std;

#define MAX 1000
#define INF (1e9)

struct Edge{
    int to,cost,c;
    Edge(int to,int cost,int c) :
        to(to),cost(cost),c(c) {}
};

int main(){
    int M,D,N,K;
    int d[MAX][1<<6];    
    while(cin >> M >> N >> K >> D, M){
        vector<Edge> G[MAX];
        vector<int> cake(M);
        for(int i = 0 ; i < M ; i++){
            cin >> cake[i];
        }
        int idx = 0,c;
        string a,b;
        map<string,int> mp;
        for(int i = 0 ; i < D ; i++){
            cin >> a >> b >> c;
            if(!mp.count(a)) mp[a] = idx++;
            if(!mp.count(b)) mp[b] = idx++;
            if(a[0] == 'C'){
                G[mp[b]].push_back(Edge(mp[a],c,a[1]-'1'));             
            }else{
                G[mp[b]].push_back(Edge(mp[a],c,-1));           
            }
            if(b[0] == 'C'){
                G[mp[a]].push_back(Edge(mp[b],c,b[1]-'1'));
            }else{
                G[mp[a]].push_back(Edge(mp[b],c,-1));           
            }

        }
        int s = mp["H"],t = mp["D"];
        for(int i = 0 ; i < MAX ; i++){
            for(int j = 0 ; j < (1<<6) ; j++){
                d[i][j] = INF;
            }
        }
        d[s][0] = 0;
        bool update = 1;
        while(update){
            update = 0;
            for(int i = 0 ; i < (int)mp.size() ; i++){
                for(int j = 0 ; j < (int)G[i].size() ; j++){
                    Edge e = G[i][j];
                    for(int S = (1<<6)-1 ; S >= 0 ; S--){
                        int ncost = d[i][S];
                        if(ncost == INF) continue;
                        ncost += e.cost*K;
                        if(e.c == -1){
                            if(ncost < d[e.to][S]){
                                d[e.to][S] = ncost;
                                update = 1;
                            }
                        }else{
                            if(S >> e.c & 1) continue;
                            if(ncost-cake[e.c] < d[e.to][S|(1<<e.c)]){
                                d[e.to][S|(1<<e.c)] = ncost-cake[e.c];
                                update = 1;
                            }
                        }
                    }
                }
            }
        }
        int res = INF;
        for(int i = 0 ; i < (1<<6) ; i++){
            res = min(res, d[t][i]);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1528
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

	string ans = s + t;
	REP(i, n+1) {
		if (s.substr(n - i, i) == t.substr(0, i)) {
			ans = s + t.substr(i, n);
		}
	}
	cout << ans.length() << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate
n, k = map(int, input().split())
A = list(map(int, input().split()))
Acum = [0]
Acum.extend(accumulate(A))

cnt = defaultdict(int)
for i in range(n):
    for j in range(i+1, n+1):
        beauty = Acum[j]-Acum[i]
        cnt[beauty] += 1


def check(x):
    res = 0
    for beauty, c in cnt.items():
        if x & beauty == x:
            res += c
    return k <= res


L = 0
R = 1 << 40
while L != R-1:
    M = (L+R)//2
    if check(M):
        L = M
    else:
        R = M
print(L)

Measured memory_bytes: 90596
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int N, temp;
  std::cin >> N;
  
  std::vector<int> pos;
  int max_pos = -1;
  int min_pos = 101;
  
  while (std::cin >> temp) {
    max_pos = std::max(max_pos, temp);
    min_pos = std::min(min_pos, temp);
    pos.emplace_back(temp);
  }
  
  int result = std::numeric_limits<int>::max();
  for (int i=min_pos; i<=max_pos; ++i) {
    int t = 0;
    for (auto &&e : pos) {
      t += (e - i) * (e - i);
    }
    result = std::min(result, t);
  }
  
  std::cout << result << "\n";
} 

Measured memory_bytes: 256
#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=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  if(n>1) ans+=n*(n-1)/2;
  if(m>1) ans+=m*(m-1)/2;
  cout << ans << endl;
}

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

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}



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

int main() {
  int n, m; cin>>n>>m;
  vector<vector<pair<int, int>>> g;
  vector<int> l(m), r(m), d(m);

  map<int, int> ma;
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int lt, rt, dt; cin>>lt>>rt>>dt;
    if (ma.find(lt) == ma.end()) {
      lt = ma[lt] = cnt;
      ++cnt;
    } else {
      lt = ma[lt];
    }
    if (ma.find(rt) == ma.end()) {
      rt = ma[rt] = cnt;
      ++cnt;
    } else {
      rt = ma[rt];
    }
    l[i] = lt;
    r[i] = rt;
    d[i] = dt;
  }

  g.resize(cnt);
  for (int i = 0; i < m; i++) {
    g[l[i]].emplace_back(r[i], d[i]);
    g[r[i]].emplace_back(l[i], -d[i]);
  }

  vector<int> dist(cnt, 1e9+1);
  for (int i = 0; i < cnt; i++) {
    if (dist[i] == 1e9+1) {
      dist[i] = 0;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int cur = q.front(); q.pop();
        for (auto nx: g[cur]) {
          int pos, diff;
          tie(pos, diff) = nx;
          if (dist[pos] != 1e9+1 and dist[pos] != dist[cur] + diff) {
            cout << "No" << endl;
            return 0;
          } else if (dist[pos] == 1e9+1) {
            dist[pos] = dist[cur] + diff;
            q.push(pos);
          }
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

struct PrimeSieve {
  size_t sz;
  vector<long long> min_div;
public:
  PrimeSieve(size_t sz) : sz(sz), min_div(sz+1,-1) {
    for(size_t i = 2; i*i <= sz; ++i){
      if(min_div[i] > 0) continue;
      for(size_t j = i+1; i*j <= sz; ++j){
        min_div[i*j] = i;
      }
    }
  }
  bool is_prime(size_t x){
    if(x > sz){
      cerr << x << endl;
    }
    assert(x <= sz);
    return min_div[x] < 0;
  }
};

int main(){
  PrimeSieve sieve(2e5);
  int X;
  cin >> X;
  while(1){
    if(sieve.is_prime(X)){
      cout << X << endl;
      return 0;
    }
    ++X;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll getMid(ll s, ll e)  
{ 
    return s + (e - s) / 2; 
} 
ll MaxUtil(ll* st, ll ss, ll se, ll l,  
            ll r, ll node) 
{ 
    if (l <= ss && r >= se) 
        return st[node]; 
  
    // If segment of this node does not 
    // belong to given range 
    if (se < l || ss > r) 
        return -1; 
  
    // If segment of this node is partially 
    // the part of given range 
    ll mid = getMid(ss, se); 
      
    return max(MaxUtil(st, ss, mid, l, r,  
                       2 * node + 1), 
               MaxUtil(st, mid + 1, se, l,  
                       r, 2 * node + 2)); 
} 
void updateValue(ll arr[], ll* st, ll ss, ll se,  
                 ll index, ll value, ll node) 
{ 
    if (index < ss || index > se)  
    { 
        return; 
    } 
      
    if (ss == se)  
    {    
        // update value in array and in segment tree 
        arr[index] = value; 
        st[node] = value; 
    } 
    else { 
            ll mid = getMid(ss, se); 
              
            if (index >= ss && index <= mid) 
                updateValue(arr, st, ss, mid, index,  
                            value, 2 * node + 1); 
            else
                updateValue(arr, st, mid + 1, se,  
                            index, value, 2 * node + 2); 
              
            st[node] = max(st[2 * node + 1],  
                       st[2 * node + 2]); 
    } 
    return; 
} 
ll getMax(ll* st, ll n, ll l, ll r) 
{ 
    // Check for erroneous input values 
    if (l < 0 || r > n - 1 || l > r)  
    { 
        return -1; 
    } 
  
    return MaxUtil(st, 0, n - 1, l, r, 0); 
} 
ll constructSTUtil(ll arr[], ll ss, ll se,  
                    ll* st, ll si) 
{ 
    if (ss == se)  
    { 
        st[si] = arr[ss]; 
        return arr[ss]; 
    } 
    ll mid = getMid(ss, se); 
      
    st[si] = max(constructSTUtil(arr, ss, mid, st,  
                                 si * 2 + 1), 
                 constructSTUtil(arr, mid + 1, se,  
                                 st, si * 2 + 2)); 
      
    return st[si]; 
} 
ll* constructST(ll arr[], ll n) 
{ 
    // Height of segment tree 
    ll x = (ll)(ceil(log2(n))); 
  
    // Maximum size of segment tree 
    ll max_size = 2 * (ll)pow(2, x) - 1; 
  
    // Allocate memory 
    ll* st = new ll[max_size]; 
  
    // Fill the allocated memory st 
    constructSTUtil(arr, 0, n - 1, st, 0); 
  
    // Return the constructed segment tree 
    return st; 
} 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	ll h[n],b[n];

	for(ll i=0;i<n;i++)
		cin>>h[i];
	for(ll i=0;i<n;i++)
		cin>>b[i];
	ll dp[n];
	for(ll i=0;i<n;i++)
		dp[i]=0;

	ll* st=constructST(dp,n);

	for(ll i=0;i<n;i++)
	{
		dp[h[i]-1]=getMax(st,n,0,h[i]-1)+b[i];
		updateValue(dp, st, 0, n - 1, h[i]-1, dp[h[i]-1], 0); 
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<endl;


}

Measured memory_bytes: 9088
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    if (X % 2 == 0 && X != 2) {
      X += 1;
    }
    while (true) {
      boolean A = isPrime(X);
      if (A) {
        System.out.println(X);
        break;
      } else {
        X += 2;
      }
    }
  }

  public static boolean isPrime(int num) {
    if (num < 2)
      return false;
    else if (num == 2)
      return true;
    else if (num % 2 == 0)
      return false; // 偶数はあらかじめ除く

    for (int i = 3; i < num; i += 2) {
      if (num % i == 0) {
        // 素数ではない
        return false;
      }
    }

    // 素数である
    return true;
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll N, K;
    cin >> N >> K;
    ll H[N];
    for(ll i = 0; i < N; i++) cin >> H[i];

    sort(H, H + N);
    ll ans = 0;
    for(ll i = 0; i < N - K; i++){
        ans += H[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, d := nextInt(), nextInt()
	xi, yi := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		xi[i], yi[i] = nextInt(), nextInt()
	}

	result := 0
	d2 := d * d
	for i := 0; i < n; i++ {
		if xi[i]*xi[i]+yi[i]*yi[i] <= d2 {
			result++
		}
	}

	fmt.Fprintln(out, result)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


Measured memory_bytes: 9220
N, K = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
    cost = 0
else:
    cost = 10 ** 11

for i in range(2 ** (N - 1)):
    r = str(format(i, 'b')).zfill(N - 1)
    ma = a[0]
    k = 1
    p = 0
    for j in range(N - 1):
        if r[j] == '1':
            k += 1
            if a[1 + j] > ma:
                ma = a[1 + j]
            elif a[1 + j] <= ma:
                p += ma - a[1 + j] + 1
                ma = ma + 1
        elif r[j] == '0':
            if a[1 + j] > ma:
                ma = a[1 + j]
    if k >= K and p < cost:
        cost = p

print(cost)

Measured memory_bytes: 3064
N = int(input())
hList = [int(i) for i in input().split()]

dp = [float("inf") for _ in range(N)]
dp[0] = 0
dp[1] = abs(hList[1] - hList[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(hList[i] - hList[i - 1]), dp[i - 2] + abs(hList[i] - hList[i - 2]))

print(dp[N - 1])



Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << 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...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    string s,t;cin>>s>>t;
    if(s==t.substr(0,s.size())) cout<<"Yes\n";
    else cout<<"No\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

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

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

int main()
{
    int A, B, C, K;

    cin >> A >> B >> C >> K;
    if (A >= K)
    {
        cout << K << "\n";
    } else if (A + B >= K)
    {
        cout << A << "\n";
    } else
    {
        cout << A - (K - (A + B)) << "\n";
    }
    
    return 0;
}

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

vector<int> A;

int main(void){
    int N; cin >> N;
    A.resize(N);
    int minA = 10000000;
    int maxA = -1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        minA = min(minA, A[i]);
        maxA = max(maxA, A[i]);
    }
    
    if (maxA - minA > 1) {
        cout << "No" << endl;
        return 0;
    } else if (maxA - minA == 1) {
        int color = maxA;
        int not_unique_hat = 0;
        int unique_hat = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] != maxA) {
                unique_hat++;
            } else {
                not_unique_hat++;
            }
        }
        if (color <= unique_hat) {
            cout << "No" << endl;
            return 0;
        }
        
        if (!(unique_hat + 1 <= color && color <= unique_hat + not_unique_hat/2)) {
            cout << "No" << endl;
            return 0;
        }
    } else if (maxA - minA == 0) {
        int color_if_all_hats_are_unique = maxA + 1;
        int color_if_all_hats_are_not_unique_lower = 1;
        int color_if_all_hats_are_not_unique_upper = N/2;
        if (N != color_if_all_hats_are_unique && !(color_if_all_hats_are_not_unique_lower <= maxA && maxA <= color_if_all_hats_are_not_unique_upper)) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{

    string a;
    cin>>a;
    if(a == "SUN"){
        cout<<"7";
    }
    else if(a == "MON"){
        cout<<"6";
    }
    else if(a == "TUE"){
        cout<<"5";
    }
    else if(a == "WED"){
        cout<<"4";
    }
    else if(a == "THU"){
        cout<<"3";
    }
    else if(a == "FRI"){
        cout<<"2";
    }
    else if(a == "SAT"){
        cout<<"1";
    }
    return 0;
}

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

int main() {
	string s; cin >> s;
	int l = s.size();
	int ans = 0;
	for (int i = 0; i < l / 2; i++) {
		if (s.at(i) != s.at(l - 1 - i)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string S, T; cin >> S >> T;

    if(S.length() < T.length()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    int index = S.length() - 1;
    bool ok = true;
    for(; index >= T.length()-1; --index) {
        ok = true;
        for(int j = 0; j < T.length(); ++j) {
            // cout << "S[" << index-j << "] = " << S[index-j] << ", T[" << T.length()-j-1 << "] = " << T[T.length()-j-1] << endl;
            if(S[index-j] != '?' && T[T.length()-j-1] != S[index-j]) {
                ok = false;
                break;
            }
        }

        if(ok) {
            break;
        }
    }

    if(ok) {
        for(int i = 0; i < T.length(); ++i) {
            S[index-i] = T[T.length()-1-i];
        }

        for(int i = 0; i < S.length(); ++i) {
            if(S[i] == '?') S[i] = 'a';
        }

        cout << S << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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







int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c,max(b*d,max(a*d,b*c)));
    cout  << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

vector<double> memo(200005);

double solveHope (int m) {
  if (memo.at(m) != 0) return memo.at(m);

  double sum = 0.0;
  FOR1(x, m) {
    sum += x / (double)m;
  }

  memo.at(m) = sum;

  return sum;
}


void solve(long long N, long long K, std::vector<long long> p){
  vector<double> hopes(N);
  REP(x, N) {
    hopes.at(x) = solveHope(p.at(x));
  }

  double sum = 0;
  double maxHopes = 0;
  REP(x, K){
    sum += hopes.at(x);
    maxHopes += hopes.at(x);
  }

  for(int x = K; x < N; x++) {
    sum += hopes.at(x);
    sum -= hopes.at(x - K);

    maxHopes = max(maxHopes, sum);
  }

  printf("%f\n", maxHopes);
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(N, K, std::move(p));
}


Measured memory_bytes: 4992