akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,K;cin>>N>>K;
    vector<ll> H(N);
    rep(i,N)cin>>H[i];
    sort(all(H));

    ll sum = 0;
    rep(i,N){
        if(i < N-K){
            sum += H[i];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scanln(&s)
	fmt.Scanln(&t)
	ans := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <memory.h>
using namespace std;

template<typename T> inline void read(T& w)
{
    w = 0;
    char ch = getchar();
    while(ch<'0' || ch>'9')
        ch = getchar();
    while(ch>='0' && ch<='9') {
        w = (w<<3) + (w<<1) + ch-'0';
        ch = getchar();
    }
    return;
}
template<typename T> inline void write(T w)
{
    if(w > 9) {
        write(w / 10);
    }
    putchar(w%10 + '0');
    return;
}

const int MAXM = 1024;
const int MAXD = 8200;
const int INF = 0x3f3f3f3f;
int n, m, ed;
int dp[MAXM][MAXD];
int price[MAXM];
int data[MAXM];

int main()
{
    memset(dp, INF, sizeof(dp));
    int b, c;
    read(n); read(m);
    for(int i=0; i<n; i++){
        ed = (ed|1)<<1;
    }
    for(int i=0; i<m; i++){
        read(price[i]); read(b);
        for(int j=0; j<b; j++){
            read(c);
            data[i] |= (1<<c);
        }
    }
    dp[0][data[0]] = price[0];
    dp[0][0] = 0;
    for(int i=1; i<m; i++){
        for(int j=0; j<=ed; j++){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            dp[i][data[i]|j] = min(dp[i][data[i]|j], dp[i-1][j]+price[i]);
        }
    }
    if(dp[m-1][ed] == INF){
        puts("-1");
    }
    else{
        write(dp[m-1][ed]);
    }
    return 0;
}


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

int N,Q;

struct Data {
    int a,b;
    string ss;
    Data() {};
    Data(int a,int b,string ss) :
        a(a),b(b),ss(ss) {};

    bool operator<(const Data& data_) const {
        return (data_.b) > (b);
    }
    bool operator<(const int& val) const {
        return val > b;
    }
};

void solve() {
    Data data[1003];

    rep(i,N) {
        int a,b;
        string ss;
        cin>>ss>>a>>b;

        data[i] = Data(a,b,ss);
    }
    sort(data,data+N);

    rep(i,Q) {
        int a;
        cin>>a;
        int pos = lower_bound(data,data+N, a) - data;
        if(pos ==N) {
            cout<<"Unknown"<<endl;
            continue;
        }
        int t = a - (data[pos].b-data[pos].a);
        if(t <= 0) {
            cout<<"Unknown"<<endl;
            continue;
        }
        cout<<data[pos].ss<<" "<<t<<endl;


        
        
    }


}

int main() {
    while(cin>>N>>Q) {
        if(N+Q==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1288
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")

int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    double d,e,f,m,n,p,x,y,z,t,i,j,k;
    cin>>n>>x>>t;
    d=ceil(n/x);
    int c=d*t;
    cout<<c<<endl;
}


Measured memory_bytes: 3696
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def operation(a:list, n:int, idx:int):
    for i,ai in enumerate(a):
        if i==idx:
            a[i] += n
        else:
            a[i] -= 1
            
    return a

k = ni()
mod = k%50

a = [i for i in range(50)]

for m in range(mod):
    a = operation(a,50,m)

geta = k//50

a = [ai+geta for ai in a]

print(50)
print(*a)

Measured memory_bytes: 3064
using System;
using System.IO;

namespace problem
{
    class Program
    {
        static void Main(string[] args)
        {
            string honsu = Console.ReadLine();
            int a = int.Parse(honsu);
            // 半角スペースで文字列を分割して、各々を配列の要素として入れる
            string[] strs = honsu.Split(' ');
            int b = int.Parse(strs[0]);

            switch (a % 10) 
            {
                case 0:
                    Console.WriteLine("pon");
                    break;
                case 1:
                    Console.WriteLine("pon");
                    break;
                case 2:
                    Console.WriteLine("hon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
                case 4:
                    Console.WriteLine("hon");
                    break;
                case 5:
                    Console.WriteLine("hon");
                    break;
                case 6:
                    Console.WriteLine("pon");
                    break;
                case 7:
                    Console.WriteLine("hon");
                    break;
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 9:
                    Console.WriteLine("hon");
                    break;
            }

            Console.WriteLine();
        }
    }
}


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

int main(){
  int n,m;
  cin>>n>>m;

  vector<int> s[m];
  for(int i=0;i<m;i++){
    int k; cin>>k;
    s[i].resize(k);
    for(int j=0;j<k;j++){
      cin>>s[i][j];
      s[i][j]--;
    }
  }

  vector<int> p(m);
  for(int i=0;i<m;i++) cin>>p[i];
  
  int ans=0;
  for(int bit=0; bit<(1<<n);bit++){
    bool flag=true;
    for(int i=0;i<m;i++){
      int cnt=0;
      for(int j:s[i]){
        if((bit>>j)&1) cnt++;
      }
      if(cnt%2!=p[i]) flag=false;
    }
    if(flag) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
  int d,s,t;
  cin>>d>>s>>t;
  if(d <= (s*t))
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M;
  cin>>N>>M;
  if(max(N,M)==1)cout<<1<<endl;
  else if(min(N,M)==1)cout<<max(N,M)-2<<endl;
  else cout<<(N-2)*(M-2)<<endl;
  return 0;
}


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

int main() {
    int N;
    string work;

    cin >> N;

    N = N % 10;

    switch (N){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            work = "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            work = "pon";
            break;
        case 3:
            work = "bon";
            break;
        default:
            break;
    }

    

    cout << work << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   string s, t;
   cin >> s >> t;
   cout << t << s << endl;
}

Measured memory_bytes: 3588
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		char[][] maze = new char[h][w];
		for (int x = 0; x < h; x++) {
			maze[x] = in.next().toCharArray();
		}
		int countdot = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (maze[i][j] == '.') countdot++;
			}
		}
		int[][] v = new int[h][w];
		for (int y = 0; y < h; y++) {
			Arrays.fill(v[y], -1);
		}
		int sx = 0, sy = 0, gx = h-1, gy = w-1;
		int[] dx = {0,0,1,-1};
		int[] dy = {1,-1,0,0};
		Deque<P> q = new ArrayDeque<>();
		q.push(new P(sx, sy));
		v[sx][sy] = 1;

		while (!q.isEmpty()) {
			P p = q.pop();
			int x = p.x;
			int y = p.y;

			for (int i = 0; i < 4; i++) {
				int mx = x + dx[i];
				int my = y + dy[i];
				if (mx < 0 || mx >= h || my < 0 || my >= w || maze[mx][my] == '#') {
					continue;
				}
				if (v[mx][my] != -1) {
					continue;
				}
				q.add(new P(mx, my));
				v[mx][my] = v[x][y] + 1;
			}
		}
		int ans = v[gx][gy] != -1 ? countdot - v[gx][gy] : -1;
		System.out.println(ans);
	}

	public static class P {
		int x;	// 縦
		int y;	// 横

		public P(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

}


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

int main()
{
	int line,n;
	char c;
	cin >> line;
	cin >> n;

	int values[31];
	for(int i=0;i<line;i++)
	{
		values[i] = i+1;
	}

	for(int i=0;i<n;i++)
	{
		int a,b;
		cin >> a >> c >> b ;

		int value = values[a-1];
		values[a-1] = values[b-1];
		values[b-1] = value;
	}

	for(int i=0;i<line;i++)
	{
		cout << values[i] << endl; 
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
    int N;
    string S,T="";
    cin >> N >> S;
    char U=' ';
    for (int i=0; i<N; i++) {
        if (U != S[i]) {
            T += S[i];
            U = S[i];
        }
    }
    cout << T.length() << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>

using namespace std;

int main(){
    int n;
    cin >> n;
    map<int, int> m;
    int temp;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        m.emplace(temp, i+1);
    }
    for(auto itr : m)
    {
        cout << itr.second<<" ";
    }
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <cmath>
#define llint long long
#define inf 1e18
#define eps 1e-9

using namespace std;

struct vec3d{
	double x, y, z;
	vec3d(){}
	vec3d(double x, double y, double z){
		this->x = x, this->y = y, this->z = z;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec3d operator+(vec3d ope){
		return vec3d(add(x, ope.x), add(y, ope.y), add(z, ope.z));
	}
	vec3d operator-(vec3d ope){
		return vec3d(add(x, -ope.x), add(y, -ope.y), add(z, -ope.z));
	}
	double dot(vec3d ope){
		return add(add(x*ope.x, y*ope.y), z*ope.z);
	}
	vec3d cross(vec3d ope){
		double retx = add(y*ope.z, -z*ope.y);
		double rety = add(z*ope.x, -x*ope.z);
		double retz = add(x*ope.y, -y*ope.x);
		return vec3d(retx, rety, retz);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

double distPP(vec3d p, vec3d q){
	return (p-q).norm();
}
double distSP(vec3d p, vec3d q, vec3d x){
	if((x-p).dot(q-p) <= 0) return distPP(p, x);
	if((x-q).dot(p-q) <= 0) return distPP(q, x);
	return fabs((x-p).cross(q-p).norm()/distPP(p, q));
}

llint n, Q;
vec3d p[55], s, t;
double r[55];
llint l[55];

int main(void)
{
	cin >> n >> Q;
	for(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y >> p[i].z >> r[i] >> l[i];
	
	for(int i = 1; i <= Q; i++){
		cin >> s.x >> s.y >> s.z >> t.x >> t.y >> t.z;
		llint ans = 0;
		for(int j = 1; j <= n; j++){
			if(distSP(s, t, p[j]) <= r[j]+eps) ans += l[j];
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
 
const int N = 3e2 + 10;

double dp[N][N][N], e[N][N][N];
ll a[N], n, cnt[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(9);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	dp[cnt[1]][cnt[2]][cnt[3]] = 1;
	for (int k = n; ~k; k--) {
		for (int j = n; ~j; j--) {
			for (int i = n; ~i; i--) {
				if(i == 0 && j == 0 && k == 0)
					continue;
				if(i + j + k > n)
					continue;
				double ev = (double) (n - (i + j + k)) / n;
				ev = ev / (1 - ev) + 1;
				e[i][j][k] += ev * dp[i][j][k];
				if(i > 0) {
					ev = (double) i / (i + j + k);
					dp[i - 1][j][k] += dp[i][j][k] * ev;
					e[i - 1][j][k] += e[i][j][k] * ev;
				}
				if(j > 0) {
					ev = (double) j / (i + j + k);
					dp[i + 1][j - 1][k] += dp[i][j][k] * ev;
					e[i + 1][j - 1][k] += e[i][j][k] * ev;
				}
				if(k > 0) {
					ev = (double)k / (i + j + k);
					dp[i][j + 1][k - 1] += dp[i][j][k] * ev;
					e[i][j + 1][k - 1] += e[i][j][k] * ev;
				}
			}
		}
	}
	cout << e[0][0][0] << "\n";
}

Measured memory_bytes: 452864
// ABC160E - Red and Green Apples

#include <bits/stdc++.h>
using namespace std;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	multimap<int, int> a;

	for (int i = 0; i < A; i++) {
		int temp;
		cin >> temp;
		a.insert(make_pair(temp, 1));
	}
	for (int i = 0; i < B; i++) {
		int temp;
		cin >> temp;
		a.insert(make_pair(temp, 2));
	}
	for (int i = 0; i < C; i++) {
		int temp;
		cin >> temp;
		a.insert(make_pair(temp, 3));
	}

	long long int answer = 0;
	int x = 0;
	int y = 0;
	int z = 0;

	multimap<int, int>::reverse_iterator rit;
	for (rit = a.rbegin(); rit != a.rend(); rit++) {
		pair<int, int> temp = *rit;
		if ((temp.second == 1)&&(x < X)) {
			answer += temp.first;
			x++;
		} else if ((temp.second == 2)&&(y < Y)) {
			answer += temp.first;
			y++;
		} else if ((temp.second == 3)&&(x + y + z < X + Y)) {
			answer += temp.first;
			z++;
		}

		if (x + y + z == X + Y) {
			break;
		}
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 14336
n=int(input())
a=[0]
for i in input().split():
    a.append(int(i))
a.append(0)

s=0
for i in range(n+1):
    s+=abs(a[i]-a[i+1])


for i in range(n):
    print(s+abs(a[i]-a[i+2])-abs(a[i]-a[i+1])-abs(a[i+1]-a[i+2]))

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

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

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, K; cin >> N >> K;
    vi a(N); REP(i, N) cin >> a[i];
    int ans = INF;
    REP(b, 1 << N)
    {
        if(__builtin_popcount(b) < K) continue;
        bitset<15> bit(b);
        int maxheight = 0;
        int cost = 0;
        REP(i, N)
        {
            if(bit[i] && a[i] <= maxheight) 
            {
                maxheight++;
                cost += maxheight-a[i];
            }
            chmax(maxheight, a[i]);
        }
        chmin(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int N,L;
    cin >> N >> L;
    string S[100];
    for(int i = 0;i < N;i++){
        cin >> S[i];
    }
    sort(S,S+N);
    for(string str:S)cout << str;
    cout << endl;
}

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

void solve() {
	char c;
	cin >> c;
	if (c < 97) {
		cout << 'A' << endl;
	} else cout << 'a' << endl;
}

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

    int t = 1;
//    cin>>t;
    for(; t; t--) {
    	solve();
	}
	return 0;
}

Measured memory_bytes: 3660
# include <cstdio>
# include <queue>
# include <algorithm>

using namespace std;

const int MAX_N = 2e5 + 10;

int n;
int p[MAX_N];
int id[MAX_N];
int tree[2][MAX_N * 4];

int ans[MAX_N];

priority_queue <pair <pair <int, int>, pair <int, int>>> pq;

void update (int pa, int idx, int l, int r, int q, int u)
{
    if (l == r)
    {
        tree[pa][idx] = u;
        return;
    }

    int mid = (l + r) >> 1;

    if (q <= mid)
        update (pa, idx * 2, l, mid, q, u);
    else
        update (pa, idx * 2 + 1, mid + 1, r, q, u);

    if (tree[pa][idx * 2] < tree[pa][idx * 2 + 1])
        tree[pa][idx] = tree[pa][idx * 2];
    else
        tree[pa][idx] = tree[pa][idx * 2 + 1];
}


int find (int pa, int idx, int l, int r, int ql, int qr)
{
    if (ql <= l && r <= qr)
        return tree[pa][idx];

    int mid = (l + r) >> 1;

    int la, ra;

    if (ql <= mid)
        la = find (pa, idx * 2, l, mid, ql, qr);
    else
        la = (1 << 30);

    if (mid < qr)
        ra = find (pa, idx * 2 + 1, mid + 1, r, ql, qr);
    else
        ra = (1 << 30);

    return (la < ra) ? la : ra;
}

pair <int, int> get (int l, int r)
{
    pair <int, int> f;
    f.first = -find (l & 1, 1, 1, n, l, r);
    f.second = -find ((l & 1) ^ 1, 1, 1, n, id[-f.first], r);
    return f;
}

void add (int l, int r)
{
    if (r < l)
        return;
    pair <int, int> f = get (l, r);
    ///printf ("%d %d = %d %d\n", l, r, -f.first, -f.second);

    pq.push ({f, {l, r}});
}

int main ()
{
    int i;

    scanf ("%d", &n);
    for (i = 1; i <= n; i ++)
    {
        scanf ("%d", &p[i]);
        id[p[i]] = i;
        update (i & 1, 1, 1, n, i, p[i]);
        update ((i & 1) ^ 1, 1, 1, n, i, (1 << 30));
    }

    pq.push ({{get (1, n)}, {1, n}});

    for (i = 0; i < n; i += 2)
    {
        pair <pair <int, int>, pair <int, int>> pqt = pq.top ();
        pair <int, int> can = pqt.first;
        pair <int, int> itr = pqt.second;

        pq.pop ();

        ///printf ("%d %d %d %d\n", -can.first, -can.second, itr.first, itr.second);

        ans[i] = -can.first;
        ans[i + 1] = -can.second;

        int x = id[ans[i]], y = id[ans[i + 1]];

        add (itr.first, x - 1);
        add (x + 1, y - 1);
        add (y + 1, itr.second);
    }

    for (i = 0; i < n; i ++)
        printf ("%d ", ans[i]);
    printf ("\n");

    return 0;
}


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int l, k;
ll dp[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> l >> k;
  dp[1] = dp[k] = 1;
  for (int i = 1; i <= l; i++) {
    if (i+2 <= l) dp[i+2] += dp[i];
    if (i+k+1 <= l) dp[i+k+1] += dp[i];
  }
  ll ans = 0;
  for (int i = 1; i <= l; i++) {
    ans += dp[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


bool chk1(string s) {
  bool res = true;
  rep(i, sz(s)) if (s.substr(i, 2) == "##") res = false;
  return res;
}

bool chk2(string s) {
  bool res = false;
  rep(i, sz(s)) if (s.substr(i, 3) == "...") res = true;
  return res;
}

int main() {
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  --a, --b, --c, --d;
  string s; cin >> s;

  bool ok = true;

  if (!chk1(s.substr(a, c-a+1))) ok = false;
  if (!chk1(s.substr(b, d-b+1))) ok = false;
  if (d < c) {
    if (!chk2(s.substr(b-1, d-b+3))) ok = false;
  }

  cout << (ok ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fastio
    int a,b,c,d;cin>>a>>b>>c>>d;
    int turn=1;
    while(1){
      if(turn){
        if(c<=b){
          break;
        }
        c-=b;
      }else{
        if(a<=d){
          break;
        }
        a-=d;
      }
      turn^=1;
    }   
    if(turn)  cout<<"Yes\n";
    else      cout<<"No\n"; 
    return 0;
}

Measured memory_bytes: 3608
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
ans = 0
now = 1
while (1):
    now = l[now - 1]
    ans += 1

    if now == 2:
        print(ans)
        exit()
    if ans > n:
        print(-1)
        exit()


Measured memory_bytes: 7084
#include <stdio.h>
#include <string.h>

int main(void)
{
	char roman[1000];
	int roman_fix;
	int i;
	int len;
	int temp;
	
	while (scanf("%s",roman) != EOF){
		getchar();
		len = strlen(roman) - 1;
		roman_fix = 0;
		temp = 0;
		
		for (i = len; i >= 0; i--){
			switch (roman[i]){
				case 'I':
				if (temp > 1) roman_fix += -1;
				else roman_fix += 1;
				temp = 1;
				break;
				
				case 'V':
				if (temp > 5) roman_fix += -5;
				else  roman_fix += 5;
				temp = 5;
				break;
				
				case 'X':
				if (temp > 10) roman_fix += -10;
				else roman_fix += 10;
				temp = 10;
				break;
				
				case 'L':
				if (temp > 50) roman_fix += -50;
				else roman_fix += 50;
				temp = 50;
				break;
				
				case 'C':
				if (temp > 100) roman_fix += -100;
				else roman_fix += 100;
				temp = 100;
				break;
				
				case 'D':
				if (temp > 500) roman_fix += -500;
				else roman_fix += 500;
				temp = 500;
				break;
				
				case 'M':
				roman_fix += 1000;
				temp = 1000;
				break;
			}
		}
		printf("%d\n", roman_fix);
		memset(roman, '\0', sizeof(roman));
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  int A,B; cin>>A>>B;
  int ct=0;
  int now=1;
  while(now<B){
    ++ct;
    now+=(A-1);
  }
  cout<< ct<<"\n";
}

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


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        if( (k-1)*i >= (n-1)){
            out(i);
            return 0;
        }
    }
}

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

int main() {

    int n;
    cin >> n;
    vector<int> d(n);
    vector<int> empty(n);
    for(int i = 0; i < n; i++)  cin >> d[i];

    int count = 0;

    for(int i = 0; i < n; i++){
        int max = 0;
        for(int j = 0; j < n; j++){
            if(d[j] > max)  max = d[j];
        }

        count += 1;

        for(int k = 0; k < n; k++){
            if(d[k] == max){
                d[k] = 0;
            }
        }

        if(d == empty ) break;

    }

    cout << count;
        


}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, min int
	fmt.Scan(&n, &min)
	xs := make([]int, 4)
	for i := range xs {
		fmt.Scan(&xs[i])
		if xs[i] < min {
			min = xs[i]
		}
	}
	fmt.Println(int64(math.Ceil(float64(n)/float64(min))) + 4)
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;


int main(){

   string S;
   cin>> S;

   int ans=0;
   char p;
   for(int i=0; i<S.size(); i++){
      if(i>0){
         if(p!=S[i]){
            ans++;
         }
      }
      p=S[i];
   }

   cout<< ans<< endl;

   return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    string s;
    cin >> s;
    int n = s.length();
    int ans = 1000;
    for(int i = 0; i <= n-3; i++){
        int x = (s[i] - '0')*100 + (s[i+1] - '0')*10 + (s[i+2] - '0');
        ans = min(ans, abs(x - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int num1 = Integer.parseInt(sc.next());
        String op = sc.next();
        int num2 = Integer.parseInt(sc.next());
        if ("+".equals(op)) {
        	System.out.println(num1 + num2);
        } else {
            System.out.println(num1 - num2);
        }
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
int f(int *n,int l,int min,int max){
  int r=1,i,j,s[10000];
  for(s[i=0]=min-1;i<l;i++){
    for(s[j=r]=max+1;s[j-1]>=n[i];j--);
    s[j]=n[i];
    if(j==r)r++;
  }
  return r-1;
}
int lub(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lub(l,m,n,d):lub(m+1,r,n,d);
}
int lis(int *d,int n){
  int r=0,i,j,s[10000]={d[0]};
  for(i=1;i<n;i++)s[r]<d[i]?(s[++r]=d[i]):(s[lub(0,r,d[i],s)]=d[i]);
  return r+1;
}
int main(){
  int n,m,a[110][2],b[110][2],c[210],i,j,ar,br;
  while(scanf("%d",&n),n){
    for(i=ar=0;i<n;i++)scanf("%d %d",&a[i][0],&a[i][1]);
    scanf("%d",&m);
    for(i=br=0;i<m;i++)scanf("%d %d",&b[i][0],&b[i][1]);
    a[n][0]=b[m][0]=10000;
    for(i=0;i<n+m;i++){
      if     (a[ar][0]<b[br][0])c[i]=a[ar++][1];
      else if(a[ar][0]>b[br][0])c[i]=b[br++][1];
      else{
	if   (a[ar][1]<b[br][1])c[i]=b[br++][1];
	else                    c[i]=a[ar++][1]; 
      }
    }
    printf("%d\n",lis(c,n+m));
  }
  return 0;
}
  

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

llint dps(llint h) {
	if (h==1) {
		return 1;
	} else {

		return 1+2*dps(h/2);
	}
}

int main (void)
{
	//INPUT
	llint H;
	cin>> H;

	llint ans=dps(H);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    int N,M;
    cin>>N>>M;
    vector<int>s(M);
    vector<char>c(M);
    string d;
    set<int>S;
    map<int,char>ma;
    rep(i,M){
        cin>>s[i]>>c[i];
    }
    rep(i,M){
        int a=s[i]-1;
        char b=c[i];
        if(ma.count(a)&&ma.at(a)!=b){
            cout<<-1<<endl;
            return 0;
        }
        ma[a]=b;
        d[a]=b;
    }
    if(d[0]=='0'&&N!=1){
        cout<<-1<<endl;
        return 0;
    }
    rep(i,N){
        if(d[i]>=48&&d[i]<=57){
        }else{
            d[i]='0';
        }
    }
    if(N>=2&&d[0]=='0'){
        d[0]='1';
    }
    rep(i,N){
        cout<<d[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
signed main(void) 
{
    ll a, b, k;
    ll r = 0;
    cin >> a >> b >> k;
    cout << max(a-k, r) << " " << min (b, max(a+b-k, r));
   
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
string out(vector<int> ve, int size) {
    string s;
    for (int i = 0; i < size-1; ++i)
    {
        s += to_string(ve[i]) + " ";
    }
    s += to_string(ve[size-1]);
    return s;
}
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    cout << out(a, n) << endl;
 
    for (int i = 1; i < n; ++i)
    {
        int v = a[i];
        int j = i-1;
        while (j >= 0 && a[j] > v)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        cout << out(a, n) << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef vector<LL> vl;
typedef pair<LL, LL> pl;
typedef vector<pair<LL, LL>> VP;
typedef tuple<LL, LL, LL> tl;
const LL N=pow(10, 9)+7;
#define ull unsigned long long int 
#define endl "\n"
#define REP(i, a, b) for(LL i=a; i<b; i++)
#define RREP(i, a, b) for(LL i=a; i>b; i--)
#define WE(i) while(i--)
#define PB push_back
#define PF pop_front
#define MP make_pair
#define MT make_tuple
#define F first
#define S second

LL sod(LL a)
{
    LL sum=0;
    while(a!=0)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

LL num1(LL a)
{
    LL s=0;
    while(a!=0){
        if(a%2==1){
            s++;
        }
        a=a/2;
    }
    return s;
}

LL bmod(string s, LL a)
{
    LL res=0;
    REP(i, 0, s.length()){
        res=(10*res+(LL)s[i]-'0')%a;
    }
    return res;
}

void pd(LL n) 
{ 
    LL ans=0, x=sqrt(n);
    if(x%1==0){
        REP(i, 1, x+1){
            if(n%i==0){
                ans+=2;
            }
            if(n==i*i){
                ans--;
            }
        }
    }
    else{
        REP(i, 0, x){
            if(n%i==0){
                ans+=2;
            }
        }
    }
    cout << ans << endl;
}

void primeFactors(LL n, vl &v)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        v.PB(2); 
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            v.PB(i);
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        v.PB(n);  
}  

LL decToBinary(LL n) 
{
    LL sum=0;
    while (n > 0) { 
        if(n%2==1) sum++; 
        n=n/2; 
    } 
    return sum;
} 

LL solve()
{
    LL n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2==1){
        cout << "No" << endl;
    }
    else{
        REP(i, 0, n/2){
            if(s[i]!=s[i+n/2]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}

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

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

    LL T=1;
    //cin >> T;
    WE(T){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, cl[100007], mx;
vector<pt> g[100007];

void dfs(ll v, ll pa, ll paCl) {
    ll color = 1;
    for(auto i : g[v]) {
        if(i.fi == pa) continue;
        if(color == paCl) color ++;

        cl[i.se] = color;
        mx = max(mx, color);

        dfs(i.fi, v, color);
        color ++;
    }
}

int main () {
    fastIO
    cin >> n;
    for(li i = 1, u, v; i < n; i ++) {
        cin >> u >> v;
        g[--u].push_back({--v, i});
        g[v].push_back({u, i});
    }
    cl[0] = 1;
    dfs(0, -1, 0);

    cout << mx << "\n";
    for(li i = 1; i < n; i ++) cout << cl[i] << " ";
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n, m;
  cin >> n >> m;

  vi s(n), t(m);
  rep(i, 0, n) cin >> s[i];
  rep(i, 0, m) cin >> t[i];

  vvi dp(n+1, vi(m+1));
  dp[0][0] = 1;
  rep(i, 0, n+1) rep(j, 0, m+1){
    if(i-1 >= 0 and j-1 >= 0){
      (dp[i][j] = dp[i][j]-dp[i-1][j-1]+mod) %= mod;
      if(s[i-1] == t[j-1]){
        (dp[i][j] += dp[i-1][j-1]) %= mod;
      }
    }
    if(i-1 >= 0) (dp[i][j] += dp[i-1][j]) %= mod;
    if(j-1 >= 0) (dp[i][j] += dp[i][j-1]) %= mod;
  }

  cout << dp[n][m] << endl;

  return 0;
}


Measured memory_bytes: 31616
#include <stdio.h>

int main(void){

  long n,t[5];
  scanf("%ld", &n);
  for (int i = 0; i < 5; i++) {
    scanf("%ld", &t[i]);
  }
  long min = t[0];
  for (int i = 1; i < 5; i++) {
    if (t[i] < min) {
      min = t[i];
    }
  }
  long answer = n/min+4;
  if (n%min != 0) {
    answer++;
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<int> A(N); rep(i,N) std::cin >> A[i];
  ll S = 0; rep(i,N) S += A[i];
  std::sort( all(A), std::greater<int>() );
  if ( A[M-1]*4*M >= S ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}



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

typedef long long LL;

int main(void){
    int x;
    cin >> x;
    int a = 0,b = 0,tmp = 0;
    a = x / 500;
    if(a != 0){
        tmp = x - a * 500;
        b = tmp / 5;
    }else{
        b = x / 5;
    }
    int ans = a * 1000 + b * 5;
    cout << ans << endl;
}

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

int main() {
    string S;
    //string ans;
    int w;
    char s[1005];
    cin>>S;
    cin>>w;

    int cnt=0;
    int tmp=0;

    while(cnt <= S.size()){
        //cout<<S[cnt];
        //SS.push_back(S[cnt]);
        s[tmp] = S[cnt];
        cnt += w;
        tmp++;
    }

    cout<<s<<endl;

    // for(int i = 0; i < tmp ;i++){
    //     cout<<SS[i]<<endl;
    // }

}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#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;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    map<int, int> plus;
    for(int i=0; i<n; i++) plus[a[i] + i]++;

    ll ans = 0;
    for(int i=0; i<n; i++){
        if(i - a[i] <= 0) continue;
        ans += plus[i - a[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14228
#!/usr/bin/env perl
use strict;
use warnings;

my $hp = 0;
my $n = 0;
($hp, $n) = split / /, <STDIN>;
chomp ( my @special_attacks = split / /, <STDIN> );

@special_attacks = sort { $b <=> $a } @special_attacks;

for my $attack (@special_attacks) {
  $hp = $hp - $attack;
}

if ($hp <= 0) {
  print "Yes\n";
} else {
  print "No\n";
}


Measured memory_bytes: 18212
from sys import stdin 
from collections import Counter

N, P = map(int, stdin.readline().split())
S = stdin.readline().strip()

ans = 0
if P in (2, 5):
	for i in range(N):
		if int(S[i]) % P == 0:
			ans += i + 1


else:

	count = Counter()
	ten = 1
	mod = 0
	for i in range(N):
		x = (int(S[N - i - 1])*ten + mod) % P
		ten = ten*10 % P 
		mod = x
		count[x] += 1

	count[0] += 1


	for i in count.values():
		ans += i*(i - 1)//2

print (ans)

Measured memory_bytes: 42956
#include<iostream>
#include<cstdio>
#include<queue>
#include<set>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
const int MOD=1000000007;
int a[MAXN];
map<int,int> mp;
char s[2][60];
vector<int> v;

bool cmp(int x,int y)
{
    return x>y;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        v.clear();
        scanf("%s",s[0]);
        scanf("%s",s[1]);
        for(int i=0;i<n;i++)
        {
            if(s[0][i]==s[1][i]) v.push_back(1);
            else if(i<=n-1&&s[0][i]==s[0][i+1])
            {
                v.push_back(2);
                i++;
            }
        }
        int sz=v.size();
        LL ans=0;
        if(v[0]==1) ans=3;
        else if(v[0]==2) ans=6;
        for(int i=1;i<sz;i++)
        {
            if(v[i-1]==1&&v[i]==1) ans=(ans*2)%MOD;
            else if(v[i-1]==1&&v[i]==2) ans=(ans*2)%MOD;
            else if(v[i-1]==2&&v[i]==2) ans=(ans*3)%MOD;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int res = 0;
  int x, a, b, c; cin >> a >> b >> c >> x;
  x /= 50;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        res += i * 10 + j * 2 + k == x;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    cnt = 0
    for _ in range(N):
        d1,d2 = LI()
        if d1 == d2:
            cnt += 1
            if cnt >= 3:
                print('Yes')
                return
        else:
            cnt = 0
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 68744