akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define R register int 
#define ll long long
#define inf 2147483647
using namespace std;
const int N=500000;
int n,ans,w[N],lim;
int gi(){
    R x=0,k=1;char c=getchar();
    while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')k=-1,c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*k;
}
int main(){
	n=gi(),lim=gi(),ans=2e9;
	for(R i=1;i<=n;++i){
		R x=gi(),y=gi();
		if(y<=lim)ans=min(ans,x);
	}
	if(ans==2e9)puts("TLE");
	else 
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(void){
    int n;cin>>n;
    vector<int>T(n),A(n);
    rep(i,n)cin>>T[i];rep(i,n)cin>>A[i];
    int l=0,r=n-1;
    rep(i,n-1){
        if(T[n-i-1]>T[n-i-2]){l=n-i-1;break;}
    }
    rep(i,n-1){
        if(A[i+1]<A[i]){r=i;break;}
    }
    if(T[n-1]!=A[0] || l>r)cout<<0<<endl;
    else {
        int ans=1;
        rep(i,r-1){
            if(T[i+1]>T[i])continue;
            ans=ans*T[i+1]%mod;
        }
        for(int i=n-1;i>r;i--){
            if(A[i-1]>A[i])continue;
            ans=ans*A[i-1]%mod;
        }
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>

using namespace std;

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

      int n,i,ac=0,tle=0,re=0,wa=0;cin>>n;
      vector<string> a(n);
    
      for(i=0;i<n;i++)
      {
        cin>>a[i];
        
        if(a[i].compare("AC")==0)
        ac++;
        
        else if(a[i].compare("TLE")==0)
        tle++;
        
        else if(a[i].compare("RE")==0)
        re++;
        
        else if(a[i].compare("WA")==0)
        wa++;
        
     }
     
     cout<<"AC x "<<ac<<endl;
     cout<<"WA x "<<wa<<endl;
     cout<<"TLE x "<<tle<<endl;
     cout<<"RE x "<<re<<endl;
    
      
   
    
     
      return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int n,ok = 0;
    string s,S; 
    vector<string> V;
    cin >> n; cin >> s;
    V.push_back(s);
    for(int i = 0;i<n-1;i++){
        cin >> S;
        if(s[s.size()-1] == S[0]){
            for(int j=0;j<V.size();j++){
                if(V[j] == S){cout << "No";return 0;}
            }
        }
        else {cout << "No"; return 0;}
        V.push_back(S);
        s = S;
    }
    cout << "Yes";
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n;
    cin>>n;
    cout << fixed << setprecision(11);
    double dp[n+1][n+1];
    double p[n+1];
    rep(i,n){
        cin>>p[i+1];
    }
    rep(i,n+1){
      dp[0][i]=0;}
    dp[0][0]=1;
    rep(i,n){
      dp[i+1][0]=dp[i][0]*(1-p[i+1]);}
    for (int i=1;i<n+1;i++){
        for (int j=1;j<n+1;j++){
            if (i<j){
                dp[i][j]=0;
                break;
            }
            else{
                dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
            }
        }
    }
    double ans=0;
    for (int i=1+(n/2);i<n+1;i++){
        ans+=dp[n][i];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 69504
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
using namespace std;
void Read(int &x){
	char c;
	bool flag=0;
	while(c=getchar(),c!=EOF&&(c<'0'||c>'9')&&c!='-');
	if(c=='-'){	c=getchar();flag=1;}
	x=c-'0';
	while(c=getchar(),c!=EOF&&c>='0'&&c<='9')x=x*10+c-'0';
	if(flag)x=-x;
} 

#define MAXN 100010
#define MAXP 33
long long sum[MAXP][2][MAXP],tot;
bool flag=0;
int n;
pair<long long,long long> a[MAXN];
int get_pos(long long x,long long y){
	for(long long i=30;i>=0;i--)
		if((x&(1<<i))==0&&(y&(1<<i))!=0)
			return i+1;
	return 0;
}
long long k;
long long get_sum(int x){
	//PF("[%d]\n",x);
	long long res=0;
	for(int i=0;i<=x;i++)
		res+=sum[x][0][i];
	return res;
}
int main(){
	Read(n);
	SF("%lld",&k);
	long long x,y;
	for(int i=1;i<=n;i++){
		SF("%lld%lld",&x,&y);
		//PF("(%d)",get_pos(k,x));
		for(long long j=31;j>0;j--)
			sum[j][(x&(1<<(j-1)))!=0][get_pos(k,x)]+=y;//the first pos which ki=0 and xi=1
		sum[0][0][get_pos(k,x)]+=y;
	}
	long long ans=0;
	for(long long i=31;i>0;i--)
		if((k&(1<<(i-1)))!=0)
			ans=max(ans,get_sum(i));
	ans=max(ans,get_sum(0));
	PF("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,P;
    cin >> N >> P;
    ll n;
    ll zero = 0,one = 0;
    rep(i,N){
        cin >> n;
        (n % 2 == 0 ? zero++:one++);
    }
    if(one == 0){
        if(P == 1){
            cout << "0\n";
            return 0;
        }
        else{
            cout << modpow(2,N,INF) << "\n";
            return 0;
        }
    }
    cout << modpow(2,N - 1,INF) << "\n";
}


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

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<long long> dp(n, 1LL * 1LL << 60);
	dp[0] = 0;
	for(int i = 0; i < n - 1; i++) {
		for(int j = 1; j <= k; j++) {
			if(i + j < n) {
				dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
	return 0;	
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(abs(a-b)<abs(a-c))
    {
        cout<<"A"<<endl;
    }
    else
        cout<<"B"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=1000001;

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

    ll n;
    cin>>n;
    vector<ll> ar(n),br(n),ans(n);
    vector<ll> idx,idx1;
    for(ll i=0;i<n;++i){cin>>ar[i];}
    for(ll i=0;i<n;++i){
        cin>>br[i];
        ans[i]=br[i];
        if(ar[i]==br[i]){
            idx.pb(i);
        }
        else{
            idx1.pb(i);
        }
    }
    if(idx.size()>0){
        ll len=0;
        for(ll i=0;i<idx.size();++i){
            ll j=i+1;
            while(j<idx.size()&&br[idx[j]]==br[idx[i]]){++j;}
            --j;
            len=max(len,j-i+1);
            i=j;
        }
        //cout<<"!!"<<len<<endl;
        for(ll i=0;i<idx.size();++i){
            ans[idx[i]] = br[idx[(i+len)%idx.size()]];
        }
    }
    bool check=1;
    for(ll i=0;i<n;++i){
        if(ar[i]==ans[i]){
            check=0;
        }
    }
    if(check){
        cout<<"Yes"<<endl;
        for(ll i=0;i<n;++i){
            cout<<ans[i]<<" ";
        }
    }
    else{
        //cout<<"!!";
        //for(auto x:ans){cout<<x<<" ";}
        //cout<<endl;
        idx.clear();
        for(ll i=0;i<n;++i){
            if(ar[i]==ans[i]){
                idx.pb(i);
            }
        }
        if(ans[idx.front()]!=ans[idx.back()]){
            exit(1);
        }
        ll j=0;
        for(auto i:idx1){
            if(ar[i]!=ans[idx[j]]){
                swap(ans[i],ans[idx[j]]);
                ++j;
            }
            if(j==idx.size()){break;}
        }
        check=1;
        for(ll i=0;i<n;++i){
            if(ar[i]==ans[i]){
                check=0;
            }
        }
        if(check){
            cout<<"Yes"<<endl;
            for(ll i=0;i<n;++i){
                cout<<ans[i]<<" ";
            }
        }
        else{
            cout<<"No";
        }
    }

    return (0);
}


Measured memory_bytes: 10252
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    cs
    set<int> s;
    ll n,k,t,x;cin>>n>>k;
    vector<int> v(n);
    for(auto &i:v) cin>>i;
    vector<int> ans;ans.push_back(1);
    s.insert(1);t=1;
    while(1){
        t=v[t-1];
        if(s.count(t)) break;
        s.insert(t);ans.push_back(t);
    }
    Repp(i,ans.size()-1,0) if(ans[i]==t) {x=i;break;}

    if(k<=x) cout<<ans[k%ans.size()];
    else {k-=x;cout<<ans[x+k%(ans.size()-x)];}
}

Measured memory_bytes: 13808
package main

import "fmt"

func print(rstr []rune, a,b int) {
	
	for i:=a; i<=b; i++ {
		fmt.Print(string(rstr[i]))
	}
	fmt.Println()
}
func swap(x,y rune)(rune, rune) {
	return y, x
}
func reverse(rstr []rune, a,b int) []rune {
	
	for i:=0; i<(b-a+1)/2; i++ {
		rstr[a+i], rstr[b-i] = swap(rstr[a+i], rstr[b-i])
	}
	return rstr
}
func replace(rstr []rune, p []rune, a,b int) []rune {

	for i:=a; i<=b; i++ {
		rstr[i] = p[i-a]
	}
	return rstr
}

func main() {

	var str string
	fmt.Scan(&str)
	//rstr := []rune(str)
	var n int
	fmt.Scan(&n)

	for i:=0; i<n; i++ {
		var op, p string
		var a, b int
		fmt.Scan(&op, &a, &b)

		if op=="replace" {
			fmt.Scan(&p)
			str = string(replace([]rune(str),[]rune(p),a,b))
		}
		if op=="reverse" {
			str = string(reverse([]rune(str),a,b))
		}
		if op=="print" {
			print([]rune(str),a,b)
		}
	} 
}


Measured memory_bytes: 2028
//g++ C.cpp -I /usr/local/include/ac-library
#include<cmath>

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

stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main(){
    int n,m;
    cin >> n>> m;
    dsu d(n+m);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int l;
            cin>> l;
            l+=n;
            l--;
            d.merge(l,i);
        }
    }
    int ch=d.leader(0);
    rep(i,n){
        if(d.leader(i)!=ch){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
   
    return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if(c <= a ||c <= b)printf("No\n");
	else{
		ll ans1 = 4*a*b, ans2 = (c-a-b)*(c-a-b);
		if(ans1 < ans2) printf("Yes\n");
		else printf("No\n");	
	}

	

}
/*
1 1000000000 1000000000
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
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 P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll 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 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 Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
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;


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

  ll ans = a * b;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
long long a,b;
string st;
bool findnumber(string st,int different)
{
	for(int i=0;i<st.size();i++)
		if(i!=different-1&&st[i]<'0'||i!=different-1&&st[i]>'9') return true;
	return 0;
}
int main()
{
	cin>>a>>b;
	cin>>st;
	if(st[a]!='-'||findnumber(st,a+1)) cout<<"No\n"; else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout << "Left" << endl;
  else if(a+b<c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int n, c[499], s[499], f[499], ans;
 
int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    for (int i = 0; i < n; i++) {
        ans = 0;
        for (int j = i; j < n - 1; j++) {
            if (ans <= s[j]) {
                ans = s[j];
            } else if (ans % f[j] != 0) {
                ans = ans + f[j] - ans % f[j];
            }
            ans += c[j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, cnt = 0;
  char s[100010];
  scanf("%s", s);
  n = strlen(s);
  ll ans[n];
  for(i = 0; i < n; ++i) ans[i] = 0;
  for(i = 0; i < n; ++i) {
    if(s[i] == 'R') ++cnt;
    else {
      ans[i] += cnt / 2;
      ans[i - 1] += (cnt + 1)/ 2;
      cnt = 0;
    }
  }
  for(i = n - 1; i >= 0; --i) {
    if(s[i] == 'L') ++cnt;
    else {
      ans[i] += cnt / 2;
      ans[i + 1] += (cnt + 1)/ 2;
      cnt = 0;
    }
  }
  for(i = 0; i < n; ++i) printf("%lld ", ans[i]);
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
struct ha{
	vector<int> a;
}c[2005];
int gcd(int a,int b){
	int t;
	while(b){
		t=a;a=b;b=t%a;
	}
	return a;
}
int n,a[2005],b[2005][2005],tot[2005],now;
pair<int,int> g[2005];
bool mp[2005][2005];
int fst[2005],lst[2005],cnt=0,e[4000005];
bool vis[2005];
vector<int> ans;
void dfs(int k){
	vis[k]=1;c[now].a.push_back(k);
	for(int i=fst[k];i<=lst[k];i++) if(!vis[e[i]])
		dfs(e[i]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		fst[i]=cnt+1;
		for(int p=1;p<=n;p++) if(p!=i){
			if(gcd(a[i],a[p])>1) e[++cnt]=p,mp[i][p]=1;
		}
		lst[i]=cnt;
		sort(e+fst[i],e+lst[i]+1);
	}
	for(int i=1;i<=n;i++) if(!vis[i]){
		now++;
		dfs(i);
		g[now]=make_pair(a[c[now].a[0]],now);
		/*for(int i=0;i<c[now].a.size();i++){
			int x=c[now].a[i];
			for(int p=i-1;~p;p--){
				if(mp[x][c[now].a[p]]){
					if(x<=c[now].a[p+1]) break;
					c[now].a.erase(c[now].a.begin()+i);
					c[now].a.insert(c[now].a.begin()+p+1,x);
					break;
				}
			}
		}*/
	}
	sort(g+1,g+now+1);
	for(int i=now;i;i--){
		int id=g[i].second;
		for(int p=0;p<c[id].a.size();p++)
			ans.push_back(c[id].a[p]);
	}
	for(int i=0;i<ans.size();i++){
		int x=ans[i],now=i;
		for(int p=i-1;~p;p--){
			if(mp[x][ans[p]]) break;
			if(x<=ans[p]) continue;
			ans.erase(ans.begin()+now);
			ans.insert(ans.begin()+p,x);
			now=p;
		}
	}
	for(int i=0;i<ans.size();i++) printf("%d ",a[ans[i]]);
	return 0;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<"="<<x<<endl
const int N = 1e4+55;
int main(){
    int n;
    cin>>n;
    int a=n%10;
    if(a==9)cout<<"Yes"<<endl;
    else {
        n/=10;
        a=n%10;
        if(a==9)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

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

    vector<ll>dp(n+1);
    dp[0]=1;
    for(int now=0;now<n;now++){
        for(int next=now+1;next<=min(n,now+2);next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
 
    cout << dp[n] << endl;
    return 0;
}

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

const int VMAX = 10000;

int main() {
    int N, W;
    std::cin >> N >> W;
    std::vector<int> dp(VMAX + 1, W + 1);
    dp[0] = 0;
    // dp[v] = 価値vを達成する最小の重さ

    for (int i = 0; i < N; ++i) {
        int v, w;
        std::cin >> v >> w;
        for (int j = VMAX; j - v >= 0; --j) {
            dp[j] = std::min(dp[j], dp[j - v] + w);
        }
    }

    for (int v = VMAX; v >= 0; --v) {
        if (dp[v] <= W) {
            std::cout << v << std::endl;
            break;
        }
    }
    return 0;
}



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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> v;
	int s = 0;
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		s += t;
		if (t % 10)v.push_back(t);
	}
	if ((s % 10) == 0 && !v.empty()){
		sort(v.begin(), v.end());
		s -= v[0];
	}
	printf("%d\n", s % 10 ? s : 0);
}

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

int cmp(string &A, string &B) {
    if(A.size() != B.size()) if(A.size() > B.size()) return 1; else return -1;
    //A.size() == B.size()
    for(int i = 0; i < A.size(); ++i) {
        if(A[i] != B[i]) if(A[i] > B[i]) return 1; else return -1;
    }
    return 0;
}

int main()
{
    string A, B;
    cin >> A >> B;
    int res = cmp(A, B);
    if(res == 1) cout << "GREATER" << endl;
    else if(res == -1) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = input()
    n = int(N[-1])
    if n in (2, 4, 5, 7, 9):
        print('hon')
    elif n in (0, 1, 6, 8):
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
int rmax(int x, int y) { return x > y ? x : y; }
int rmin(int x, int y) { return x > y ? y : x; }
ll llrmax(ll x, ll y) { return x > y ? x : y; }
ll llrmin(ll x, ll y) { return x > y ? y : x; }
int asc(const void* a, const void* b) { return *(int*)a - *(int*)b; }
int desc(const void* a, const void* b) { return *(int*)b - *(int*)a; }
int llasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }
int lldesc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }
int getgcd(int n, int m)
{
int r;
if (n > m) {
int t = m;
m = n;
n = t;
}
while ((r = m % n) != 0) {
m = n;
n = r;
}
return n;
}
int main(void){
    int n,a[10000000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);
    int min=a[0],min_i=0;
    int cnt=2;
    int gcd;
    gcd=getgcd(a[0],a[1]);
    while(cnt!=n){
        gcd=getgcd(gcd,a[cnt]);
        cnt++;    
    }    
    printf("%d\n",gcd);
    return 0;
}


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

int N,M,K;
int64_t A[20000];
constexpr int64_t INF = 1000000000000000;

int64_t dp[20000];
//[i?????°??????
int64_t func(int i)
{
	if(i>=N){return 0;}
	if(dp[i]>0){return dp[i];}
	
	int64_t min=A[i],max=A[i];
	int64_t min_cost=INF;
	for(int nexti = i+1,i_end=std::min(i+M,N);nexti<=i_end;++nexti)
	{
		min_cost = std::min(min_cost,
			func(nexti)+K+int64_t(nexti-i)*(max-min));
		min=std::min(min, A[nexti]);
		max=std::max(max, A[nexti]);
	}
	return dp[i]=min_cost;
}

int main()
{
	std::cin.sync_with_stdio(false);
	std::cin >> N>>M>>K;
	for(int i =0 ;i < N;++i){
		std::cin >> A[i];
	}
	std::cout << func(0)<<std::endl;
}

Measured memory_bytes: 5092
#include <stdio.h>

#define N 100000

int cnt, n, q;
int s[N], t[N];

void binarySearch(int a) {
	int left, right, mid;

	right = n;
	left = 0;

	while (right >= left) {
		mid = (right + left) / 2;
		if (s[mid] == a) {
			cnt++;
			break;
		} else if (s[mid] > a) {
			right = mid - 1;
		} else {
			left = mid + 1;
		}
	}
}

void scanData() {
	int i;

	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]);
		binarySearch(t[i]);
	}
}

int main() {

	scanData();
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << " " << max(0, a + b - n) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        double r = Double.parseDouble(scanner.nextLine());
        
        double a = (r*r)*Math.PI;
        double b = 2*r*Math.PI;
        
        System.out.println(String.format("%.6f",a) + " " + String.format("%.6f",b));
        
    }
}



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

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




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 22;


int n;
int g[maxn][maxn];


void add(ll &x, ll y) {
    x%=mod;
    y%=mod;
    x+=y;
    x%=mod;
}


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

    cin>>n;
    for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++) {
	    cin>>g[i][j];
	}
    }

    vector<ll> dp(1<<n, 0);
    dp[0]=1;
    for (int mask=0; mask<(1<<n); mask++) {
	int i = __builtin_popcount(mask);
	for (int j=0; j<n; j++) {
	    if (!(mask>>j&1)) {
		if (g[i][j]) {
		    add(dp[mask|(1<<j)], dp[mask]);
		}
	    }
	}
    }
    

    ll res = dp[(1<<n)-1];
    res%=mod;
    res+=mod;
    res%=mod;
    cout<<res<<endl;

    return 0;
}


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

int main(){
	int n;
	string s;
	cin>>n>>s;
	int left[300005]={0};
	int right[300005]={0};
	
	for(int i=0; s[i]; i++){
		if(s[i]=='E') right[i+1]=1;
		else left[i+1]=1;
	}
	for(int i=1; i<=n; i++){
		left[i]+=left[i-1];
		right[i]+=right[i-1];
	}
	int minchange = n;
	for(int i=1; i<=n; i++){
		minchange = min(minchange,left[i-1]+right[n]-right[i]);
	}
	cout<<minchange;
}

Measured memory_bytes: 5704
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(char[] cs) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < cs.length; i += 2) {
      sb.append(cs[i]);
    }
    return sb.toString();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll k,x;
  bool f=true;
  cin>>k>>x;
  for (int i=-1000000;i<=1000000;i++){
    if (abs(x-i) < k){
      if (f) {
        cout<<i;
        f=false;
      } else {
        cout<<" "<<i;
      }
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;

 
int main() {
    string s;
    cin >> s;
    rep(i,s.length()) {
        if(s[i]=='7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;

		if ( ( B / A ) < C ) {
			ans = B / A ;
		} else {
			ans = C ;
		}

		System.out.println( ans );
	}
}

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


int main() {

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
        else if (p[i+1] < p[i] && p[i] < p[i-1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A[N - 1] - A[0] << endl;
	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n)sum+=a[i];
    int c= 0;
    rep(i,n)if(a[i]>=(sum+4*m-1)/(4*m))c++;
    if(c>=m)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2) ){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;

//struct Edge {int to, color; };
//vector<vector<edge> > G;
#define MAX_V 100001
struct Edge {
    int from;
    int to;     // �ӂ̍s����
    int color; // �ӂ̏d��
    //Edge(int t, int w) : to(t), color(w) { }
};
vector<Edge> G[MAX_V];

#define N_MAX 100001
int A[100001], B[100001], color[100010];
vector<int> nxt[100010]; //

int main()
{
    ll N;
    int max_c = 0;
 
    cin >> N;
    
    //Graph G(N);
    
    rep(i, N - 1){ 
        cin >> A[i]>> B[i];
        G[A[i]].push_back((Edge){A[i], B[i], 0});
        G[B[i]].push_back((Edge){B[i], A[i], 0});
        //color[i] = 0;
        //fprintf(stderr ,"%d, %d\n",A[i], B[i]);
    }    
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int v = que.front(); que.pop(); // �擪�v�f���폜
        int ngc = -1;
        for (auto e : G[v]) {
            if (e.color){
                ngc = e.color;
                break;
            }
        }
        int c = 1;
        for (auto &e : G[v]) {
            if (c == ngc){
                c++;
            }
            if (!e.color){
                e.color = c;
                for (auto &e2 : G[e.to]) {
                    if (e2.to == v){ 
                        e2.color = c;
                        break;
                    }
                }
                max_c = max(c, max_c);
                c++;
                que.push(e.to); 
            }
        }
    }
    cout << max_c << endl;
    for (int i = 0; i < N - 1; i++){
        for (auto &e : G[A[i]]) {
            if (e.to == B[i]){
                cout << e.color << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 10624
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int[][] point = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				point[i][j] = Integer.parseInt(sc.next());
			}
		}
		int count = 0;
		for (int i = 1; i < N; i++) {
			for (int j = 0; j < i; j++) {
				int distance_square = 0;
				for (int k = 0; k < D; k++) {
					int distance = point[i][k] - point[j][k];
					distance_square += distance * distance;
				}
				int distance_sqrt = (int) Math.sqrt(distance_square);
				if(distance_sqrt * distance_sqrt == distance_square) {
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(auto i:v[0]){
        for(auto j:v[i]){
            if(j==n-1){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s,t,res="";
    cin>>s>>t;
    int n=s.length(),m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    int r=n,c=m;
    while(r>0 && c>0)
    {
        int val= dp[r][c];
        if(dp[r-1][c]==val)
            r--;
        else if(dp[r][c-1]==val)
            c--;
        else if(dp[r-1][c-1]==val)
            r--,c--;
        else
        {
            res=t[c-1]+res;
            r--,c--;
        }
    }
    cout<<res<<endl;
    return 0;
}


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

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;
    ll p = 2;

    bool ok = true;

    while(1){
        rep(i,n) if(a[i] % p != 0) ok = false;
        if(!ok) break;
        p *= 2;
        ++ans;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int main(void){
	int k;
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	scanf("%d", &k);

	printf("%d", arr[k-1]);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL ans,x,pr[100005],sf[100005],co[100005],mul[100005];
int n;
int main()
{
    scanf("%d",&n);
    pr[0]=1,sf[n+1]=1,sf[n+2]=1;
    for(int i=1;i<=n;i++)pr[i]=pr[i-1]*i,pr[i]%=MOD;
    for(int i=n;i>0;i--)sf[i]=sf[i+1]*i,sf[i]%=MOD;
    for(int i=1;i<=n;i++)co[i]=co[i-1]+(pr[i]*sf[i+2]),co[i]%=MOD;
    for(int i=1;i<=(n+1)/2;i++)
    {
        mul[i]+=co[n-i];
        mul[i]+=co[i-1];
        mul[i]%=MOD;
    }
    for(int i=n;i>n/2;i--)mul[i]=mul[n-i+1];
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        ans+=x*pr[n];
        ans%=MOD;
        ans+=x*mul[i];
        ans%=MOD;
    }
    printf("%lld",(ans+MOD*50)%MOD);
}


Measured memory_bytes: 6920
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			String s1 = in.next(), s2 = in.next();
			System.out.println(toString(toInt(s1) + toInt(s2)));
		}
	}

	private static int toInt(String str){
		int deg = 1, ans = 0;
		for(int i=0; i<str.length(); i++){
			char c = str.charAt(i);
			if(Character.isDigit(c)){
				deg = c - '0';
			}
			else{
				switch(c){
					case 'm':
						ans += deg*1000;
						break;
					case 'c':
						ans += deg*100;
						break;
					case 'x':
						ans += deg*10;
						break;
					case 'i':
						ans += deg;
						break;
				}
				deg = 1;
			}
		}
		return ans;
	}

	private static String toString(int n){
		StringBuffer str = new StringBuffer();
		for(int d=1000; d>=1; d/=10){
			int deg = (n/d)%10;
			if(deg > 1)
				str.append((char)(deg + '0'));
			if(deg > 0){
				switch(d){
				case 1000:
					str.append('m');
					break;
				case 100:
					str.append('c');
					break;
				case 10:
					str.append('x');
					break;
				case 1:
					str.append('i');
					break;
				}
			}
		}
		return str.toString();
	}

}

Measured memory_bytes: 12000
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0] - 1]

for i in range(1, n):
    ans += B[A[i] - 1]
    if A[i] == A[i - 1] + 1:
        ans += C[A[i - 1] - 1]

print(ans)


Measured memory_bytes: 3064
k, a, b = map(int, input().split())

if a >= b:
    ans = k + 1
    print(ans)
    exit()

if (a - 1) >= k:
    ans = k + 1
    print(ans)
    exit()

ans = 1
ans += a - 1
q, r = divmod(k - (a - 1), 2)
ans += (b - a) * q
ans += r
ans = max(ans, k + 1)

print(ans)


Measured memory_bytes: 61856
fun main() = Thread(null, ::aising2020d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun aising2020d() {
    val n = readLine()!!.toInt()
    val x = readLine()!!

    val baseBitCount = x.count { it == '1' }.toLong()
    val bitCountToModded = mutableMapOf<Long, Long>()

    for (bitCount in baseBitCount - 1..baseBitCount + 1) {
        if (bitCount == 0L) {
            bitCountToModded[bitCount] = 0
            continue
        }

        var modByBitCount = 0L
        for ((index, c) in x.withIndex()) {
            if (c == '1') {
                modByBitCount += (2L).modPow(n - index - 1L, bitCount)
                modByBitCount %= bitCount
            }
        }
        bitCountToModded[bitCount] = modByBitCount
    }

    val answer = StringBuilder()

    for (i in 0 until n) {
        val currBitCount = baseBitCount + if (x[i] == '0') 1 else -1

        if (currBitCount == 0L) {
            answer.appendln(0)
            continue
        }

        val modPow = (2L).modPow(n - i - 1L, currBitCount)
        var modded = bitCountToModded[currBitCount]!! + if (x[i] == '0') modPow else -modPow
        modded += currBitCount
        modded %= currBitCount

        var currX = modded.toInt()
        var count = 1

        while (currX > 0) {
            currX %= Integer.bitCount(currX)
            count++
        }

        answer.appendln(count)
    }

    print(answer)
}

private fun Long.modPow(p: Long, m: Long): Long {
    var x = this % m
    var y = p
    var result = 1L
    while (y > 0) {
        if (y % 2 == 1L) result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }
    return result
}


Measured memory_bytes: 46888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  
  int max_price = 0;
  rep(i,N) max_price = max(max_price, p[i]);
  
  int answer = 0;
  rep(i,N) answer += p[i];
  
  cout << answer - max_price / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,W;
	cin >> N >> W;
	vector<lli> weight(N, 0), value(N, 0);
	vector<vector<lli>> dp(N+1, vector<lli>(W+1));
	for (int i = 0; i < N; i++) {
		cin >> weight[i] >> value[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (weight[i] <= j) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

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

using namespace std;

int main() {

	int n,m;
	vector<vector<int> > vt;

	vector<int> tmpv;

	int data;

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> data;
			tmpv.push_back(data);
		}
		vt.push_back(tmpv);
		tmpv.clear();
	}

	vector<int> bv;

	for (int j = 0; j < m; j++) {
		cin >> data;
		bv.push_back(data);
	}

	int c = 0;


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c += vt[i][j] * bv[j];
		}
		cout << c << endl;
		c = 0;
	}

	return 0;
}

Measured memory_bytes: 3184
while x=gets
 a=x.chomp.to_i
 pas=[a]
 2.times do |i|
  b=gets.chomp.to_i
  pas[i+1]=b
 end
 ju=[]
 2.times do |j|
  c=gets.chomp.to_i
  ju[j]=c
 end
 pas=pas.sort
 ju=ju.sort
 n=pas[0]+ju[0]-50
 puts n.to_s
end

Measured memory_bytes: 6096