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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s; cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
    cout << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll h,n;
  cin>>h>>n;ll a[n],b[n];
  vector<ll> dp(h+1, 1LL<<60);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  dp[0]=0;
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<n;j++)
    {
      ll x=i+a[j];x=min(h,x);
      dp[x]=min(dp[x],dp[i]+b[j]);
    }
    
  }
  cout<<dp[h];
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

  int N,i,j,k,v,count=0;

  scanf("%d", &N);
  int A[N];

  for(i=0;i<N;i++)scanf("%d",&A[i]);
  
  for( i = 0 ; i < N-1 ; i++){
    for( j = N-1 ; j > i ; j--){      
      if(A[j] < A[j-1]){
	v = A[j];
	A[j] = A[j-1];
	A[j-1] = v;  
	count++;	
      }
    }
  }
  printf("%d",A[0]);
  for(k=1;k<N;k++)printf(" %d",A[k]);
  printf("\n%d\n",count);
  
 return 0;

}



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

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

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int a, b, c;
    cin >> a >> b >> c;

    if(a+b == c || a+c == b || b+c == a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  constexpr int INF = 1000000;
  vector<int> A(N), B(N+1, INF);
  for(int i = 1; i <= N - 1; ++i)cin >> B[i];
  for(int i = 0; i < N; ++i)
  	A[i] = min(B[i], B[i + 1]);
  int ans = accumulate(begin(A), end(A), 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define true 1
#define false 0

int n,A[50];

int solve(i, m){
    if( m == 0){
     return true;
   }if( i >= n){
     return false;
  } int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return res;
 }
int main(){
  int p,N,j;

  scanf("%d",&n);
  for(j=0;j<n;j++){
    scanf("%d",&A[j]);
  }scanf("%d",&p);
  for(j=0;j<p;j++){
    scanf("%d",&N);
    if(solve(0,N)) printf("yes\n");
    else printf("no\n");
  }
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

char get_char(i32 d) {
    return (char)('a' + d);
}

void Main() {
    i64 N;
    cin >> N;
    string ans = "";
    while (N != 0) {
        N--;
        ans = (char)('a' + (N % 26)) + ans;
        N /= 26;
    }
    cout << ans << endl;


}


Measured memory_bytes: 3652
#include "stdio.h"
#include "string.h"
#include <algorithm> //排序
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
	int HW[101][101];
	int count[10001];
	int H, W, N, i = 1, j = 1, x = 1;
	cin >> H >> W >> N;
	for (int n = 1; n <= N; n++) {
		cin >> count[n];
	}
	for (int n = 1; n <= N; n++) {
		int number = 0;
		for (; i <= H * W; ) {
			if (i%W == 0) {
				HW[j][x] = n;
				j++;
				i++;
				number++;
				if (number >= count[n])
					break;
			}
			else if (j % 2 == 0) {
				HW[j][x--] = n;
				i++;
				number++;
				if (number >= count[n])
					break;
			}
			else if (j % 2 != 0) {
				HW[j][x++] = n;
				i++;
				number++;
				if (number >= count[n])
					break;
			}
		}
	}
	for (int m = 1; m <= H; m++) {
		for (int n = 1; n <= W; n++) {
			cout << HW[m][n] << " ";
		}
		cout << "\n";
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];
  vector<ll> B(N+1);
  rep(i,N) B[i+1]=B[i]+A[i];
  ll ans=B[N];
  rep(i,N){
    ans=min(ans,abs(B[N]-B[i]*2));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
ab = []

n, m = list(map(int, input().split()))
for i in range(n):
  ab.append(list(map(int, input().split())))
  
ab.sort()

drink = 0
money = 0

while True:
  for i in range(n):
    if ab[i][1] + drink >= m:
      money += ab[i][0] * (m - drink)
      print(money)
      exit()
    else:
      money += ab[i][0] * ab[i][1]
      drink += ab[i][1]

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

int main()
{
    double w;

    while( cin >> w )
    {
        if( w <= 48.00 )
            cout << "light fly" << endl;
        else if( w <= 51.00 )
            cout << "fly" << endl;
        else if( w <= 54.00 )
            cout << "bantam" << endl; 
        else if( w <= 57.00 )
            cout << "feather" << endl;
        else if( w <= 60.00 )
            cout << "light" << endl;
        else if( w <= 64.00 )
            cout << "light welter" << endl;
        else if( w <= 69.00 )
            cout << "welter" << endl;
        else if( w <= 75.00 )
            cout << "light middle" << endl;
        else if( w <= 81.00 )
            cout << "middle" << endl;
        else if( w <= 91.00 )
            cout << "light heavy" << endl;
        else 
            cout << "heavy" << endl;
    }

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
main () {
	string str;
	while(cin >> str) {
		int sum = 0;
		for (int i=0; i<str.length(); i++) {
			sum += str[i] - 48;
		}
		if (sum == 0) break;
		cout << sum << endl;
	}
}

Measured memory_bytes: 3176
package main

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

var (
	uft  []int
	rank []int
	ch   []int
	ans  []int64
)

func find(x int) int {
	if uft[x] == x {
		return x
	}

	uft[x] = find(uft[x])
	return uft[x]
}

func union(a, b, i int) {
	ans[i-1] = ans[i]
	ar, br := find(a), find(b)
	if ar == br {
		return
	}

	ans[i-1] -= int64(ch[ar] * ch[br])

	if rank[ar] < rank[br] {
		uft[ar] = uft[br]
		ch[br] += ch[ar]
		return
	} else if rank[ar] == rank[br] {
		rank[ar]++
	}
	uft[br] = uft[ar]
	ch[ar] += ch[br]
}

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	uft = make([]int, n+1)
	rank = make([]int, n+1)
	ch = make([]int, n+1)
	for i := range uft {
		uft[i] = i
		ch[i] = 1
	}

	ans = make([]int64, m)
	ans[m-1] = int64(n * (n - 1) / 2)
	for i := m - 1; i >= 1; i-- {
		union(as[i], bs[i], i)
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 7552
import sys
import os
from collections import deque

def file_input():
    f = open('ABC168/input.txt', 'r')
    sys.stdin = f

def main():
    if os.getenv("ENV")=='LOCAL':
        file_input()

    N,M=map(int, input().split())
    r={}
    for i in range(M):
        A,B=map(int, input().split())
        # print("A:"+str(A[i])+" B:"+str(B[i]))
        if A not in r:
            r[A]=[B]
        else:
            r[A].append(B)
        if B not in r:
            r[B]=[A]
        else:
            r[B].append(A)
        # print(tmp[A[i]-1])
    # print(r)

    q=deque()
    q.append(1)
    visited=set()
    visited.add(1)
    out=[0]*(N-1)
    while len(q)>0:
        # print("q="+str(q))
        position=q.popleft()
        # print("p="+str(position))
        for des in r[position]: #今いる場所から行ける場所を探索
            if des not in visited:  #訪問済みでないなら
                q.append(des)   #行ける場所だった場合キューに追加
                visited.add(des)   #訪問済みにする
                out[des-2]=position
                # print("destination="+str(des)+" p="+str(position)+" q="+str(q))
    # print(visited)



    print('Yes')
    [print(x) for x in out]

if __name__ == '__main__':
    main()


Measured memory_bytes: 46464
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Measured memory_bytes: 4468
import numpy as np

n = int(input())
B = list(map(int, input().split()))
A = [0]*n
A[0] = B[0]
A[n-1] = B[n-2]
for i in list(range(1,n-1)):
    A[i] = min(B[i-1], B[i])
print(sum(A))

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int a,b,c;cin>>a>>b>>c;bool ans=0;
    for(int i=1;i<b;i++){
        if(i*a%b==c) ans=1;
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1234567890;

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

  int N;
  while(cin>>N,N){
	int lb = -INF, ub = INF; // x is in [lb, ub]
	VI vi, xs;
	vi.PB(INF);
	REP(i,N){
	  string s; cin >> s;
	  if(s == "x"){
		vi.PB(-INF);
		xs.PB(i+1);
	  }else{
		int n;
		stringstream ss(s);
		ss >> n;
		vi.PB(n);
	  }
	}

	for(int i: xs){
	  if(i % 2)
		ub = min(ub, min(vi[i-1]-1, (i==N? INF: vi[i+1]-1)));
	  else
		lb = max(lb, max(vi[i-1]+1, (i==N? -INF: vi[i+1]+1)));
	}
	for(int i=1;i<N;++i){
	  if(vi[i] == -INF) continue;
	  if(i % 2){
		if(vi[i+1] != -INF && vi[i] >= vi[i+1])
		  lb = ub+1;
	  }
	  else
		if(vi[i+1] != -INF && vi[i] <= vi[i+1])
		  lb = ub+1;
	}
	
	if(lb == ub)
	  cout << lb << endl;
	else if(lb < ub)
	  cout << "ambiguous" << endl;
	else
	  cout << "none" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1264
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        int x = i;
        int cnt = 0;
        while (x > 0) {
            x /= 10;
            ++cnt;
        }
        if (cnt & 0x1) {
            ++res;
        }
    }
    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = []
num = m
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
ab.sort()
ans = 0
for i in ab:
    if i[1] >= num:
        ans += i[0]*num
        break
    else:
        ans += i[0]*i[1]
        num -= i[1]
print(ans)
        

Measured memory_bytes: 20048
#include<stdio.h>

void proc(int n,int x){
  int cnt=0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
	  for(int k=j+1;k<=n;k++){
	    if(i+j+k==x)++cnt;
		else if(i+j+k>x)break;
	  }
	}
  }
  printf("%d\n",cnt);
}

int main(){
  while(true){
    int a,b;
	scanf("%d%d",&a,&b);
	if(!a&&!b)break;
	proc(a,b);
  }
  return 0;
}

Measured memory_bytes: 1012
#整数の入力

# A = int(input())
# B = int(input())

A, B = map(int, input().split())

# 和、差、積を順に求めて最大値を出力する

if (A + B) > (A - B):
	MAX = (A + B)
else:
	MAX = (A - B)

if MAX > (A * B):
	print(MAX)
else:
	print(A * B)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
 
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int h, w, m;
    cin >> h >> w >> m;
    int x, y;
    int row[h + 1], col[w + 1];
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    set<pair<int, int>> s;
    for (int i = 1; i <= m; i++)
    {
        cin >> x >> y;
        s.insert({x, y});
        row[x]++;
        col[y]++;
    }
    x = 1;
    y = 1;
    for (int i = 1; i <= h; i++)
    {
        if (row[i] > row[x])
            x = i;
    }
    for (int i = 1; i <= w; i++)
    {
        if (col[i] > col[y])
            y = i;
    }
    int ans = 0;
    for (int i = 1; i <= w; i++)
    {
        if (s.find({x, i}) != s.end())
        {
            ans = max(ans, row[x] + col[i] - 1);
        }
        else
        {
            ans = max(ans, row[x] + col[i]);
        }
    }
    for (int i = 1; i <= h; i++)
    {
        if (s.find({i, y}) != s.end())
        {
            ans = max(ans, row[i] + col[y] - 1);
        }
        else
        {
            ans = max(ans, row[i] + col[y]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 20020
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    char a[30];
    cin>>a;
    for(int i=0;i<3;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 3620
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let r = scan "%f" id

let () =
  Printf.printf "%.10f\n" @@ 2.0 *. Float.pi *. r


Measured memory_bytes: 5532
#include <bits/stdc++.h>
int MOD;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline void Add(int &a,int b)
{a+=b;a>=MOD?a-=MOD:1;}
using namespace std;
const int Q=156;
int pp[Q];
int f[2][Q][Q];
int main()
{
	int n,k;
	scanf("%d%d%d",&n,&k,&MOD);
	if((k&1)^1){
		pp[0]=1;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=(k>>1)&&j<i;j++)
				pp[i]=add(pp[i],pp[i-j-1]);
		return 0&printf("%lld\n",1LL*pp[(n>>1)+1]*pp[n-(n>>1)+1]%MOD);
	}
	int now=0,nxt=1;
	for(int pi=1,i=(k>>1)+1;i>=0;--i){
		f[now][0][i]=pi;
		if(i!=(k>>1)+1)pi=add(pi,pi);
	}
	for(int owo=2;owo<=n;owo+=2){
		for(int i=0;i<=k+1;i++)
			fill(f[nxt][i],f[nxt][i]+k+2,0);
		for(int i=0;i<=k+1;i++)
			for(int j=0;j<=k+1;j++){
				if(owo+k<=n)Add(f[nxt][max(i+1,j+2)][min(j+1,k+1)],f[now][i][j]);
				Add(f[nxt][i?i+1:0][0],f[now][i][j]);
				if(owo+k<=n)Add(f[nxt][0][min(j+1,k+1)],f[now][i][j]);
				Add(f[nxt][0][0],f[now][i][j]);
			}
		now^=1,nxt^=1;
	}
	int als=0;
	for(int i=0;i<=k+1;i++)
		for(int j=0;j<=k+1;j++)
			Add(als,f[now][i][j]);
	printf("%d\n",als);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
using ll = long long;
int main(void) {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	ll dist = abs(a - b);
	YES(dist - t * (v - w) <= 0);
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define make_pair mp
#define pb push_back
#define pf push_front
#define all(vec) vec.begin(),vec.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define lli long long int
using namespace std;
int main(){
  fast;
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  int dp[n][3];
  dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
//   cout<<dp[n-1][0]<<endl<<dp[n-1][1]<<endl<<dp[n-1][2]<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >>b;

    int mx = max(a, b);
    int mi = min(a, b);

    for(int i = 0; i < mx; i++) {
        cout << mi ;
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
s=[['.']*100 for i in range(50)]+[['#']*100 for i in range(50)]
a,b=map(int, input().split())
a-=1
b-=1
a1,a2=a%50,a//50
b1,b2=b%50,b//50
for i in range(b2):
    for j in range(50):s[i*2][j*2]='#'
for j in range(b1):s[48][j*2]='#'
for i in range(a2):
    for j in range(50):s[51+i*2][j*2]='.'
for j in range(a1):s[98][j*2]='.'
print(100,100)
for i in s:print(''.join(i))

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

struct Node{int p,l,r;};
typedef struct Node Node;
Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].l,d + 1);
    setDepth(T[u].r,d + 1);
}

int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].l!=NIL) h1 = setHeight(T[u].l) + 1;
    if(T[u].r!=NIL) h2 = setHeight(T[u].r) + 1;
    if(h1>h2) return H[u]=h1;
    else return H[u]=h2; 
}

int getSibling(int u){
    if(T[u].p == NIL) return NIL;
    if(T[T[u].p].l != u && T[T[u].p].l != NIL)
        return T[T[u].p].l;
    if(T[T[u].p].r != u && T[T[u].p].r != NIL)
        return T[T[u].p].r;
    return NIL;
}

void print(int u){
     printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));

     int deg = 0;
     if(T[u].l!=NIL) deg++;
     if(T[u].r!=NIL) deg++;
     printf("degree = %d, ",deg);
     printf("depth = %d, ",D[u]);
     printf("height = %d, ",H[u]);


    if(T[u].p == NIL){
        printf("root\n");
    }
    else if(T[u].l == NIL && T[u].r == NIL){
        printf("leaf\n");
    }   
    else{
        printf("internal node\n");
    }
}

int main(){
    int v,l,r,root = 0,i;
    scanf("%d",&n);

    for(i = 0;i<n;i++)
    T[i].p = NIL;
    for(i = 0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }
    for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
    setDepth(root,0);
    setHeight(root);
    for(i=0;i<n;i++) print(i);
    return 0;
}


Measured memory_bytes: 2104
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

string s;
vector<int> Fx, Fy;
int n, m;

#define RIGHT 0
#define DOWN 1
#define LEFT 2
#define UP 3

bool dpx[18000][9000];
bool dpy[18000][9000];

void dfs(int x, int i, int n, int tgt, bool dp[18000][9000], vector<int> &F) {
  // print(vector{ x-9000, i });
  assert(x >= 0);
  if (dp[x][i]) return;
  dp[x][i] = true;
  if (i>=n) return;
  int f = F[i];
  dfs(x - f, i + 1, n, tgt, dp, F);
  dfs(x + f, i + 1, n, tgt, dp, F);
}

int main() {
  in(s);
  int tgt_x, tgt_y;
  in(tgt_x); in(tgt_y);
  tgt_x += 9000;
  tgt_y += 9000;
  n = s.size();
  int cnt = 0;
  vector<int> F;
  loop(i,0,n) {
    if (s[i] == 'F') cnt++;
    else {
      F.push_back(cnt);
      cnt = 0;
    }
  }
  F.push_back(cnt);
  tgt_x -= F[0];
  n = F.size();
  loop(i,0,n) {
    if (i==0) continue;
    if (i%2==0) Fx.push_back(F[i]);
    else Fy.push_back(F[i]);
  }
  n = Fx.size();
  m = Fy.size();
  // print(Fx);
  // print(Fy);
  // print("=========");
  
  dfs(9000, 0, n, tgt_x, dpx, Fx);
  // print("==========");
  dfs(9000, 0, m, tgt_y, dpy, Fy);
  if (dpx[tgt_x][n] and dpy[tgt_y][m]) print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 66020
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	vector<vector<int>> v1(26), v2(26);
	for(int i = 0; i < s.length(); i++) {
		v1[s[i]-'a'].push_back(i);
		v2[t[i]-'a'].push_back(i);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	if(v1 == v2) cout << "Yes";
	else cout << "No";
	return 0;
}


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

using namespace std;


int main()
{
  int64_t a,b,c;

  cin >> a >> b >> c;

  if(a < (b + c))
    {
      cout << (b + c) - a << endl;
    }
  else
    {
      cout << 0 << endl;
    }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll n;
	cin>>n;
	vector<ll> a,b;
	vector< pair<ll,ll> > dval;
	ll rem=0;
	for(int i=0;i<n;i++){
		ll ta,tb;
		cin>>ta>>tb;
		a.pb(ta);
		b.pb(tb);
	}
	ll ans = 0, f = 0;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i])f=1;
		if(a[i]==b[i]){
			ans += b[i];
		}
		if(a[i]<b[i]){
			ans += a[i];
			rem += b[i]-a[i];
		}
		if(a[i]>b[i]){
			dval.pb( mp(b[i],i) );
			ans += a[i];
		}
	}
	if(f==0){
		cout<<0<<endl;
		return 0;
	}
	sort( dval.begin(),dval.end() );
	ans -= dval[0].first;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d,x,sum=0;
	cin >> n >> d >> x;
	int y;
	for(int i=0;i<n;i++){
		cin >> y;
		for(int j=0;j<d;j++){
			if(y*j+1<=d){
				sum++;
			}else{
				break;
			}
		}
	}
	cout << sum+x << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
# 0段目からN段目まで、壊れているか否かを表す flag
issafe = [1] * (N+1)
for i in range(M):
  a = int(input())
  issafe[a] = 0

mod = 10**9 + 7

# 0段目からN段目までの移動方法の数
dp = [0] * (N + 1)
dp[0] = 1
if issafe[1]: dp[1] = 1
# 漸化式に従って計算する
for i in range(2, N + 1):
  if issafe[i-1]: dp[i] += dp[i-1]
  if issafe[i-2]: dp[i] += dp[i-2]
  dp[i] %= mod
  
print(dp[N])

Measured memory_bytes: 13508
def inpl():
    return list(map(int, input().split()))


def count(n):
    ret = 0
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret += 2
    return ret


N = int(input())

print(len([i for i in range(1, N + 1, 2) if count(i) == 8]))


Measured memory_bytes: 2940
n = int(input())
S = input()

ans = 0
for i in range(1000):
    T = str(i).zfill(3)
    cur = 0
    for j in range(n):
        if S[j] == T[cur]:
            cur += 1
            if cur == 3:
                break
    if cur == 3:
        ans += 1

print(ans)

Measured memory_bytes: 41052
s = input()
n = len(s)
ans = 0
numa = 0
i = 0
while i < n-1:  # 最後'BC'以外は、最後の文字は関係ないので s[n-1]は不要
    if s[i] == 'A':
        numa += 1   # Aが連続で続く場合は数える
    elif s[i:i+2] == 'BC':
        ans += numa # AAAA と BC を入れ替える回数。またBCが来たら加算する
        i += 1  # BCの場合は、2文字進めるので+1
    else:
        numa = 0
    i += 1
print(ans)

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

int main() {
  //定義一覧
  char C;
  
  cin >> C;
  if(C == 'a' or C == 'e' or C == 'i' or C == 'o' or C == 'u'){
  	cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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() {
    int x;
    cin >> x;
    for (int i = 1; i <= x; ++i) {
        if(100*i <= x && x <= 105*i){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int min(int x,int y){
    return x>y?y:x;
}

int max(int x,int y){
    return x>y?x:y;
}
 
int main(){
 
  int n, x=(int)1e9, y, ans=-(int)1e9, i;
 
  scanf("%d%d",&n,&y);
 
  for(i=1;i<n;i++){
    x=min(x,y);
    scanf("%d",&y);
    ans=max(ans,y-x);
  }
 
  printf("%d\n",ans);
 
  return 0;
 
}


Measured memory_bytes: 2116
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long W = sc.nextLong();
    long[] w = new long[N];
    long[] v = new long[N];
    for(int i = 0; i < N; i++) {
      w[i] = sc.nextLong();
      v[i] = sc.nextLong();
    }
    long[][][] dp = new long[N][300][N + 1];
    for(int j = 0; j < 300; j++) {
      dp[0][j][1] = v[0];
    }
    for(int i = 1; i < N; i++) {
      long a = w[i] - w[0];
      for(int j = 0; j < 300; j++) {
        for(int k = 1; k < N + 1; k++) {
          if((int)a <= j) {
            dp[i][j][k] = Math.max(dp[i - 1][j][k], dp[i - 1][j - (int)a][k - 1] + v[i]);
          } else {
            dp[i][j][k] = dp[i - 1][j][k];
          }
        }
      }
    }
    long ans = 0;
    for(int k = 1; k < N + 1; k++) {
      if((W - k * w[0]) >= 0) {
        if((W - k * w[0]) < 300) {
          ans = Math.max(ans, dp[N - 1][(int)(W - k * w[0])][k]);
        } else {
          ans = Math.max(ans, dp[N - 1][299][k]);
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 54484
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<int> primes(0);
void prime_number(int N){
    vector<int> tmp(N+1,1);
    tmp[0]=tmp[1]=0;
    for(int i=2; i<=N; i++){
        if(tmp[i]==1){
            primes.push_back(i);
        }
        for(long long j= (long long) i*i; j<=N; j+=i){
            tmp[j]=0;
        }
    }
}

vector<int> factorize(int x){
    vector<int> ret(primes.size(),0);
    for(int i=0; i<primes.size(); i++){
        int p=primes[i];
        if(x<p)break;
        while(x%p==0){
            x/=p;
            ret[i]++;
        }
    }
    if(x!=1){
        primes.push_back(x);
        ret.push_back(1);
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    ll ans=1;
    prime_number(1001);
    vector<ll> cnt((int)primes.size(),0);
    for(ll i=1; i<=N; i++){
        int j=0;
        for(auto &x:factorize(i)){
            cnt[j]+=x;
            j++;
        }
    }

    for(auto &x:cnt){
        ans*=(ll)(x+1);
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<pair<int, int>> x;
  REP(i, N) {
    int j;
    cin >> j;
    j--;
    x.push_back({j, i});
  }

  vector<int> a(N * N, -1);
  sort(x.begin(), x.end());
  for (int j = N - 1; j >= 0; --j) {
    int i = x[j].second;
    int xi = x[j].first;

    a[xi] = i;
    int rem = N - i - 1;
    for (int k = N * N - 1; k > xi && rem > 0; --k) {
      if (a[k] == -1) {
        a[k] = i;
        rem--;
      }
    }

    if (rem > 0) {
      cout << "No\n";
      return 0;
    }
  }

  REP(j, N) {
    int i = x[j].second;
    int xi = x[j].first;

    int rem = i;
    for (int k = 0; k < xi && rem > 0; ++k) {
      if (a[k] == -1) {
        a[k] = i;
        rem--;
      }
    }

    if (rem > 0) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  for (int x : a) cout << x + 1 << ' ';
  cout << '\n';
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main() {
    unsigned long long int a;
    unsigned long long int b;
   unsigned long long int x;

   cin>>a>>b>>x;
   if(b==0){cout<<1;}
   else if(a==0){cout<<(b/x)+1;}
   else{
    a=(a-1)/x;
    b=b/x;
    a=(b-a);
   cout<<a;}

   return 0;
}


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

#define BIG 2000000007

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;


#define N_MAX 100
#define M_MAX 20

ull n, m, k;
ull h, w;
ull a[N_MAX];
// ull b[M_MAX][N_MAX];
ull dp[N_MAX][M_MAX + 1];
// char s[N_MAX][M_MAX + 1];

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}

int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}

int min(ull x, ull y){
	return (x < y) ? x : y;
}

ull solve(){
	int i, j;

	i = n / 100;
	j = n % 10;

	if (i == j) {
		puts("Yes");
	} else {
		puts("No");
	}

}

int main(void){
	ull i, j;

	scanf("%llu", &n);
	solve();

	return 0;
}


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;

using vqi=vector<queue<int>>;
using bs=bitset<60>;
using vbi=vector<bs>;
constexpr ll MOD = 1e9 + 7;


int main() {
    ll A, B;
    cin >> A >> B;
    if (B < A) {
        swap(B, A);
    }

    ll a = A;
    ll b = B;
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    ll gcd=A*B/b;

    cout << A * B / b << endl;
    return 0;
}


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

int main()
{
  long n;
  cin >> n;
  long a = 2;
  int c, s;
  c = 0;
  s = 0;
  while (n >= a*a) {
    if (n % a == 0) {
      n /= a;
      c++;
    } else {
      if(c > 0){
        for(int i = 1;i <15 ;++i){
          c-=i;
          if(c < 0) break;
          else s++;
        }
      }
      a++;
      c = 0;
    }
  }
  if(n == a) c++;
  for(int i = 1;i <15 ;++i){
    c-=i;
    if(c < 0) break;
    else s++;
  }
  if(n != a && n > 1) s++;
  
  cout << s << endl;
}


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

using namespace std;

int main()
{
    int n,q;

    int a[10001];

    cin>>n;

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

    sort(a,a+n);

    cin>>q;

    int cnt=0,b;
    for(int i=0;i<q;i++)
    {
        cin>>b;

        if(*lower_bound(a,a+n,b)==b)
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3156
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
#n,d = [int(i) for i in readline().split()]


ans = 0
for i in range(1,n+1):
    if len(str(i))%2: ans += 1

print(ans)
    











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

vector<bool> msprime(300000,true);

int main(){
    msprime[1]=false;
    for(int n=2; n<300000; n++){
        if(n%7!=1 && n%7!=6){
            msprime[n]=false;
        }else if(msprime[n]){
            for(int i=2; n*i<300000; i++){
                msprime[n*i]=false;
            }
        }
    }

    while(1){
        int n;
        cin >> n;
        if(n==1) break;

        cout << n << ":";
        for(int i=2; i<300000; i++){
            if(msprime[i] && n%i==0){
                cout << " " << i;
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3100
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int a,b,c;
    cin >> a >> b >> c;
    ans = a/b;
    if(a%b>0) ans++;
    ans*=c;
    cout << ans << endl;
    return 0;
}


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

mod = 10**9+7
r = n-k

def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    invs[0] = 1
    
    return factorials, invs

fr, inv = prepare(2010, mod)
for i in range(k):
    ans = 1
    if r-i < 0:
        ans = 0
    else:
        ans = (((fr[n-k+1] * inv[i+1] * inv[n-k-i]) % mod) * fr[k-1] * inv[i] * inv[k-1-i]) % mod
    print(ans)

Measured memory_bytes: 41968
import java.util.Scanner;

public class Main {

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

        final String s = sc.next();
        final String t = sc.next();

        if (t.substring(0, t.length()-1).equals(s)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35716
import sys
from typing import List


if __name__ == "__main__":
    input_str = input()
    target_str = input()
    target_str_len = len(target_str)

    for idx, s in enumerate(input_str):
        if len(input_str[idx:]) < target_str_len:
            break
        if s == target_str[0]:
            if input_str[idx:idx + target_str_len] == target_str:
                print(idx)



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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >>a[i];
    int count=0;
    int target=1;
    for(int i=0;i<n;i++){
        if( a[i]==target ){target++;}else{count++;}
    }
    if(count==n){cout << -1;}else{cout << count;}
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> v = a;
	sort(v.begin(), v.end());
	rep(i, n) {
		if (a[i] == v[n - 1]) cout << v[n - 2] << endl;
		else cout << v[n - 1] << endl;
	}
}

Measured memory_bytes: 3200
from collections import deque

N = int(input())
S = list(input())

queue = deque(S)
Ans = []

temp = queue.popleft()
Ans.append(temp)

while len(queue) != 0:
    if temp == queue[0]:
        queue.popleft()
    else:
        temp = queue.popleft()
        Ans.append(temp)

print(len(Ans))


Measured memory_bytes: 5832
import sys
sys.setrecursionlimit(10**9)

n=int(input())
maxn=110000
memo=[-1 for i in range(maxn)]
def rec(n):
    if n==0:
        return 0
    if memo[n]!=-1:
        return memo[n]
    res=n
    i=1
    while i<=n:
        res=min(res,rec(n-i)+1)
        i*=6
    j=1
    while j<=n:
        res=min(res,rec(n-j)+1)
        j*=9
    memo[n]=res
    return memo[n]
print(rec(n))
#print(memo)

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

int main(){

	long int e;

	cin >>e;

	while(!(e == 0)){
		long int ans = 2000000;

		for(int i = 0;i*i*i <= e; i++){
			for(int j = 0; j * j <= e-i*i*i;j++){
				long int  m = e - (i*i*i-i)-(j*j-j);
				if(m > 0){
					ans = min(ans,m);
				}
			}
		}
		cout <<ans<<endl;
		cin >>e;
	}
	return 0;
}



Measured memory_bytes: 2960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;
 
int main() {
    string s;
    cin >> s;
    rep(i, 0, s.size()){
        if(s[i] == '?')s[i] = 'D';
    }
    cout << s << endl;
}

Measured memory_bytes: 3748
import sys
import queue

#+++++

def aaa(ll,a,b,c):
	ret=a+b+c
	for i,v1 in enumerate(ll):
		t1=abs(a-v1)
		if ret < t1:
			continue
		for j,v2 in enumerate(ll):
			if i==j:
				continue
			t2=t1 + abs(b-v2)
			if ret < t2:
				continue
			for k,v3 in enumerate(ll):
				if i==k or j==k:
					continue
				t3 = t2 + abs(c-v3)
				ret=min(ret, t3)
	return ret		

def mk_str(ll):
	ll.sort()
	return '_'.join([str(v) for v in ll])


def main():
	n , a, b, c = map(int, input().split())
	est=lambda ll:aaa(ll,a,b,c)
	
	bb=[]
	for i in range(n):
		bb.append(int(input()))
	
	cl=set()
	ol=queue.PriorityQueue()
	
	st=bb
	ee=est(st)
	cc=0
	cl.add(mk_str(bb))
	ol.put((ee+cc, (cc, bb)))	
	while True:
		if ee == 0:
			return cc
		
		#to goal no join
		rr=cc+ee
		ol.put((rr, (rr, [a,b,c])))
		
		#join 1
		if len(st) > 3:
			cc+=10
			for i, v in enumerate(st):
				kk=st[:]
				m=kk.pop(i)
				for j, _ in enumerate(kk):
					kkk=kk[:]
					kkk[j]+=m
					stk=mk_str(kkk)
					if stk not in cl:
						cl.add(stk)
						ol.put((cc, (cc, kkk)))
		v,(cc, st) = ol.get()
		ee = est(st)
				
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 5488
n=int(input())
for i in range(n):
    x,y,b,p=map(int,input().split())
    if b>=5 and p>=2:
        print(int((x*b+y*p)*0.8))
    else:
        keep=x*b+y*p
        if b<5:b=5
        if p<2:p=2
        keep2=int((x*b+y*p)*0.8)
        print(min(keep,keep2))


Measured memory_bytes: 5620
#include<stdio.h>
#define N 100
#define inf 1000000000
#define NIL -1
#define BLACK 2
#define GRAY 1
#define WHITE 0

int n,A[N][N];

void dijkstra(){
  int mincost,d[N],color[N],i,u,v;

  for(i = 0;i < n;i++) {
    d[i] = inf;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1) {
    mincost = inf;
    u = NIL;
    for(i = 0;i < n;i++) {
      if(mincost > d[i] && color[i] != BLACK) {
	u = i;
	mincost = d[i];
      }
    }
    if(u == NIL) break;
    color[u] = BLACK;
    for(v = 0;v < n;v++) {
      if(color[v] != BLACK && A[u][v] != inf) {
	if(d[v] > d[u] + A[u][v]) {
	  d[v] = d[u] + A[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i = 0;i < n;i++) {
    d[i] == inf ? -1 : d[i];
    printf("%d %d\n",i,d[i]);
  }
}

int main()
{
  int i,j,k,c,u,v;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++) {
    for(j = 0;j < n;j++) {
      A[i][j] = inf;
    }
  }

  for(i = 0;i < n;i++) {
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++) {
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}
    




Measured memory_bytes: 2048
def f(s,target):
    cnt = 0
    while len(set(s)) != 1:
        tmps = ""
        for i in range(len(s)-1):
            if s[i] == target and s[i+1] != target:
                tmps += target * 2
            elif s[i] != target and s[i+1] == target:
                tmps += target * 2
            else:
                tmps += s[i]
        cnt += 1
        s = tmps
    return cnt

ans = float('inf')
s = input()
for alp in sorted(set(s)):
    print
    ans = min(f(list(s),alp),ans)
print(ans)

Measured memory_bytes: 9076
#include<iostream>
using namespace std;
int main(){
  	int N;
  cin >>N;
	int A[N],B[N],C[N];
  int i;
  for(i=0;i<N;i++){
    cin >>A[i];
  }
  for(i=0;i<N;i++){
    cin >>B[i];
  }
  for(i=0;i<N;i++){
    cin >>C[i];
  }
  int ans=0;
  for(i=0;i<N;i++){
    ans+=B[i];
  }
  for(i=0;i<N-1;i++){
    if(A[i+1]==A[i]+1)ans+=C[A[i]-1];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ROAD=[None]*M

for i in range(M):
    ROAD[i]=tuple(sorted(list(map(int,input().split()))))
  
import itertools

NOROAD=list(itertools.combinations(range(1,N+1),2))

NOROAD=set(NOROAD) - set(ROAD)

Group=[[i,[]] for i in range(N+1)]

def find(x):
    while Group[x][0] != x:
        x=Group[x][0]
    return x


for i in NOROAD:
    a,b=i
    #print(a,b)
    Group[a][1]+=[b]
    Group[b][1]+=[a]

    if find(a) != find(b):
        Group[find(a)][0]=min(find(a),find(b))
        Group[find(b)][0]=min(find(a),find(b))
        Group[a][0]=min(find(a),find(b))
        Group[b][0]=min(find(a),find(b))

GroupSORT=[[i,j[1]] for i,j in enumerate(Group)]
GroupSORT.sort(key=lambda x:len(x[1]))
NUMBERING=[[find(i),"none"] for i in range(N+1)]
CHECK=[0 for i in range(N+1)]

for i in range(N):
    if CHECK[find(GroupSORT[i][0])]==0:
        
        NUMBERING[GroupSORT[i][0]][1]=0
        CHECK[find(GroupSORT[i][0])]=1

CONDITION=1
#print(NUMBERING)


repeat_condition=1
while repeat_condition==1:

    repeat_condition=0

    for i in range(1,N+1):
        if NUMBERING[i][1]==0:
            for j in Group[i][1]:
                if NUMBERING[j][1]==0:
                    CONDITION=0
                    break
                elif NUMBERING[j][1]=="none":
                    NUMBERING[j][1]=1
                    repeat_condition=1

        if NUMBERING[i][1]==1:
            for j in Group[i][1]:
                if NUMBERING[j][1]==1:
                    CONDITION=0
                    break
                elif NUMBERING[j][1]=="none":
                    NUMBERING[j][1]=0
                    repeat_condition=1


import sys
if CONDITION==0:
    print(-1)
    sys.exit()

NUMBERS=set()
for i in range(1,len(NUMBERING)):
    NUMBERS=NUMBERS|{NUMBERING[i][0]}

count=[]
for i in NUMBERS:
    count+=[(i,NUMBERING.count([i,0]),NUMBERING.count([i,1]))]

DP=[set() for i in range(len(count))]
DP[0]={count[0][1],count[0][2]}

for i in range(1,len(count)):
    for k in DP[i-1]:
        DP[i]=DP[i]|{k+count[i][1],k+count[i][2]}

DIVIDE=list(DP[len(count)-1])
#print(DIVIDE)
for i in range(len(DIVIDE)):
    DIVIDE[i]=abs(DIVIDE[i]-N/2)

x=int(min(DIVIDE)+N/2)

print(x*(x-1)//2+(N-x)*(N-x-1)//2)


Measured memory_bytes: 71008
#include<stdio.h>
#include<string.h>
int main(){
	char num[1000000];
	scanf("%s",num);
	long long int k=0;
	for(int i=0;i<strlen(num);i++){
		k+=num[i]-'0';
	}
	if(k%9==0) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 2204
using System;
class Program
{
    static void Main(string[] args)
    {
        
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
      
        int ans = c - a + b;
        //出力
        if (ans < 0){
            ans = 0;
            Console.WriteLine(0);

        }
        else { Console.WriteLine(ans); }
    }
}


Measured memory_bytes: 11092