akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

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

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

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

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

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

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

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

priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;

int main() {
  ll N,K,L;
  cin>>N>>K>>L;

  UnionFind road(N);

  UnionFind train(N);

  FOR(i,0,K-1){
    ll tp1,tp2;
    cin>>tp1>>tp2;
    road.unite(tp1-1,tp2-1);
  }
  FOR(i,0,L-1){
    ll tp1,tp2;
    cin>>tp1>>tp2;
    train.unite(tp1-1,tp2-1);
  }
  FOR(i,0,N-1){
    //cout<<road.root(i)<<endl;
  }
  FOR(i,0,N-1){
   // cout<<train.root(i)<<endl;
  }

  pair<ll,ll> p;
  map<pair<ll,ll>,int> mp;

  FOR(i,0,N-1){
    mp[make_pair(road.root(i),train.root(i))]++;
  }

  FOR(i,0,N-1){
    cout<<mp[make_pair(road.root(i),train.root(i))]<<" ";
  }
  cout<<endl;



return 0;
 
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// 与えられる数列の偶数番目と奇数番目をプラス側かマイナス側どちらにするかを決め打ちすれば、
// それぞれ必要な最小コストは一意に定まる
// +-+- ... または -+-+ ...

// 今2番目の項を見ているとして、それがプラスにすべき項だとする。
// これまでの累積和が負であり、1項目が-2以下ならば、今の項に足すか前の項を足すか、また両方に足すかを選べるが
// これはどれを選択しても後の項の操作に変化はない
// なぜならば、どれを選択肢てもプラス側の累積和とマイナス側の累積和の和は変わらず、
// その後の項をプラス側もしくはマイナス側にするためのコストも同じになるからである

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=LINF;
  // +-+-...
  {
    ll p=0, m=0;
    ll tmp=0;
    rep(i,n){
      if(i%2==0){
        p+=a[i];
        if(p+m<=0){ // 累積和がプラスになるべき項だがマイナスになる場合
          tmp+=abs(p+m)+1;
          p+=abs(p+m)+1;
        }
      }else{ // 累積和がマイナスになるべき項だがプラスになる場合
        m+=a[i];
        if(p+m>=0){
          tmp+=abs(p+m)+1;
          m-=abs(p+m)+1;
        }
      }
    }
    chmin(ans,tmp);
  }
  
  // -+-+...
  {
    ll p=0, m=0;
    ll tmp=0;
    rep(i,n){
      if(i%2==1){ // 上記の実装のうちこの箇所だけ変更すればよい
        p+=a[i];
        if(p+m<=0){
          tmp+=abs(p+m)+1;
          p+=abs(p+m)+1;
        }
      }else{
        m+=a[i];
        if(p+m>=0){
          tmp+=abs(p+m)+1;
          m-=abs(p+m)+1;
        }
      }
    }
    chmin(ans,tmp);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum = 0, cnt = 0;
		String[] n = new String[2];
		String[] e = null;
		List<Integer> list = new ArrayList<>();
		List<Integer> eleList = new ArrayList<>();
		n = br.readLine().split(" ");
		list.add(Integer.parseInt(n[0]));list.add(Integer.parseInt(n[1]));
		e = new String[list.get(0)];
		e = br.readLine().split(" ");
		Arrays.sort(e);
		for (int i = 0; i < list.get(0); i++) {
			eleList.add(Integer.parseInt(e[ i ]));
			sum += eleList.get(i);
		}
		for (int i = 0; i < list.get(0); i++) {
			if ((double) sum / (4 * list.get(1)) <= eleList.get(i))
				cnt++;
		}
		System.out.println(list.get(1) <= cnt ? "Yes" : "No");
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}

const int MOD = 1e9+7; //998244353;
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e5;
const int M = 2e4+1;
int n, w[N], s[N], v[N], idx[N];
ll DP[M];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> w[i] >> s[i] >> v[i];
    idx[i] = i;
  }
  sort(idx, idx+n, [](int l, int r){return w[l]+s[l] < w[r]+s[r];});
  FOR(_i, 0, n){
    int i = idx[_i];
    FORR(j, s[i], 0) maxs(DP[j+w[i]], DP[j]+v[i]);
  }
  ll ans = 0;
  FOR(i, 0, M) maxs(ans, DP[i]);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unistd.h>
#include <stdlib.h>
#include <atcoder/segtree>

using namespace std;
using namespace atcoder;

// using mint = long double;
// using mint = modint998244353;
// using mint = modint1000000007;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;

const ll INF = 2e18;
const ll fact_table = 3200008;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll m = mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= m; b >>= 1;}(x *= a) %= m; b--;} return x;}
vec readvec(ll read) { vec res(read); for (int i = 0; i < read; i++) { cin >> res[i]; } return res;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/

bool multicase = false;

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return -INF;
}


void solve() {
    ll n, k;
    cin >> n >> k;
    segtree<ll, op, e> seg(vec(300005, 0));
    for (int i = 0; i < n; i++) {
        ll idx;
        cin >> idx;
        ll l = idx - k;
        ll r = idx + k + 1;
        l = max(l, 0ll);
        r = min(r, 300001ll);
        ll find_max = seg.prod(l, r);
        seg.set(idx, find_max + 1);
    }
    ll ans = seg.prod(0ll, 300001ll);
    p(ans);
    return;
}


int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }

    // solve();
    return 0;
}

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

int main() {
    int a[5];

    int max = 0;
    int index = 0;
    for(int i=0; i<5; i++){
        cin>>a[i];
        if(a[i]%10 == 0) continue;
        if(max <= 10 - a[i]%10){
            max = 10 - a[i]%10;
            index = i;
            //cout <<"aa" << max << endl;
        }
    }

    int sum = 0;
    for(int i=0; i<5; i++){
        if(i == index){
            sum += a[i];
            //cout << "-" << a[i] << endl;
        }else{
            sum += ((a[i]-1)/10 + 1)*10;
           // cout <<sum << endl;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c[b];
    for(int i = 0; i < b; i++) c[i] = 0;
    for(int i = 0; i < a; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int e;
            cin >> e;
            c[e-1]++;
        }
    }
    int f = 0;
    for(int i = 0; i < b; i++) {
        if(c[i] == a) {
            f++;
        }
    }
    cout << f << endl;

}


Measured memory_bytes: 256
def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if v <= w:
        print("NO")
    else:
        if abs(a - b) <= t * (v - w):
            print("YES")
        else:
            print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61848
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int main(){
    ll N, M;cin >> N >> M;
    vector<pair<ll, ll>> p(N);
    rep(i, N)cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    ll i = 0;
    ll ans = 0;
    while(M > 0){
        M -= p[i].second;
        ans += p[i].first * p[i].second;
        ++i;
    }
    if(M < 0){
        ans += M * p[i - 1].first;
    }

    cout << ans;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define ld long double
int const M=2e5+10,inf=1e9+10,mod=1e9+7,M2=1e6+10,sq=447;
int dp[1000+10][1000+10];
bool mark[1000][1000];
int cnt=0,col[M],n;
pii good[M];
void dfs(int v,int now)
{
	col[v]=now;
	if(now==1)good[cnt].F++;
	else good[cnt].S++;
	for(int i=1;i<=n;i++)
	{
		if(!col[i] && !mark[v][i])dfs(i,3-now);
		if(!mark[v][i] && col[v]==col[i])
		{
			cout<<-1;
			exit(0);
		}
	}
}
int32_t main()
{
	int m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)mark[i][i]=1;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		mark[a][b]=1;
		mark[b][a]=1;
	}
	for(int i=1;i<=n;i++)
	{
		if(!col[i])++cnt,dfs(i,1);
	}
	dp[cnt+1][0]=1;
	for(int i=cnt;i>=1;i--)
	{
		//cout<<good[i].F<<" "<<good[i].S<<endl;
		for(int j=0;j<=n;j++)
		{
			if(j>=good[i].F)
				dp[i][j]|=dp[i+1][j-good[i].F];
			if(j>=good[i].S)dp[i][j]|=dp[i+1][j-good[i].S];
		}
	}
	int mn=inf;
	for(int i=0;i<=n;i++)
	{
		if(dp[1][i])
		{
			//cout<<i<<endl;
			int tmp=i*(i-1)/2;
			int res=n-i;
			tmp+=(res)*(res-1)/2;
			mn=min(mn,tmp);
		}
	}
	cout<<mn;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std; 
#define loop for(int i=0;i<n;i++)
const int N=100020;
vector<int> adj[N];
int visited[N];
int n;
vector<int> ans[N];
int32_t  main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int winner=0;
	int i=0;
	while(a>0 and c>0)
	{
		if(i%2==1){
			a=a-d;
		}
		else
		{
			c=c-b;
		}
		if(a<=0){
		winner=2;
		break;
		}if(c<=0)
		{winner=1;
		break;
	}
	i++;
}
if(winner==1)
cout<<"Yes";
else
cout<<"No";
}

	


		
			
		
		
		

		
		


	


Measured memory_bytes: 8328
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();
	 
	 ll n;
	 cin >> n;
	 vector<ll> v(n);
	 scan(v);

	 ll min;
	 min = *min_element(v.begin(), v.end());

	 for (ll& a : v) {
		 a -= min;
	 }

	 ll count = min;
	 while (true) {
		 int l, r;

		 l = n;
		 for (int i = 0; i < n; i++) {
			 if (v[i] != 0) {
				 l = i;
				 break;
			 }
		 }

		 if (l == n) {
			 cout << count << endl;
			 return 0;
		 }

		 count++;
		 r = n;
		 for (int i = l ; i < n; i++) {
			 if (v[i] == 0) {
				 r = i;
				 break;
			 }
		 }

		 for (int i = l; i < r; i++) {
			 v[i]--;
		 }
	 }
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


Measured memory_bytes: 888
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();

        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] B = new int[r+1][c+1];

        for (int i=0; i<r; i++) {
            for (int j=0; j<c; j++) {
                B[i][j] = sc.nextInt();
                B[i][c] += B[i][j];
                B[r][j] += B[i][j];
                B[r][c] += B[i][j];
            }
        }
        for (int i=0; i<r+1; i++) {
            for (int j=0; j<c+1; j++) {
                System.out.print(B[i][j]);
                if (j != c)
                    System.out.print(" ");
                else
                    System.out.println();
            }
        }


    }
}


Measured memory_bytes: 42120
def find(A):
    if A[0]>1:
        A[0]-=1
    for i in range(1,len(A)):
        if A[i]>A[i-1]:
            A[i]-=1
        
        elif A[i]==A[i-1]:
            continue
        else:
            return "No"
    return "Yes"
input()
A=list(map(int,input().strip().split(' ')))
print(find(A))

Measured memory_bytes: 63708
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	ll x, i = 1;
	cin >> x;
	while((360 * i) % x != 0){
	    i++;
	}
	cout << (360 * i) / x << "\n";
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n,l;
    cin>>n>>l;
    vector<string>v;
    while(n--)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    cout<<v[i];
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){

int a[3];
REP(i,3)cin>>a[i];
sort(a,a+3);
printf("%d %d %d\n",a[0],a[1],a[2]);

  return 0;
}

Measured memory_bytes: 1160
function main(input) {
    var row = input.split('\n');
    var output = [];
    for (var i = 0; i < row.length; i++) {
        var data = row[i].split(' ');
        var a = parseInt(data[0]);
        var b = parseInt(data[2]);
        var op = data[1];
        if(op == '+'){
            output.push(a+b);
        }

        else if(op == '-'){
            output.push(a-b);
            
        }
        else if(op =='*'){
            output.push(a*b);
            
        }
        else if(op == '/'){
            output.push(Math.floor(a/b));
            
        }
        else if(op =='?'){
            break;
        }
    }
    console.log(output.join('\n'));
}

process.stdin.resume();
var input = '';  
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  main(input);
});

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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
#define MAX 200002

int n;

vector<int> v[MAX];

vector<int> nd[2];

inline void dfs(int b,int dep=0,int pr=-1){
	nd[dep&1].push_back(b);
	for(int el:v[b]){
		if(pr==el)continue;
		dfs(el,dep+1,b);
	}
}
vector<int> val[3];
int ans[MAX];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	for(int i=1;i<=n;i++)val[i%3].push_back(i);
	auto apply=[&](int a,int b,int c=-1){
		while(nd[a].size()&&val[b].size()){
			ans[nd[a].back()]=val[b].back();
			nd[a].pop_back();
			val[b].pop_back();
		}
		b=c;
		while(b!=-1&&nd[a].size()&&val[b].size()){
			ans[nd[a].back()]=val[b].back();
			nd[a].pop_back();
			val[b].pop_back();
		}
	};
	if(nd[0].size()<=val[0].size()){
		apply(0,0);
		apply(1,1,2);
		apply(1,0);
	}
	else{
		if(nd[1].size()<=val[0].size()){
			apply(0,1,2);
			apply(1,0);
			apply(0,0);
		}
		else{
			if(nd[0].size()>=val[1].size()&&nd[1].size()>=val[2].size()){
				apply(0,1);
				apply(1,2);
			}
			else{
				apply(0,2);
				apply(1,1);
			}
			apply(0,0);apply(1,0);
		}
	}
	for(int i=0;i<n;i++){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 18292
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

typedef array<int,3> A;

int dist[100][100];
void solve(long long H, long long W, std::vector<std::string> s){
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			dist[i][j]=1<<29;
		}
	}
	if(s[0][0]=='.'){
		dist[0][0]=0;
	}
	else{
		dist[0][0]=1;
	}
	
	priority_queue<A,vector<A>,greater<A> > pq;
	pq.push(A{{dist[0][0],0,0}});
	while(pq.size()){
		auto t=pq.top();
		pq.pop();
		int x=t[1];
		int y=t[2];
		int d=t[0];
		if(d>dist[x][y])continue;
		int dx=1,dy=0;
		for(int k=0;k<2;k++,swap(dx,dy)){
			int u=dx+x;
			int v=dy+y;
			int w=d;
			if(0<=u&&u<H&&
				0<=v&&v<W){
				if(s[u][v]!=s[x][y]&&s[u][v]=='#'){
					w++;
				}
				if(w<dist[u][v]){
					dist[u][v]=w;
					pq.push(A{{w,u,v}});
				}
			}
		}
	}
	cout << dist[H-1][W-1] << endl;

}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(W);
    for(int i = 0 ; i < W ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


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

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [100*A[0], 0]
max_ = -1

for w in water.keys():
    for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)):
        d = min(((w//100*A[4])-c*A[2])//A[3], (A[5]-w-c*A[2])//A[3])
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) <= A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

print(ans[0], ans[1])

Measured memory_bytes: 3064
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N;
	int P[200005];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
	}

	int ans = 1, min = P[0];
	for (int i = 1; i < N; i++)
	{
		if (P[i] < min)
		{
			min = P[i];
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main( )
{
    int n , num[100] , count = 0  , i ;
    scanf("%d" , &n);
    
    for( i = 1 ; i <= n ; i++)
        scanf("%d" , &num[i]);
    
    for( i = 1 ; i < n-1 ; i++)
    {
        if( num[i] < num[i+1])
        {
            if( num[i+1] < num[i+2])
                count++ ;
        }
        
        else if( num[i] > num[i+1] )
        {
                if( num[i+1] > num[i+2])    
                    count++ ;
        }
    }
    
    printf("%d\n" , count);
    
    return 0 ;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int main() {
  ll a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  ll a1 = (a - 1) / c;
  ll a2 = (a - 1) / d;
  ll a3 = (a - 1) / lcm(c, d);

  ll b1 = b / c;
  ll b2 = b / d;
  ll b3 = b / lcm(c, d);

  ll aa = (a - 1) - a1 - a2 + a3;
  ll bb = b - b1 - b2 + b3;
  cout << bb - aa << endl;
}


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

using namespace std;

typedef long long int ll;

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

  double d, t, s, ans;
  cin >> d >> t >> s;
  ans = d / s;
  cout << (ans <= t ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin>>s;
  if(s.length()!=6)
    	cout<<"No";
 	else if(s[2]==s[3]&&s[4]==s[5])
      	cout<<"Yes";
  else
    	cout<<"No";
  return 0;
}

Measured memory_bytes: 256
def isEcho(N, S):
    if N % 2 != 0: # 偶数じゃなければ
        return False
    
    first_S = S[0:int(N / 2)]
    last_S = S[int(N / 2):N]
    if first_S == last_S:
        return True
    return False

N = int(input())
S = input()
isTrue = isEcho(N, S)
if isTrue:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

ll n, len; 
char s[maxn];

int main() {
	
	scanf("%lld", &n);
	while (n) {
		s[++len] = (char)((n % 26 - 1 + 26) % 26 + 'a');
		n = (n - 1) / 26;
	}
	for (int i = len; i >= 1; i--) printf("%c", s[i]);
	puts("");
	// printf("(%lld, %lld)", n / 26, n % 26);

	return 0;
}		


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


int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s,t;
  map<char, vector<int> > mp;
  cin>>s>>t;

  for(int i=0;i<s.size();i++){
    char c = s[i];
    mp[c].push_back(i);
  }

  for(int i=0;i<t.size();i++){
    char c = t[i];
    if(mp.count(c)==0){
      cout<<-1<<endl;
      return 0;
    }
  }

  ll res=0;
  int s_p=0;

  for(int i=0;i<t.size();i++){
    char c = t[i];
    auto it = lower_bound(mp[c].begin(), mp[c].end(), s_p);
    if(it == mp[c].end()){
      res += s.size() - s_p;
      s_p = 0;
      res += mp[c][0] - s_p + 1;
      s_p = mp[c][0] + 1;
    } else {
      res += *it - s_p + 1;
      s_p = *it + 1;
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    
    long long d=n/(a+b);
    long long m=n%(a+b);
    long long ans=a*d;
    
    ans+=m>a?a:m;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque
H,W=map(int,input().split())
maze=[]
white=0
for i in range(H):
    s=input()
    c=s.count(".")
    white+=c
    maze.append(s)
path=[[None]*W for _ in range(H)]
path[0][0]=1
q=deque([[0,0]])
while q:
    h,w=q.popleft()
    for nh,nw in ([h+1,w],[h-1,w],[h,w+1],[h,w-1]):
        if nh<0 or nh>H-1 or nw<0 or nw>W-1:
            continue
        if maze[nh][nw]=="#" or path[nh][nw]!=None:
            continue
        q.append([nh,nw])
        path[nh][nw]=path[h][w]+1
        if nh==H-1 and nw==W-1:
            print(white-path[nh][nw])
            exit()
print(-1)

Measured memory_bytes: 74144
#include <bits/stdc++.h>
#define int long long
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ms(v, x) memset((v), (x), sizeof(v))
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define iopt ios::sync_with_stdio(false); cin.tie(0)

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int power(int x, int p, int MOD) {
    if(p == 0) return 1%MOD;
    if(p == 1) return x%MOD;
    int res = power(x, p/2, MOD);
    res = (long long)res*res%MOD;
    if(p&1) res = (long long)res*x%MOD;
    return res;
}

typedef pair<int, int> ii;
typedef long double LD;
typedef vector<int> vi;

const int N = 105;
const int oo = numeric_limits<int>::max();
vector<int> adj[N];
int hideg[N], L[N];
int n;

int mult(int a, int b) {
  int res;
  if(__builtin_smulll_overflow(a, b, &res))
    return oo;
  return res;
}

void dfs(int u, int p = -1) {
  hideg[L[u]] = max(hideg[L[u]], (int) adj[u].size() - 1 + (p == -1));
  for(int v : adj[u]) {
    if(v != p) {
      L[v] = L[u]+1;
      dfs(v, u);
    }
  }
}

ii solve(int u, int v = -1) {
  ms(hideg, 0);
  ms(L, 0);
  if(v == -1)
    dfs(u);
  else {
    dfs(u, v);
    dfs(v, u);
  }
  int depth = 0;
  for(int i = 0; i < n; i++) depth = max(depth, L[i]);

  int acc = v == -1 ? 1 : 2;
  for(int i = 0; i < depth; i++) {
    acc = mult(acc, hideg[i]);
  }

  return {depth + 1, acc};
}

ii ed[N];

int32_t main(){
  cin >> n;
  for(int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].pb(b);
    adj[b].pb(a);
    ed[i] = {a, b};
  }

  ii ans = {oo, oo};
  for(int i = 0; i < n; i++) {
    ans = min(ans, solve(i));
  }

  for(int i = 0; i < n-1; i++) {
    ans = min(ans, solve(ed[i].first, ed[i].second));
  }

  cout << ans.first << " " << ans.second << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    vector<int> v = {
            1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049
    };
    u32 n;
    cin >> n;
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (auto &&x : v) {
            if(i-x >= 0){
                dp[i] = min(dp[i-x]+1, dp[i]);
            }else break;
        }
    }
    cout << dp[n] << "\n";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  int sum = 0;
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  for(int j=0;j<N;j++){
    for(int k=j+1;k<N;k++){
      sum += (d[j] * d[k]);
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int[] num = new int[4];

   for(int i = 0; i < 4; i++){
       num[i] = scan.nextInt();
   }

   int a = num[0] * num[1];
   int b = num[2] * num[3]; 

  System.out.println(Math.max(a,b));
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b;
ll mem[5005][5005];
int p[5005], pos[5005];
ll dp(int id, int cur){
    if (mem[id][cur] != -1) return mem[id][cur];
    if (id == 0) return mem[id][cur] = 0;
    if (pos[id] > cur) {
        //printf("%d at %d needs to move to %d, cost %d\n",id,pos[id],cur,b);
        return mem[id][cur] = dp(id-1,cur)+b; ///move id to cur.
    }
    //printf("%d at %d, can move to %d, cost %d\n",id,pos[id],cur,a);
    return mem[id][cur] =  min(dp(id-1,pos[id]),dp(id-1,cur)+a);
}
int main(){
    scanf("%d%d%d",&n,&a,&b);
    for (int i = 1; i <= n; i++){
        scanf("%d",&p[i]);
        pos[p[i]] = i;
    }
    memset(mem,-1,sizeof(mem));
    printf("%lld",dp(n,n));
}


Measured memory_bytes: 196352
A,B,C = map(int,input().split())
K = int(input())

for i in range(K):
    tmp = min(B,C)
    if(B==C):
        C *= 2
    elif(2*B >= C):
        C *= 2
    else:
        B *=2
    # print(A,B,C)
if A< B and B<C:
    print('Yes')
else:
    print('No')

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

int a[105];
int ans;
int main()
{
	int n;
	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-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]==a[j]) continue;
			for(int k=j+1;k<=n;k++)
			{
				if(a[i]==a[k]||a[j]==a[k]) continue;
				if(a[i]+a[j]<=a[k]) break;
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3748
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
names = {"M":0 , "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    name = input()
    if name[0] in names.keys():
        names[name[0]] += 1
m,a,r,c,h = names["M"], names["A"], names["R"], names["C"], names["H"]

ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h
#print(m,a,r,c,h)
print(ans)


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

public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");
		
		int n = scn.nextInt(), i = 0;
		int[] arr = new int[100000];
		int k = 6;
		while(k <= n) {
			arr[i++] = k;
			k = 6 * k;
		}
		k = 9;
		while(k <= n) {
			arr[i++] = k;
			k = 9 * k;
		}
		
		arr = Arrays.copyOf(arr, i);
		Arrays.sort(arr);
		
		int[] dp = new int[n + 1];
		for(i = 0; i < Math.min(n + 1, 6); i++) {
			dp[i] = i;
		}
		
		for(i = 6; i <= n; i++) {
			int min = n + 1;
			for(int j = 0; j < arr.length; j++) {
				if(i - arr[j] >= 0) {
					min = Math.min(min, dp[i - arr[j]] + 1);
				}
			}
			dp[i] = min;
		}
		System.out.println(dp[n]);
	}
	
	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
}


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

#define ull unsigned long long
#define ll long long

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

    vector<int> seg;
    for(int i=1; i<n; ++i){
        seg.push_back(a[i]-a[i-1]);
    }
    seg.push_back(k-a[n-1] + a[0]);


    int lg = *max_element(seg.begin(), seg.end());
    cout << k - lg;
    return 0;
}

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

#define int long long

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

int H, W;
string A[8];

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                cnt++;
            }
        }
    }
    if (cnt == H + W - 1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


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

int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	vector<int> A(M);
	int ans = 0;
	int ansans = 0;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			A[j] = 0;
			cin >> A[j];
		}
		ans = 0;
		for (int j = 0; j < M; j++) {
			ans += A[j] * B[j];
		}
		ans += C;
		if (ans > 0) {
			ansans++;
		}
	}
	cout << ansans << endl;
}

Measured memory_bytes: 256
class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def C(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def P(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


P = int(input())
c = Combi(P-1, P)
A = list(map(int,input().split()))
power=[1 for i in range(P)]
ans = [0 for i in range(P)]
for i in range(P):
    if A[i] != 0:
        ans[0] += 1
        power[0]
        for  _ in range(1,P):
            power[_]=power[_-1]*(-i)%P
        for j in range(P):
            ans[j] -= c.C(P-1, j)*power[P-1-j] 
for i in range(P):
    ans[i] %= P
print(*ans)


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

char tmp[111];
int place;

int dfs(){
	
	if(isdigit(tmp[place])){
		return tmp[place++] - '0';
	}
	else{
		place++;
		char c = tmp[place++];
		int A = dfs();
		int B = dfs();
		place++;
		if(c == '+'){
			return (A | B);
		}
		else if(c == '*'){
			return (A & B);
		}
		else{
			return (A ^ B);
		}
	}
}

int get_hash(string str,string num){
	REP(i,str.size()){
		if(str[i] >= 'a' && str[i] <= 'd'){
			tmp[i] = num[str[i] - 'a'];
		}
		else{
			tmp[i] = str[i];
		}
	}
	place = 0;
	return dfs();
}

int main(){
	
	string str;
	while(cin >> str,str[0] != '.'){
		
		string num;cin >> num;
		int hash = get_hash(str,num);
		cout << hash << ' ';
		
		int ans = 0;
		for(int i = 0;i < 10000;i++){
			string seica = "";
			int hoge = i;
			REP(j,4){
				seica += (char)('0' + (hoge % 10));
				hoge /= 10;
			}
			if(get_hash(str,seica) == hash)ans++;
		}
		
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  unordered_set<char> C;
  for (char c : S) C.insert(c);
  if (C.size() == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
tree = {i: set() for i in range(n)}
cost = {}
for _ in range(n-1):
    u, v, w = map(lambda x: int(x)-1, input().split())
    tree[u].add(v)
    tree[v].add(u)
    cost[(u, v)] = w + 1

color = [-1] * n
color[0] = 0
que = deque([0])
while que:
    now = que.popleft()
    for i in tree[now]:
        if color[i] != -1:
            continue
        if cost[(min(now, i), max(now, i))] % 2 == 0:
            color[i] = color[now]
        else:
            color[i] = color[now] ^ 1
        que.append(i)
print('\n'.join(map(str, color)))


Measured memory_bytes: 73628
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.insert(0,0)
loop=[]
keys = [i for i in range(1,n+1)]
values=[0 for i in range(n)]
dd=dict(zip(keys, values))
start=10
nex=1
pos=a
while start!=nex:
  start=1
  if dd[nex]==1:
    pos=loop.index(nex)
    loop1=loop[pos:]
    nex=1
  else:
    loop.append(nex)
    dd[nex]=1
    nex=a[nex]

if pos==a:
  length=len(loop)
  print(loop[k%length])
else:
  length=len(loop1)
  if k>=len(loop):
    k=k-pos
    print(loop1[k%length])
  else:
    print(loop[k])

Measured memory_bytes: 42836
import sys
input = sys.stdin.readline

def main():
    N, W = map(int, input().split())
    vw = [list(map(int, input().split())) for i in range(N)]

    # dp[i]: 重さj以下での価値の最大値
    dp = [0] * (W+1)
    for i in range(N):
        v, w = vw[i]
        if w <= W:
            for j in range(W-w, -1, -1):
                dp[w+j] = max(dp[w+j], dp[j] + v)
    print(dp[W])

if __name__ == "__main__":
    main()


Measured memory_bytes: 5928