akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
pi dp[(1 << 18)];

void update(pi &pa, pi &pb) {
	vector<int> vec;
	vec.pb(pa.fst); vec.pb(pa.sec);
	vec.pb(pb.fst); vec.pb(pb.sec);
	sort(all(vec));
	pa = pi(vec[3], vec[2]);
}

void solve() {
	cin >> N;
	rep(i, 0, (1 << N)) {
		cin >> dp[i].fst;
		dp[i].sec = -inf;
	}
	for(int i = 0; i < N; i++) {
		for(int bit = 0; bit < (1 << N); bit++) {
			if(bit & (1 << i)) {
				update(dp[bit], dp[bit ^ (1 << i)]);
			}
		}
	}
	int res = 0;
	for(int i = 1; i < (1 << N); i++) {
		MAX(res, dp[i].fst + dp[i].sec);
		cout << res << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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(){
  string s;
  cin >> s;
  rep(i,s.size())cout << "x";
  cout << endl;
}

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

int N;

void solve()
{
	vector<string> M;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		M.push_back(s);
	}
	vector<vector<int> > Dp(N,vector<int>(N,0));
	int ans=0;

	for(int i=0;i<N;i++){
		if(M[0][i]=='.') Dp[0][i]=1;
		if(M[i][0]=='.') Dp[i][0]=1;
	}

	for(int y=1;y<N;y++){
		for(int x=1;x<N;x++){
			if(M[y][x]=='.'){
				if(M[y-1][x]=='.' && M[y][x-1]=='.'){
					Dp[y][x]=min(Dp[y-1][x-1],min(Dp[y-1][x],Dp[y][x-1]))+1;
				}
				else Dp[y][x]=1;
			}
			ans=max(Dp[y][x],ans);
		}
	}
	cout<<ans<<endl;
}


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

}

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




int main() {
 int N,K;
 cin >> N >> K;
 int a = 1;
 rep(i,N+1){
 if( N ==0 || N == 1){
     cout << 1;
     return 0;
 }
 if(N < a) {
     cout << i;
     return 0;
 }
 a *= K;
 }
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll INF = 1145141919810364;
template <typename T>
class edge
{
public:
    T cost, to, from;
    edge(T from, T to, T cost) : from(from), to(to), cost(cost) {}
};
template <typename T>
class Graph
{
public:
    vector<vector<edge<T>>> graph;

    Graph(T n, vector<T> from, vector<T> to, bool no_direction, vector<T> cost)
    {
        graph.resize(n);
        for (int i = 0; i < from.size(); i++)
        {
            edge<T> params(from[i], to[i], cost[i]);
            graph[from[i]].emplace_back(params);
            if (no_direction)
            {
                swap(params.from, params.to);
                graph[to[i]].emplace_back(params);
            }
        }
    }
    vector<ll> shortest_path;
    void Dijkstra(ll start)
    {
        shortest_path.resize(graph.size(), INF);
        shortest_path[start] = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, start);
        while (!que.empty())
        {
            P p = que.top();
            que.pop();
            ll v = p.second;
            if (shortest_path[v] < p.first)
                continue;
            for (int i = 0; i < graph[v].size(); i++)
            {
                ll k = graph[v][i].to;
                ll l = graph[v][i].cost;
                if (shortest_path[k] > shortest_path[v] + l)
                {
                    shortest_path[k] = shortest_path[v] + l;
                    que.push(P(shortest_path[k], k));
                }
            }
        }
    }
};

int main()
{
    ll v, e, r;
    scanf("%lld%lld%lld", &v, &e, &r);
    vector<ll> s(e), t(e), d(e);
    for (int i = 0; i < e; i++)
    {
        scanf("%lld%lld%lld", &s[i], &t[i], &d[i]);
    }
    Graph<ll> graph(v, s, t, false, d);
    graph.Dijkstra(r);
    for (int i = 0; i < v; i++)
    {
        if (graph.shortest_path[i] == INF)
            printf("%s\n", "INF");
        else
        {
            printf("%lld\n", graph.shortest_path[i]);
        }
    }
}


Measured memory_bytes: 44504
#include<iostream>
#include<cstdio>
#include<set>
#define inf 1e18
#define mk make_pair
#define fi first
#define se second
#define pii pair<long long,long long>
#define p 1000000007
using namespace std;
int T,sz;
long long ans;
long long f[1010],b[1010];
set<pii> s[1010];
set<pii>::iterator it;
int main()
{
	scanf("%d",&T);
	f[0]=f[1]=1;
	for(sz=2;;sz++)
	{
		f[sz]=f[sz-1]+f[sz-2];
		if(f[sz]>=inf) break;
	}
	for(int i=1;i<sz;i++)
		if(f[i]*2>f[i+1])
		s[i].insert(mk(f[i],f[i+1]));
	s[1].insert(mk(1,1));
	for(int i=1;i<=sz-2;i++)
	{
		b[i]=f[i],b[i+1]=f[i+2];
		if(b[i]*2LL>b[i+1])
		s[i].insert(mk(b[i],b[i+1]));
		for(int j=i+1;;j++)
		{
			b[j+1]=b[j]+b[j-1];
			if(b[j+1]>=inf) break;
			if(b[j]*2LL>b[j+1])
			s[j].insert(mk(b[j],b[j+1]));
		}
	}
	while(T--)
	{
		long long X,Y;
		scanf("%lld%lld",&X,&Y);
		if(X>Y) swap(X,Y);
		int ma=1;
		for(;;ma++)
		{
			pii x=*s[ma].begin();
			if(x.fi>X||x.se>Y) break;
		}
		ma--;
		if(ma==1) ans=X%p*Y%p;
		else
		for(it=s[ma].begin();it!=s[ma].end();it++)
		{
			pii x=*it;
			if(x.fi<=X)
				(ans+=max(0LL,Y-x.se+x.fi)/x.fi+max(0LL,X-x.se+x.fi)/x.fi)%=p;
		}
		printf("%d %lld\n",ma,ans);
		ans=0;
	}			
	return 0;
}

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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n;
int a,b,c,d;
string s;

/*funcs*/


/*main*/
int main(){
    cin>>n>>a>>b>>c>>d>>s;
    int flag;
    if(a<b&&b<c&&c<d){
        flag=1;
    }else if(a<b&&b<d&&d<c){
        flag=2;
    }else if(a<c&&c<b&&b<d){
        flag=3;
    }
    int ans=1;
    if(flag==1||flag==3){
        for(int i=a-1;i<d-1;i++){
                if(s[i]=='#'&&s[i+1]=='#'){
                    ans=0;
                    break;
                }
            }
    }else{
        for(int i=a-1;i<c-1;i++){
                if(s[i]=='#'&&s[i+1]=='#'){
                    ans=0;
                    break;
                }
            }
            int jud=0;
            for(int i=b-2;i<d-1;i++){
                if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
                    jud=1;
                    break;
                }
            }
            if(jud==1&&ans==1){
                    ans=1;
                }else{
                    ans=0;
                }
    }
    if(ans==1){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
        
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void inverse(ll n,vector<ll> &inv){
    //要素数:n+1 (0~n)
    inv[0]=1;
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=(MOD-inv[MOD%i]*(MOD/i))%MOD;
    }
}

void inverse_u(ll n,vector<ll> &inv){
    //要素数:n+1 (0~n)
    for(ll i=2;i<=n;i++){
        inv[i]=(inv[i]*inv[i-1])%MOD;
    }
}

void factorial(ll n,vector<ll> &fac){
    //要素数:n+1 (0~n)
    fac[1]=1;
    for(ll i=2;i<=n;i++){
        fac[i]=(fac[i-1]*i)%MOD;
    }
}

ll nCr(ll n,ll r,vector<ll> &inv,vector<ll> &fac){
    return fac[n]*inv[r]%MOD*inv[n-r]%MOD;
}

int main() {
    ll n,k,ans=1; cin>>n>>k;
    vector<ll> inv(2*n+1,0),fac(2*n+1,0);
    inverse(2*n,inv);
    inverse_u(2*n,inv);
    factorial(2*n,fac);
    if(n-1<=k){
        cout<<(nCr(2*n-1,n,inv,fac)+MOD)%MOD<<endl;
    }
    else{
        for(ll i=1;i<=k;i++){
            ll ad=(nCr(n,i,inv,fac)*nCr(n-1,i,inv,fac))%MOD;
            ans=(ans+ad)%MOD;
        }
        cout<<(ans+MOD)%MOD<<endl;
    }
}

Measured memory_bytes: 6528
#include<stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int a[200000];
	int i;
	int max1=0;
	int max2=0;
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<N;i++){
		
		if(max1<a[i]){
	    max2=max1;
		max1=a[i];
		}
		
			else if(max2<a[i]&&a[i]<=max1){
				max2=a[i];
			}
		
	}
	
	
	
	for(i=0;i<N;i++){
		if(a[i]==max1)
			a[i]=max2;
		else
			a[i]=max1;
	}
	
	for(i=0;i<N;i++){
		printf("%d\n",a[i]);
	}
		
	
		return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

void mppop(map<int,int> & mp,int x){
  --mp[x];
  if(mp[x]==0)mp.erase(x);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  map<int,int> mp;
  queue<PII> que;
  int n = 1<<N;
  int m = 0;
  rep(i,n){
    int x;cin >> x;
    ++mp[-x];
    m = max(m,x);
  }
  que.push(PII(m,N));
  mppop(mp,-m);

  bool issat = true;
  while(!que.empty()){
    int H = que.front().first;
    int num = que.front().second;
    que.pop();
    auto it = mp.upper_bound(-H);
    if(it == mp.end()){
      issat = false;
      break;
    }
    if(num!=1){
      que.push(PII(H,num-1));
      que.push(PII(-it->first,num-1));
    }
    mppop(mp,it->first);
  }
  YesNo(issat);
  return 0;
}


Measured memory_bytes: 13696
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toInt)
    val bList = readLine()!!.split(" ").map(String::toInt)
    val cList = readLine()!!.split(" ").map(String::toInt)

    var count = 0
    for (i in 0 until aList.size - 1) {
        if (aList[i] + 1 == aList[i+1]) count += cList[aList[i]-1]
    }
    println(count + bList.sum())
}

Measured memory_bytes: 37744
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
else
  cout<<"red"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 2019;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
struct mint {
    LL x; // typedef long long LL;
    mint(LL x=0):x( x >= 0 ? x%mod : x%mod+mod){}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }
    mint operator+(const mint a) const {
      mint res(*this);
      return res+=a;
    }
    mint operator-(const mint a) const {
      mint res(*this);
      return res-=a;
    }
    mint operator*(const mint a) const {
      mint res(*this);
      return res*=a;
    }
    mint pow(LL t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }
   
    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a) {
      return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
      mint res(*this);
      return res/=a;
    }
  };

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string S; cin >> S;
    int slen = S.length();
    map<int,int> mp;
    mint ten = 10;
    LL acc = 0;
    LL ans = 0;
    mp[0] = 1;

    for(int i = slen-1; i >= 0; i--){
        acc +=  ten.pow(slen-1-i).x * (S[i] - '0') ;
        acc %= 2019;
        ans += mp[acc];
        mp[acc]++;
    }
    cout << ans << endl;


}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<char,char,char,char,char,char,char,char,char,char> T;

int main() {
  int N;
  cin >> N;
  T t[N];
  for (int i = 0; i < N; i++) {
    vector<char> s;
    for (int j = 0; j < 10; j++) {
      char c;
      cin >> c;
      s.push_back(c);
    }
    sort(s.begin(), s.end());
    t[i] = T(s.at(0),s.at(1),s.at(2),s.at(3),s.at(4),s.at(5),s.at(6),s.at(7),s.at(8),s.at(9));
  }
  priority_queue<T> que;
  for (int i = 0; i < N; i++) {
    que.push(t[i]);
  }
  vector<ll> leng;
  ll l = 0;
  for (ll i = 0; i < N-1; i++) {
    T q = que.top();
    que.pop();
    T r = que.top();
    if (q != r) {
      leng.push_back(i+1-l);
      l = i+1;
    }
  }
  leng.push_back(N-l);
  
  ll ans = 0;
  for (int i = 0; i < leng.size(); i++) {
    ans = ans + leng[i] * (leng[i]-1) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3956
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll DP[3001][3001][10],item[3001][3001];

int main(){
  ll R,C,K;
  cin>>R>>C>>K;
  
  for(int i=0; i<=R; ++i){
    for(int j=0; j<=C; ++j){
      item[i][j]=-1;
      for(int k=0; k<10; ++k){
        DP[i][j][k]=0;
      }
    }
  }
  
  REP(i,K){
    ll r,c,v;
    cin>>r>>c>>v;
    item[r][c]=v;
  }
  
  
  for(int i=1; i<=R; ++i){
    for(int j=1; j<=C; ++j){
      for(int k=0; k<10; ++k){
        if(item[i][j]!=-1){
          if(k<3) chmax(DP[i][j][k+1],DP[i][j-1][k]+item[i][j]);
          chmax(DP[i][j][1],DP[i-1][j][k]+item[i][j]);
        }
        chmax(DP[i][j][k],DP[i][j-1][k]);
        chmax(DP[i][j][0],DP[i-1][j][k]);
      }
    }
  }
  
  ll ans=0ll;
  REP(k,10) chmax(ans,DP[R][C][k]);
  co(ans);
  return 0;
}

Measured memory_bytes: 777428
N, M = map(int, input().split())
ans = 1

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)


Measured memory_bytes: 3064
S = input()
T = input()

min_diff=len(T)
for i in range(len(S)-len(T)+1):
    diff=len(T)
    for j in range(len(T)):
        if T[j]==S[i+j]:
            diff -= 1
    if diff<min_diff:
        min_diff = diff
ans = min_diff
print(ans)

Measured memory_bytes: 8920
from sys import stdin

def main():
    AB = stdin.read().splitlines()

    ab = ''.join(AB)
    cnt = [0] * 5
    for i in range(1, 5):
        cnt[i] = ab.count(str(i))

    ans = tuple(sorted(cnt))
    if ans == (0, 1, 1, 2, 2):
        print('YES')
    else:
        print('NO')

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
 
typedef long long          num;
 
using namespace std;
 
const int nsz = 2e5;
int n, a[nsz + 5], rt, lst, ans;
int ql, qr, q[2 * nsz + 5];
 
struct treap {
	int sz, ls[nsz + 5], rs[nsz + 5], pri[nsz + 5];
	int key[nsz + 5], mn[nsz + 5], mx[nsz + 5];
	
	int inline node(int w) {
		int u = ++sz;
		key[u] = mn[u] = mx[u] = w, pri[u] = rand();
		return u;
	}
	
	void inline up(int u) {
		mn[u] = ls[u] ? mn[ls[u]] : key[u];
		mx[u] = rs[u] ? mx[rs[u]] : key[u];
	}
	
	int merge(int v1, int v2) {
		if (!v1 || !v2)  return v1 | v2;
		return pri[v1] < pri[v2] ? (rs[v1] = merge(rs[v1], v2), up(v1), v1) : (ls[v2] = merge(v1, ls[v2]), up(v2), v2);
	}
	
	void split(int u, int w, int &v1, int &v2) {
		if (!u) { v1 = v2 = 0; return; }
		key[u] <= w ? (v1 = u, split(rs[u], w, rs[u], v2), up(u)) : (v2 = u, split(ls[u], w, v1, ls[u]), up(u));
	}
	
	void inline push_back(int &rt, int w) { rt = merge(rt, node(w)); }
	
	void inline pop_back(int &rt, int w) { int v; split(rt, w - 1, rt, v); }
};
treap tr;
 
void inline init() {
	cont (i, n) {
		if (i == 1 || a[i] < a[i - 1])  ++qr; // divide into segments
		tr.push_back(q[qr - 1], a[i]);
	}
	
	for (lst = n; tr.mx[q[qr - 1]] == lst && lst; tr.pop_back(q[qr - 1], lst--)); // consecutive element in the end
}
 
void inline deal() {
	for (++ans; !q[ql] && ql != qr; ++ql); // find the first non-empty segment
	
	int u = q[ql++], mx = tr.mx[u], v1, v2; // all elements in the first segment are high
	for (int k = ql; k != qr && mx != lst; ++k) {
		if (!q[k] || tr.mx[q[k]] < mx)  continue;
		
		tr.split(q[k], mx, v1, v2);
		q[k] = v1, u = tr.merge(u, v2), mx = tr.mx[u];
		
		int &r1 = q[k - 1], &r2 = q[k];
		if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0; // merging
	}
	
	int &r1 = q[qr - 1], &r2 = u;
	if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	for (; tr.mx[u] == lst && lst; tr.pop_back(u, lst--)); // consecutive element in the end
	
	q[qr++] = u;
}
 
int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	for (init(); lst; deal());
	printf("%d\n", ans);
}

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

int main(){
	int k, s;
	int num=0;
	cin >> k >> s;
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			int m=s-i-j;
			if(0<=m && m<=k) num++;
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 3452
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// sc.Split(bufio.ScanWords)
	S := nextLine()

	fmt.Printf("%d\n", ABC045C(S))
}

// ABC045C ...
func ABC045C(S string) (res int) {
	for bit := 0; bit < (1 << uint(len(S)-1)); bit++ {
		tmp, last := 0, 0
		//tmpstr := ""
		for i := 0; i < len(S)-1; i++ {
			if bit>>uint(i)&1 == 1 {
				num, _ := strconv.Atoi(S[last : i+1])
				tmp += num
				//tmpstr += S[last:i+1] + "+"
				last = i + 1
			}
		}
		num, _ := strconv.Atoi(S[last:])
		tmp += num
		//tmpstr += S[last:]
		//fmt.Println(tmpstr)

		res += tmp
	}

	return
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
namespace INIT {
	const int maxn = 1020;
	struct ques {
		long long x, y;
	} q[maxn];
	int n;
	void init () {
		n = read ();
		for (int i = 1;i <= n;i ++)
			q[i].x = read(), q[i].y = read ();
	}
} using namespace INIT;

namespace CHECK {
	bool odd = 0;
	void check () {
		for (int i = 1;i < n;i ++)
			if (((q[i].x + q[i].y) & 1) != ((q[i + 1].x + q[i + 1].y) & 1)) {
				printf ("%d\n", -1);
				exit (0);
			}
		odd = (q[1].x + q[1].y) & 1;
	}
} using namespace CHECK;

namespace get_Di {
	long long d[50]; int m = 0;
	void work1 () {
		d[++ m] = 1;
		while (d[m] <= 1e9)
			d[++ m] = 1ll * d[m - 1] << 1;
		if (!odd) d[++ m] = 1;
		printf ("%d\n", m);
		for (int i = 1;i <= m;i ++)
			printf ("%lld ",d[i]);
		printf ("\n");
	}
} using namespace get_Di;

namespace get_direct {
	inline double dis (long long x, long long y) {
		return sqrt ((double)x * x + (double)y * y);
	}
	vector <char> ans;
	void work2 () {
		for (int i = 1;i <= n; i ++) {
			ans.clear ();
			long long x = q[i].x;
			long long y = q[i].y;
			for (int j = m;j >= 1;j --)
				if (abs (x) > abs (y)) {
					if (x < 0) {
						ans.push_back ('L');
						x += d[j];
					}
					else {
						ans.push_back ('R');
						x -= d[j];
					}
				}
				else {
					if (y < 0) {
						ans.push_back ('D');
						y += d[j];
					}
					else {
						ans.push_back ('U');
						y -= d[j];
					}
				}
			for (int i = ans.size () - 1;i >= 0;i --)
				printf ("%c",ans[i]);
			printf ("\n");
		}
	}
} using namespace get_direct;
int main () {
	init ();
	check ();
	work1 ();
	work2 ();
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC042B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int L = int.Parse(target[1]);
            string[] s = new string[N]; 
            for(int i = 0; i<N;i++){
                s[i] = Console.ReadLine();
            }
            Array.Sort(s);
            for(int i = 0; i<N;i++){
                Console.Write(s[i]);
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 11360
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    long long N;
    cin >> N;
    if (N % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    long long count = 0;
    long long i = 2 * 5;
    while (i <= N) {
        count += N / i;
        i *= 5;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import math
a,b,c = map(int,input().split())
K = (a*b)*math.sin(math.radians(c))/2
L = math.sqrt((a**2)+(b**2)-2*(a*b)*math.cos(math.radians(c)))
S = a+b+L
print(K)
print(S)
P = 2*K/a
print(P)


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

int main() {
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        int s[n], p[n], q[n], r[n];
        
        for (int i=0; i<n; i++) {
            cin >> s[i] >> p[i] >> q[i] >> r[i];
        }
        
        int P, Q, R, C;
        cin >> P >> Q >> R >> C;
        
        bool flag = true;
        
        for (int i=0; i<n; i++) {
            if (p[i]<=P && q[i]<=Q && r[i]<=R && 4*p[i]+9*q[i]+4*r[i]<=C) {
                cout << s[i] << endl;
                flag = false;
            }
        }
        
        if (flag) {
            cout << "NA" << endl;
        }
    }
}


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

int main(){
    string s, t;
    bool isSame = true;
    cin >> s;
    cin >> t;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            isSame = false;
        }
    }
    if(isSame == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

const long long mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //データの入力
    int n;
    ll k;
    ll* a;
    cin >> n >> k;
    a = new ll[n];
    ll sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }

    //sum(A)の約数を求める
    priority_queue<ll> divisor;
    for(ll i = 1; i*i <= sum; ++i){
        if(sum%i == 0){
            divisor.push(i);
            if(i*i != sum) divisor.push(sum/i);
        }
    }

    //求めた約数の大きいものから一つずつ条件を満たしているか調べる
    ll *r;
    r = new ll[n];
    while(!divisor.empty()){
        //約数で割った余り(操作が必要なもの)を求める
        for(int i = 0; i < n; ++i){
            r[i] = a[i]%divisor.top();
        }

        sort(r, r+n);

        ll sumR = 0;
        for(int i = 0; i < n; ++i){
            sumR += r[i];
        }
        int counter = 0;
        for(int i = 0; i < (n-sumR/divisor.top()); ++i){
            counter += r[i];
        }

        if(counter <= k){
            cout << divisor.top() << "\n";
            break;
        }

        divisor.pop();
    }
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  A, B, K = map(int, readline().split())
  if A>=K:
    print(A-K, B)
  else:
    print(0, max(B-K+A,0))
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;
const double pi = 3.14159265358979323846;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,h,x;
    cin>>a>>h>>x;
    double V=a*a*h;
    if(2*x<=V){
        cout<<setprecision(15)<<90-atan((2*x)/(a*h*h))*360/(2*pi);
    }
    else cout<<setprecision(15)<<90-atan(a/(2*(V-x)/(a*a)))*360/(2*pi);
}


Measured memory_bytes: 256
#AtCoder Grand Contest 006 a
def check(moji):
    x1=""
    x2=""
    for i in range(n):
        x1+=moji[i]
        x2+=moji[len(moji)-n+i]
    if s==x1 and t==x2:
        return True
    else:
        return False
n=int(input())
s=input()
t=input()
ans=[]
ans.append(s)
for i in range(len(t)-1,-1,-1):
    ans.append(s+t[i:])
for i in ans:
    if check(i):
        print(len(i))
        break


Measured memory_bytes: 9200
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

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

int main()
{
    // A_Poor_Problem
    /*int A,B,C;

    cin >> A >> B >> C;

    if((A == B && A != C && B != C) || (A == C && A!= B && C != B) || (B == C && A != B && A != C))
    {
        cout << "Yes" << endl;
    }

    if(A == B && B == C && C == A)
    {
        cout << "No" << endl;
    }

    if(A != B && B != C && C != A)
    {
        cout << "No" << endl;
    }*/

    // B_Papers_Please
    int N,A,cnt = 0,ct = 0;

    cin >> N;

    while(N--)
    {
        cin >> A;
        if(A%2 == 0)
        {
            ct++;
            if(A%3 == 0 || A%5 == 0)
            {
                cnt++;
            }
        }
    }

    if(ct == cnt)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 0, y, ans = 0, W;
        cin >> n >> W;
        ll w[n], v[n];
        for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
        ll dp[N];
        for(int j = N - 1; j > -1; j--) dp[j] = -INF;
        dp[0] = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = N - 1; j > -1; j--)
            {
                if(j - w[i] >= 0)
                dp[j] = max(dp[j - w[i]] + v[i], dp[j]);
            }
        }
        for(auto j = 0; j <= W; j++)
        {
            ans = max(dp[j], ans);
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int a,b,c;
    cin >> a >> b >> c;
    cout << (b-a==c-b? "YES":"NO")<<endl;
    return 0;
}


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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int h,w,x,y,r;
    cin >> w >> h >> x >> y >> r;
    cout << (((x+r <= w) && (x-r >= 0) && (y+r <= h) && (y-r >= 0))?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3236
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&as[i], &bs[i])
	}

	cnt := n * (n - 1) / 2
	cnts := make([]int, 0)
	cnts = append(cnts, cnt)

	uf := newUnionFind(n + 1)

	for i := m - 1; i > 0; i-- {
		a, b := as[i], bs[i]
		if !uf.same(a, b) {
			ac := uf.size(a)
			bc := uf.size(b)
			cnt -= ac * bc
		}
		cnts = append(cnts, cnt)
		uf.unite(a, b)
	}

	for i := len(cnts) - 1; i >= 0; i-- {
		fmt.Println(cnts[i])
	}
}

// UnionFind .
type UnionFind struct {
	par   []int
	rank  []int
	sizes []int
}

func newUnionFind(n int) UnionFind {
	u := UnionFind{}
	u.par = make([]int, n)
	u.rank = make([]int, n)
	u.sizes = make([]int, n)

	for i := 0; i < n; i++ {
		u.par[i] = i
		u.rank[i] = 0
		u.sizes[i] = 1
	}

	return u
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}

	if u.rank[x] < u.rank[y] {
		u.par[x] = y
		u.sizes[y] += u.sizes[x]
	} else {
		u.par[y] = x
		u.sizes[x] += u.sizes[y]
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) size(x int) int {
	return u.sizes[u.root(x)]
}


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

#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
using P = pair<int,int>;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここから書く

const int M = 1001001;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, count;
  cin >> n;
  count = 0;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  for(int i = 0; i < n; i+=2){
    if(a[i] % 2 == 1){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}




Measured memory_bytes: 3604
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			StringBuffer str = new StringBuffer(sc.nextLine());
			String ret = new String();
			int i, length = str.length();
			for (i = 0; i < length; i++) {
				ret = ret + str.charAt(str.length() - 1);
				str.deleteCharAt(str.length() -1);
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 26072
#include<iostream>
#include<algorithm>
#include<vector>

int main(){
    int n,a_buf;
    std::vector<int> a;

    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>a_buf;
        a.push_back(a_buf);
    }

    int m,b_buf;
    std::vector<int> b;

    std::cin>>m;
    for(int i=0;i<m;i++){
        std::cin>>b_buf;
        b.push_back(b_buf);
    }

    if(std::includes(a.begin(),a.end(),b.begin(),b.end())){
        std::cout<<"1"<<std::endl;
    }else{
        std::cout<<"0"<<std::endl;
    }
    return 0;
}



Measured memory_bytes: 5244
import java.util.Scanner;

public class Main {
  private Scanner s;

  public void run() {
    int n;
    final int U = 0;
    final int B = 1;
    final int N = 2;
    final int S = 3;
    final int E = 4;
    final int W = 5;
    while ((n = s.nextInt()) != 0) {
      int sum = 1;
      int[] dice = { 1, 6, 5, 2, 3, 4 };
      for (int i = 0; i < n; i++) {
        String d = s.next();
        int tmp;
        if (d.equals("North")) {
          tmp = dice[U];
          dice[U] = dice[S];
          dice[S] = dice[B];
          dice[B] = dice[N];
          dice[N] = tmp;
        }
        if (d.equals("South")) {
          tmp = dice[U];
          dice[U] = dice[N];
          dice[N] = dice[B];
          dice[B] = dice[S];
          dice[S] = tmp;
        }
        if (d.equals("West")) {
          tmp = dice[U];
          dice[U] = dice[E];
          dice[E] = dice[B];
          dice[B] = dice[W];
          dice[W] = tmp;
        }
        if (d.equals("East")) {
          tmp = dice[U];
          dice[U] = dice[W];
          dice[W] = dice[B];
          dice[B] = dice[E];
          dice[E] = tmp;
        }
        if (d.equals("Left")) {
          tmp = dice[N];
          dice[N] = dice[E];
          dice[E] = dice[S];
          dice[S] = dice[W];
          dice[W] = tmp;
        }
        if (d.equals("Right")) {
          tmp = dice[N];
          dice[N] = dice[W];
          dice[W] = dice[S];
          dice[S] = dice[E];
          dice[E] = tmp;
        }
        sum += dice[U];
      }
      System.out.printf("%d\n", sum);
    }
  }

  public void init() {
    s = new Scanner(System.in);
  }

  static public void main(String[] args) {
    Main m = new Main();
    m.init();
    m.run();
  }
}

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

int main() {
  string s;
  cin >> s;

  vector<int> w;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      w.push_back(i);
    }
  }

  long long ans = 0;
  for (int i = 0; i < w.size(); i++) {
    ans += (w[i] - i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1532
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		
    		int ans = 0;
    		
    		for (int i = 0; i < 4; i++) {
    			if (S.charAt(i) == '+') {
    				ans++;
    			} else {
    				ans--;
    			}
    		}
    		
    		System.out.println(ans);
    		
    	}
    }

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, a;
  cin >> N;
  a=(N-N%111)/111;
  if (N%111==0) {
    cout << N << endl;
  }
  else {
    cout << 111*(a+1) << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

class TreeNode
{
public:
	TreeNode(int key) : key(key), pLeftChild(0), pRightChild(0) {}

public:
	int key;
	TreeNode* pLeftChild;
	TreeNode* pRightChild;
};

class BST
{
public:
	bool Insert(int key)
	{
		{
			if (!m_pRoot)
			{
				m_pRoot = new TreeNode(key);
				return true;
			}
			else
				return Insert(m_pRoot, key);
		}
	}

	bool Find(int key)
	{
		return Find(m_pRoot, key);
	}

	void PreOrder()
	{
		PreOrder(m_pRoot);
	}

	void InOrder()
	{
		InOrder(m_pRoot);
	}

private:
	bool Insert(TreeNode* currentNode, int key)
	{
		if (key == currentNode->key) return false;
		else if (key < currentNode->key)
		{
			if (currentNode->pLeftChild) return Insert(currentNode->pLeftChild, key);
			else
			{
				currentNode->pLeftChild = new TreeNode(key);
				return true;
			}
		}
		else
		{
			if (currentNode->pRightChild) return Insert(currentNode->pRightChild, key);
			else
			{
				currentNode->pRightChild = new TreeNode(key);
				return true;
			}
		}
	}

	bool Find(TreeNode* currentNode, int key)
	{
		if (!currentNode) return false;

		if (key == currentNode->key) return true;
		else if (key < currentNode->key)
			return Find(currentNode->pLeftChild, key);
		else
			return Find(currentNode->pRightChild, key);
	}

	void PreOrder(TreeNode* currentNode)
	{
		if (!currentNode) return;

		cout << " " << currentNode->key;
		PreOrder(currentNode->pLeftChild);
		PreOrder(currentNode->pRightChild);
	}

	void InOrder(TreeNode* currentNode)
	{
		if (!currentNode) return;

		InOrder(currentNode->pLeftChild);
		cout << " " << currentNode->key;
		InOrder(currentNode->pRightChild);
	}

private:
	TreeNode* m_pRoot = 0;
};

int main()
{
	BST tree;
	int n; cin >> n;
	string oper;
	int key;
	for (int i = 0; i < n; ++i)
	{
		cin >> oper;
		if (0 == oper.compare("insert"))
		{
			cin >> key;
			tree.Insert(key);
		}
		else if(0 == oper.compare("print"))
		{
			tree.InOrder();
			cout << endl;
			tree.PreOrder();
			cout << endl;
		}
		else if (0 == oper.compare("find"))
		{
			cin >> key;
			cout << (tree.Find(key) ? "yes" : "no") << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 15620
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N,M;
int d[100100];

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

  cin>>N>>M;

  int a,b;
  while (M --> 0) cin>>a>>b, d[a]++,d[b]++;

  bool good=1;
  for (int i=1;i<=N;i++) if (d[i]&1) {
      good=0;break;
    }

  cout << (good ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 640
def solve():
  n = int(input())
  words = []

  for _ in range(n):
    word = input()
    words.append(word)
  set_word = set(words)
  if len(set_word) != len(words):
    print("No")
    return 0

  for i, word in enumerate(words):
    if i > 0:
      last = words[i-1][-1]
      front = words[i][0]

      if front != last:
        print("No")
        return 0
      

  print("Yes")



solve()

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

int main(){
  int n;
  string s;
  cin >>n >>s;
  rep(i,s.size()){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  return 0;
}

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

int main(){
  int a, b, c, k;
  int i=0;
  scanf("%d", &k);
  while(i<k){
    scanf("%d %d %d", &a, &b, &c);
    i++;
    int max = (int)fmax((double)a, fmax((double)b, (double)c));
    int sum = a*a + b*b + c*c;
    if (sum==2*max*max)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 2564
import java.util.*;
import java.io.*;
class Main {
    static long MOD = (long)(1e9+7);
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        long[][] dp = new long[n][n];
        dp[0][0] = 1;
        for(int i = 1; i<n; i++) {
            long[] prefPrev = new long[n];
            prefPrev[0] = dp[i-1][0];
            for(int j = 1; j<n; j++) 
                prefPrev[j] = (prefPrev[j-1]+dp[i-1][j])%MOD;
            for(int j = 0; j<=i; j++) {
                int l = -1;
                int r = -1;
                if(s.charAt(i-1)=='<') {
                    l = 0;
                    r = j-1;
                }
                else {
                    l = j;
                    r = i;
                }
                if(l==-1 || r==-1) continue;
                long ans = prefPrev[r];
                if(l-1>=0)
                    ans = ((ans-prefPrev[l-1])%MOD+MOD)%MOD;
                dp[i][j] = ans;
            }
        }
        long ans = 0;
        for(int i = 0; i<n; i++)
            ans = (ans + dp[n-1][i])%MOD;
        System.out.println(ans);
    }
}

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

int BinarySearch(vector<int> A, int key){
	int left = 0;
	int right = A.size();

	while(left < right){
		int mid = (left + right) / 2;
		if(A[mid] == key){
			return 1;
		}else if(key < A[mid]){
			right = mid;
		}else{
			left = mid + 1;
		}
	}
	return 0;

}

int main() {
	int n,q,c=0;
	vector<int> S,T;

	cin >> n;
	for(int i = 0; i < n; i++){
		int v;
		cin >> v;
		S.push_back(v);
	}

	cin >> q;
	for(int j = 0; j < q; j++){
		int v;
		cin >> v;
		T.push_back(v);
	}

	for(auto v1:T){
		if(BinarySearch(S,v1)){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 4012