akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i, 0, n) cin >> a[i];
        sort(all(a));
        ll l = a[n / 2 - 1];
        ll r = a[n / 2];
        ll ans = r - l;
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char **argv){
	int a,b,c;
	int i,n;
	
	scanf("%d %d %d",&a, &b, &c);

	n = 0;
	for(i=a;i<=b;i++){
		if( c % i == 0 ){
			n++;
		}
	}
	printf("%d\n",n);
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define ld long double
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)3e3+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

ld a[N], dp[N][N];
int main(){
    int n;sc(n);
    fr(i, 1, n) cin >>a[i];
    dp[1][1] = a[1];
    dp[1][0] = 1-a[1];
    fr(i, 2, n){
        fr(j, 0, i)
            if (!j)
                dp[i][j] += dp[i-1][j] * (1-a[i]);
            else{
                dp[i][j] += dp[i-1][j-1] *(a[i]) + dp[i-1][j] *(1-a[i]);
            }
    }
    trace(dp[1][0], dp[1][1], dp[2][0], dp[2][1], dp[2][2]);
    ld ans = 0.0;
    fr(i, n/2+1, n) ans += dp[n][i];
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}



Measured memory_bytes: 139264
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <functional>
#include <iostream>
#include <vector>


using bint = boost::multiprecision::cpp_int;


template <class T>
void combination(const std::vector<T>& seed, const int& target_size, std::vector<std::vector<int>>& ans)
{
    std::vector<int> indices(target_size);
    const int seed_size = seed.size();
    int start_index = 0;
    int size = 0;
    int ans_index = 1;
    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
                std::vector<T> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
                }
                ans.at(comb[0] - 1).emplace_back(ans_index);
                ans.at(comb[1] - 1).emplace_back(ans_index);
                ans_index++;
                break;
            }
        }
        size--;
        if (size < 0) {
            break;
        }
        start_index = indices[size] + 1;
    }
}


int main()
{
    int N;
    std::cin >> N;
    std::vector<int> applies{};
    bint n = 2;
    bint max = 1;
    for (int i = 0; i < 10; i++) {
        max *= 10;
    }
    while (true) {
        bint nC2 = n * (n - 1) / 2;
        if (nC2 > max) {
            break;
        }
        applies.emplace_back(nC2);
        n++;
    }
    auto it = std::find(applies.begin(), applies.end(), N);
    if (it == applies.end()) {
        std::cout << "No" << std::endl;
        return 0;
    }
    std::cout << "Yes" << std::endl;
    int k = std::distance(applies.begin(), it) + 2;
    std::cout << k << std::endl;
    std::vector<std::vector<int>> ans(k);
    std::vector<int> comb(k);
    for (int i = 0; i < k; i++) {
        comb.at(i) = i + 1;
    }
    combination<int>(comb, 2, ans);
    for (const auto& row : ans) {
        std::cout << row.size() << " ";
        for (const auto& col : row) {
            if (col != row.at(row.size() - 1)) {
                std::cout << col << " ";
            } else {
                std::cout << col << " ";
            }
        }
        std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int ans=0;
  rep(i,n){
    int w;
    cin >> w;
    if(w!=i+1)ans++;
  }
  if(ans==0||ans==2)cout << "YES" << endl;
  else cout << "NO" << endl;
}  


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

typedef unsigned long long L;
int main(){
	for(L a,b,c,d,e; cin>>a>>b;){
		for(c=a,d=b;;){
			e = c % d;
			c = d;
			d = e;
			if(!e)break;
		}
		cout<<c<<" "<<a*b/c<<endl;
	}
}

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

long long Gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return Gcd(b, a % b);
}

long long Lcm(long long a, long long b) { return a / Gcd(a, b) * b; }

int main() {
  int A, B;
  cin >> A >> B;
  cout << Lcm(A, B) << endl;
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    int a[5], ans;
    forn(i, 0, 5)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		String str = sc.next();
		if(str.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(str.equals("Cloudy")) {
			System.out.println("Rainy");
		}else{
			System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 23124
#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
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
 
int main() {
  string s;
  cin>>s;
  ll ans=0;
  int n=s.size();
for(int bit=0;bit < (1<<n);++bit){
    string S=s;
for(int i = 0; i < n ;i++){
    int g=2*(i+1)-1;
if(bit&(1<<i)){
    S.insert(g,"+");
}else
{
    S.insert(g,"0");
}
}
ll count=0;
for(int i=0;i<S.size();i++){
if(S[i]=='0') continue;
else if(S[i]=='+'){
    ans+=count;
    count=0;
}else
{
    count*=10;
    count+=S[i]-'0';
}
//cout<<ans<<endl;
}
ans+=count;
count=0;
//cout<<S<<endl;
}
cout<<ans/2<<endl;
    return 0;
}


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

int main(){
    ll a,b,c,k;
    ll ans=0;
    cin >> a >> b >> c >> k;
    if(a==k or a+b==k){
        cout << a << endl;
        return 0;
    }else if(a>k or a+b>k){
        cout << k << endl;
        return 0;
    }else if(a+b+c==k){
        cout << a-c << endl;
        return 0;
    }else if(a+b+c>k)
        cout << a-(k-(a+b)) << endl;
        return 0;
    }


Measured memory_bytes: 3584
#include <stdio.h>

int main(){
  int N,S=0;
  int A[30],B[30],C[30];
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
    scanf("%d",A+i);
  for(int i=1;i<=N;i++)
    scanf("%d",B+i);
  for(int i=1;i<=N;i++)
    scanf("%d",C+i);
  for(int i=1;i<=N;i++)
    S+=B[A[i]];
  for(int i=1;i<N;i++)
    if(A[i]+1==A[i+1])
      S+=C[A[i]];
  printf("%d\n",S);
  return 0;
}


Measured memory_bytes: 1712
#include <stdio.h>

int main(void) {
	int N, A, B, C, D;
	int i;
	int count1 = 0;
	int count2 = 0;

	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);

	char masu[N];

	for (i = 0;i < N;i++) {
		scanf("%s", &masu[i]);
	}

	if (C < D) {
		for (i = A-1;i <= C-3;i++) {
			if (masu[i] == '#'&& masu[i+1]=='#'){
				count1++;
			}
		}

		for (i = B-1;i <= D - 3;i++) {
			if (masu[i] == '#' && masu[i + 1] == '#') {
				count1++;
			}
		}

		if (count1 == 0) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	else {
		for (i = A-1;i <= C - 3;i++) {
			if (masu[i] == '#' && masu[i + 1] == '#') {
				count1++;
			}
		}
		for (i = B - 2;i <= D - 2;i++) {
			if (masu[i] == '.' && masu[i + 1] == '.' && masu[i + 2] == '.') {
				count2++;
			}
		}
		if (count1==0 && count2 > 0) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}

	return 0;

}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100;
int x[MAXN + 5], y[MAXN + 5];
int main() {
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	for(int i=1;i<=N;i++)
		scanf("%d", &x[i]);
	sort(x+1, x+N+1);
	for(int i=1;i<=M;i++)
		scanf("%d", &y[i]);
	sort(y+1, y+M+1);
	if( max(X, x[N]) < min(Y, y[1]) ) puts("No War");
	else puts("War");
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DAddAndRemove {
public:

    vector<ll> a;
    map<P, ll> dp[20][20];

    ll calc(int l, int r, int xl, int xr) {
      if (l + 1 == r) return 0;
      P p = {xl, xr};
      if (dp[l][r].find(p) != dp[l][r].end()) {
        return dp[l][r][p];
      }
      ll ret = LLONG_MAX;
      for(int m=l+1; m<r; m++) {
        ll now = calc(l, m, xl, xl+xr) + calc(m, r, xl+xr, xr)
            + (xl + xr) * a[m];
        chmin(ret, now);
      }
      dp[l][r][p] = ret;
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      a.resize(n);
      rep(i, n) {
        cin >> a[i];
      }
      ll ret = calc(0, n-1, 1, 1);
      cout << ret + a[0] + a[n-1] << endl;
    }
};

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

Measured memory_bytes: 18560
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	Graph g(N);
	loop(N - 1) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		addEdge(g, a, b, c);
	}
	vector<int>color(N, -1);
	function<void(int,int )>dfs = [&](int v,int c) {
		color[v] = c;
		for (auto &e : g[v]) {
			if (e.w % 2 == 0) {
				if (color[e.d] == -1) {
					dfs(e.d, c);
				}
				else {
					assert(color[e.d] == c);
				}
			}
			else {
				if (color[e.d] == -1) {
					dfs(e.d, not c);
				}
				else {
					assert(color[e.d] == not c);
				}
			}
		}
	};

	dfs(0, 0);
	rep(i, 0, N) {
		cout << color[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 14464
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

string s;

int get_next_rl(int pos) {
	for (int i = pos + 1; i < s.size(); i++) {
		if (s[i] == 'R' && s[i*1] == 'L') {
			return i;
		}
	}

	return -1;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();

	s += '?';

	vector<int> cnt(n, 0);

	int pos = -1;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'L') {
			if (pos == -1) {
				pos = i;
			}

			cnt[pos - (i - pos) % 2]++;
		} else {
			pos = -1;
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'R') {
			if (pos == -1) {
				pos = i;
			}

			cnt[pos + (pos - i) % 2]++;
		} else {
			pos = -1;
		}
	}


	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << cnt[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
using ui = unsigned int;
using ul = unsigned long;
#pragma GCC optimize("Ofast")
#define loop(i, n) for (ui i = 0; i < n; i++)
ul bit[550001];
struct BIT
{
    ui n;
    inline ul sum(ui x)
    {
        ul ret = 0;
        while (x > 0)
        {
            ret += bit[x];
            x -= x & -x;
        }
        return ret;
    }
    BIT(ui n0) : n(n0) {}
    inline ul sum(ui l, ui r)
    {
        return sum(r + 1) - sum(l);
    }
    inline void add(ui i, ul x)
    {
        i++;
        while (i <= n)
        {
            bit[i] += x;
            i += i & -i;
        }
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ui N, Q;
    cin >> N >> Q;
    BIT data(N);
    loop(i, N)
    {
        ul A;
        cin >> A;
        bit[i + 1] = A;
    }
    for (ui i = 1; i < N; i++)
        bit[i + (i & -i)] += bit[i];
    loop(i, Q)
    {
        ui a, b, c;
        cin >> a >> b >> c;
        if (a == 0)
            data.add(b, c);
        else
            cout << data.sum(b, c - 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 8204
mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = [-1]*(n+1)
def make_fact(n):
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact

def make_fact_inv(n):
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact = make_fact(n+1)
fact_inv = make_fact_inv(n+1)
def comb(n, k):
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod

for i, ai in enumerate(a):
    if check[ai]<0:
        check[ai] = i
    else:
        b = check[ai]
        c = i
        break
m = c-b-1
for k in range(1, n+2):
    if n-m-1>=k-1:
        print((comb(n+1, k)-comb(n-m-1, k-1))%mod)
    else:
        print(comb(n+1, k))
        
        

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

using namespace std;

int main() {
  // n= 時間 a= 料金(1h) b= 固定料金
  int n, a, b;
  int p;
  
  cin >> n >> a >> b;

  p = n * a;

  if (p > b) cout << b << endl;
  if (p < b) cout << p << endl;
  if (p == b) cout << b << endl;

  return(0);
}

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

cnt = [0] * n
for i in range(1, n+1):
  if i % 2 != 0:
    for j in range(1, i+1):
    	if i % j == 0:
          cnt[i-1] += 1

res = 0
for elem in cnt:
  if elem == 8:
    res += 1
print(res)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a<c && c<b)
    cout << "Yes" << endl;
  
  else if(b<c && c<a)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sdo(a) scanf("%lf",&a)
#define sdo2(a,b) scanf("%lf %lf",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
const int mod=1e9+7;

int main()
{
    int h,w,n;
    while(cin>>h>>w>>n)
    {
        int k=max(h,w);
        if(n%k==0)
            cout<<n/k;
        else
            cout<<n/k+1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

int N,K;
ll dp[100010];
ll sum[100010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N>>K;
  dp[0]=1;
  for(int i=1;i<=N;i++){
    int a;cin>>a;
    sum[0]=0;
    repeat(j,K+1){
      sum[j+1] = (sum[j]+dp[j])%MOD;
    }
    //debugArray(sum,K+2);
    repeat(j,K+1){
      dp[j] = (sum[j+1] - sum[max(0,j-a)]+MOD)%MOD;
    }
  }
  cout<<dp[K]<<endl;
  return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

from operator import xor
from functools import reduce

B = [0]*N

for i in range(N)[::-1]:
  B[i] = reduce(xor, B[i:N:(i+1)])^A[i]
  
ans = [i+1 for i,b in enumerate(B) if b==1]
print(len(ans))
for a in ans:
  print(a)
  

Measured memory_bytes: 71388
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


# inputna
s = input()
d = {"a":0, "b":0, "c": 0}
for c in s:
    d[c] += 1
if max(d.values()) - min(d.values())<=1:
    print("YES")
else:
    print("NO")

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

int main(){
  int n;
  while(cin >> n){
  int ans = 0;
  for(int a=0;a<10;a++){
  for(int b=0;b<10;b++){
  for(int c=0;c<10;c++){
  for(int d=0;d<10;d++){
  if(a+b+c+d==n)ans++;
  }
  }
  }
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ar[n];
	for (int i=0;i<n;i++){
		cin>>ar[i];
	}
	sort(ar,ar+n);
	int ans=0;
	for (int i=0;i<n;i++){
		ans+=ar[i]-1;
	}
	printf ("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


int d1[(int)1e5];
int d2[(int)1e5];
vector<vector<int>> g;
int mx = 0;


void dfs2(int v, int p, int d) {
	d2[v] = d;
	for (int u : g[v])
		if (u != p)
			dfs2(u, v, d + 1);
}


void dfs1(int v, int p, int d) {
	if (g[v].size() != 1) {
		mx = max(mx, d2[v]);
		//cout << '\t' << v << ' ' << d2[v] << endl;
	}
	else {
		mx = max(mx, d2[v] - 1);
	}
	if (d2[v] <= d) {
		return;
	}
	for (int u : g[v]) {
		if (u != p)
			dfs1(u, v, d + 1);
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int u, s, t, v, n;
	cin >> n >> s >> t;
	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	s--;
	t--;
	d1[u] = 0;
	dfs2(t, -1, 0);
	dfs1(s, -1, 0);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 9984
#include<stdio.h>


int main(void){
	int n,h,w;
	int a[1000],b[1000];
	int i,j;
	int count;

	count = 0;

	scanf("%d %d %d",&n,&h,&w);
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
		if(a[i] >= h && b[i] >= w){
			count++;
		}
	}


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


	return 0;
}


Measured memory_bytes: 128
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b, c = input_a
if b / a > c
  puts c
else
  puts b / a
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a.at(i).at(j);
		}
	}
	vector<int> b(m);
	for (int i = 0; i < m; i++) cin >> b.at(i);
	for (int i = 0; i < n; i++) {
		int c = 0;
		for (int j = 0; j < m; j++) {
			c += a.at(i).at(j) * b.at(j);
		}
		cout << c << endl;
	}
}


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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll j = 1, c = 0;
    while (j <= n)
    {
        j *= k;
        c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int linearSearch(int *,int,int);

int main(){
    int S[10000],T[500];
    int n,q,i,count=0;

    scanf("%d",&n);

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

    scanf("%d",&q);

    for(i=0;i<q;i++) {
        scanf("%d",&T[i]);
        if(linearSearch(S,n,T[i])==1) count++;
    }

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

    return 0;
}

int linearSearch(int *S,int n,int key){
    int i;
    for(i=0;i<n;i++){
    if(S[i]==key) return 1;
    }
    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string Sa,Sb,Sc,dod=".";
	int TATE, YOKO ;
    cin >> TATE >> YOKO >>Sb ;
    Sa = dod + dod + dod;
    Sb = dod+Sb+dod;
  

  
    for (int tate = 0; tate  < TATE ; tate++){

      if (tate != TATE){   
        cin >> Sc ;
      if (tate == (TATE-1)) {
        Sc = dod + dod + dod ;
      }
      }
  
       for (int LOOK = 0; LOOK < YOKO ; LOOK++){
         
         int sum = 0;
         
  			if ( tate == 0){
    			Sa = Sa + dod;
    				}
            
   			if (LOOK==0){
                      Sc = dod+Sc;
   					 }
            if (tate == (TATE-1)){
                     Sc = Sc + dod  ;
            }
         
   			if (LOOK==(YOKO-1)){
                      Sc = Sc+dod;
   					 }
          
    
    		char A,B,C,D,E,F,G,H,I;
   			 A = Sa.at(LOOK);
   			 B = Sa.at(LOOK+1);
   			 C = Sa.at(LOOK+2);
   			 D = Sb.at(LOOK);
   			 E = Sb.at(LOOK+1);
   			 F = Sb.at(LOOK+2);
   			 G = Sc.at(LOOK);
   			 H = Sc.at(LOOK+1);
   			 I = Sc.at(LOOK+2);
  
  
    		 if (E == '#'){
    			cout << '#';
   			 }else{
   			   if (A == '#'){
  			      sum++;
   			   }if (B == '#'){
  			      sum++;
   			   }if (C == '#'){
			      sum++;
   			   }if (D == '#'){
  			      sum++;
   			   }if (F == '#'){
   			      sum++;
  			   }if (G == '#'){
  			      sum++;
   			   }if (H == '#'){
 			      sum++;
 		       }if (I == '#'){
   			      sum++;
  		       }
                        
   	          cout << sum;
             }

    } 
           
     Sa = Sb;
     Sb = Sc;

     cout << endl;
   }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=1e9+7;
const int maxn =1e6+11;
int n,m,k;

char s[10][10];
int R[10],C[10];


bool judge(int r,int c){
    me0(R);me0(C);
    fo(i,0,n-1){
        R[i+1]=r>>i&1;
    }
    fo(i,0,m-1){
        C[i+1]=c>>i&1;
    }
    int cnt=0;
    fo(i,1,n){
        fo(j,1,m){
            if(R[i]||C[j]) continue;
            if(s[i][j]=='#') cnt++;
        }
    }
    return cnt==k;
}

int main(){

    int ans=0;

    read(n);read(m);read(k);
    fo(i,1,n) scanf("%s",s[i]+1);
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            ans+=judge(i,j);
        }
    }
    printf("%d\n",ans);

    return 0;
}

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

#define ll  int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
const int mod=1e9+7;
const int MAXN = 1e5+2;
vector<int> adj[MAXN];
int dp[MAXN],vis[MAXN];

void dfs(int s){
	vis[s]=1;
  for(auto i:adj[s]){ if(!vis[i]) dfs(i);
	  dp[s]=max(dp[s],dp[i]+1);
  } 
}

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

for(int i=0;i<m;i++){
	int x,y; cin>>x>>y;
	adj[x].pb(y); 
}

for(int i=1;i<=n;i++){
	if(!vis[i]) dfs(i);
}
int ans=0;
for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
cout<<ans<<"\n";

	
return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<double> p;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        p.push_back(x);
    }
    
    
    
    size_t max = 0;
    
    for (int i=0; i<K; i++) {
        max += p[i];
    }
    double temp = max;
    for (int i=K; i<N; i++) {
        temp = temp - p[i-K] + p[i];
        
        if (temp > max) {
            max = temp;
        }
    }
    
    double ans = 0.5*(max+K);
    
    printf("%.6lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 2420
fun main(args: Array<String>) {
    val h = readLine()!!.toLong()
    var h1 = h
    var cnt = 0
    while (h1 > 1) {
        cnt++
        h1 /= 2
    }
    var ans = 1L
    repeat(cnt) {
        ans += Math.pow(2.0, (it + 1).toDouble()).toLong()
    }
    println(ans)
}


Measured memory_bytes: 33636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; char ch; cin>>a>>ch>>b;
	cout<<(ch=='+'?a+b:a-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 1e3+5;
const char S4[4][4] = {{'a','b','c','c'}, {'a','b','d','d'}, {'e','e','f','g'}, {'h','h','f','g'}};
const char S5[5][5] = {{'.','.','a','b','c'}, {'.','.','a','b','c'}, {'d','d','e','f','f'}, {'g','g','e','.','h'}, {'i','i','j','j','h'}};
const char S6[6][6] = {{'.','.','.','a','b','c'}, {'.','.','.','a','b','c'}, {'d','.','e','e','.','f'}, {'d','g','g','.','.','f'}, {'h','h','i','.','j','j'}, {'k','k','i','l','l','.'}};
const char S7[7][7] = {{'.','.','.','.','a','b','c'}, {'.','.','.','.','a','b','c'}, {'.','.','.','.','d','e','f'}, {'.','.','.','.','d','e','f'}, {'g','g','h','h','.','.','i'}, {'j','j','k','k','.','.','i'}, {'l','l','m','m','n','n','.'}};
int n, m, c[N*N]; char s[N][N];
void sol(int &n, int x)
{
    for(int i = 0; i < x; ++i) for(int j = 0; j < x; ++j)
        if(x == 4) s[n+i][n+j] = S4[i][j];
        else if(x == 5) s[n+i][n+j] = S5[i][j];
        else if(x == 6) s[n+i][n+j] = S6[i][j];
        else s[n+i][n+j] = S7[i][j];
    n += x;
}
int main()
{
    scanf("%d", &n); if(n <= 2) return puts("-1"), 0;
    if(n == 3) return puts("a..\na..\n.aa"), 0;
    for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) s[i][j] = '.';
    sol(m, 4+(n&3)); while(m+4 <= n) sol(m, 4);
    for(int i = 0; i < n; ++i) puts(s[i]);
    return 0;
}


Measured memory_bytes: 4744
N,Z,*A = `dd`.split.map &:to_i
INF = 10**15
dp = (0..1).map{ Array.new(N+1, nil) }

def dig(player,i,dp)
  return dp[player][i] if dp[player][i]
  ad = A[i]
  if player == 0    
    v = (i+1...N).map{ |k| dig(1, k, dp) }.max || 0
    dp[player][i] = [v, (ad - A[N]).abs].max
  else
    v = (i+1...N).map{ |k| dig(0, k, dp) }.min || INF
    dp[player][i] = [v, (ad - A[N]).abs].min
  end
  #p [player, i, dp[player][i]]
  dp[player][i]
end
#p N, A
p dig(0,0,dp)

Measured memory_bytes: 34824
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+20;
const ll MOD = 1e9+7;
using namespace std;

ll dp1[MAX_N];
ll dp2[MAX_N];
ll sum[MAX_N];
ll a[MAX_N];
int n,k;

int main()
{
    cin >> n >> k;
    if (!k)
        return cout << 1,0;
    for(int i = 1;i<=n;++i)
        cin >> a[i];
    for(int i = 0;i<=k;++i)
        sum[i] = 1;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=k;++j)
        {
            if (j-a[i]<=0)
                dp2[j] = sum[j];
            else
                dp2[j] = (sum[j] - sum[j-a[i]-1] + MOD)%MOD;
        }
        for(int j = 1;j<=k;++j)
            sum[j] = (sum[j-1]+dp2[j])%MOD;
        memcpy(dp1 ,dp2 , sizeof dp1);
        dp2[0] = 1;
    }
    cout << dp1[k];
    return 0;
}


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

vector<vector<int>> BreadthFirst(const vector<vector<int>>& graph) 
{
    auto N = graph.size();
    vector<bool> isChecked(N);
    vector<vector<int>> connectedGraph;

    for (int i = 0; i < N; ++i) {
        if (!isChecked[i]) {
            queue<int> Q;
            Q.push(i);
            isChecked[i] = true;
            vector<int> v;
            while (!Q.empty()) {
                auto q = Q.front();
                Q.pop();
                v.push_back(q);
                for (int x : graph[q]) {
                    if(!isChecked[x]) {
                        Q.push(x);
                        isChecked[x] = true;
                    }
                }
            }
            connectedGraph.push_back(v);
        }
    }
    return connectedGraph;
}

vector<vector<int>> DepthFirst(vector<vector<int>>& graph) 
{
    auto N = graph.size();
    vector<bool> isChecked(N);
    vector<vector<int>> connectedGraph;

    for (int i = 0; i < N; ++i) {
        if (!isChecked[i]) {
            stack<int> S;
            S.push(i);
            isChecked[i] = true;
            vector<int> v;
            while (!S.empty()) {
                auto q = S.top();
                if (!graph[q].empty()) {
                    auto it = graph[q].begin();
                    if (!isChecked[*it]) {
                        S.push(*it);
                        isChecked[*it] = true;
                    }
                    graph[q].erase(it);
                }
                else {
                    v.push_back(q);
                    S.pop();
                }
            }
            connectedGraph.push_back(v);
        }
    }
    return connectedGraph;
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    for (auto& v : graph) {
        sort(v.begin(), v.end());
        auto it = unique(v.begin(), v.end());
        v.erase(it, v.end());
    }
    auto connection = DepthFirst(graph);
    int size = 0;
    for (const auto& v : connection) {
        size = max<int>(size, v.size());
    }
    cout << size << endl;
}

Measured memory_bytes: 18868
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h> //円周率はM_PI
using namespace std;


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


	while (1) {
		
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}

		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
		
	}


}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int n = Integer.parseInt(sc.next()) ;
        int bit = 0 ;
        for(int i=0;i<n;i++){
            bit |= Integer.parseInt(sc.next()) ;
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<pair<int,int>,string> item;
main(){
	int n,i,w,s,S;
	string f;
	for(;cin>>n,n;){
		vector<item> items;
		vector<int> num,result;
		for(i=0;i<n;i++)cin>>f>>w>>s,items.push_back(make_pair(make_pair(w,s),f)),num.push_back(i);
		S=99999;
		do{
			for(s=w=0,i=n-1;~i;i--){
				pair<int,int> weight=items[num[i]].first;
				if(weight.second<w)break;
				w+=weight.first;
				s+=(i+1)*weight.first;
			}
			if(i<0&&s<S)S=s,result=num;
		}while(next_permutation(num.begin(),num.end()));
		for(i=0;i<n;i++)cout<<items[result[i]].second<<endl;
	}
}

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

using namespace std;

typedef unsigned long long ull;

int main() {
    ull n;
    cin >> n;
    ull min_steps = n + 1; // 1 * n
    for (ull i = 2; i * i <= n; i++) {
        if (n % i == 0)
            min_steps = min(min_steps, i + (n / i));
    }
    cout << min_steps - 2;
}


Measured memory_bytes: 256
use std::cmp::max;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let t = scan!();
    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    for (i, cs) in s.chars().enumerate() {
        for (j, ts) in t.chars().enumerate() {
            if cs == ts {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
            }
        }
    }

    let mut ans = vec![];
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if dp[i][j] == dp[i - 1][j] {
            i -= 1
        } else if dp[i][j] == dp[i][j - 1] {
            j -= 1
        } else {
            ans.push(s.chars().nth(i - 1).unwrap());
            i -= 1;
            j -= 1;
        }
    }
    println!("{}", ans.into_iter().rev().collect::<String>());
}


Measured memory_bytes: 41212
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s = input_char_vec();
    let mut t = input_char_vec();
    t.remove(t.len() - 1);
    if s == t {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2108
line = STDIN.gets
k,s = line.split(' ').map(&:to_i)

satisfied = 0

0.upto(k) do |x|
  0.upto(k) do |y|
    z = s - x - y
    if (z <= k && z >= 0)
      satisfied += 1  
    end
  end
end

puts satisfied

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

bool is_prime(int x){
    for(int i = 2; i*i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main(){
    int x; cin >> x;
    int ans = x;
    
    while(!is_prime(ans)) ans++;
    cout << ans << endl;
    return 0;
}


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

int main(void) {
	int N;
	long long K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	vector<int> vert; // 頂点(街)
	vector<int> ord(N + 1, -1); // 頂点のインデックス配列
	int c = 1, l = 0;
	{
		int v = 1;
		while (ord[v] == -1) {
			ord[v] = vert.size();
			vert.push_back(v);
			v = a[v - 1];
		}
		c = vert.size() - ord[v];
		l = ord[v];
	}
	if (K < l) cout << vert[K] << endl;
	else {
		K -= l;
		K %= c;
		cout << vert[l + K] << endl;
	}

	return 0;
}

Measured memory_bytes: 5828
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[100001];
	int n;
	cin>>a;
	n=strlen(a)-1;
	for(int i=0;i<=n;i++){
		if(i%2==0) cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<string,int> ma;
    REP(i,n) {
        string s; cin >> s;
        ma[s]++;
    }
    int m; cin >> m;
    REP(i,m) {
        string s; cin >> s;
        ma[s]--;
    }
    int ans = 0;
    for (auto p:ma) {
        ans = max(ans,p.second);
    }
    
    OUT(ans)

    return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;



const int N = 2e5+5;
vi g[N];
int vis[N];

int dfs(int v){
   int x = 1;
   vis[v]=1;
   trav(to,g[v])
     if(!vis[to])
       x+=dfs(to);
   return x;
}


void solve() {

   int n,m;
   cin>>n>>m;
   rep(_,0,m){
     int u,v;
     cin>>u>>v;
     g[u].pb(v);
     g[v].pb(u);
   }
   int ans = 0;
   fr(i,1,n)
     if(!vis[i])
        maxi(ans,dfs(i));
   cout<<ans;
  
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   // cin >> t;
    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}


int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    cin >> N;
    int a, b, ans = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> a >> b;
        ans += b-a + 1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n=sz(s);
  int ans[n];
  rep(i,n) ans[i]=0;

  for(int i=0; i<n-1; i++){
    if(s[i]=='R' && s[i+1]=='L'){
      int l=i-1,r=i+2;
      int cntr=0,cntl=0;
      //RLの左側でRが続く個数
      while(s[l]=='R' && l>=0){
        l--;
        cntr++;
      }

      while(s[r]=='L' && r<n){
        r++;
        cntl++;
      }
      ans[i]=1+cntr/2+cntl-cntl/2;
      ans[i+1]=1+cntl/2+cntr-cntr/2;
    }
  }
  rep(i,n) cout << ans[i] << " ";
  cout  << endl;
  return 0;
}


Measured memory_bytes: 1024