akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int a,b,c;cin>>a>>b>>c;
	if(a==b&&b!=c){
		cout << "Yes" << endl;return 0;
	}
	if(a==c&&b!=c){
		cout << "Yes" << endl;return 0;
	}
	if(c==b&&a!=c){
		cout << "Yes" << endl;return 0;
	}
	cout << "No" << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// リョナれひらきち 右へ左へ(下へ上へ)
// 飛ばせひらきち 遥か彼方まで

// 追記
// ひらきちさんの担当はFである事に今気づいた

int h, w;
vector<string> g;

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

	cin >> h >> w;

	g.resize(h);
	for (auto &v : g) {
		cin >> v;
	}

	vector<vector<int>> memo(h, vector<int>(w));
	// 右へ左へ
	for (int y = 0; y < h; y++) {
		int score = 0;
		for (int x = 0; x < w; x++) {
			score = g[y][x] == '.' ? score + 1 : 0;
			memo[y][x] += score;
		}

		score = 0;
		for (int x = w - 1; x >= 0; x--) {
			score = g[y][x] == '.' ? score + 1 : 0;
			memo[y][x] += score;
		}
	}

	// 下へ上へ
	for (int x = 0; x < w; x++) {
		int score = 0;
		for (int y = 0; y < h; y++) {
			score = g[y][x] == '.' ? score + 1 : 0;
			memo[y][x] += score;
		}

		score = 0;
		for (int y = h - 1; y >= 0; y--) {
			score = g[y][x] == '.' ? score + 1 : 0;
			memo[y][x] += score;
		}
	}

	int ans = 0;
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (g[y][x] == '#') continue;
			ans = max(ans, memo[y][x] - 3);
		}
	}

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


Measured memory_bytes: 20224
n = gets.chomp.to_i
x = gets.chomp.split(" ").map(&:to_i)

xc = x.clone
xc.sort!.reverse!

a = xc[x.length / 2 - 1]
b = xc[x.length / 2]

x.each do |i|
  if i < a
    puts a
  else
    puts b
  end
end

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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        long long lo,hi,mid;

        scanf("%lld %lld",&n,&k);

        for(i=0;i<n;i++)
        {
            scanf("%lld",&a); v.push_back(a); if(a>mx)mx=a;
        }

        lo=1; hi=mx;

        while(lo<hi)
        {
            cnt=0; mid=(lo+hi)>>1;

            for(i=0;i<n;i++)
            {
                p=v[i]/mid; if(v[i]%mid!=0)p++; p--; cnt=cnt+p; if(cnt>k)break;

            }

            if(cnt<=k)hi=mid;
            else{ lo=mid+1;  }

        }


        printf("%lld\n",lo);






    return 0;
}





Measured memory_bytes: 5312
def main():
    X = input()
    Y = input()
    N = len(X)
    M = len(Y)
    dp = [[0]*(M+1) for _ in range(N+1)]
    for i, x in enumerate(X):
        for j, y in enumerate(Y):
            if x == y:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
    res = ""
    while N > 0 and M > 0:
        if dp[N][M] == dp[N-1][M]:
            N -= 1
        elif dp[N][M] == dp[N][M-1]:
            M -= 1
        else:
            res = X[N-1] + res
            N -= 1
            M -= 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 112732
n,a,b = map(int,input().split())

x = list(map(int,input().split()))

res = 0

now = x[0]

for nxt in x[1:]:
    dis = nxt - now
    if dis*a>b:
        res+=b
    else:
        res+=dis*a
    now = nxt
print(res)


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  vector<vector<int>> ot(n);
  rep(i,m) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    to[s].push_back(t);
    ot[t].push_back(s);
  }

  vector<double> en(n), pn(n);
  pn[n-1] = 1;
  for (int v = n-2; v >= 0; --v) {
    int deg = to[v].size();
    for (int u : to[v]) {
      en[v] += en[u];
      pn[v] += pn[u];
    }
    en[v] /= deg; en[v] += 1;
    pn[v] /= deg;
  }

  vector<double> e1(n), p1(n);
  p1[0] = 1;
  for (int v = 1; v < n; ++v) {
    for (int u : ot[v]) {
      e1[v] += (e1[u]+1)/to[u].size();
      p1[v] += p1[u]/to[u].size();
    }
  }
  // rep(i,n) printf("%d %.2f %.2f\n", i, en[i], pn[i]);
  // rep(i,n) printf("%d %.2f %.2f\n", i, e1[i], p1[i]);

  double ans = en[0];
  for (int v = 0; v <= n-2; ++v) {
    int deg = to[v].size();
    if (deg == 1) continue;
    double now = en[0];
    { // 1/deg -> 0
      double p = 1.0/deg;
      for (int u : to[v]) {
        double s = e1[v]*pn[u];
        s += p1[v]*en[u];
        s += p1[v]*pn[u];
        s *= p;
        now -= s;
      }
    }
    { // 0 -> 1/(deg-1)
      double p = 1.0/(deg-1);
      for (int u : to[v]) {
        double s = e1[v]*pn[u];
        s += p1[v]*en[u];
        s += p1[v]*pn[u];
        s *= p;
        now += s;
      }
    }
    for (int u : to[v]) {
      // 1/(deg-1) -> 0
      double p = 1.0/(deg-1);
      double s = e1[v]*pn[u];
      s += p1[v]*en[u];
      s += p1[v]*pn[u];
      s *= p;
      ans = min(ans, now-s);
    }
  }

  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define rall(hoge) (hoge).rbegin(), (hoge).rend()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
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;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin >> n >> k;
    vl a(n),f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(all(a));
    sort(all(f),greater<ll>());

    auto isok = [&](ll x) {
        ll cnt = 0;
        rep(i,n) {
            if(a[i]*f[i] <= x) continue;
            cnt += (a[i]-x/f[i]);
            if (cnt > k) return 0;
        }
        return 1;
    };

    ll ok = (ll)1e18 + 1;
    ll ng = -1;
    while (ok-ng > 1) {
        ll mid = (ok+ng)/2;
        if (isok(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }

    }
    print(ok);
    return 0;
}


Measured memory_bytes: 6300
#include<iostream>
using namespace std;
int n,a[22];
int cnt[2001];

void es(){
  for(int i=0;i<1<<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(i>>j&1)sum+=a[j];
    }
    cnt[sum]++;
  }
}

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

  es();
  
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int x;
    cin>>x;
    cout<<(cnt[x]?"yes":"no")<<endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    vector<vector<pair<lli, lli>>> t(n);
    rep(i, n){
        lli ai;
        cin >> ai;
        rep(j, ai){
            lli x, y;
            cin >> x >> y;
            t[i].push_back({x-1, y});
        }
    }
    lli ans = 0;
    rep(b, (1<<n)){
        bool ok = true;
        rep(j, n){
            if(b>>j&1){
                rep(k, t[j].size()){
                    lli u = t[j][k].second;
                    lli v = b>>t[j][k].first&1;
                    if(u != v){
                        ok = false;
                    }
                }
            }
        }
        if(ok){
            ans = max(ans, (lli)__builtin_popcount(b));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
n,p= map(int,input().split())
s = input()
ans = 0
if p == 2 or p == 5:#右端を固定すれば2,5で割り切れるならそれ以降は全部いけるのでn-iをたす
    for i in range(n):
        if int(s[-1-i]) % p == 0:
            ans += n-i
    print(ans)
    exit()
else:
  s = s[::-1]#反転させてしたからみる
  cnt = [0]*p # pで割った時のあまり
  cnt[0] = 1 # 0の時はなにも取らない時全体も入るので+1する
  modp = 0
  for i,c in enumerate(map(int,s)):#enumerateでiterator i , s[i]の値cを同時に取得
    modp = (c*pow(10,i,p) + modp)%p
    cnt[modp] += 1
  for i in range(p):
    ans += cnt[i]*(cnt[i]-1) //2
  print(ans)



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    // max_0<=i<=n-1{a[0] + ... + a[i] + b[i] + ... + b[n-1]}
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += a[j];
        }
        for (int j = i; j < n; j++) {
            sum += b[j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s, t, u;
	int a, b; cin >> s >> t >> a >> b >> u;
	if(s == u) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, money = 1000, kabu = 0, day = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> p(n);
  REP(i, n) {
    cin >> a[i];
    if (i != 0) {
      if (a[i - 1] < a[i])
        p[i] = 1;
      else if (a[i - 1] > a[i])
        p[i] = -1;
    }
  }
  vector<ll> b;

  for (ll i = 1; i < n; i++) {
    if (p[i - 1] != p[i] && p[i] != 0) {
      b.push_back(a[i - 1]);
    }
  }
  b.push_back(a[n - 1]);

  for (ll i = 0; i < b.size() - 1; i++) {
    if (b[i] < b[i + 1]) {
      //株を買う
      kabu += floor(money / b[i]);
      money -= b[i] * floor(money / b[i]);
    }
    if (b[i] > b[i + 1]) {
      //株を売る
      money += kabu * b[i];
      kabu = 0;
    }
  }
  if (kabu > 0) money += kabu * b[b.size() - 1];
  cout << money << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(long long i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii four_Dir[4] = {
	{ -1 ,0 },{ 0 ,1 },
	{ 1 ,0 },{ 0,-1 }
};
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //????????\??£??????????????¨ y?????\??£?????????????????????
		x = root(x); y = root(y);
		if (x != y) {
			//if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //x??¨y????????????????????\??£??????????????????????????????
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
};
signed main() {
	int n;
	while (scanf("%d", &n)) {
		if (!n)
			break;
		int bef = -1;
		UnionFind uf(n);
		vector<int> uft(n);
		REP(i, n) {
			int cur;
			scanf("%d", &cur);
			if (i % 2) {
				uf.unionSet(i - 1, i);
				if (uf.root(i)) {
					if(uft[uf.root(uf.root(i)-1)] == cur)
						uf.unionSet(uf.root(i) - 1, i);				
				}
			}
			else if (cur == bef) {
				uf.unionSet(i - 1, i);
			}
			bef = cur;
			uft[uf.root(i)] = cur;
		}
		int ans = 0;
		REP(i, n) {
			if (uf.isroot(i) && !uft[uf.root(i)]) {
				ans += uf.size(i);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main()
{
    char a[10];

    scanf("%s", a);

    if(strcmp(a,"SUN")==0)
        printf("7");
    if(strcmp(a,"MON")==0)
        printf("6");
    if(strcmp(a,"TUE")==0)
        printf("5");
    if(strcmp(a,"WED")==0)
        printf("4");
    if(strcmp(a,"THU")==0)
        printf("3");
    if(strcmp(a,"FRI")==0)
        printf("2");
    if(strcmp(a,"SAT")==0)
        printf("1");


    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static ArrayList<Gem> alg;
    
    public static void main(String[] args) {
        for(int n; (n = scn.nextInt()) > 0;) {
            alg = createGemList(n);
            System.out.println(searchGem(scn.nextInt()) ? "Yes" : "No");
        }
    }
    
    public static ArrayList<Gem> createGemList(int n) {
        ArrayList<Gem> list = new ArrayList<>();
        for(; n > 0; n--) {
            list.add(new Gem(scn.nextInt(), scn.nextInt()));
        }
        return list;
    }
    
    public static boolean searchGem(int m) {
        ArrayList<Gem> list = new ArrayList<>(alg);
        final int[][] move = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
        for(int x = 10, y = 10; m > 0; m--) {
            int dir = 0;
            switch(scn.next()) {
              case "W":
                dir++;
              case "S":
                dir++;
              case "E":
                dir++;
            }
            for(int num = scn.nextInt(); num > 0; num--) {
                y += move[dir][0];
                x += move[dir][1];
                for(Gem elm : alg) {
                    if(elm.compare(x, y)) {
                        list.remove(elm);
                    }
                }
            }
        }
        return list.size() > 0 ? false : true;
    }
}

class Gem {
    private final int x_;
    private final int y_;
    
    public Gem(int x, int y) {
        x_ = x;
        y_ = y;
    }
    
    public boolean compare(int x, int y) {
        return x_ == x && y_ == y;
    }
}

Measured memory_bytes: 45168
#include<iostream>

int main() {
	int v_1, s_1, v_2, s_2,result; //縦　Vertical,横　side より(google翻訳) あと余計な変数増やしたくないですがresultは条件演算子の真、偽の両方でstd::coutを書くのがめんどくさかったから
	std::cin >> v_1 >> s_1 >> v_2 >> s_2;
	
	v_1*s_1 >= v_2 * s_2 ? result = v_1 * s_1 : result = v_2 * s_2;

	std::cout << result << std::endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	
	string S;
	cin >> N >> S;
	vector<ll> vec(1000);

	 ll an= 0;
	for (int i = 0; i < 1000; i++) {
		int c=i;
		int j = 1;
		int t = 0;
		while (j < 101&&t<N) {
			char k = '0' + (c / j)%10;
			
			if (S.at(t) == k) {
				j *= 10;

			}
			t++;
		}
		if (j > 100) {
			an++;
			
		}

	}
	cout << an << endl;
	
}


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

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    ll L, R;
    cin >> L >> R;
    ll ans = 10000000;
    if(L <= 3 && R >= 673){
        ans = 0;
    }else if( R >= 2019 && L < 2019){
        ans = 0;
    }else{
        for(ll i = L; i < R; i++){
            for(ll k = i + 1; k <= R; k++){
                ll r = ((i % (ll)2019) * (k % (ll)2019)) % (ll)2019;
                ans = min(ans, r);
                if(ans == 0){
                    cout << ans << endl;
                    return 0;
                }
                
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    reverse(ALL(S));
    S += '0';
    int n = S.size();
    vector<vector<ll>> ans(n+1, vector<ll>(2,0));
    ans[0][1] = MAXINF;
    REP(i, n){
        int si = S[i]-'0';
        ans[i+1][0] = si+min(ans[i][0], 1+ans[i][1]);
        ans[i+1][1] = 10-si+min(ans[i][0], ans[i][1]-1);
    }
    pr(ans[n][0]);
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	int ans = 0;

	if(s[0] == 'R') ans = 1;

	if(s[1] == 'R'){
		if(ans == 1) ans = 2;
		else ans = 1;
	}

	if(s[2] == 'R'){
		if(ans == 2) ans = 3;
		else if(ans == 1){
			if(s[0] == 'R') ans = 1;
			else if(s[1] == 'R') ans = 2;
		}
		else ans = 1;
	}

	cout << ans;

	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    string res;
    unordered_map<string,int> hmap;

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

    cout<<hmap.size()<<endl;
    return 0;
}


Measured memory_bytes: 17792
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#include <cmath>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ct = 0;
    for(int i = 0; i < N; i++) {
        ct++;
        int j = i + 1;
        if(i != N-1) {
            bool inc = false;
            bool con = false;
            for(j = i + 1; j < N; j++) {
                if(con) {
                    if(inc && A[j - 1] > A[j]) {
                        j--;
                        break;
                    } else if(!inc && A[j - 1] < A[j]) {
                        j--;
                        break;
                    }
                } else {
                    if(A[i] == A[j]) {
                        ;
                    } else if(A[i] < A[j]) {
                        inc = true;
                        con = true;
                    } else {
                        inc = false;
                        con = true;
                    }
                }
            }
            i = j;
            continue;
        }
    }
    cout << ct << endl;

}





Measured memory_bytes: 640
/**
*    author:  yuya1234
*    created: 07.07.2020 11:16:50
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  string s;
  cin>>s;

  ll ans=0,cnt=0;
  REP(i,SZ(s))
  {
    if(s[i]=='B')cnt++;
    else ans+=cnt;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pii;
//int64 dp[2002][2002];
vector<pii> A(2002);
int n;
map<vector<int>, int64> dp;
int64 solve(int l, int r, int pos){
   if(l > r) return 0;
   if(pos >= n) return 0;
   int64 &ret = dp[{l, r, pos}];
   if(ret > 0) return ret;
   ret = A[pos].first * abs(A[pos].second - l) + solve(l + 1, r, pos + 1);
   ret = max(ret, A[pos].first * abs(A[pos].second - r) + solve(l, r - 1, pos + 1));
   return ret;
}
int main(){
	cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.rbegin(), A.rend());
    //memset(dp, -1, sizeof(dp));
    int64 ans = solve(0, n - 1, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 222736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

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

int main(){
    ll N;
    cin >> N;
    vec<int> X(N);
    for(auto& x:X) cin >> x;
    mint ans = 1;
    ll si = 0;
    int r = 0;
    for(int i=0;i<N;i++){
        while(r<N && 2*si<=X[r]){
            si++;
            r++;
            if(2*(si-1)==X[r-1]) break;
        }
        ans *= si--;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
N, K = map(int, input().split())
D = K.bit_length()
to = [[0] * D for _ in range(N)]

for i, a in enumerate(map(int, input().split())):
    to[i][0] = a - 1

for j in range(D - 1):
    for i in range(N):
        h = to[i][j]
        to[i][j+1] = to[h][j]

v = 0
for i in reversed(range(D)):
    if (K >> i) & 1:
        v = to[v][i]

print(v + 1)

Measured memory_bytes: 207420
class Dice
 
  def initialize( given_ary )
    @ary = given_ary
  end
 
  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end
 
  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end
 
  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end
 
  def top
    @ary[ 0 ]
  end
 
  def front
    @ary[ 5 ]
  end
 
  def right
    @ary[ 2 ]
  end
 
end
 
dice = Dice.new( gets.split.map(&:to_i) )
gets.to_i.times do
  top, front = gets.split.map(&:to_i)
  dice.topface( top )
  dice.frontface( front )
  puts dice.right
end

Measured memory_bytes: 8672
w,h,n=gets.chomp.split(" ").map(&:to_i)
b,c=0,0
n.times{
  x,y,a=gets.chomp.split(" ").map(&:to_i)
  case a
  when 1
    b=[b,x].max
  when 2
    w=[w,x].min
  when 3
    c=[c,y].max
  else
    h=[h,y].min
  end
}
puts [(w-b),0].max*[(h-c),0].max

Measured memory_bytes: 1788
#include <iostream>
//#include <string>
#include <cmath>
//#include <bits/stdc++.h>
//#include <algorithm>
using namespace std;

int judge(int W, int H, int x, int y, int r) {
  //left
  if (x - r < 0) return 1;
  //under
  if (y - r < 0) return 1;
  //right
  if (x + r > W) return 1;
  //top
  if (y + r > H) return 1;
  
  return 0;
}

int main() {
  int W, H, x, y, r;

  cin >> W >> H >> x >> y >> r;

  if(judge(W, H, x, y, r)){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  
  return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char ch;
	int cnt=0,i=0;
	scanf("%c",&ch);
	if(ch=='1'){
		while(ch!='\n'){
			scanf("%c",&ch);
			i+=1;
			if(i%2==1 && ch!='0'){
				cnt+=1;
			}
			if(i%2==0 && ch!='1'){
				cnt+=1;
			}
		}
	}
	if(ch=='0'){
		while(ch!='\n'){
			scanf("%c",&ch);
			i+=1;
			if(i%2==1 && ch!='1'){
				cnt+=1;
			}
			if(i%2==0 && ch!='0'){
				cnt+=1;
			}
		}
	}
	printf("%d\n",cnt-1);
	return 0;
}

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

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

using ll = long long;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<double> v(N);
  for(int i = 0; i < N; i++) {
    int n = 1;
    while(n*(i+1)<K){
      n*=2;
    }
    double p = (double)1/n;
    v[i]=p;
  }
  double ans = 0;
  for(int i = 0; i < N; i++) {
    ans+=v[i];
  }
  ans /= N;
  cout<<fixed<<setprecision(11);
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;

    cin >> n >> k;
    vector<ll> h(n);

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

    sort(h.begin(), h.end());

    ll ans = INF;

    for (int i = k - 1; i < n; i++)
    {
        ans = min(ans, h[i] - h[i - k + 1]);
    }

    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == s+1) s++;
    }
    cout << (s != 0 ? n-s : -1) << endl;
}


Measured memory_bytes: 384
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,a,b;
int main()
{
	fast;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
    return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())

ilist = [False for x in range(2020)]
a=2*10**9
for i in range(R+1)[L:L+2020]:
  imod = i % 2019
  if ilist[imod]:
    continue
  ilist[imod] = True
  for j in range(R+1)[i+1:i+1+2020]:
    jmod = j % 2019
    m = (imod * jmod) % 2019
    a = min(a,m)

print(a)

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

using ll = unsigned long long;
using namespace std;

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

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

    vector<int> r = p;
    sort(r.begin(), r.end());

    int ecc = 0;
    for(int i = 0; i < n; i++) {
        if (p[i] != r[i]) {
            ecc++;
        }
    }

    if ( ecc > 2) {
        cout << "NO" <<endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

win = {"r":P,"s":R,"p":S}
tmp = [1]*N
ans = 0

for i in range(N):
    if i<K:
        ans += win[T[i]]
        tmp[i] = 0
    else:
        if T[i]!=T[i-K] or tmp[i-K]:
            ans += win[T[i]]
            tmp[i] = 0

print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    bool f = false;
    while(1){
        if(s.size() >= 5){
            if(s.substr(0, 5) == "dream"){
                if(s.substr(5, 5) != "erase" && s.substr(5, 2) == "er") s = s.substr(2, s.size()-2);
                s = s.substr(5, s.size()-5);
            }else if(s.substr(0, 5) == "erase"){
                if(s.substr(0, 6) == "eraser") s = s.substr(1, s.size()-1);
                s = s.substr(5, s.size()-5);
            }else{
                f = true;
                break;
            }
        }else if(s.size() == 0){
            break;
        }else{
            f = true;
            break;
        }
    }
    cout << (f ? "NO" : "YES") << "\n";
    return 0;
}

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

int main(){
  ll N;
  cin >> N;
  ll cnt=0,K;
  bool can=true;
  vector<ll> vec(N+1,0);
  for(ll i=0;i<N;i++){
    if(i==0){
      K=7;
      cnt++;
      K%=N;
      vec[K]++;
    }
    else{
      K=K*10+7;
      cnt++;
      K%=N;
      vec[K]++;
    }
    
    if(K==0){
      break;
    }
    if(vec[K]>=2){
      can=false;
      break;
    }
  }
  if(can){
    cout << cnt <<endl;
  }
  else{
    cout << -1 <<endl;
  }
}
  
  

Measured memory_bytes: 11144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int W = count(s.begin(), s.end(), 'W');
  int E = count(s.begin(), s.end(), 'E');
  int w = 0, e = 0;
  int ans = E;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'W') w++;
    else e++;
    ans = min(ans, E - e + w);
  }
  print(ans);
}

Measured memory_bytes: 900
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,M=rl()
DIV = 10**9 + 7

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

l = factorize(M)

ans = 1
for _, i in l:
    res = 1
    for j in range(i):
        res *=(N-1+i-j)
    for j in range(i):
        res = res//(j+1)
    ans *= res
    ans %= DIV

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
using namespace std;
const int N=100500;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int B[2*N][2],A[N],B0;
int f[N];
int er[N];
void link(int q,int w)
{
	B[++B0][0]=A[q],A[q]=B0,B[B0][1]=w;
	B[++B0][0]=A[w],A[w]=B0,B[B0][1]=q;
}
void dfs(int q,int fa)
{
	int t=0;
	efo(i,q)if(B[i][1]!=fa)
	{
		dfs(B[i][1],q);
		t=max(t,f[q]&f[B[i][1]]);
		f[q]|=f[B[i][1]];
	}
	fo(i,1,22)if(er[i]>t&&!(f[q]&er[i])){t=i;break;}
	ans=max(ans,t);
	// printf("%d %d\n",q,t);
	f[q]=(f[q]&(er[23]-er[t]))|er[t];
}
int main()
{
	int q,w;
	er[1]=1;fo(i,2,23)er[i]=er[i-1]<<1;
	read(n);
	fo(i,1,n-1)read(q),read(w),link(q,w);
	dfs(1,0);
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 5888
#https://atcoder.jp/contests/abc125/tasks/abc125_d

from functools import reduce

def positivesum(lists):
	for i in range(len(lists)):
		if lists[i]<0:
			lists[i]=lists[i]*(-1)
	return(sum(lists))
	

n=int(input())
alist=list(map(int,input().split()))

#負数の数をカウント
count=0
for i in range(n):
	if alist[i]<0:
		count+=1


if count==n and count%2==1:
	print(-sum(alist)+2*max(alist))

elif count%2==0:
	print(positivesum(alist))
else:
	alist.sort()
	x=max(alist[count-1],-alist[count])
	print(positivesum(alist)+x*2)



Measured memory_bytes: 14908
/*
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
*/
/**

**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+7
#define EPS 1e-6
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"

int main() {
    string s;
    cin >> s;
    int ans = 1;
    bool pastbig = false;
    for (int i = 1; i < s.size(); i++) {
        if (pastbig == true) {
            pastbig = false;
            ans++;
            continue;
        }
        if (s[i] == s[i - 1]) {
            pastbig = true;
            if (i != s.size() - 1) ans++;
            i++;
        } else {
            pastbig = false;
            ans++;
        }
    }
    cout << ans;

}



Measured memory_bytes: 640
A, B, C, D, E, F = gets.split.map(&:to_i)

x = []
(F / A).times do |i|
  (F / B).times do |j|
    sum = i * A * 100 + j * B * 100
    next if sum > F
    x << sum
  end
end

y = []
(F / C).times do |i|
  (F / D).times do |j|
    sum = i * C + j * D
    next if sum > F
    y << sum
  end
end

x = x.uniq.sort
y = y.uniq.sort

beaker = { noudo: 0, water: 0, sugar: 0 }
x.each do |water|
  y.each do |sugar|
    next if water + sugar > F
    next if (water / 100.to_f) * E < sugar

    noudo = sugar / (water + sugar).to_f
    next if beaker[:noudo] >= noudo

    beaker = { noudo: noudo, water: water, sugar: sugar }
  end
end

puts "#{beaker[:water] + beaker[:sugar]} #{beaker[:sugar]}"


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int dp[3141][5926];
	
int main(){
	string s, t;
	cin >> s >> t;
	int sz = s.l_ength();
	int tz = t.l_ength();
	for( int i = 1; i <= sz; ++i ){
		for( int j = 1; j <= tz; ++j ){
			if( s[i-1] == t[j-1] ){
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max( dp[i-1][j], dp[i][j-1] );
			}
		}
	}
	string ans = "";
	{
		int i = sz, j = tz; 
		while( dp[i][j] > 0 ){
			if( s[i-1] == t[j-1] ){
				ans += s[i-1];
				--i; --j;
			} else {
				if( dp[i-1][j] >= dp[i][j-1] ){
					--i;
				} else {
					--j;
				}
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 69248
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
set<char>st;
int main() {
    quick
int n; string s,ans; cin>>n>>s;  ans=s[0];
for(int i=1; i<s.size();i++){
    if(s[i]!=ans[ans.size()-1]){
        ans.push_back(s[i]); }
}
cout<<ans.size();
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];
  int m;
  cin>>m;
  vector<int> t(m);
  rep(i,m) cin>>t[i];
  sort(all(d));
  sort(all(t));
  int cnt=0;
  int j=0;
  rep(i,n){
    if(d[i]==t[j]){
      cnt++;
      j++;
    }
  }
  if(cnt==m){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 4744
X = int(input())
a = 0
if X == 2 or X == 3:
  print(X)
  exit()
if X % 2 == 0:
  X += 1
for i in range(X , 10 ** 6, 2):
  for j in range(3,i,2):
    a = i % j
    if a == 0:
      break
  if a != 0 :
    print(i)
    exit()
        
      
        
    

Measured memory_bytes: 9156
N,Y = map(int,input().split())
if N*10000 < Y :
    print('-1 -1 -1')
else :    
    for i in range(N+1) :
        X = Y - i*10000
        for j in range(N-i+1) :
            if (X - j*5000) // 1000 == N-i-j :
                print(i,j,N-i-j)
                break
        else :
            continue
        break
    else :
        print('-1 -1 -1')

Measured memory_bytes: 3060
#include<stdio.h>

int l[101];

int main(){
	int n,x,ans=0,cnt=0;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&l[i]);
	}

	for(int j=1;j<=n;j++){
		cnt+=l[j];
		if(cnt>x) break;
		ans++;
	}

	printf("%d",ans+1);

	return 0;
}
	

Measured memory_bytes: 128
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;



class Program
{
	//Main
	static void Main(string[] args)
	{
		//出力準備（AutoFlushを切る）
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		//解答
		Solve();
		//出力終了
		Console.Out.Flush();
	}

	static void Solve()
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		for(int i=1; i<N; i++){
			ans += ((N-1)/i);
		}

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 17684