akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
template<typename T, typename C>
using PQ = priority_queue<T, vector<T>, C>;
using Complex = complex<double>;


int N;
VI fact;


void makeFact(){
    map<int, int> f;
    repe(i, 1, N){
        int n = i;
        repif(j, 2, j*j <= n)
            while(n%j == 0) f[j]++, n/=j;
        if(n != 1) f[n]++;
    }
    for(PII p : f) fact.pb(p.second+1);
}


int solve(int i = 0, int p = 1){
    if(p == 75) return 1;
    if(i == SIZE(fact) || p > 75) return 0;
    int ret = 0;
    repe(j, 1, fact[i]) ret += solve(i+1, p*j);
    return ret;
}


signed main(){
    cin >> N;

    makeFact();

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 256
int main(){
    
  int a,b,c;

  scanf("%d",&a);

  for(b = 1;b <= a;b++){

    c = b;

    if(c % 3 == 0){
      printf(" %d",b);
    }
    else{
      for(;c>0;){
        if(c % 10 == 3 && b != 3){
	  printf(" %d",b);
	  break;
        }
        
	else{
	  c = c / 10;
	}
      }
    }
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2056
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def bisect(a: "List[int]", x: int):
    lb = 0
    rb = len(a) + 1
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if a[m - 1] >= x:
            rb = m
        else:
            lb = m
    return lb


def solve(A: int, B: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
    for xk in x:
        i = bisect(s, xk)
        j = bisect(t, xk)
        m = float("inf")
        if i > 0 and j > 0:
            m2 = max(xk - s[i - 1], xk - t[j - 1])
            m = min(m, m2)
        if i > 0 and j < B:
            ld = xk - s[i - 1]
            rd = t[j] - xk
            m2 = min(ld + ld + rd, ld + rd + rd)
            m = min(m, m2)
        if i < A and j > 0:
            rd = s[i] - xk
            ld = xk - t[j - 1]
            m2 = min(ld + ld + rd, ld + rd + rd)
            m = min(m, m2)
        if i < A and j < B:
            m2 = max(s[i] - xk, t[j] - xk)
            m = min(m, m2)
        print(m)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    t = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(A, B, Q, s, t, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  string s, t;
  int dp[4001][4001];

  while(cin >> s >> t){
    int ans = 0;
    int sl = s.size(), tl = t.size();

    REP(i, sl){
      REP(j, tl) dp[i][j] = 0;
    }

    REP(i, sl){
      REP(j, tl){
        if(s[i] == t[j]){
          dp[i + 1][j + 1] = dp[i][j] + 1;
          ans = max(ans, dp[i][j] + 1);
        }
      }
    }
    cout << ans << endl;
  }
}



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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

// auto mod int
const int mod = 1000000007;
#pragma GCC diagnostic ignored "-Wshadow"
struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  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;
  }
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime 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;
  }
};
#pragma GCC diagnostic warning "-Wshadow"

struct Pattern {
  vector<int> val;
  Pattern(int n): val(n+1) {
    val[0] = 1;
    val[1] = 1;
    bool flag;
    REP(i, 1, n) {
      rep(k, 1 << i) {
        flag = true;
        rep(j, i-1) {
          if ((k >> j)*(k >> (j+1))&1) flag = false;
        }
        if (flag) val[i+1]++;
      }
    }
  }

  int score(int n) {
    return val[n];
  }
} p(8);

mint ans;
int H, W, K;


void Main() {
  cin >> H >> W >> K;
  vector<mint> dp[H+1];
  dp[0] = vector<mint>(W, 0);
  dp[0][0] = 1;
  rep(h, H) {
    dp[h+1] = vector<mint>(W, 0);
    REP(w, 1, W) dp[h+1][w-1] += dp[h][w] * p.score(w-1) * p.score(W-w-1);
    rep(w, W) dp[h+1][w] += dp[h][w] * p.score(w) * p.score(W-w-1);
    rep(w, W-1) dp[h+1][w+1] += dp[h][w] * p.score(w) * p.score(W-w-2);
  }
  cout << dp[H][K-1].x << endl;
}

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


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

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

    if (2*n <= m) {
        ans += n;
        m -= 2*n;
        n = 0;
    }
    ans += m/4;
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
#define ten5 100005

int num[ten5];
int ma[ten5];
int mi[ten5];

int main(void)
{
    int i;
    ll n,m;
    cin>>n;
    for(i=0;i<n;i++) cin>>num[i];
    ma[0]=num[0];mi[n-1]=num[n-1];
    for(i=1;i<n;i++)
    {
        ma[i]=max(ma[i-1],num[i]);
    }
    for(i=n-1;i>0;i--)
    {
        mi[i-1]=min(mi[i],num[i]);
    }
    for(i=0;i<n;i++)
    {
        if(ma[i]-mi[i]>=2)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	s := nextStr()

	for i := range s {
		if (int(s[i]) + n) > 'Z' {
			fmt.Printf("%c", (int(s[i]) + n - 'Z' + 'A' - 1))
		} else {
			fmt.Printf("%c", (int(s[i]) + n))
		}
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}


void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<int> d(n);
    if (n > 1) {
        d[0] = 1;
    }

    vector<bool> used(n);


    for (int i = 0; i < m; ++i) {
        int s, c;
        cin >> s >> c;
        --s;
        if (n > 1 && s == 0 && c == 0 ) {
            cout << -1 << "\n";
            return;
        }
        if (used[s] && d[s] != c ) {
            cout << -1 << "\n";
            return;
        }
        if (!used[s]) {
            used[s] = true;
            d[s] = c;
        }
    }

    vector<int> degs = {1, 10, 100};
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += degs[i] * d[n - i - 1];
    }
    cout << res << "\n";


}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, K, H[310], dp[310][310];
vector<ll> height;

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

/*ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void init()
{
	cin >> N >> K;
	height.push_back(0);
	for (int i = 1; i <= N; i++)
	{
		cin >> H[i];
		height.push_back(H[i]);
	}
	sort(height.begin(), height.end());
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	for (ll used = 0; used <= K; used++)
	{
		for (ll i = 0; i <= N + 1; i++)
		{
			dp[used][i] = INF;
		}
	}

	dp[0][0] = 0;
	
	for (ll used = 0; used <= K; used++)
	{
		for (ll i = 1; i <= N + 1; i++)
		{
			for (ll j = 0; j < i; j++)
			{
				if (used < i - j - 1) continue;
				dp[used][i] = min(dp[used - (i - j - 1)][j] + max(H[i] - H[j], (ll)0), dp[used][i]);
			}
		}
	}

	ans = INF;

	for (ll i = 0; i <= K; i++)
	{
		ans = min(ans, dp[K][N + 1]);
	}
}

int main()
{
	init();

	solve();

	

	output();

	cin >> N;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int n,t[100],m,p[100],x[100],i,j,sum = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&t[i]);
        sum += t[i];
    }
    scanf("%d",&m);
    for (i = 0; i < m; i++)
    {
        scanf("%d %d",&p[i],&x[i]);
    }

    for (i = 0; i < m; i++)
    {
        printf("%d\n",sum - t[p[i] - 1] + x[i]);
    }
    return 0;
}

Measured memory_bytes: 128
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long ans = 0;
    long k = 1;
    while(H >= 1){
      ans += k;
      k *= 2;
      H /= 2;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35484
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x
--------------------------------------------------------------
main = do
    n <- readLn :: IO Int
    sn <- replicateM n getLine
    m <- readLn :: IO Int
    tn <- replicateM m getLine
    
    let list = sn ++ tn
    let ans = [(length (filter (==x) sn)) - (length (filter (==x) tn)) |x <- list]
    
    print $ max (maximum ans) 0
    

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    string s, res;
    cin >> s;
    int c = 0;
    int r = 0;
    for (int i = 0; i < n; i++) {
        c += (s[i] == '(' ? 1 : -1);
        r = max(r, -c);
    }
    res = string(r, '(') + s;
    c += r;
    while (c > 0) {
        c--;
        res.push_back(')');
    }
    cout << res << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define MAX_N 50

int N,M,a[MAX_N],b[MAX_N];
vi vec;

void solve(){
    rep(i,M){
        vec[a[i]]++;
        vec[b[i]]++;
    }
    rep(i,N)
        cout << vec[i] << endl;
}

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

    vec.resize(N,0);

    rep(i,M){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    } 

    solve();
}


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

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


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

const int MAX = 510000;
const int MOD = 1000000007;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
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() {
    // 前処理
    COMinit();
    int n, k;
    cin >> n >> k;
    cout<<n-k+1<<endl;
    for (int i = 2; i <= k; i++) {
        ll ans = 0;
        if (n - k - 1 >= i - 2) {
            ans += COM(n - k - 1, i - 2);
        }
        if (n - k - 1 >= i-1) {
            ans += 2 * COM(n - k - 1, i-1);
            ans %= MOD;
        }
        if (n - k - 1 >= i ) {
            ans += COM(n - k - 1, i);
            ans %= MOD;
        }
        ans *= COM(k - 1, i - 1);
        ans %= MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 12160
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    m1, d1 = map(int, input().split())
    m2, d2 = map(int, input().split())

    print(1 if d2 == 1 else 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
long long int sum[200005];
int main(){
    long long int n,d,a;
    cin >> n >> d >> a;
    pair<int,long long int> p[n];
    for(int i=0;i<n;i++){
        cin >> p[i].first >> p[i].second;
        p[i].second = (p[i].second+a-1)/a;
    }
    sort(p,p+n);
    int r[n];
    int tmp=n-1;
    for(int i=n-1;i>=0;i--){
        while(p[tmp].first+2*d>=p[i].first && tmp>=0)tmp--;
        r[i]=tmp+1;
    }
    long long int ans=0;
    for(int i=0;i<n;i++){
        p[i].second-=(sum[i]-sum[r[i]]);
        sum[i+1]=sum[i]+max(0LL,p[i].second);
        ans+=max(0LL,p[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9008
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 5;
struct node{
    int parent,left,right,sib,dep,degree,height;
}tree[maxn];
void setDep(int u,int d){
    tree[u].dep = d;
    if(tree[u].left != -1)setDep(tree[u].left,d+1);
    if(tree[u].right != -1)setDep(tree[u].right,d+1);
}
int setHeight(int u){
    int h1 = 0,h2 = 0;
    if(tree[u].left != -1)
        h1 = 1 + setHeight(tree[u].left);
    if(tree[u].right != -1)
        h2 = 1 + setHeight(tree[u].right);
    return tree[u].height = (h1>h2?h1:h2);
}
int main()
{       
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        tree[i].parent = tree[i].left = tree[i].right= tree[i].dep = tree[i].sib = -1;
        tree[i].degree = tree[i].height = 0;
    }
     
    int id,l,r,rootid;
    for(int i=0;i<n;++i){    
        scanf("%d %d %d",&id,&l,&r);
        tree[id].left = l;
        tree[id].right = r;
        if(l!=-1){tree[l].parent = id;tree[id].degree++;tree[l].sib = r;}
        if(r!=-1){tree[r].parent = id;tree[id].degree++;tree[r].sib = l;}
         
    }   
     
    for(int i=0;i<n;++i)if(tree[i].parent == -1){rootid = i;break;}  
    setDep(rootid,0);
     
    setHeight(rootid);
     
    for(int i=0;i<n;++i){
        printf("node %d: parent = %d, sibling = %d, ",i,tree[i].parent,tree[i].sib);
        printf("degree = %d, depth = %d, height = %d, ",tree[i].degree,tree[i].dep,tree[i].height);
         
        if(tree[i].parent==-1)printf("root\n");
        else if(tree[i].left != -1 || tree[i].right != -1)printf("internal node\n");
        else printf("leaf\n");
    }
    return 0;
}

Measured memory_bytes: 3216
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, K, Q;
vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K >> Q;
  A.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> A[i];
    A[i]--;
  }

  vector<int> sum(N, 0);
  for (int i = 0; i < Q; i++) {
    sum[A[i]]++;
  }

  for (int i = 0; i < N; i++) {
    if (K - Q + sum[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
line = input()
n, t = [int(n) for n in line.split()]
min_coust = 0
route = 0
for _ in range(n):
    line = input()
    coust, time = [int(n) for n in line.split()]
    if min_coust == 0 and time <= t:
        min_coust = coust
    elif time <= t and coust <= min_coust:
        min_coust = coust
ans = "TLE" if min_coust== 0 else min_coust
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
   char S[100];
   int K;
   scanf("%d",&K);
   scanf("%s",S);
   int i;
   if(strlen(S)>K){
      for(i=0;i<K;i++){
         printf("%c",S[i]);
      }
      printf("...");
   }else{
      printf("%s",S);
   }
   return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL k, a, b;
    cin >> k >> a >> b;
    
    if( a + 1 >= b ) cout << k + 1 << endl;
    else {
        LL m = k % a;
        LL mu = k / a;
        if( mu == 0 ) {
            cout << k + 1 << endl;
            return 0;
        } else {
            LL koukan = k - (a - 1);
            LL ans = (b - a) * (koukan / 2) + a;
            if( koukan % 2 ) ++ans;
            cout << ans << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
  if(N>10)
    N=N%10;
  if(N==2||N==4||N==5||N==7||N==9)
    cout << "hon" << endl;
  if(N==0||N==1||N==6||N==8)
    cout << "pon" << endl;
  if(N==3)
    cout << "bon" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

void selectionsort(int *,int);

void selectionsort(int *A,int N)
{
  int a,minj,i,j,count=0;

  for(i=0;i<N-1;i++) {
    minj = i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj]) 
	minj = j;
    }
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
    if(i != minj)
    count++;
  }
    
  for(i=0;i<N;i++) {
    printf("%d",A[i]);
    if(i<N-1)printf(" ");
  }

  printf("\n");

  printf("%d\n",count);
}

int main()
{
    int N,A[100],i;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    scanf("%d",&A[i]);
    
    selectionsort(A,N);

    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N ; i++) {
    cin >> A.at(i);
  }
  int S = 0;
  for(int i = 0; i < N ; i++) {
    S += A.at(i);
  }
  int j = 0;
  while (S > 0) {
    S -= A.at(j) * 2;
    j++;
  }
  int T = S + A.at(j -1)*2;
  S = abs(S);
  int ans = min (S,T);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ac(n), wa(n);
    int AC = 0, WA = 0;
    rep(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC")
        {
            if (ac[p] == 1)
                continue;
            AC++;
            WA += wa[p];
            ac[p]++;
        }
        else
        {
            wa[p]++;
        }
    }
    cout << AC << " " << WA << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<stdio.h>
#define MAX 100000
#define SEN 2000000000

struct card{
  char suit;
  int value;
};
struct card R[MAX/2+2],L[MAX/2+2];

void merge(struct card *,int,int,int,int);
void mergesort(struct card *,int,int,int);
int partition(struct card *,int,int,int);
void quicksort(struct card *,int,int,int);

int main(){
  int n,i,s,stable;
  struct card A[MAX],B[MAX];
  char C[10];
  stable = 1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",C,&s);
    A[i].suit=B[i].suit=C[0];
    A[i].value=B[i].value=s;
  }
  mergesort(A,n,0,n);
  quicksort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit){
      stable  = 0;
    }
    }
  if(stable == 1){
      printf("Stable\n");
    }
    else printf("Not stable\n");
    for(i=0;i<n;i++){
      printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}
void merge(struct card A[],int n,int l,int m,int r){
  int k,i,j,n1,n2;
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++){
    L[i]=A[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[m+i];
  }
  L[n1].value=R[n2].value=SEN;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i].value <= R[j].value)A[k]=L[i++];
    else A[k] = R[j++];
  }
}
void mergesort(struct card A[],int n,int l,int r){
  int m1;
  if(l+1 < r){
    m1=(l+r)/2;
  mergesort(A,n,l,m1);
    mergesort(A,n,m1,r);
    merge(A,n,l,m1,r);
  }
}
int partition(struct card A[],int a,int b,int c){
  int i,j;
  struct card x,y;
  x=A[c];
  i=b-1;
  for(j=b;j<c;j++){
    if(A[j].value <= x.value){
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[c];
  A[c]=y;
  return i+1;
}
void quicksort(struct card A[],int n,int p,int r){
  int w;
  if(p < r){
    w = partition(A,n,p,r);
    quicksort(A,n,p,w-1);
    quicksort(A,n,w+1,r);
  }
}


Measured memory_bytes: 4044
W, H, N = map(int, input().split())

left = 0
right = W
bottom = 0
top = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  else:
    top = min(top, y)
    
print(max(0, (right-left)) * max(0, (top-bottom)))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++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;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);

    int t;
    map<string, int> m;
    map<string, int>::iterator itr;

    bool ac, wa, re, tle;

    string s;


    cin >> t;

    while(t--)
    {
        cin >> s;
        m[s]++;
    }

    ac = wa = re = tle = false;

    for(itr = m.begin(); itr != m.end(); itr++)
    {
        if(itr->first == "AC")
        {
            ac = true;
        }
        if(itr->first == "WA")
        {
            wa = true;
        }
        if(itr->first == "RE")
        {
            re = true;
        }
        if(itr->first == "TLE")
        {
            tle = true;
        }
        //cout << itr->first << " x " << itr->second << endl;
    }



    if(!ac)
    {
        cout << "AC x " << 0 << endl;
    }
    else{
        cout << "AC x " << m["AC"]  << endl;
    }

    if(!wa)
    {
        cout << "WA x " << 0 << endl;
    }
    else{
        cout << "WA x "  << m["WA"]  << endl;
    }

    if(!tle)
    {
        cout << "TLE x " << 0 << endl;
    }
    else{
        cout << "TLE x " << m["TLE"]  << endl;
    }

    if(!re)
    {
        cout << "RE x " << 0 << endl;
    }
    else{
        cout << "RE x " << m["RE"]  << endl;
    }




    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int seq=0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            seq++;
        }
    }
    cout<<seq<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int N, K;

int main(int argc, const char * argv[]) {
    cin >> N >> K;
    if (K == 1) {
        output(0);
    } else {
        output(N-K);
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main(){
	for(int i = 0; i < 7; i++){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",a-b);
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#define F first
#define S second
#define PB push_back
#define MP make_pair


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define INF 2000000000

const int max_n=1e9+1;
const ll mod=998244353;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    a=min(c,a-b);
    cout<<c-a;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int turtle_num;
		int turu_num;
		int turtle_legs;
		int turu_legs;

		int X, Y;
		X = sc.nextInt();
		Y = sc.nextInt();
		boolean hasKai=false;
		for (turtle_num = 0; turtle_num <= X; turtle_num++) {
			turu_num = X - turtle_num;
			turtle_legs = 4 * turtle_num;
			turu_legs = 2 * turu_num;
			if (turtle_legs + turu_legs == Y) {
				hasKai=true;
				break;
			}
		}
		if(hasKai) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 35740
input_number = gets.chomp.to_i
total = 0
1.upto(input_number){|n|
    if (1 <= n and n <= 9)
        total += 1
    elsif(100 <= n and n <= 999)
        total += 1
    elsif(10000 <= n and n <= 99999)
        total += 1
    end
}
puts total

Measured memory_bytes: 1788
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

H,W = mint()
A = [input() for _ in range(H)]
I = []
J = []

for i in range(H):
    for j in range(W):
        if A[i][j]=='#':
            I.append(i)
            break

for j in range(W):
    for i in range(H):
        if A[i][j]=='#':
            J.append(j)
            break

            
S = [[0]*len(J) for _ in range(len(I))]

for i in range(len(I)):
    for j in range(len(J)):
        print(A[I[i]][J[j]],end='')
    print('')

Measured memory_bytes: 75308
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main() {
	string n;
	cin >> n;
	int ans = 700;

	for (int i = 0; i < 3; i++) {
		if (n[i] == 'o') {
			ans += 100;
		}
		else {
			ans += 0;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) return (aa<bb)?aa:bb
#define max(aa,bb) return (aa<bb)?bb:aa

int main(){
	double n;
	scanf("%lf",&n);
	int x[100000],y[100000];
	Fori(n)scanf("%d%d",&x[i],&y[i]);
	double sum[100000];
	int k=0;
	Fori(n)for(int j=i+1;j<n;j++){
		sum[k]=sqrt(((x[j]-x[i])*(x[j]-x[i]))+((y[j]-y[i])*(y[j]-y[i])));
		k++;
	}
	double ans=0.0;
	for(int i=0;i<k;i++){
		ans+=sum[i]*(double)(n-1);
	}

	printf("%.10lf\n",ans/(double)(k));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int i,j,H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W == 0) break;
		else if(H ==0 || W == 0) printf("\n");
		else {
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
			for(i=1;i<(H-1);i++){
				printf("#");
				for(j=1;j<(W-1);j++){
					printf(".");
				}
				printf("#");
				printf("\n");
			}
			for(j=0;j<W;j++){
				printf("#");
			}
			
			printf("\n");
		}
	printf("\n");
	}
	return 0;
}

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

using namespace std;

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

    vector<int> heap(h + 1);
    for (int i = 1; i <= h; ++i)
        cin >> heap[i];

    for (int i = 1; i <= h; ++i) {
        cout << "node " << i << ": key = " << heap[i];
        if (i > 1)
            cout << ", parent key = " << heap[i / 2];

        int left_idx = i * 2;
        int right_idx = i * 2 + 1;
        if (left_idx <= h)
            cout << ", left key = " << heap[left_idx];
        if (right_idx <= h)
            cout << ", right key = " << heap[right_idx];
        cout << ", \n";
    }
}



Measured memory_bytes: 3076
require 'prime'
lr = Array.new(gets.chomp.to_i) { gets.chomp.split.map(&:to_i) }

sums = Array.new(10 ** 5 + 1, 0).tap do |y|
  (1..10**5).each do |i|
    y[i] = y[i-1] + (Prime.prime?(i) && Prime.prime?((i+1)/2) ? 1 : 0)
  end
end

lr.each do |l, r|
  puts sums[r] - sums[l-1]
end


Measured memory_bytes: 12564
// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    int_fast64_t n, m;
    cin >> n >> m;

    int_fast64_t ans = 1;
    for (int_fast64_t i = 2; i * i <= m; i++) {
        if (m % i != 0) continue;
        if (m / i >= n)
            ans = max(ans, i);
        if (i >= n)
            ans = max(ans, m / i);
    }
    if (n == 1) ans = max(ans, m);
    cout << ans;

    return 0;
}

/*
  Raise your standard.
*/

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
using namespace std;
typedef string::const_iterator State;

set<int> expression(State &begin);
set<int> term(State &begin);
set<int> factor(State &begin);
set<int> elem(State &begin);

map<char, set<int>> m;
set<int> all;

set<int> expression(State &begin){
    set<int> ret = term(begin);
    while(1){
        if(*begin == 'i'){
            begin++;
            set<int> tmp = term(begin), res;
            for(int val : ret)  if(tmp.count(val))  res.insert(val);
            ret = res;
        }else if(*begin == 'u'){
            begin++;
            set<int> tmp = term(begin);
            for(int val : tmp)  ret.insert(val);
        }else if(*begin == 'd'){
            begin++;
            set<int> tmp = term(begin), res;
            for(int val : ret)  if(tmp.count(val) == 0) res.insert(val);
            ret = res;
        }else if(*begin == 's'){
            begin++;
            set<int> tmp = term(begin), res;
            for(int val : ret)  if(tmp.count(val) == 0) res.insert(val);
            for(int val : tmp)  if(ret.count(val) == 0) res.insert(val);
            ret = res;
        }else{
            break;
        }
    }
    return ret;
}

set<int> term(State &begin){
    if(*begin == 'c'){
        begin++;
        set<int> tmp = factor(begin);
        set<int> ret;
        for(int x : all)    if(tmp.count(x) == 0)   ret.insert(x);
        return ret;
    }else{
        return factor(begin);
    }
}

set<int> factor(State &begin){
    if(*begin == '('){
        begin++;
        set<int> tmp = expression(begin);
        begin++;    // )
        return tmp;
    }else{
        return elem(begin);
    }
}

set<int> elem(State &begin){
    set<int> ret = m[*begin];
    begin++;
    return ret;
}

int main(){
    char c;
    int n;
    while(cin >> c >> n){
        m.clear();
        all.clear();
        while(c != 'R'){
            for(int i = 0; i < n; i++){
                int x;  cin >> x;
                m[c].insert(x);
                all.insert(x);
            }
            cin >> c >> n;
        }
        string s;
        cin >> s;
        State it = s.begin();
        set<int> res = expression(it);
        if(res.size()){
            for(set<int>::iterator it = res.begin(); it != res.end(); it++){
                if(it != res.begin())   cout << " ";
                cout << *it;
            }
            cout << endl;
        }else{
            cout << "NULL" << endl;
        }
    }
    return 0;
}


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

int main()
{
    ll N,C,K;
    cin >> N >> C >> K;
    vector<ll> T(N);

    for(ll i = 0; i < N; i++)
    {
        cin >> T.at(i);
    }
    sort(T.begin(),T.end());

    ll num = 0;
    ll bus = 1;
    ll mintmp = T.at(0);

    for(ll i = 0; i < N - 1; i++)
    {
        num++;
        if((mintmp + K) < T.at(i+1) || num == C)
        {
            num = 0;
            bus++;
            mintmp = T.at(i+1);
        }
    }

    cout << bus << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    string s, t;
    cin >> s >> t;
    rep(i,0,s.size())
    {
        if(s[i] != t[i])
        {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin >> t; while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;


 
int main() {
  string S;
  cin >> S;
  int num=0;
  int ans=0;
  for (auto i : S){
    if(i=='A' || i=='C' || i=='G' || i=='T'){
      num++;
      ans =max(ans, num);
    }
    else{
      num=0;
    }    
  }
  cout << ans ;

  return 0;
   

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map <string,int> mp;
 
int main(){
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    mp.clear();
    string a;
    map <string,int> point;
    for(int i=0;i<n;i++){
      int m;
      cin>>a>>m;
      mp[a]=0;
      point[a]=0;
      for(int j=0,b;j<m;j++) cin>>b,mp[a]|=(1<<b);
    }
 
 
    for(int i=0;i<=30;i++){
      int sum=n+1;
      for(auto it=mp.begin();it!=mp.end();it++) sum-=((mp[it->first]>>i)&1);
 
      for(auto it=mp.begin();it!=mp.end();it++)
    if((mp[it->first]&1<<i))point[it->first]+=sum;
    }
    int ans=1e9;
    string str;
    for(auto it=mp.begin();it!=mp.end();it++)
      if(ans>point[it->first])ans=point[it->first],str=it->first;
    cout <<ans<<" " <<str<<endl;
  }
  return 0;
}

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		A[0] = sc.nextInt();
		int temp = A[0];
		for(int i = 1; i < N; i++) {
			A[i] = sc.nextInt();
			temp = gcd(temp, A[i]);
		}
		System.out.println(temp);
		
	}
	
	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a % b) : a;
	}
}


Measured memory_bytes: 48088
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min(a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i))
    print(a[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n); for(int & v : a) cin >> v;
  vector<vector<long long> > f(n, vector<long long>(n, 0));
  vector<long long> p(n, a[0]);
  for(int i = 1; i < n; i++) p[i] = p[i - 1] + a[i];
  auto get = [&](int l, int r){
    long long ans = p[r];
    if(l) ans -= p[l - 1];
    return ans;
  };
  for(int i = 1; i < n; i++){
    for(int j = 0; j < n-i; j++){
      int l = j, r = j + i;
      f[l][r] = 1ll<<62;
      long long inc = get(l, r);
      for(int k = l; k < r; k++){
        f[l][r] = min(f[l][r], f[l][k] + f[k+1][r]);
      }
      f[l][r] += inc;
    }
  }
  cout << f[0][n-1] << endl;
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main(){
  int N,A[100],count = 0;;
  
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> A[i];
  }

  for (int i=0;i<N;i++) {
    int minj = i;
    for (int j=i;j<N;j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if (i != minj) {
      int tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      count++;
    }

  }

  for (int i=0;i<N-1;i++) {
    cout << A[i] << " ";
  }
  cout << A[N-1] << endl;
  cout << count << endl;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<string>
using namespace std;

struct restraunt
    {
    string name;
    int id;
    int point;

    bool operator<(const restraunt& another) const {
    if (name == another.name && point != another.point){
        return point > another.point;
    }
    return name < another.name; // 高い順に並べたいので演算子を逆に

  }
};

int main(){
    vector<restraunt> restraunts;
    int N;
    int i;
    cin >> N;
    for(i = 0; i < N; i++){
        restraunt rest;
        cin >> rest.name >> rest.point;
        rest.id = i + 1;
        restraunts.push_back(rest);
    }
    sort(restraunts.begin(), restraunts.end());
    for(i = 0; i < N; i++){
        cout << restraunts[i].id << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int k, x, m;
	scanf("%d %d", &k, &x);
	k>=1;
	k<=100;
	x>=1;
	x<=100000;
	
	m = k*500;
	if(m>x-1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 3136
n,k = map(int,input().split())

# Function of Combination mod M
# set n >= max p expected
M = 10**9+7


if k >= n-1:
    fac = [1]+[0]*(2*n-1)
    for i in range(1,2*n): fac[i] = fac[i-1]*i %M
    comb = lambda p,q:(fac[p]*pow(fac[q],M-2,M)*pow(fac[p-q],M-2,M))%M
    y = comb(2*n-1,n-1)
    
else:
    y = 1
    c1,c2=1,1
    for i in range(1,k+1):
        p = pow(i,M-2,M)
        c1 = c1*(n+1-i)*p%M
        c2 = c2*(n-i)*p%M
        y += c1*c2%M
        # y = (y+c1*c2)%M
print(y%M)


Measured memory_bytes: 18748