akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h){
        cin >> a[i];
    }
    bool deleted[105][105] = {};
    REP(i, h){
        ll j;
        for(j = 0; j < w; j++){
            if(a[i][j] == '#') break;
        }
        if(j == w){
            REP(k, w){
                deleted[i][k] = true;
            }
        }
    }
    REP(i, w){
        ll j;
        for(j = 0; j < h; j++){
            if(a[j][i] == '#') break;
        }
        if(j == h){
            REP(k, h){
                deleted[k][i] = true;
            }
        }
    }
    
    REP(i, h){
        bool e = false;
        REP(j, w){
            if(!deleted[i][j]){
                cout << a[i][j];
                e = true;
            }
        }
        if(e) cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N,K;
    cin >>N>>K;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >>A.at(i);
    }
    
    if (N/K==0) {
        cout<<1<<endl;
    }else{
        if ((N-K)%(K-1)==0) {
            cout<<1+(N-K)/(K-1)<<endl;
        }else{
            cout<<1+(N-K)/(K-1)+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int a,b;
  if(scanf("%d",&a)==1 && scanf("%d",&b)==1){}
  
  int c;
  if(a>b){
    c=a;
    a=b;
    b=c;
  }
  
  if((a+b)%2 == 0){
    printf("%d",a+(b-a)/2);
  }else{
    printf("IMPOSSIBLE");
  }
  
  return 0;
}

Measured memory_bytes: 128
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 300005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
inline bool is_square(int x) {
	double r = sqrt(1.0 * x);
	return (int)ceil(r) == (int)floor(r);
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N, D;
	scanf("%d %d", &N, &D);
	int res = 0;
	int x[80][80];
	for (int i = 0; i < N; i++) for (int d = 0; d < D; d++) scanf("%d", &x[i][d]);
	for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) {
		int sum = 0;
		for (int d = 0; d < D; d++) {
			sum += (x[i][d] - x[j][d]) * (x[i][d] - x[j][d]);
		}
		if (is_square(sum)) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc076/tasks/abc076_c

S_ = input()    # ?入りの文字
T = input()     # 部分文字列


len_S_ = len(S_)
len_T = len(T)

S_list = []

for i in reversed(range(len_S_)):
    is_target = True
    S = ''

    if i + len_T <= len_S_:
        S = S_[:i] + T + S_[i + len_T:]

        # 残った「?」を全部aにする(条件2)
        for j in range(len(S)):
            if S[j] != S_[j] and S_[j] != '?':
                is_target = False
                break

            if S[j] == '?':
                S = S[:j] + 'a' + S[j + 1:]

        if is_target:
            S_list.append(S)

    else:
        continue
        
if len(S_list) > 0:
    print(min(S_list))
else:
    print('UNRESTORABLE')

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

int main() {
    int N, A, odd_count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (A % 2 != 0) odd_count++;
    }
    if (odd_count % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main() {

  string s, t;

  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

#define NUM 11000

int main(){
	int table[NUM],limit,numTable[10001] = {0};

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int index = 0,primeTable[1230];

	for(int i = 2; i <= 9997; i++){
		if(table[i] == 1)primeTable[index++] = i;	//?´???°????¨????
	}

	int sum;
	for(int left = 0; left <= index-1; left++){ //??????????????????
		for(int div = 0; left + div <= index-1; div++){ //?????????????¶?????´???°????????°????????????
			sum = 0;
			for(int p = 0; p <= div; p++){
				sum += primeTable[left+p];
			}
			if(sum <= 10000)numTable[sum]++;
			else{
				break;
			}
		}
	}

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d\n",numTable[n]);
	}
	return 0;
}

Measured memory_bytes: 3296
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int a[n], fr[n];
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	
	int col=0;
	fr[col]=a[0];
	int frmin=a[0];
	//int frminnum=0;	//colの番号
	col++;
	for(int i=1;i<n;i++){
		if(a[i]<=frmin){
			fr[col]=a[i];
			frmin=fr[col];
			//frminnum=i;
			col++;
		}else{
			for(int k=0;k<col;k++){
				if(fr[k]<a[i]){
					fr[k]=a[i];
					if(k==col-1){
                      	frmin=a[i];
                    }
                  	break;
				}
			}
		}
	}
	
	
	printf("%d", col);
	
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <map>
using namespace std;

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

template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

typedef long long ll;

const ll INF = 1LL << 62;

const int NMAX = 100 + 10;
const int VMAX = 1000 * (NMAX);
ll dp[NMAX][VMAX];

int main() {
  int N,W; cin>>N>>W;
  vector<int> v(N);
  vector<ll> w(N);
  REP(i,N) cin>>w[i]>>v[i];
  REP(i,NMAX) REP(j,VMAX) dp[i][j] = INF;
  dp[0][0] = 0LL;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < VMAX; j++) {
      chmin(dp[i+1][j], dp[i][j]);
      int nv = j - v[i];
      if(nv >= 0) {
	chmin(dp[i+1][j], dp[i][nv] + w[i]);
      }
      if(dp[i+1][j] <= W) {
	chmax(ans, j);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

    string ans = "";
    if (a < b)
    {
        auto a_str = to_string(a);
        for (auto i = 0; i < b; i++)
        {
            ans += a_str;
        }
    }
    else
    {
        auto b_str = to_string(b);
        for (auto i = 0; i < a; i++)
        {
            ans += b_str;
        }
    }
    cout << ans << endl;
    return 0;
}


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

bool solve() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S; cin >> S;
  rep(i, B, D) if(S[i-1] == '#' && S[i] == '#') return false;
  rep(i, A, C) if(S[i-1] == '#' && S[i] == '#') return false;
  if(C < D) return true;
  int mx = 0;
  int cnt = 0;
  rep(i, B-2, D+1) {
    if(S[i] != '#') cnt++;
    else cnt = 0;
    mx = max(mx, cnt);
  }
  if(mx >= 3) return true;
  else return false;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
    int a;
    int b;
    cin >> a;
    cin >> b;
    int result;
    if (a > b) {
        result = 2 * a - 1;
    } else if (a == b) {
        result = 2 * a;
    } else {
        result = 2 * b - 1;
    }
    cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#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 argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    REP(i, S.size()){
        cout << "x";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  long long t,T,ans=0,prev=0,d;cin>>n>>T;
  for(int i=0;i<n;i++){
    cin>>t;
    d=t-prev;
    prev=t;
    ans+=(T>d?d:T);
  }
  cout<<ans+T;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#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> 

using namespace std;

#define _int64 long long

int now;

void doit(_int64 n,vector<int> &s1,vector<int> &s2)
{
  //cout<<n<<endl;
  if (n==1)
  {
    s1.push_back(now);
    s2.push_back(now);
    now++;
    return;
  }
  if (n%2==1)
  {
    doit(n/2,s1,s2);
    s1.push_back(now);
    s2.push_back(now);
    now++;
  }
  else
  {
    n--;
    doit(n,s1,s2);
    s1.push_back(now);
    s2.insert(s2.begin(),now);
    now++;
  }
}

int main()
{
  _int64 n;
  int i,j;
  vector<int> s1,s2;
  scanf("%lld",&n);
  s1.clear();s2.clear();
  now=1;
  doit(n,s1,s2);
  printf("%d\n",(int)s1.size()+(int)s2.size());
  for (i=0;i<s1.size();i++)
  {
    if (i!=0) printf(" ");
    printf("%d",s1[i]);
  }
  for (i=0;i<s2.size();i++)
  {
    printf(" %d",s2[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            int x = in.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            a.add(x);
            if (x - k + 1 >= -1000000)
                for (int i = 1; i <= k - 1; i++) {
                    a.add(x - i);
                }
            if (x + k - 1 <= 1000000)
                for (int i = 1; i <= k - 1; i++) {
                    a.add(x + i);
                }
            Collections.sort(a);
            for (int i = 0; i < a.size(); i++) {
                out.print(a.get(i) + " ");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    unordered_map<int, int> Map_D;
    unordered_map<int, int> Map_T;
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        Map_D[a]++;
    }
    int M; cin >> M;
    vector<int> T(M, 0);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
        Map_T[T[i]]++;
    }
    for (int i = 0; i < M; i++) {
        if (Map_T[T[i]] > Map_D[T[i]]) {
            cout << "NO" << endl; return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 20636
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
int h;
int a;
int ans;
int main()
{
	cin>>h>>a;
	ans=h/a;
	if(ans*a<h)
	{
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N;
  int M;
  cin>>N;
  map<int,int> mp;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin>>D[i];
    mp[ D[i] ]++;
  }
  cin>>M;
  vector<int>T(M);

  int ans=1;
  for(int i=0;i<M;i++){
    cin>>T[i];
    mp[ T[i] ]--;
    if(mp[ T[i] ]<0)ans=0;
  }

  cout<< (ans>0?"YES":"NO") <<endl;
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

ll n, a, b, now;
vector<pll> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	while(n--) {
		cin >> a >> b;
		vec.push_back(pll(b, a)); // lim len
	}
	sort(vec.begin(), vec.end());
	for (pll p: vec) {
		if(now + p.second > p.first) {
			cout << "No\n";
			return 0;
		}
		now += p.second;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;

    int dp[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=0;
    }
    vector<int>v[n+1];
    int indegree[n+1];
    for(int i=0;i<=n;i++){
        indegree[i]=0;
    }

    for(int i=0;i<m;i++){

        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        indegree[y]++;
    }

    queue<int>q;
    for(int i=1;i<=n;i++){
        if(indegree[i]==0){
            q.push(i);
            dp[i]=0;
        }
    }

    while(!q.empty()){

        int k=q.size();
        while(k--){

            int curr=q.front();
            q.pop();
            int s=v[curr].size();
            for(int i=0;i<s;i++){
                indegree[v[curr][i]]--;
                if(indegree[v[curr][i]]==0){
                    q.push(v[curr][i]);
                    dp[v[curr][i]]=max(dp[v[curr][i]],dp[curr]+1);
                }
            }

        }

    }

    int ans=INT_MIN;
    for(int i=0;i<=n;i++){
        ans=max(ans,dp[i]);
    }

    cout<<ans;
    
}


Measured memory_bytes: 9788
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n = 3;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	bool f = false;
	if (a[0] == a[1] && a[1] != a[2]) f = true;
	if (a[1] == a[2] && a[0] != a[1]) f = true;
	if (f) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
ans = -1
for n in range(min(X), max(X) + 1):
  cnt = 0
  for x in X:
    cnt += (x - n) **2
  if ans > 0:
    ans = min(ans, cnt)
  else:
    ans = cnt
print(ans)

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


ll GCD(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while(v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}

ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

int main(){
    ll A, B;
    int C, D;
    cin >> A >> B >> C >> D;
    
    ll total = B - A + 1;
    ll c_cnt = (B / C) - ((A - 1) / C);
    ll d_cnt = (B / D) - ((A - 1) / D);
    ll cd = LCM(C, D);
    ll cd_cnt = (B / cd) - ((A - 1) / cd);
    
    cout << (total - (c_cnt + d_cnt - cd_cnt)) << endl;
    return 0;
}

Measured memory_bytes: 256
import math 
A, B, H, M = map(int,input().split())

timeHr = H + (M / 60)
angVelA = (1/6) * 180
angVelB = (2) * 180

degA = (angVelA * timeHr) % (2 * 180)
degB = (angVelB * timeHr) % (2 * 180)


degDiff = abs(degB - degA) 

disX_2 = math.pow(B, 2) + math.pow(A, 2) - (2 * A * B * math.cos(math.radians(degDiff)))
disX = math.sqrt(disX_2)

print(disX)

Measured memory_bytes: 9364
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n,k,q;cin>>n>>k>>q;
	ll a[n];rep(i,0,n)a[i]=k;
	rep(i,0,q){
		ll x;cin>>x;x--;
		a[x]++;
	}
	
	rep(i,0,n){
		if(a[i]>q)cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}



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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
const int N_max=51;
const int M_max=N_max*(N_max-1);
vector<int> v[51];
bool isVisited[N_max];
void initialize(){
    REP(i,N_max){
        isVisited[i]=false;
    }
}
void dfs(int v_now){
    isVisited[v_now]=true;
    for(int i:v[v_now]){
        if(!isVisited[i]){
            dfs(i);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<int> A;
    int B;
    int temp;
    REP(i,N+1){
        cin>>temp;
        A.push_back(temp);
    }
    ll ans;ans=0;
    int amari;amari=0;
    REP(i,N){
        cin>>B;
        if(B+amari>=A[i]){
            ans+=A[i];
            amari=min(B,B+amari-A[i]);
        }else{
            ans+=B+amari;
            amari=0;
        }
    }
    ans+=min(A[N],amari);
    print(ans);
}

Measured memory_bytes: 892
#include<cstdio>
#include<algorithm>
#include<iostream>
#define MAXN 200005
using namespace std;
int main(){
	int n,m;
	int d[MAXN],t[MAXN];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>d[i];
	sort(d,d+n);
	cin>>m;
	for(int j=0;j<m;j++)
		cin>>t[j];
	sort(t,t+m);
	int i=0,j=0;
	while(i<n && j<m){
		while(d[i]!=t[j] && i<n)
			i++;
		if(i==n)
			break;
		i++;
		j++;
	}
	if(j!=m)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	cout << (N / 3) << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  string s;
  cin >> s;
  int n = s.size();
  vvint dp(n,vint(2));
  dp[0][0] = 2;
  dp[0][1] = 1;
  rep(i,1,n){
    if(s[i] == '0'){
      dp[i][0] = dp[i-1][0];
      dp[i][1] = dp[i-1][1]*3;
      dp[i][0] %= MOD;
      dp[i][1] %= MOD;
    }
    else{
      dp[i][0] = (dp[i-1][0])*2;
      dp[i][1] = dp[i-1][1]*3 + dp[i-1][0];
      dp[i][0] %= MOD;
      dp[i][1] %= MOD;
    }
  }
  
  cout << (dp[n-1][0] + dp[n-1][1])%MOD << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll len=0;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        len+=a[i];
    }
    ll tmp=0;
    ll res=1e10;
    rep(i,n){
        tmp+=a[i];
        chmin(res, abs(len-2*tmp));
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

int n,m;
char s[1000001];

int main(){
	while(scanf("%d%d",&n,&m), n != 0){
		scanf("%s",s);
		int ans = 0;
		char fore = '0';
		for(int i = 0; i < m - (n*2);i++){
			if(fore == '0'&& s[i] == 'I'){
				fore = s[i];
				bool f = true;
				for(int j = 1; i+j < m;j++){
					if(s[i+j] == fore){
						int tmp;
						if(fore == 'I'){
							tmp = j / 2 - n + 1;
						}
						else{
							tmp = j / 2 - n;
						}
						if(tmp > 0){
							ans += tmp;
						}
						fore = '0';
						i += j - 1;
						f = false;
						break;
					}
					else{
						fore = s[i+j];
					}
				}
				if(f){
					int tmp;
					if(s[m-1] == 'I'){
						tmp = (m-i) / 2 - n + 1;
					}
					else{
						tmp = (m-i) / 2 -n;
					}
					ans += tmp;
					break;
				}

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

Measured memory_bytes: 3552
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define INF9 (int64)(1e9)
#define INF18 (int64)(1e18)

template<typename T>
struct compF{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.first < b.first;
	}
};

template<typename T>
struct compS{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.second < b.second;
	}
};

template<typename T>
void printMatrix(const string &txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(const string &txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}

template<typename T>
void readVector(int n, vector<T> &a){
	if (a.size() < n)
		a.resize(n);

	fori(n) cin >> a[i];
}

template<typename T1, typename T2>
bool exist(map<T1, T2> &m, T1 x){
	if (m.find(x) == m.end())
		return false;

	return true;
}

int64 gcd(int64 a, int64 b){
	while (a != 0 && b != 0){
		if (b > a)
			b %= a;
		else
			a %= b;
	}

	return a + b;
}

int64 minFactor(int64 x){
	for (int64 i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return i;

	return x;
}

int64 allFactors(int64 x, vint64 &prms, vint64 &prm_cnt){
	prms.clear();
	prm_cnt.clear();
	while (x > 1){
		int64 t = minFactor(x);
		prms.push_back(t);
		int s = prms.size() - 1;
		prm_cnt.push_back(0);
		while (x % t == 0){
			x /= t;
			++prm_cnt[s];
		}
	}

	return 0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();

	int64 n;
	cin >> n;
	vint res;
	while (n > 0){
		n--;
		res.push_back(n % 26);
		n /= 26;
	}
	reverse(ALL(res));

	fori(res.size())
		cout << (char)(res[i] + 'a');
	return 0;
}


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

using namespace std;

int main()
{
    int N,a;
    a=0;
    cin >>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
        for(int j=0;j<N;j++){
            if(i!=j){
                a+=d.at(i)*d.at(j);
            }
        }
    }
    cout <<a<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>

class ATherefore {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        int t = n % 10;
        if(t==3){
            out << "bon" << std::endl;
        }else if(t == 0 || t == 1 || t == 6 || t == 8){
            out << "pon" << std::endl;
        }else{
            out << "hon" << std::endl;
        }
    }
};


int main() {
    ATherefore solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBeginnersContest
{
    class ABC100D
    {
        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = nm[0];
            int m = nm[1];

            var score = new long[n + 1, m + 1, 8];
            var temp = new long[8];
            for (int i = 1; i <= n; i++)
            {
                var xyz = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
                for (int j = 1; j <= Math.Min(i, m); j++)
                {
                    // - - -
                    temp[0] = score[i - 1, j - 1, 0] - xyz[0] - xyz[1] - xyz[2];
                    temp[1] = score[i - 1, j - 1, 1] - xyz[0] - xyz[1] + xyz[2];
                    temp[2] = score[i - 1, j - 1, 2] - xyz[0] + xyz[1] - xyz[2];
                    temp[3] = score[i - 1, j - 1, 3] - xyz[0] + xyz[1] + xyz[2];
                    temp[4] = score[i - 1, j - 1, 4] + xyz[0] - xyz[1] - xyz[2];
                    temp[5] = score[i - 1, j - 1, 5] + xyz[0] - xyz[1] + xyz[2];
                    temp[6] = score[i - 1, j - 1, 6] + xyz[0] + xyz[1] - xyz[2];
                    temp[7] = score[i - 1, j - 1, 7] + xyz[0] + xyz[1] + xyz[2];
                    if (i != j)
                        for (int k = 0; k < 8; k++)
                            score[i, j, k] = temp[k] > score[i - 1, j, k] ? temp[k] : score[i - 1, j, k];
                    else
                        for (int k = 0; k < 8; k++)
                            score[i, j, k] = temp[k];
                }
            }

            long maxScore = 0;
            for (int i = 0; i < 8; i++)
            {
                if (maxScore < score[n, m, i])
                    maxScore = score[n, m, i];
            }

            Console.WriteLine(maxScore);
        }
    }
}


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

const int mod=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    rep(i,60){
        ll cnt=0;
        rep(j,n){
            if(a[j]&(1LL<<i))cnt++;
        }
        ll x=cnt*(n-cnt)%mod;
        rep(j,i){
            x=x*2%mod;
        }
        x%=mod;
        ans+=x;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<deque>
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,n) for(lld i=a;i<n;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,n) for(lld i=n-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector 
#define p(x,y)  pair<x,y> 
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<": "; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/ 
void bfs(lld s,v<lld> g[],lld n)
{ 
   bool vis[n]; 
   rec(i,n) 
    vis[i]=false; 
    
   vis[s]=true; 
   deque<lld> q; 
   q.pb(s); 
   
   while(!q.empty()) 
   {  
      s=q.front(); 
     q.pop_front(); 
      
     for(int i=0;i<g[s].size();i++) 
      {  
        if(!vis[g[s][i]])
         { vis[g[s][i]]=true; 
            q.pb(g[s][i]); 
         }
      }
   }
}

void dfs(lld u,v<lld> g[],bool *vis)
{ 

   vis[u]=true; 
   for(int i=0;i<g[u].size();i++) 
     if(!vis[g[u][i]])
          dfs(i,g,vis); 
       
}
void contest(lld t); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld T=1; 
   // cin>>T;
    rec(t,T) 
    {
      contest(t); 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest(lld z)
{ 
   lld ans=inf; 
   string s,t; 
   cin>>s>>t; 
   
   lld n=s.length(),m=t.length(); 
   
   rec(i,n)
   {  
     if((i+m-1)>=n) 
      break; 
      
     lld temp=0; 
     
     rec(j,m) 
     if(s[i+j]!=t[j]) 
       temp++; 
     
     ans=min(ans,temp); 
   }
    cout<<ans; 
    cout<<endl; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define check(x,y) if(x.at(j+y) =='#') count++

int main(){
  int H, W, count;
  string a, b, c;
  cin >> H >> W >> c;
  for (int i=0; i<H; i++){
    a = b; b = c;
    cin >> c;
    for(int j=0; j<W; j++){
      if(b.at(j) == '#') continue;
      count = 0;
      if(i >= 1){
        if(j-1 >= 0) check(a,-1);
        check(a,0);
        if(j+1 < W) check(a,1);
      }
      if(j-1 >= 0) check(b,-1);
      if(j+1 <W) check(b,1);
      if(i <= H-2){
        if(j-1 >= 0) check(c,-1);
        check(c,0);
        if(j+1 < W) check(c,1);
      }
      b.at(j) = to_string(count).at(0);
    }
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 4294967291LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long double dp[305][305][305];
int freq[4];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // dp[i,j,k,l,m...] expected number

    // we can compress this down to dp[i][j][k] (1s, 2s, 3s), 0s can be deduced

    int n; cin >> n;

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

    int a = freq[1], b = freq[2], c = freq[3];

    for(int k = 0; k <= c; ++k){
        for(int j = 0; j <= b + c; ++j){
            for(int i = 0; i <= n; ++i){
                long double left = i + j + k;
                if(i > 0)
                    dp[k][j][i] += dp[k][j][i - 1] * i;
                if(j > 0)
                    dp[k][j][i] += dp[k][j - 1][i + 1] * j;
                if(k > 0)
                    dp[k][j][i] += dp[k - 1][j + 1][i] * k;
                if(left > 0)
                    dp[k][j][i] = (dp[k][j][i] + n) / left;
            }
        }
    }

    cout << setprecision(10) << fixed << dp[c][b][a];

    return 0;
}


Measured memory_bytes: 436480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClarss
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string[] s = Input();
		int a = int.Parse(s[0]);
		int b = int.Parse(s[1]);
		int c = int.Parse(s[2]);
		Console.WriteLine(Math.Max(0,c-(a-b)));
	}

	
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Functional
template<typename U> auto mapf(const auto& a, auto f){Arr<U> r; for(const auto& x:a)r.pushb(f(x)); return r;}
template<typename T> auto reduce(const auto& a, T acc){ return accumulate(all(a),acc); }
template<typename T> auto reduce(const auto& a, T acc, auto f){ return accumulate(all(a),acc,f); }
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	string s,t; cin>>s>>t;
	cout<<(s==t.substr(0,sz(s))?"Yes":"No")<<endl;
	return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
  string s,t;
  cin>>s>>t;
  long long int sl=s.length(),tl=t.length();
  vector<vector<int> >dp(sl+1,vector<int>(tl+1,0));
  long long int i,j;
  for(i=1;i<=sl;i++)
  {
    for(j=1;j<=tl;j++)
    {
      if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  string ans="";
  i=sl;j=tl;
  while(dp[i][j]!=0)
  {
    if(s[i-1]==t[j-1])
    {
      ans+=s[i-1];
      i--;j--;
    }
    else
    {
      if(dp[i-1][j]>=dp[i][j-1])
        i--;
      else
        j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;
  return 0;
}


Measured memory_bytes: 35584
// Problem : B - Addition and Multiplication
// Contest : AtCoder - AtCoder Beginner Contest 076
// URL : https://atcoder.jp/contests/abc076/tasks/abc076_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,k;cin>>n>>k;
int ans=1;
while(n--)
{
	if(ans*2<ans+k)
	ans=2*ans;
	else
	ans+=k;
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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


int main(){

    int a, b, x;
    cin >> a >> b >> x;
    for(int i = 0; i <= b; i++){
        if (a + i == x){
            cout << "YES" << endl;
            exit(0);
        }
    }
    cout << "NO" << endl;

}

Measured memory_bytes: 3592
<?php
list($h, $n) = ints();
for ($i = 0; $i < $n; ++$i) list($a[], $b[]) = ints();
$dp = array_fill(0, $h + 1, PHP_INT_MAX);
$dp[0] = 0;
for ($i = 1; $i <= $h; ++$i) {
    for ($j = 0; $j < $n; ++$j) {
        $d = $b[$j] + $dp[max(0, $i - $a[$j])];
        if ($dp[$i] > $d) $dp[$i] = $d;
    }
}
echo $dp[$h];

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;
using ll = long long;

//container util
#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)


int main(void){

	int N; cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N-1);

	REP(i,N) cin >> A[i];
	REP(i,N) cin >> B[i];
	REP(i,N-1) cin >> C[i];

	int prev = -1;

	int ans = 0;

	REP(i,N){
		int idx = A[i] - 1;
		ans += B[idx];
		
		if(idx == (prev + 1)) ans += C[prev];
		prev = idx;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	char A, B, C, D;
	cin >> A >> B >> C >> D;
	int a, b, c, d;
	a = A - 0x30;
	b = B - 0x30;
	c = C - 0x30;
	d = D - 0x30;
	for(int x = 0; x < 2; x++) {
		for(int y = 0; y < 2; y++) {
			for(int z = 0; z < 2; z++) {
				int ans = a;
				if(x) ans += b;
				else ans -= b;
				if(y) ans += c;
				else ans -= c;
				if(z) ans += d;
				else ans -= d;
				if(ans == 7) {
					cout << A << (x ? '+' : '-') <<
						B << (y ? '+' : '-') <<
						C << (z ? '+' : '-') << D << "=7" << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256