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

	int main(){
      int N;
      cin >> N;
      int a[N];
      for (int i;i<N;i++){
        cin >> a[i];
      }
      int k=1;
      for (int i=1;i<=N;i++){
        k=a[k-1];
        if (k==2){
          cout << i << endl;
          return 0;
        }
      }
      cout << -1 <<endl;
    }


Measured memory_bytes: 640
def can_move(coord1, coord2):
    distance = abs(coord2[1] - coord1[1]) + abs(coord2[2] - coord1[2])
    time = coord2[0] - coord1[0]
    if distance > time:
        return False
    quotient, remainder = divmod(distance - time, 2)
    if remainder == 1:
        return False
    return True

N = int(input())
coord = [[0,0,0]]
for i in range(N):
    coord.append(list(map(int,input().split())))

flag = True
for i in range(N):
    flag = flag and can_move(coord[i], coord[i+1])

if flag:
    print("Yes")
else:
    print("No")

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int d;cin >> d;
    string ans = "";
    if(d == 22) ans = "Christmas Eve Eve Eve";
    if(d == 23) ans = "Christmas Eve Eve";
    if(d == 24) ans = "Christmas Eve";
    if(d == 25) ans = "Christmas";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut s = vec![vec![]; m];
    for i in 0..m {
        let k: usize = read();
        for _ in 0..k {
            // sにはk個の各スイッチの1～Nの番号
            let a = read::<usize>() - 1;
            s[i].push(a);
        }
    }
    let p: Vec<usize> = (0..m).map(|_| read()).collect();

    let mut res = 0;
    for bit in 0..1 << n {
        let mut ok = true;
        for (i, switch) in s.iter().enumerate() {
            let mut con = 0;
            for &i in switch.iter() {
                if bit & 1 << i == 1 << i {
                    con += 1;
                }
            }
            if con % 2 != p[i] {
                ok = false;
                break;
            }
        }
        if ok {
            res += 1;
        }
    }
    println!("{}", res);
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	set<string> mset;
	string s;
	int k;
	cin >> s;
	cin >> k;
	int n = (int)s.length();
	for (int l=1; l <= min(n,k); ++l) {
		for (int i = 0; i <= n-l; ++i) {
			int j = i+l-1;
			string t = "";
			for (int p = i; p <= j; ++p) {
				t += s[p];
			}
			mset.insert(t);
		}
	}

	--k;
	while (k--) {
		mset.erase(mset.begin());
	}
	cout << *mset.begin() << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

using namespace std;

vector<vector<int>> from;
vector<int> dp;
vector<bool> det;

void dfs(int v) {
    for(int vf: from.at(v)) {
        if(!det.at(vf)) dfs(vf);
        dp.at(v) = max(dp.at(v), dp.at(vf) + 1);
    }
    det.at(v) = true;
}

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

    int n, m;

    cin >> n >> m;

    int x, y;
    vector<bool> head(n + 1, true);

    from = vector<vector<int>>(n + 1);
    det = vector<bool>(n + 1);

    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        from.at(y).emplace_back(x);
        head.at(x) = false;
    }

    dp = vector<int>(n + 1);

    int ans = 0;

    for(int i = 1; i <= n; ++i) if(head.at(i)) dfs(i);
    for(int i = 1; i <= n; ++i) ans = max(ans, dp.at(i));

    printf("%d\n", ans);

    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w.at(i);
    }
    for (int i = 1; i < n; i++) {
        if ( w.at(i).at(0) != w.at(i - 1).at(w.at(i - 1).size() - 1) ) {
            cout << "No" << endl; return 0;
        }
        for (int j = 0; j < i; j++) {
            if (w.at(i) == w.at(j)) {cout << "No" << endl; return 0;}
        }
    }
    cout << "Yes" << endl;
}

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



int vacation(vector<int> vect[], int n, int c)
{
	int t[n+1][c+1];
	memset(t, -1, sizeof(t));
	
	t[1][1] = vect[0][0];
	t[1][2] = vect[0][1];
	t[1][3] = vect[0][2];
	
	f(i, 2, n+1)
	{
		t[i][1] = vect[i-1][0] + max(t[i-1][2], t[i-1][3]);
		t[i][2] = vect[i-1][1] + max(t[i-1][1], t[i-1][3]);
		t[i][3] = vect[i-1][2] + max(t[i-1][2], t[i-1][1]);
	}
	return max({t[n][1], t[n][2], t[n][3]});
}

int main()
{
	int n;
	cin >> n;
	vector<int> vect[n];
	f(i, 0, n)
	{
		int a, b, c;
		cin >> a >> b >> c;
		vect[i].push_back(a);
		vect[i].push_back(b);
		vect[i].push_back(c);
	}
	int a = vacation(vect, n, 3);
	cout << a;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
struct Knapsack01 { // 最大1個
    void add_item(int vi, int wi){ v.push_back(vi); w.push_back(wi);}
    int solve(int W){
        int n=v.size(); vector<int> dp(W+1,0);
        for(int i=0;i<n;++i)
            for(int j=W;j>=w[i];--j)
                dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        return dp[W];
    }
    vector<int> v, w;  // val, wei
};

int main(){
  int N, W, v, w;
  cin >> N >> W;
  Knapsack01 k;
  for(int i=0;i<N;++i){
    cin >> v >> w;
    k.add_item(v,w);
  }
  cout << k.solve(W) << endl;
}


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

int main(){
  int n,m,t,a=0;cin>>n>>m;
  REP(i,m){
    cin>>t;
    a+=t;
  }
  cout<<(n-a>=0?n-a:-1);
}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAXN=100+10;
int n,k,x,ans;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);read(k);
	for(register int i=1;i<=n;++i)
	{
		read(x);
		ans+=(min(abs(x-k),abs(x))*2);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W = map(int,readline().split())
grid = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W]

white = (grid == b'.')

U = np.ones((H + 2, W + 2), np.int32)
U[:H, :W] = white
for i in range(H):
  for j in range(W):
    if U[i, j] == 0:
      if U[i - 1, j] * U[i + 1, j] * U[i, j - 1] * U[i, j + 1] != 0:
        print('No')
        quit()
print('Yes')

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

int main()
{
 int x;
 cin >> x;
 if( x == 3){
     cout << "YES" << endl;
 }else if(x == 5){
     cout << "YES" << endl;
 }else if(x == 7){
     cout << "YES" << endl;
 }else{
     cout << "NO" << endl;
 }
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void dfs(string s, int pos, int cnt);

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

    cin >> n;
    string s = "a";
    dfs(s, 1, 1);

    return 0;
}

void dfs(string s, int pos, int cnt) {
    if(cnt == n) {
        cout << s << endl;
        return;

    }
    for(int i = 0; i <= pos; ++i) {
        string t = s;
        if(i == 0) t += "a";
        if(i == 1) t += "b";
        if(i == 2) t += "c";
        if(i == 3) t += "d";
        if(i == 4) t += "e";
        if(i == 5) t += "f";
        if(i == 6) t += "g";
        if(i == 7) t += "h";
        if(i == 8) t += "i";
        if(i == 9) t += "j";
        if(i < pos) dfs(t, pos, cnt + 1);
        else dfs(t, pos + 1, cnt + 1);

    }

    return;
}


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

int main() {
    using namespace std;
    unsigned long N, H, W;
    cin >> N >> H >> W;
    vector<pair<unsigned long, pair<unsigned long, unsigned long>>> cards(N);
    for(auto& i : cards){
        cin >> i.second.first >> i.second.second >> i.first;
        --i.second.first;
        --i.second.second;
    }
    sort(cards.rbegin(), cards.rend());
    vector<unsigned long> countH(H), countW(W);
    vector<unsigned long> uf(H + W), cap(H + W, 1UL), cnt(H + W);
    iota(uf.begin(), uf.end(), 0UL);
    auto find = [&uf](unsigned long i){
        while(uf[i] != i)i = uf[i] = uf[uf[i]];
        return i;
    };
    auto unite = [&uf, &cap, &cnt, &find](unsigned long i, unsigned long j){
        i = find(i);
        j = find(j);
        if(i == j)return;
        if(cap[i] < cap[j])swap(i, j);
        uf[j] = i;
        cap[i] += cap[j];
        cnt[i] += cnt[j];
    };
    unsigned long ans{0};
    for(auto& i : cards){
        auto h = find(i.second.first);
        auto w = find(i.second.second + H);
        auto capacity = h == w ? cap[h] : cap[h] + cap[w];
        auto counter = h == w ? cnt[h] : cnt[h] + cnt[w];
        if(capacity > counter){
            ans += i.first;
            unite(h, w);
            ++cnt[find(h)];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;
int a[MAXN],b[MAXN];
int c,d;
int n,q;
long long sum;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[a[i]]++;
		sum+=a[i];
	}
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>c>>d;
		b[d]+=b[c];
		sum+=b[c]*(d-c);
		b[c]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 4336
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0:
  	break
  for j in range(2):
    if c!=0:
      	break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    
    int b[100010],c[100010],m = -1;
    memset(c, 0, sizeof(c));
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&b[i]); c[b[i]] ++;
        m = max(m, b[i]);
    }
    int ans = 0;
    for(int i=0; i<=m; i++)
        ans = max(ans, c[i]+c[i+1]+c[i+2]);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
integer N
integer(16), allocatable::A(:,:)
integer(16) ans
logical direct
read*,N
allocate(A(N,N))
do i=1,N
  read*,A(i,:)
end do

ans=0
do i=1,N
  do j=i+1,N
    direct=.true.
    do k=1,N
      if(i==k.or.j==k)cycle
      if(A(i,j)>A(i,k)+A(k,j))then
        print"(i0)",-1
        stop
      else if(A(i,j)==A(i,k)+A(k,j))then
        direct=.false.
      endif
    end do
    if(direct)ans=ans+A(i,j)
  end do
end do

print"(I0)",ans

end

Measured memory_bytes: 1664
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int a, b, c;
//variable

void init()
{
	a = read(), b = read(), c = read();
}
//functions

int main()
{
	init();
	cout << min(b / a, c) << endl;
	return 0;
}
//main


Measured memory_bytes: 256
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll x;
    cin>>x;
    if(x>=30){cout<<"Yes";}
    else{cout<<"No";}
    return 0;
}



Measured memory_bytes: 3628
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextLong();
            if (a[i] == 0) {
                System.out.println(0);
                return;
            }
        }
        BigInteger bi = new BigInteger("1");
        long ans = 1l;
        for (int i = 0 ; i < n ; i++) {

            bi = bi.multiply(new BigInteger(String.valueOf(a[i])));
            if (bi.compareTo(new BigInteger("1000000000000000000")) > 0) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(bi.longValue());
    }

}

Measured memory_bytes: 62696
#include <iostream>
#include <string>

using namespace std;

void Toggling(string& str)
{
  for (int i = 0; i < str.length(); i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') {
      str[i] += 0x20;
    } else if (str[i] >= 'a' && str[i] <= 'z') {
      str[i] -= 0x20;
    }
  }
}

int main()
{
  string s;

  getline(cin, s);
  Toggling(s);

  cout << s << endl;
}
                                    



Measured memory_bytes: 3156
package main

import (
	"fmt"
)

func main() {
	var n, x, t int

	fmt.Scanf("%d %d %d", &n, &x, &t)
	num := n / x

	m := n % x
	if m > 0 {
		num++
	}
	fmt.Println(num * t)
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
#define R freopen("666input.txt","r",stdin);
#define W freopen("666output.txt","w",stdout);
#define N 100005
int i,n,t,a,b,dis[N],dis2[N],vis[N],cnt,cnt2;
queue <int> q;
vector<int> v[N];
int main()
{
    
    cin>>n;
    for(i=1;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);

    }
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        int sz=v[cur].size();
        for(i=0;i<sz;i++)
        {
            if(!vis[v[cur][i]])
            {
                vis[v[cur][i]]=1;
                q.push(v[cur][i]);
                dis[v[cur][i]]=dis[cur]+1;
            }
        }
    }
    memset(vis,0,sizeof(vis));
    q.push(n);
    vis[n]=1;
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        int sz=v[cur].size();
        for(i=0;i<sz;i++)
        {
            if(!vis[v[cur][i]])
            {
                vis[v[cur][i]]=1;
                q.push(v[cur][i]);
                dis2[v[cur][i]]=dis2[cur]+1;
            }
        }
    }
    for(i=1;i<=n;i++)
        if(dis[i]<=dis2[i])cnt++;
        else cnt2++;
    if(cnt>cnt2)cout<<"Fennec";
    else cout<<"Snuke";
    return 0;
}


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

int w, h;

void disp(const vector<vector<int> >& v) {
  for (auto it1 = v.begin(); it1 != v.end(); it1++) {
    for (auto it2 = it1->begin(); it2 != it1->end(); it2++) {
      cout << *it2;
    }
    cout << endl;
  }
}

int dfs(vector<vector<int> >& map, int x, int y, int d) {
  static int dx[4] = {0, 1, 0, -1};
  static int dy[4] = {1, 0, -1, 0};
  int ans = 11;

  if(d > 10)
    return 11;

  for(int i = 0; i < 4; i++) {
    int nx, ny;
    nx = x + dx[i];
    ny = y + dy[i];
    
    if(nx < 0 || nx >= w || ny < 0 || ny >= h)
      continue;

    if(map[ny][nx] == 1)
      continue;

    if(map[ny][nx] == 3)
      return d;
    

    while(1) {
      nx += dx[i];
      ny += dy[i];

      if(nx < 0 || nx >= w || ny < 0 || ny >= h)
	break;

      if(map[ny][nx] == 3)
	return d;

      if(map[ny][nx] == 1){
	vector<vector<int>> n_map = map;
	n_map[ny][nx] = 0;
	ans = min(dfs(n_map, nx - dx[i], ny - dy[i], d + 1), ans);
	break;
      }
    }
  }

  return ans;
} 

int main() {
  while (cin >> w >> h, w != 0) {
    vector<vector<int> > map(h, vector<int> (w));
    int x, y;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	cin >> map[i][j];
	if(map[i][j] == 2){
	  x = j;
	  y = i;
	}
      }
    }
    cout << [](int x){return x == 11 ? -1 : x;}(dfs(map, x, y, 1)) << endl;
  }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll arr[n],sum=0;
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n,greater<ll>());
    for(ll i=k;i<n;i++)
    sum+=arr[i];
    cout<<sum;
} 


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

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

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

    int N,M; cin >> N >> M;
    vector<int> s[11];

    for (int i = 0;i < M;i++){
        int k; cin >> k;
        for (int j = 0;j < k;j++){
            int t; cin >> t;
            s[t-1].push_back(i);
        }
    }

    vector<int> p;

    for (int i = 0;i < M;i++){
        int t; cin >> t;
        p.push_back(t);
    }
    int ans = 0;

    for (int i = 0;i < (1<<N);i++){
        int cnt[10] = {0};
        for (int j = 0;j < N;j++){
            if((1<<j) & i){
                for (int k = 0;k < s[j].size();k++){
                    cnt[s[j][k]]++;
                }
            }
        }
        bool flag = true;
        for (int j = 0;j < M;j++){
            if(cnt[j]%2 != p[j]) flag = false;
        }
        if(flag){ ans++;}
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    REP(i, a) cin >> p[i];
    REP(i, b) cin >> q[i];
    REP(i, c) cin >> r[i];
    sort(ALL(p), greater<>());
    sort(ALL(q), greater<>());

    priority_queue<ll, vector<ll>, greater<ll>> que;
    REP(i, x) que.push(p[i]);
    REP(i, y) que.push(q[i]);
    REP(i, c) que.push(r[i]), que.pop();

    ll ans = 0;
    while(que.size()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

    return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;


int n, m;
vi p;
vector<vi> s;

int dfs(int i, vector<int>on) {
	if (i == n) {
		int j, count = 0;
		rep(j, m) {
			if (on[j] % 2 == p[j])count++;
		}
		if (count == m)return 1;
		else return 0;
	}
	else {
		int ans, j;
		vector<int> nexton = on;
		rep(j, s[i].size()) {
			nexton[s[i][j]]++;
		}
		ans = dfs(i + 1, on) + dfs(i + 1, nexton);
		return ans;
	}
}


int main() {
	int i, j, k, x, y;
	vector<int>on;

	cin >> n >> m;
	SIZE(s, n);
	SIZE(p, m);
	SIZE(on, m);

	rep(i, m) {
		cin >> x;
		rep(j, x) {
			cin >> y;
			PB(s[y - 1], i);
		}
	}
	rep(i, m) {
		cin >> j;
		p[i] = j;
	}

	cout << dfs(0, on);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
typedef std::vector<int> Vector_i;
void CountingSort(Vector_i &A, Vector_i &B, int k) {
	Vector_i C(k + 1, 0);
	//C[i]???i???????????°????¨?????????????
	for (unsigned int j = 0; j < A.size(); ++j) {
		C[A[j]] ++;
	}	
	//C[i]???i??\????????°???????????°????¨??????????
	for (int i = 0; i < k; ++i) {
		C[i + 1] += C[i];
			}
	for (int i = 0; i <= k; ++i) {
		C[i ] --;
	}
	for (int j = A.size()-1 ; j >= 0; --j) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	return;
}
int main(void) {
	int n, k = 0;;
	std::cin >> n;
	Vector_i A(n, 0);
	Vector_i B(n, 0);
	for (int i = 0; i < n; ++i) {
		std::cin >> A[i];
		if (k < A[i]) { k = A[i]; }
	}

	CountingSort(A, B, k);
	for (unsigned int i = 0; i < B.size(); ++i) {
		if (i == B.size() - 1) { std::cout << B[i] << std::endl; }
		else {
			std::cout << B[i] << " ";
		}
	}
//	system("pause");
	return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  cout<<n*n*n<<endl;
}



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

using namespace std;

int main(void){
	string a, b, a1, a2;
	cin >> a >> b;
	int len, tmp, flag = 0;
	len = a.length();
	tmp = len;
	while(tmp--){
		if(a == b){
			flag = 1;
			break;
		}else{
			a2 = a2.assign(a, len-1, len-1);
			a1 = a1.assign(a, 0, len-1);
			
			a = a2 + a1;
//			cout << a << endl;	
		}
	}
	if(flag)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <bitset>
using namespace std;

int main()
{
    string s;
    cin >> s;

    s = 'a' + s;

    int flag = 0;
    int res = 100000;
    int n = s.size() - 1;

    for (int i = 1; i < n; i++)
    {
        if (s[i] != s[i + 1])
        {
            int tmp;
            tmp = max(i, n - i);
            res = min(res, tmp);
            flag = 1;
        }
    }

    if (flag == 0)
    {
        cout << n;
    }
    else
    {
        cout << res;
    }

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        long[] a = new long[n];
        a[0] = sc.nextLong();
        long ans = 0L;
        if(a[0] > x){
            ans += a[0] - x;
            a[0] -= ans;
        }
        for (int i = 1; i < n; i++) {
            a[i] = sc.nextLong();
            if(a[i-1] + a[i] > x){
                long diff =  (a[i-1] + a[i]) - x;
                a[i] -= diff;
                ans += diff;
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 63232
import sys
sys.setrecursionlimit(1000000)
def search(i, total):
  for dist, to in edges[i]:
    if dists[to] == None:
      dists[to] = total + dist
      if not search(to, total + dist):
        return False
    else:
      if dists[to] == total + dist:
        continue
      else:
        return False
  return True

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
  l, r, d = map(int, input().split())
  l -= 1
  r -= 1
  edges[l].append((d, r))
  edges[r].append((-d, l))

dists = [None] * n

for i in range(n):
  if dists[i] == None:
    dists[i] = 0
    if not search(i, 0):
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 131960
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,n = LI()
    aa = [LI() for _ in range(n)]
    r = (a*b+b*c+c*a) * 2

    for d,e,f in aa:
        r += 6
        if d == 0:
            r -= 2
        if e == 0:
            r -= 2
        if f == 0:
            r -= 2
        if d == a-1:
            r -= 2
        if e == b-1:
            r -= 2
        if f == c-1:
            r -= 2

    def k(a,b):
        return sum(map(lambda x: abs(a[x]-b[x]), range(3)))

    for i in range(n):
        ai = aa[i]
        for j in range(i+1,n):
            if k(ai, aa[j]) == 1:
                r -= 2

    return r




print(main())



Measured memory_bytes: 9100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#define N 200010
using namespace std;
int n, m;
vector<int> edge[N];
bool vis[N];
deque<int> q;


int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	
	int u = 1;
	bool flag = 1;
	while (flag) {
		q.push_back(u);
		vis[u] = 1;
		flag = 0;
		for (int i = 0; i < edge[u].size(); ++i) {
			int v = edge[u][i];
			if (!vis[v]) {
				u = v;
				flag = 1;
				break;
			}
		}
	}
	
	u = 1;
	flag = 1;
	while (flag) {
		vis[u] = 1;
		flag = 0;
		for (int i = 0; i < edge[u].size(); ++i) {
			int v = edge[u][i];
			if (!vis[v]) {
				q.push_front(v);
				u = v;
				flag = 1;
				break;
			}
		}
	}

	printf("%d\n", (int)q.size());
	for (auto it = q.begin(); it != q.end(); ++it) {
		printf("%d ", *it);
	}
	
}

Measured memory_bytes: 9088
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=t(r.split("\n")[0].split(" ").map(function(r){return Number(r)}),2),n=e[0],o=e[1],u=500,i=0,f=0;f<n;f++)Math.abs(o+f)<u&&(u=Math.abs(o+f),i=f);for(var l=0,a=0;a<n;a++)a!=i&&(l+=o+a);console.log(l)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 7372
num = gets.chomp.to_i
array = [*(1..num)]
list = array.permutation(num).to_a
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
p (list.find_index(a) - list.find_index(b)).abs

Measured memory_bytes: 6780
#include <cstdio>

int main() {
		int sum = 0;
		int ordered[5];
		int ryouri[5];

		for ( int i = 0; i < 5; i++ ) scanf("%d", &ryouri[i]);

		for ( int i = 0; i < 5; i++ ) ordered[i] = 0;

		for ( int j = 0; j < 5; j++ ) {
				int min_d = 1e9, min_i;
				for ( int i = 0; i < 5; i++ ) {
						if ( !ordered[i] ) {
								int x;	
								if ( (sum + ryouri[i] ) % 10 == 0 ) x = 0;
								else x = 10 - (( sum + ryouri[i] ) % 10);

								if ( min_d > x ) {
										min_d = x;
										min_i = i;
								}
						}
				}
				ordered[min_i] = 1;
				if ( j == 4 ) sum += ryouri[min_i];
				else sum += (ryouri[min_i] + min_d);
		}

		printf("%d\n", sum);

		return 0;
}


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

int main() {
int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  
  int last = h2*60+m2-k;
  int st= h1*60+ m1;
  
  cout << last-st;
  
  
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
char s[5];
int main()
{
     scanf("%s",s);
     int sum=0;
     for(int i=0;i<3;i++)
     {
          if(s[i]=='1')
               sum++;
     }
     printf("%d\n",sum);
     return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, x: "List[int]", y: "List[int]"):
    pattern = list(itertools.permutations(range(N)))
    sum_dist = 0
    for p in pattern:
        for i in range(1,N):
            sum_dist+=((x[p[i]]-x[p[i-1]])**2+(y[p[i]]-y[p[i-1]])**2)**(1/2)

    print(sum_dist/len(pattern))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10100
fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let a: Vec<usize> = sc.read_vec(n);
    let ans: u32 = a.iter().map(|&a| a.trailing_zeros()).sum();
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long int
#define INF 1000000005
#define pb push_back
#define MOD 1000000007
#define FF first
#define SS second
#define int long long int

using namespace std;
typedef long long ll;

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

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll modx(ll Base, ll exponent)
{
  ll ans = 1;
  if(Base == 1)
    return Base;
  while(exponent)
  {
    if(exponent & 1)
      ans = (ans * Base)%MOD;
    Base = (Base * Base)%MOD;
    exponent = exponent >> 1;
  }
  return ans;
}

ll inmodx(ll num)
{
  return (modx(num, MOD-2LL));
}

bool cmp(pii loc, pii b)//true for loc before b
{
  if(loc.SS < b.SS)
    return 1;
  if(loc.SS > b.SS)
    return 0;
  if(loc.FF <= b.FF)
    return 1;
  return 0;
}
const int maxn=1000005;
int n,m,dp[maxn],best,path[maxn],root;
vector<pair<int,int>> g[maxn];
     
int dfs(int u)
{
    if(dp[u])
     return dp[u];
    dp[u]=1;
    for(auto v:g[u])
     {
        int c=v.FF;
        if(dp[u]<dfs(c)+1)
         {
            dp[u]=dp[c]+1;
            path[u+1]=c+1;
        }
    }
    return dp[u];
}

 
signed main()
{
    //  freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); 
    cin.tie(0);
    cout.tie(0);
    int x,y;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;

        
        x--;
        y--;
        g[x].pb(make_pair(y,i+1));
    }
    for(int i=0;i<n;i++) 
    {
        int len=dfs(i);
        if(best<len) 
        {
            root=i;
            best=len;
        }
    }
    cout<<best-1<<endl;
    return 0;
}
  


 
   

Measured memory_bytes: 32000
/*
No not today :3
*/
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define mp make_pair
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
using namespace std;
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
ll POWER(ll x,ll y, ll m){
    if(y==0) return 1;
    if(y%2==0) { ll temp= POWER(x,y/2,m);   temp*=temp; temp%=m;	return temp;}
    ll temp= POWER(x,y-1,m);    temp*=x;	temp%=m;	return temp;
}

ll POWER(ll x,ll y){
    if(y==0) return 1;
    if(y%2==0) { ll temp= POWER(x,y/2);   temp*=temp;  return temp;	}
    ll temp= POWER(x,y-1);    temp*=x;	return temp;
}
int a[202];
int main(){
    //cout.precision(12);
    ifstream fin("ali");
    int n; cin>>n;
    for(int i=0;i<2*n;i++)cin>>a[i];
    n*=2; sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i+=2)ans+=a[i];
    cout<<ans<<endl;
}


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

int main(void)
{
  int N;
  std::cin >> N;
  std::string input, lhs, rhs;
  std::cin >> input;

  int l = 0;
  for(auto c : input){
    if(c == '('){
      l += 1;
    } else {
      if(l > 0){
        l -= 1;
      } else {
        lhs += "(";
      }
    }
  }

  for(int i = 0; i < l; ++i){ rhs += ")"; }

  std::cout << lhs << input << rhs << std::endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

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

    max = 0;
    for (int i = 0; i < n; i++)
    {
        int ans = 0;
        map<char, int> mp;
        for (int j = 0; j < i; j++)
        {
            mp[s[j]] = 1;
        }
        for (int j = i; j < n; j++)
        {
            if (mp[s[j]] == 1)
            {
                ans++;
                mp[s[j]] = 0;
            }
        }

        if (ans > max)
            max = ans;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
A = MAP()

souwa = 0
for a in A:
	souwa += 1/a

print(1/souwa)

Measured memory_bytes: 3060
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;

int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    cin.sync_with_stdio( false );

    int tests=1;
    // cin>>tests;
    while(tests--)
    {
    	string s,t;
    	cin>>s>>t;
    	if(s.length()+1==t.length() && s==t.substr(0,s.length())) cout<<"Yes";
    	else cout<<"No";

   	}
    	return 0;
    
}

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

int main(){
    int x,n,s=0;
    cin >> n;
    x=n;
    while (n>0)
    {
        s+=n%10;
        n=n/10;
    }
    if (x%s==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())

big = 10**6+10

furui = [0]*big
furui[0]=1
furui[1]=1

for i in range(2,big):
    if furui[i]==0:
        for j in range(i,len(furui),i):
            furui[j] = 1
            furui[i]=0
        
prime = [i for i in range(len(furui)) if furui[i]==0]

soinsuu=[]
for p in prime:

    while n%p==0:
        n //= p
        soinsuu.append(p)

if n!=1:
    soinsuu.append(n)
    
# print(soinsuu)

ans=0

for i in set(soinsuu):
    
    kai = ((8*soinsuu.count(i)+1)**0.5 -1)/2
    ans += int(kai)
    
print(ans)    


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B, N; cin >> A >> B >> N;
    //A*x/B - x/B の最大値は?
    //xが大きい方がよさそぅ
    if(B == 1) cout << 0 << endl;
    else if(B-1 > N) cout << A*N/B - A*(N/B) << endl;
    else{
        ll ok = (N+1)/B;
        ll x = ok*B-1;
        cout << A*x/B - A*(x/B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#include <iostream>
using namespace std;
void dfs(bool vis[],ll i,vector<ll> v[],ll d[]){
	if(vis[i])return ;
	vis[i]=true;
	for(int j=0;j<v[i].size();j++){
		if(!vis[v[i][j]])dfs(vis,v[i][j],v,d);
		d[i]=max(d[i],1+d[v[i][j]]);
	}
	return ;
}
int main() {
	ll n,m,t1,t2;
	cin>>n>>m;
	vector<ll> v[n+1];
	for(ll i=1;i<=m;i++){
		cin>>t1>>t2;
		v[t1].push_back(t2);
	}
	bool vis[n+1];
	ll len[n+1];
	memset(len,0,sizeof(len));
	memset(vis,0,sizeof(vis));
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			dfs(vis,i,v,len);
		}
	}
	ll m1=0;
	for(ll i=1;i<=n;i++){
		m1=m1>len[i]?m1:len[i];
	}
	cout<<m1;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int x = n/2;
    for(int i=x;i<=n;++i){
        int p = i*1.08;
        if(p==n){
            cout<<i<<endl;
            return 0;
        }
    }
cout<<":("<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


pair<ll,ll> norm(ll x, ll y) {
    ll g = __gcd(x,y);
    x /= g;
    y /= g;
    if (x<0 || (x==0 && y<0)) {
	x=-x;
	y=-y;
    }
    assert(x>=0);
    return make_pair(x,y);
}


pair<ll,ll> perp(pair<ll,ll> p) {
    return norm(-p.second, p.first);
}

ll pw2[maxn];

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

    pw2[0]=1;
    for (int i=1; i<maxn; i++) {
	pw2[i]=2ll*pw2[i-1]%mod;
    }

    int n;
    cin>>n;
    ll zero=0;
    map<pair<ll,ll>,ll> mp;
    
    assert(perp(norm(1,2)) == make_pair(2ll,-1ll));
    
    while (n--) {
	ll x,y;
	cin>>x>>y;
	if (x==0 && y==0) {
	    zero++;
	    continue;
	}
	pair<ll,ll> pt = norm(x,y);
	mp[pt]++;
	mp[perp(pt)] += 0;
    }

    ll res = 1;

    for (auto p: mp) {
	auto pt = p.first;
	auto ptinv = perp(pt);
	if (pt > ptinv) continue;

	ll cnt1 = mp[pt];
	ll cnt2 = mp[ptinv];

	ll ways = (pw2[cnt1] + pw2[cnt2] - 1)%mod;
	//watch(ways);
	res = res * ways % mod;
    }

    ll ans = (res-1) + zero;
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

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

    if(N % 2 == 0) {
        ll B = (N + 2) / 2;
        ll W = N - 1;
        ll left = 0, right = N-2, cnt = 0;
        while(W > B && cnt < M) {
            cout << left+1 << " " << right+1 << endl;
            ++left; --right;
            W = right - left + 1;
            ++cnt;
        }
        --right;
        while(cnt < M) {
            cout << left+1 << " " << right+1 << endl;
            ++left; --right;
            ++cnt;
        }
    }
    else {
        ll left = 0, right = N-2, cnt = 0;
        while(cnt < M) {
            cout << left+1 << " " << right+1 << endl;
            ++left; --right;
            ++cnt;
        }
    }
    return 0;
}

/*






*/

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll a, v, b, w, t, t2;



void solve()
{
	cin >> a >> v >> b >> w >> t;
	if(a == b)
	{
		cout << "YES\n";
		return;
	}
	if(v <= w)
	{
		cout << "NO\n";
		return;
	}
	t2 = abs(a - b) / (v - w);
	if(t > t2 || (t == t2 && abs(a - b) % (v - w) == 0))cout << "YES\n";
	else cout << "NO\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3596
def args():
    N, W = list(map(int, input().split()))

    WV = []
    for _ in range(N):
        WV.append(tuple(map(int, input().split())))

    # print(N, W, WV)

    return N, W, WV


def solve(N, W, WV):
    x, y = N + 1, W + 1
    DP = [[0 for _ in range(y)] for _ in range(x)]

    for i in range(N):
        weight = WV[i][0]
        for w in range(W + 1):
            # 選ぶ
            if w + weight <= W:
                tw = w + weight
                DP[i + 1][tw] = max(DP[i + 1][tw], DP[i][w] + WV[i][1])

            # 選ばない
            DP[i + 1][w] = max(DP[i + 1][w], DP[i][w] + 0)

    # print(DP)
    # print(max(DP[-1]))
    return max(DP[-1])


if __name__ == '__main__':
    res = solve(*args())
    print(res)


Measured memory_bytes: 171528