akhauriyash/Code-Regression huggingface dataset:
while True:
    n,x=map(int,input().split())
    cnt=0
    if n==0 and x==0:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    cnt+=1
    print(cnt)


Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= 9; ++i)
        for(int j = 1; j <= 9; ++j)
            if(i * j == n)
                return cout << "Yes" << endl, 0;
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, x, l, d = 0, cnt = 1;
  cin >> n >> x;

  for (int i = 0; i < n; i++) {
    cin >> l;
    d += l;
    if (d <= x) {
      cnt++;
    } else {
      break;
    }
    //cout << d << endl;
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  int answer = 0;
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
    if (h.at(i) >= K) {
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

    int n,k;
    cin>>n>>k;

    int arr[200001]={0};

    int tmp;
    int ans=0;

    REP(i,n){
        cin>>tmp;
        arr[tmp-1]++;
    }

    sort(arr,arr+n);

    REP(i,n){
        // cout<<arr[i]<<" ";
    }cout<<endl;

    REP(i,n-k){
        ans+=arr[i];
    }
    cout<<ans<<endl;
 	return 0;

}



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

int main() {
    int a, b;
    cin >> a >> b;
    switch (a + b) {
        case 3:
            cout << 3;
            break;
        case 4:
            cout << 2;
            break;
        case 5:
            cout << 1;
            break;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,string> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{

 int d,n;
 cin>>d>>n;
 if(d==0)
 {
     if(n!=100)
     cout<<n;
     else
        cout<<n+1;
 }else if(d==1)
 {
      if(n!=100)
     cout<<100*n;
     else
        cout<<100*n+100;
 }else
 {
      if(n!=100)
     cout<<10000*n;
     else
        cout<<10000*n+10000;
 }

go;
}


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

long long func(long long n, long long x){
    if(n < 0)return 0;
    else return n / x + 1;
}
int main(){
    long long a, b, x;
    cin >> a >> b >> x;
    cout << func(b, x) - func(a - 1, x) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
    ll N,M,K;
    ll A[100010],B,C,X;
    bool F=true;
    ll ans=0;
    string S,T[200000];

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        if(i%2==0&&A[i]%2==1)ans++;
    }
        cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 9900
//
//  main.cpp
//  atc-reg68-C
//
//  Created by 岩井聡 on 2017/02/10.
//  Copyright © 2017年 岩井聡. All rights reserved.
//

#include <iostream>

long long t;
long long solve(void);

int main(int argc, const char * argv[]) {
//    freopen("/Volumes/4HOPE/Dropbox/17Todai/CodeJam/R1C-2015-C/in.txt","r",stdin);
    //    freopen("/Volumes/4HOPE/Dropbox/17Todai/CodeJam/R1C-2015-C/out.txt","w",stdout);

    scanf("%lld",&t);
    printf("%lld",solve());
    return 0;
}

long long solve(void){
    if(t % 11 == 0){
        return (long long)(t/11)*2;
    }else if( t %11 > 6){
        return ((long long)(t/11))*2+2;
    }else{
        return ((long long)(t/11))*2+1;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int INF = 0x3f3f3f3f;

int main()
{
	int n, m[105];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> m[i];
	int flag = 1;
	int ans = 0;
	while(flag)
	{
		flag = 0;
		for(int i = 0; i < n-1; i++)
		{
			if(m[i] > m[i+1])
			{
				int temp = m[i];
				m[i] = m[i+1];
				m[i+1] = temp;
				ans++;
				flag = 1;
			}
		}
	}
	cout<<m[0];
	for(int i = 1; i < n; i++)
		cout<<" "<<m[i];
	cout<<endl<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define ld          long double
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(3e5) + 7;
const int logN = 17;
const int mod = int(1e9) + 7;
const ld  eps = 1e-9;
typedef pair<ld, int> pii;

int n, x, y, r, vis[N];
ld dis[N], d;
pii top;
struct TCircle {
    ld x, y, r;
    TCircle() {}
    TCircle(ld x, ld y, ld r): x(x), y(y), r(r) {}
    ld operator - (const TCircle& o) const {
        return max((ld)0, sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y)) - r - o.r);
    }
} c[N];
priority_queue<pii, vector<pii>, greater<pii>> pq;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    for(int i = 1; i <= 2; ++i) {
        cin >> x >> y; r = 0;
        c[i] = TCircle(x, y, r);
    }
    cin >> n; n += 2;
    for(int i = 3; i <= n; ++i) {
        cin >> x >> y >> r;
        c[i] = TCircle(x, y, r);
    }
    for(int i = 1; i <= n; ++i) dis[i] = 1e18;
    dis[1] = 0; pq.push(mp(0, 1));
    while(pq.size()) {
        top = pq.top(); pq.pop();
        if(top.fi - dis[top.se] > eps) continue;
        vis[top.se] = 1;
        for(int i = 1; i <= n; ++i) {
            if(i == top.se || vis[i]) continue;
            d = top.fi + (c[top.se] - c[i]);
            if(dis[i] > d) dis[i] = d, pq.push(mp(d, i));
        }
    }
    cout << fixed << setprecision(9) << dis[2];
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  ll a,b;
  cin>>a>>b;
  if(a<10&&b<10)cout<<a*b<<endl;
  else cout<<-1<<endl;

}

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string S = "";
    cin >> S;

    list<char> LS;

    for (size_t i = 0; i < S.length(); i++)
    {
        LS.push_back(S[i]);
    }

    long long Q = 0;
    cin >> Q;

    bool isReversed = false;

    for (size_t i = 0; i < Q; i++)
    {
        long long T = 0;
        cin >> T;

        if (T == 1)
        {
            isReversed = !isReversed;
        }
        else
        {
            long long F = 0;
            cin >> F;

            char C = '#';
            cin >> C;

            if (F == 1)
            {

                if (isReversed == false)
                {
                    // S = C + S;
                    LS.push_front(C);
                }
                else
                {
                    // S = S + C;
                    LS.push_back(C);
                }
            }
            else
            {
                if (isReversed == false)
                {
                    // S = S + C;
                    LS.push_back(C);
                }
                else
                {
                    // S = C + S;
                    LS.push_front(C);
                }
            }
        }
    }

    if (!isReversed)
    {
        for (auto it = LS.begin(); it != LS.end(); it++)
        {
            cout << *it;
        }
        cout << endl;
    }
    else
    {
        for (auto it = LS.rbegin(); it != LS.rend(); it++)
        {
            cout << *it;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 9984
n,t = map(int,input().split())
a = list(map(int,input().split()))

s = 0
f = 0
res = 0

for e in a:
    if e <= f:
        f = e+t
    else:
        res += f-s
        s = e
        f = s+t
res += f-s
print(res)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
ll n;
cin>>n;
ll a[n];
ll count =0;
rep(i,n){
    cin>>a[i];
    if(a[i] % 2 == 0)count++;
}
    cout<<pow(3,n) - pow(2,count)<<endl;





   return 0;
}


Measured memory_bytes: 4084
#include<cstdio>
#include<cstring>
int t;
int a[15];

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        int i;
        int z[15],y[15];
        memset(z,0,sizeof(z));
        memset(y,0,sizeof(y));
        for( i=0;i<10;i++)
            scanf("%d",&a[i]);

            z[0]=a[0];int f=1;
            int t=0;int tt=0;
            for(int i=1;i<10;i++)
            {
                if(a[i]>z[t])
                {
                    z[++t]=a[i];
                    f++;
                }
                else if(a[i]>y[tt])
                    {
                        y[++tt]=a[i];
                        f++;
                    }
            }
           // printf("%d!",f);
        if(f==10)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 2428
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);    
    ll t;cin>>t;
    map<string,ll> m;
    ll p = INT_MIN;
    while(t--){
        string str;  
        cin>>str;
        m[str]++;
        
        p = max(p,m[str]);
    }
    
    for(auto x:m){
        if(x.second==p){
            cout<<x.first<<endl;
        }
    }
    
    
}

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

void solve() {
	string s; cin >> s;

	int res = (1 << 29);
	for (int start = 0; start <= 1; start++) {
		int val = start;
		int cnt = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] - '0' != val) cnt++;

			val = 1 - val;
		}
		res = min(res, cnt);
	}

	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

// #include "prettyprint.hpp"

using namespace std;
typedef long long ll;
// vector<vector<int>> vvi;
// vvi = vector<vector<int>>(20, vector<int>(10, 0));

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

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> vec(N);

    for (int i = 1; i < S.size(); ++i)
    {
        if (S[i - 1] == 'A' && S[i] == 'C')
        {
            vec[i]++;
        }
    }
    // cout << vec << endl;

    for (int i = 1; i < S.size(); ++i)
    {
        vec[i] = vec[i] + vec[i - 1];
    }
    // cout << vec << endl;

    for (int i = 0; i < Q; ++i)
    {
        int l, r;
        cin >> l >> r;
        // cout << vec[r] << endl;
        // cout << vec[l] << endl;
        cout << vec[r - 1] - vec[l - 1] << endl;
        // cout << "---" << endl;
    }
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a >= k) cout << k << endl;
  else if(a >= k-b) cout << a << endl;
  else cout << a-(k-a-b) << endl;
}

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

int main() {
	int N, x; cin >> N >> x;
	int a[100010];
	for(int i=0; i<N; ++i) cin >> a[i];
	long ans=0;
	if(a[0]>x){
	    ans=a[0]-x;
	    a[0]=x;
	}
	for(int i=1; i<N; ++i){
	    if(x-a[i-1]<a[i]){
	        ans += a[i]-(x-a[i-1]);
	        a[i]=x-a[i-1];
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        long[] a = ReadLong(n).ToArray();
        long sum = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] < a[i - 1])
            {
                sum += a[i - 1] - a[i];
                a[i] = a[i - 1];
            }
        }
        Console.WriteLine(sum);
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 59156
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define hashset unordered_set
#define hashmap unordered_map
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;
typedef pair<int, int> pii;
template <typename T>
inline vector<T> readvector(size_t size) {
    vector<T> res(size);
    for (size_t i = 0; i < size; ++i) {
        cin >> res[i];
    }
    return res;
}
template <typename T>
inline void printvector(vector<T> &arr, string sep = " ", string ends = "\n") {
    for (size_t i = 0; i < arr.size(); ++i) {
    }
}
inline int binPow(int x, int deg, int mod) {
    int ans = 1;
    for (int i = sizeof(x) * CHAR_BIT - 1; i >= 0; i--) {
        ans *= ans;
        ans %= mod;
        if (getbit(deg, i)) ans *= x;
        ans %= mod;
    }
    return ans;
}
const int MAXN = 2e4 + 10;
const int MOD = 1e9 + 7;

int arr[MAXN];
int a[MAXN], b[MAXN];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h, n;
    cin >> h >> n;
    fill(arr, arr + h + 1, INT_MAX);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    arr[0] = 0;
    for (int x = 1; x <= h; x++) {
        for (int i = 0; i < n; i++) {
            if (arr[x] >= arr[max(0ll, x - a[i])] + b[i]) {
                arr[x] = arr[max(0ll, x - a[i])] + b[i];
            }
        }
    }
    cout << arr[h] << endl;

    return 0;
}

Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    int K = s.length(), win = 15 - K;
    // fprintf(stderr, "win = %lld\n", win);
    for(int i=0; i<K; i++) {
        if(s[i] == 'o') win++;
    }

    // fprintf(stderr, "win = %lld\n", win);
    if(win >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

#logging.debug("デバッグスタート") #
l = [[] for i in range(n)]#期待値
m = [[] for i in range(n - k + 1)]  #k個の合計

for i in range(n):
    l[i] = (1 + p[i]) / 2

#logging.debug("l = {}".format(l))#
m[0] = sum(l[0:k])
ans = m[0]

for i in range(1, n - k + 1):
    #logging.debug("m[i-1] = {} ,l[i-1] = {} ,l[i+k] = {}".format(m[i - 1], l[i - 1], l[i + k - 1]))  #
    m[i] = m[i - 1] - l[i - 1] + l[i + k - 1]
    if m[i] > ans:
        ans = m[i]

#logging.debug(m)#
print(ans)

Measured memory_bytes: 43488
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll a = in(), p = in();
    cout << (3 * a + p) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 55

ll arr[SIZE];
int main() {
   ll k, n = 50;
   cin >> k;
   ll m = cil (k, n) + n - 1;
   ll d = (k != 0) ? n * cil(k, n) - k : 0;
   for (int i = 0 ; i < n ; ++i) arr[i] = m;
   for (int i = 0 ; i < d ; ++i) {
      arr[i] = arr[i] - n + d - 1;
   } 
   for (int i = d ; i < n ; ++i) arr[i] = arr[i] + d;
   cout << n << endl;
   for (int i = 0 ; i < n ; ++i) cout << arr[i] << " ";
   cout << endl;
   return 0;
}

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

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n;
    cin >> n;
    int a[100500];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    cout << a[n - 1] - a[0];
}


int main(){
    
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 100;
const int MAXM = 1e5;

ll dp[MAXN + 1][MAXM + 1];
int w[MAXN + 1], v[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main() {
	fast_io();
//	freopen("input/DP_D.txt", "r", stdin);
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= k; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if(j - w[i] >= 0) dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}
	
	ll ans = 0;
	for(int i = 1; i <= k; i++) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << '\n';
	
	return 0;
}

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

bool has3(int x){
    while(x){
    if(x % 10 == 3) return true;
    x /= 10;
    } 
    return false;
}
void call(int n){
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || has3(i)){
            cout << " " << i;
        } 
    }
     cout << endl;
}

int main(){
    int n;
    cin >> n;
    call(n);
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5+1;
int n, c, p, s[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  s[0] = 1;
  FOR(i, 0, n){
    cin >> c;
    if(p==c) continue;
    s[c] = (s[c]+s[p]) % MOD;
    p = c;
  }
  cout << s[c] << endl;
}

Measured memory_bytes: 1024
# Aizu Problem ITP_1_5_B: Print a Frame
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    H, W = [int(_) for _ in input().split()]
    if H == W == 0:
        break
    print('#' * W)
    for _ in range(H - 2):
        print('#' + '.' * (W - 2) + '#')
    print('#' * W)
    print()

Measured memory_bytes: 7688
#include<bits/stdc++.h>
#define nl '\n'
#define vi vector<long int>
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define int long int
using namespace std;

signed main(){
    ios;
    int n,w;
    cin>>n>>w;
    vector<vector<long int>> vec(n);
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        vec[i].push_back(x);
        cin>>x;
        vec[i].push_back(x);
    }
    long int arr[n][w+1];
    for(int i=0;i<n;i++) arr[i][0]=0;
    for(int j=1;j<=w;j++){
        if(vec[0][0]>j) arr[0][j]=0;
        else arr[0][j]=vec[0][1];
    }
    for(int i=1;i<n;i++){
        int curr=vec[i][1];
        for(int j=1;j<=w;j++){
            if(vec[i][0]>j) arr[i][j]=arr[i-1][j];
            else arr[i][j]=max(arr[i-1][j],curr  + arr[i-1][j-vec[i][0]]);
        }
    }
//    for(int i=0;i<n;i++) {
//        for (int j = 0; j <= w; j++)
//            cout << arr[i][j] << " ";
//        cout << nl;
//    }
    cout<<arr[n-1][w];
}


Measured memory_bytes: 78336
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
Z = -100
message = 'No War'

if X <= Y:
    Z = X+1
    for xi in x:
        if Z < xi:
            Z = xi+1
    for yi in y:
        if Z <= yi:
            pass
        else:
            message = 'War'
            break
    if Z > Y:
        message = 'War'
else:
    message = 'War'

print(message)



Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

struct node
{
    string a;
    int b;
    int index;
};

node t[2000];
int n;

bool cmp(node a, node b)
{
    if (a.a!=b.a) return a.a<b.a;
    return a.b>b.b;
}

int main()
{
    cin >> n;
    for (int i=0; i<n; ++i)
    {
        cin>>t[i].a>>t[i].b;
        t[i].index=i;
    }
    sort(t,t+n,cmp);
    for(int i=0; i<n; ++i)
        cout<<t[i].index+1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B;
	scan(A);scan(B);
	if(A%2==1&&B%2==1) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
const int Max=200005;
int main()
{
    int n,k,A[Max],b[Max];
    while(~scanf("%d%d",&n,&k))
    {
        int i,x,len,j=1,sum=0;
        memset(A,0,sizeof(A));
        memset(b,0,sizeof(b));
        for(i = 0; i<n; i++)
        {
            cin>>A[i];
        }
        len=i;
        sort(A,A+len);
        b[j]=1;
        for(i = 1; i<len; i++)
        {
            if(A[i-1]==A[i]) b[j]++;
            else j++,b[j]=1;
        }sort(b+1,b+j+1);//for(i = 1;i<=j;i++) cout<<'k'<<b[i]<<i<<endl;
        if(j<=k)
            printf("0\n");
        else
        {
            for(i = 1;i<=j-k;i++)
            {
                sum+=b[i];
               // cout<<'s'<<b[i]<<endl;
            }
           printf("%d\n",sum);
        }

    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 1;
    int ans = 0;
    rep(i,n){
        int in;
        cin >> in;
        if(in == cnt){
            cnt++;
        }else{
            ans++;
        }
    }
    if(ans != n) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include<iterator>
#include<functional>
#include<string.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//namespace mp = boost::multiprecision;


int main() {
	int n, k; cin >> n >> k;
	vector<int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	int tmp = pow(10, 9);
	for (int i = 0; i <= n - k; i++) {
		//cout << h[i] << " " << h[i + k-1]<<endl;
		int d = abs(h[i] - h[i + k - 1]);
		//cout << d << endl;
		if (tmp > d) {
			tmp = d;
		}
	}
	cout << tmp << endl;
}




Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.io.IOException {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			final Map<String, Double> map = new HashMap<String, Double>();
			String[] seed = new String[n];
			for (int i = 0; i < n; i++) {
				String L = sc.next();
				seed[i] = L;
				int P = sc.nextInt();
				int A = sc.nextInt();
				int B = sc.nextInt();
				int C = sc.nextInt();
				int D = sc.nextInt();
				int E = sc.nextInt();
				int F = sc.nextInt();
				int S = sc.nextInt();
				int M = sc.nextInt();
				int t = A + B + C + M * (D + E);
				int inc = (M * F * S - P);
				double ef = 1.0 * inc / t;
				map.put(L, ef);
			}
			Arrays.sort(seed);
			Arrays.sort(seed, new Comparator<String>() {
				public int compare(String a, String b) {
					return map.get(b) - map.get(a) > 0 ? 1 : -1;
				}
			});
			for (int i = 0; i < n; i++) {
				System.out.println(seed[i]);
			}
			System.out.println(("#"));
		}
	}
}

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

int main(int argc, char const* argv[]) {
  int  size = 4;
  char array[size];
  for (int i = 0; i < size; i++) {
    std::cin >> array[i];
  }
  // for (int i = 0; i < size; i++) {
  //   // std::cout << array[i];
  // }

  int flag_zero  = 0;
  int flag_other = 0;
  for (int i = 1; i < size; i++) {
    if (array[0] == array[i]) {
      flag_zero = 1;
      if (i == 1) {
        if ((array[0]!=array[2])&&(array[2] == array[3])) {
          flag_other = 1;
        };
      } else if (i == 2) {
        if ((array[0]!=array[1])&&(array[1] == array[3])) {
          flag_other = 1;
        };
      } else if (i == 3) {
        if ((array[0]!=array[1])&&(array[1] == array[2])) {
          flag_other = 1;
        };
      }
    }
  }

  // std::cout << flag_other << ":" << flag_zero << std::endl;
  if ((flag_zero == 1) && (flag_other == 1)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

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

	int N, K, Q, tmp;
	scanf("%d %d %d", &N, &K, &Q);
	int initial_score = K - Q;
	vector<int> A(N, initial_score);

	for (int i = 0; i < Q; i++) {
		cin >> tmp;
		A[tmp - 1]++;
	}

	for (int i = 0; i < N; i++) {
		if (A[i] > 0) {
			putchar('Y');
			putchar('e');
			putchar('s');
			putchar('\n');
		}
		else {
			putchar('N');
			putchar('o');
			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 1024
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	string s; cin >> s;
	int n = s.length();
	cout << (n % 2 == (s[0] == s[n - 1]) ? "Second" : "First") << '\n';
	return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    ll  A,V,B,W,T;
    cin >>A>>V>>B>>W>>T;
    if(V<=W) cout <<"NO"<<endl;
    else{
        if((V-W)*T>=abs(A-B)){
            cout <<"YES"<<endl;
        }
        else cout <<"NO"<<endl;
    }
}



Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 100;
const int W = 1e5 + 10;
long long dp[W];

void relax(long long& a, long long b) {
	a = max(a, b);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, WW;
	cin >> n >> WW;
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	while (n--) {
		int w, v;
		cin >> w >> v;	
		for (int j = W - v; j >= 0; --j) {
			if (dp[j] != -1) {
				if (dp[j + v] == -1) {
					dp[j + v] = dp[j] + w;
				} else {
					dp[j + v] = min(dp[j + v], dp[j] + w);
				}
			}
		}
	}
	long long answer = 0;
	for (int i = 0; i < W; ++i) {
		if (dp[i] != -1) {
			if (dp[i] <= WW) {
				relax(answer, i);
			}
		}
	}
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pb(a) push_back(a)
#define oo 1000000007
#define maxN 55
using namespace std;
int n, k, a[maxN];
long long f[55][55][55*55];


int main() {
    //freopen("tak.inp", "r", stdin);
    //freopen("tak.out", "w", stdout);
    scii(n, k);
    fto(i, 1, n) sci(a[i]);
    long long res = 0;
    f[0][0][0] = 1;
    fto(i, 0, n) {
        fto(j, 0, i) {
            fto(s, 0, 55*55) {
                if(f[i][j][s]) {
                    f[i+1][j+1][s+a[i+1]] += f[i][j][s];
                    f[i+1][j][s] += f[i][j][s];
                }
            }
        }
    }
    fto(j, 1, n) {
        fto(s, 1, 55*55) {
            if(f[n][j][s] > 0 && s == j*k) {
                res += f[n][j][s];
            }
        }
    }
    
    cout << res << endl;
    return 0;
}

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


int main() {
  
  long A,B;
  
  cin>>A>>B;
  
  long X,tmp,r;
  
  X=A*B;
 
  /* 自然数 a > b を確認・入替 */
  if(A<B){
    tmp = A;
    A = B;
    B = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = A% B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
 
  /* 最小公倍数を出力 */
 // printf("最小公倍数 = %d\n", x/b);
  
  cout<<X/B<<endl;

  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;

const int MAXN = 3007;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

inline void chkmax(string &a, string b) { if(a.length() < b.length()) a = b; }

string dp[2][MAXN];

char s[MAXN], t[MAXN];
int n, m, pos;

inline void solve() {
	scanf("%s", s + 1); n = strlen(s + 1);
	scanf("%s", t + 1); m = strlen(t + 1);
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			chkmax(dp[pos][j], dp[pos ^ 1][j]);
			chkmax(dp[pos][j], dp[pos][j - 1]);
			chkmax(dp[pos][j], dp[pos ^ 1][j - 1]);
			if(s[i] == t[j]) chkmax(dp[pos][j], dp[pos ^ 1][j - 1] + (string){s[i]});
		}
		pos ^= 1;
	}
	cout << dp[pos ^ 1][m] << endl;
}

int main() {
	solve();

	return 0;
}



Measured memory_bytes: 4864
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n, m = 0;
    cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
    }
    int sum = 0;
    rep(i, n){
        sum += v[i];
        m = max(m, v[i]);
    }
    if(sum-m > m)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
using namespace std;
int main() {
    int n, b;
    cin >> n;
    int h[n];
    for (int i=0;i<n;i++) {
        cin >> b;
        h[i] = b;
    }
    long long int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
    }

    cout << dp[n-1] << endl;
}


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


int dfs(int now, const vector<vector<bool> >& graph, vector<bool> visited){
  bool all_visited = true;
  int n = graph.size();
  for(int i = 0; i < n; i++){
    if(!visited[i]){
      all_visited = false;
      i = n;
    }
  }
  if(all_visited) return 1;

  int ans = 0;
  for(int i = 0; i < n; i++){
    if(!graph[now][i]) continue;
    if(visited[i]) continue;

    visited[i] = true;
    ans += dfs(i, graph, visited);
    visited[i] = false;
  }
  // cout << "now: " << now << " ans:" << ans << endl;
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<bool> > graph(n, vector<bool>(n, false));
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    graph[a][b] = graph[b][a] = true;
  }

  vector<bool> visited(n, false);
  visited[0] = true;
  cout << dfs(0, graph, visited) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <pair <int, int> > a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    int mx = 0;
    for(auto &i : a){
        cin >> i.first >> i.second;
        mx = max(mx, i.second - i.first + 1);
    }
    int g = 0, h = 0;
    for(int i = 0 ; i < n ; i++){
        if(a[i].first > a[g].first) g = i;
        if(a[i].second < a[h].second) h = i;
    }
    int ans = mx + max(0, a[h].second - a[g].first + 1);
    vector <pair <int, int> > c;
    for(int i = 0 ; i < n ; i++){
        c.push_back(make_pair(max(0, a[i].second - a[g].first + 1), max(0, a[h].second - a[i].first + 1)));
    }
    sort(c.begin(), c.end());
    vector <pair <int, int> > suff(n);
    suff[n - 1] = c[n - 1];
    for(int i = n - 2 ; i >= 0 ; i--){
        suff[i].first = min(c[i].first, suff[i + 1].first);
        suff[i].second = min(c[i].second, suff[i + 1].second);
    }
    pair <int, int> pref = c[0];
    for(int i = 0 ; i < n - 1 ; i++){
        pref.first = min(pref.first, c[i].first);
        pref.second = min(pref.second, c[i].second);
        ans = max(ans, pref.first + suff[i + 1].second);
        ans = max(ans, pref.second+ suff[i + 1].first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2804
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 100100

//head

int n;
vi G[N];

unsigned int dfs(int i, int j) {
  unsigned int grundy = 0;
  for(int ne:G[i]) {
    if(ne == j) continue;
    grundy ^= dfs(ne, i)+1;
  }
  return grundy;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  cout << (dfs(0, -1)?"Alice\n":"Bob\n");
}

Measured memory_bytes: 13764
#include<stdio.h>
#define MAX 500000
#define SENTI 2000000000
int count = 0;
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void Marge(int*, int, int, int, int);
void margeSort(int*, int, int, int);

int main(){
  int n, i, A[MAX];

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

  margeSort(A, n, 0, n);

  for(i = 0 ; i < n ; i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }

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

  return 0;
}

void Marge(int A[], int n, int l, int m, int r){
  int n1, n2,i,j,k;

  n1 = m - l;
  n2 = r - m;
  for(i = 0 ; i < n1 ; i++){
    L[i] = A[l + i];
  }
  for(i = 0 ; i < n2 ; i++){
    R[i] = A[m + i];
  }
  L[n1] = R[n2] = SENTI;

  i = 0;
  j = 0;
  for(k = l ; k < r ; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void margeSort(int A[], int n, int l, int r){
  int m;
  if(l + 1 < r ){
    m = (l + r) / 2;
    margeSort(A, n, l, m);
    margeSort(A, n, m, r);
    Marge(A, n, l, m, r);
  }
}



Measured memory_bytes: 5644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	int l=s.size();
	if(s.size()%2)
	{
		printf("No");
		return 0;
	}
	for(int i=0;i<l/2-1;i++)
	{
		if(s[i]=='b')
			if(s[l-i-1]!='d')
			{
				printf("No");
				return 0;
			}
		if(s[i]=='p')
			if(s[l-i-1]!='q')
			{
				printf("No");
				return 0;
			}
		if(s[i]=='d')
			if(s[l-i-1]!='b')
			{
				printf("No");
				return 0;
			}
		if(s[i]=='q')
			if(s[l-i-1]!='p')
			{
				printf("No");
				return 0;
			}
	}
	printf("Yes");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        double a,b; cin>>a>>b;
        cout<<ceil((b-1)/(a-1))<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{
  int H,N;
  cin >> H >> N;

  int A;
  for(int i=0; i<N; i++){
    cin >> A;
    H -= A;
    if(H<=0){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256