akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
cout<<fixed<<setprecision(12);
double r;
cin>>r;
double p=3.14159265359;
double s=r*r*p;
double l=2*r*p;
cout<<s<<" "<<l<<endl;
return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int n = 1000005;

int N, K;

long long Xs[n];

int main(){
	cin >> N >> K;
	int i0 = -1;
	int nN = N;
	for(int i= 0; i < nN; ++i){
		int a;
		cin >> a;
		if(a > 0 && i0 == -1){
			i0 = i;
			Xs[i++] = 0;
			nN++;
		}else if (a == 0){
			i0 = i;
			K--;
		}
		Xs[i] = a;
	}
	if(Xs[nN-1] < 0){
		Xs[nN] = 0;
		i0 = nN;
		nN++;
	}
	//for(int i = 0; i < nN; ++i){
	//	cout << Xs[i] << " ";
	//}
	//cout << endl;
	long long mD = 100000000000;
	for(int i = 0; i < nN; ++i){
		int lit = abs(i0 - i);
		int leftL = K - lit;
		long long dist = abs(Xs[i]);
		//cout << "lit: " << lit << " left: " << leftL << endl;
		//cout << "i: " << i << " dist: " << dist << endl;
		if(leftL > 0){
			int i2 = 0;
			if(i <= i0){
				i2 = i0 + leftL;
				//cout << "i0: "<< i0 << " i2: "<< i2 << " Xs[i2] " <<Xs[i2]<<endl;
				if(i2 < nN)
					dist += abs(Xs[i] - Xs[i2]);
				else
					continue;
			}else{
				i2 = i0 - leftL;
				if(i2 >= 0)
					dist += abs(Xs[i] - Xs[i2]);
				else
					continue;
			}
		}
		//cout << "i: " << i << " dist: " << dist << endl;
		mD = min(mD, dist);
	}
	cout << mD << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll T(N);
        rep(i, 0, N) cin >> T[i];

        ll l = T[0];
        rep(i, 0, N) {
                l = l(l, T[i]);
        }
        cout << l << endl;
}

Measured memory_bytes: 256
io = STDIN
_,_,_,K=io.gets.split.map(&:to_i)
a,b,c=3.times.map{io.gets.split.map(&:to_i)}
def f(a,b)
  a.product(b).map{|x,y|x+y}.max (K)
end
puts f(f(a,b),c)


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

const int INF = 1<<28;
const int H = 5;
const int W = 5;

struct State {
  int g[H][W];
  int x[2], y[2];
  bool operator < (const State &s) const {
    for(int i = 0; i < H; ++i) {
      for(int j = abs(2-i); j < W-abs(2-i); ++j) {
        if(g[i][j] != s.g[i][j]) return g[i][j] < s.g[i][j];
      }
    }
    return false;
  }
  bool operator == (const State &s) const {
    return !(*this < s) && !(s < *this);
  }
};

map<State,int> bfs1(State src) {
  const static int dx[4] = {1,0,-1,0};
  const static int dy[4] = {0,1,0,-1};
  map<State,int> cost;
  queue<State> que;
  cost[src] = 0;
  que.push(src);
  while(que.size()) {
    const State s = que.front();
    que.pop();
    if(cost[s] == 10) continue;
    for(int k = 0; k < 2; ++k) {
      for(int i = 0; i < 4; ++i) {
        int nx = s.x[k] + dx[i];
        int ny = s.y[k] + dy[i];
        if(nx < 0 || nx >= W) continue;
        if(ny < 0 || ny >= H) continue;
        if(s.g[ny][nx] <= 0) continue;
        State t = s;
        swap(t.g[t.y[k]][t.x[k]], t.g[ny][nx]);
        t.x[k] = nx;
        t.y[k] = ny;
        if(cost.count(t)) continue;
        cost[t] = cost[s] + 1;
        que.push(t);
      }
    }
  }
  return cost;
}

int bfs2(State src, map<State,int> rcost) {
  const static int dx[4] = {1,0,-1,0};
  const static int dy[4] = {0,1,0,-1};
  if(rcost.count(src)) return rcost[src];
  map<State,int> cost;
  queue<State> que;
  cost[src] = 0;
  que.push(src);
  int res = INF;
  while(que.size()) {
    const State s = que.front();
    que.pop();
    if(cost[s] == 10) continue;
    for(int k = 0; k < 2; ++k) {
      for(int i = 0; i < 4; ++i) {
        int nx = s.x[k] + dx[i];
        int ny = s.y[k] + dy[i];
        if(nx < 0 || nx >= W) continue;
        if(ny < 0 || ny >= H) continue;
        if(s.g[ny][nx] <= 0) continue;
        State t = s;
        swap(t.g[t.y[k]][t.x[k]], t.g[ny][nx]);
        t.x[k] = nx;
        t.y[k] = ny;
        if(cost.count(t)) continue;
        cost[t] = cost[s] + 1;
        que.push(t);
        if(rcost.count(t)) {
          res = min(res, cost[t] + rcost[t]);
        }
      }
    }
  }
  return res;
}

int main() {
  State src, dst;
  fill(dst.g[0], dst.g[H], -1);
  for(int i = 0, k = 0, t = 0; i < H; ++i) {
    for(int j = abs(2-i); j < W-abs(2-i); ++j) {
      dst.g[i][j] = t++ % 12;
      if(dst.g[i][j] == 0) {
        dst.x[k] = j;
        dst.y[k] = i;
        ++k;
      }
    }
  }
  const map<State,int> rcost = bfs1(dst);
  while(1) {
    fill(src.g[0], src.g[H], -1);
    for(int i = 0, k = 0; i < H; ++i) {
      for(int j = abs(2-i); j < W-abs(2-i); ++j) {
        cin >> src.g[i][j];
        if(src.g[i][j] == -1) return 0;
        if(src.g[i][j] == 0) {
          src.x[k] = j;
          src.y[k] = i;
          ++k;
        }
      }
    }
    int res = bfs2(src, rcost);
    if(res > 20) cout << "NA" << endl;
    else cout << res << endl;
  }
  return 0;
}

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

int main()
{
    ll n;cin>>n;
    ll ans = 1;
    for(ll i = 1; i<= n; i++){
       ans *= i;
       ans %= (ll)(1e9 + 7);
        
    }
    cout << ans << endl;
    return 0;
}


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

char turn;

int turnConsumption(string* S, char player){
    if((*S).empty()){
        cout << player << endl;
        return 1;
    }
    else{
        turn=(*S)[0];
        (*S).erase((*S).begin());
        return 0;
    }
}

int main(){
    string A,B,C;
    cin >> A >> B >> C;
    turn = 'a';

    while(true){
        if(turn=='a'){
            if(turnConsumption(&A,'A')) return 0;
        }
        if(turn=='b'){
            if(turnConsumption(&B,'B')) return 0;
        }
        if(turn=='c'){
            if(turnConsumption(&C,'C')) return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int D[50];
int main(){
  int i;
  int res = 0;
  int s;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(D[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    int Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = D[0];
      for(KL2GvlyY=(1);KL2GvlyY<(N);KL2GvlyY++){
        Q5VJL1cS += D[KL2GvlyY];
      }
    }
    s =Q5VJL1cS;
  }
  for(i=(0);i<(N);i++){
    res += D[i] * (s - D[i]);
  }
  wt_L(res / 2);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191027-1

// --- original code ---
// int N, D[50];
// {
//   int res = 0, s;
//   rd(N,D(N));
//   s = sum(D(N));
//   rep(i,N) res += D[i] * (s - D[i]);
//   wt(res / 2);
// }


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

constexpr int nax = 2e5, logg = 19, rozm = (1 << logg);

int n, m, tab[nax + 1], cnt[nax + 1], tree[rozm << 1], sum[rozm << 1];

const pair< int, int > seg(const int v)
{
    return {max(0, v - cnt[v]), v - 1};
}

void update(const int v)
{
    if (v >= rozm)
        sum[v] = (tree[v]? 0 : 1);
    else
        sum[v] = (tree[v]? 0 : sum[(v << 1)] + sum[(v << 1) + 1]);
}
            

void block(int l, int r, int c = 1)
{
    if (l > r) return;
    l += rozm, r += rozm;
    tree[l] += c;
    if (l != r) tree[r] += c;
    update(l); update(r);
    while ((l >> 1) != (r >> 1))
    {
        if ((l & 1) == 0)
        {
            tree[l + 1] += c;
            update(l + 1);
        }
        if ((r & 1) == 1)
        {
            tree[r - 1] += c;
            update(r - 1);
        }
        update(l), update(r);
        l >>= 1; r >>= 1;
    }

    update(l); update(r);
    
    for (l >>= 1; l; l >>= 1)
        update(l);
}

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

    cin >> n >> m;

    for (int i = 1; i <= n; ++i)
    {
        int v; cin >> v; tab[i] = v, ++cnt[v];
    }

    for (int i = rozm; i < 2 * rozm; ++i)
        sum[i] = 0, tree[i] = 1;

    for (int i = 0; i <= n - 1; ++i)
	sum[i + rozm] = 1, tree[i + rozm] = 0;

    for (int i = rozm - 1; i >= 1; --i)
        sum[i] = sum[(i << 1)] + sum[(i << 1) + 1];

    for (int i = 1; i <= n; ++i)
    {
        int lo = i - cnt[i], hi = i - 1;
        block(lo, hi);
    }

    for (int i = 1; i <= m; ++i)
    {
        int x, y; cin >> x >> y;

        block(seg(tab[x]).first, seg(tab[x]).second, -1);
        --cnt[tab[x]];
        block(seg(tab[x]).first, seg(tab[x]).second);

        block(seg(y).first, seg(y).second, -1);
        ++cnt[y];
        block(seg(y).first, seg(y).second);

        tab[x] = y;

        cout << sum[1] << '\n';
    }
}


Measured memory_bytes: 11264
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 200001;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	vector<int> h(200000);
	rep(i, N) h[i] = getint();

	rep(i, N) add(h[i], query(h[i]) + getint());

	printf("%lld", query(N));

	Would you please return 0;
}

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



signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    int left = 0,right = 0,lmin = 0,rmin = 0;

    rep(i,0,n){
        if(s[i]=='('){left++;}
        else{left--;}
        lmin = min(left,lmin);
    }
    rep(i,0,n){
        if(s[n-1-i]==')'){right++;}
        else{right--;}
        rmin = min(right,rmin);
    }
    string l="",r="";
    rep(i,0,max(0,-lmin)){
        l += '(';
    }
    rep(i,0,max(0,-rmin)){
        r+=')';
    }
    l +=s+r;
    cout<<l<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll s;
  std::cin>>s;

  std::cout<<"0 0 ";

  ll INF=1e9;
  ll mod=s%INF;

  ll y=(INF-mod)%INF;
  ll x=(s+y)/INF;

  std::cout<<x<<" "<<y<<" 1 1000000000\n";

  return 0;
}

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

int main(){
	int num=0;
	double w=0,h=0;
	
	while((scanf("%d,%lf,%lf",&num,&w,&h))!=EOF){
		if(w/(h*h)>=25){
			cout<<num<<endl;
		}
	}
}

Measured memory_bytes: 1232
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if(x%y!=0) System.out.println(x);
		else System.out.println(-1);
		return;
	}
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main(){
  int n, w;
  int in[100][2];
  int dp[101][10001];
  cin >> n >> w;
  for(int i = 0;i < n; i++)
    cin >> in[i][0] >> in[i][1];
  for(int i = 1;i <= n; i++){
    for(int j = 1;j <= w; j++){
      dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
      if(j>=in[i-1][1])
	dp[i][j]=max(dp[i][j], max(dp[i-1][j-in[i-1][1]]+in[i-1][0], dp[i][j-in[i-1][1]]+in[i-1][0]));
    }
  }
  cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 5076
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b;
        for(int i=0;i<7;i++){
            a=sc.nextInt();
            b=sc.nextInt();
            System.out.println(a-b);
        }
    }
}

Measured memory_bytes: 17192
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9 + 7
n,m = Is()
ns = [0] * (n+1)
ns[0] = 1
for i in range(m):
    ns[I()] = -1
for i in range(n):
    if ns[i] >= 0 and i+1 <= n and ns[i+1] >= 0:
        ns[i+1] = (ns[i+1] + ns[i]) % MOD
    if ns[i] >= 0 and i+2 <= n and ns[i+2] >= 0:
        ns[i+2] = (ns[i+2] + ns[i]) % MOD
print(ns[n])
    	

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,V,P;
    cin >> N >> M >> V >> P;
    vec<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.rbegin(),A.rend());

    auto ok = [&](int m){
        vec<ll> B = A;
        B[m] += M;
        if(B[m]<B[P-1]) return false;
        ll res = M*(V-1);
        for(int i=0;i<P-1;i++){
            res -= M;
        }
        for(int i=N-1;i>m;i--){
            res -= min(B[m]-B[i],M);
        }
        for(int i=m-1;i>=P-1;i--){
            if(B[i]>B[m]) return false;
            else res -= min(B[m]-B[i],M);
        }
        return res<=0;
    };

    int l = P-1,r = N;
    while(l+1<r){
        int m = (l+r)>>1;
        (ok(m)? l:r) = m;
    }
    cout << r << endl;
}

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

ll solve(int n, vector<ll> const & a) {
    ll cnt = 0;
    int r = 0, acc = 0;
    REP (l, n) {
        while (r < n and (acc & a[r]) == 0) {
            acc |= a[r];
            ++ r;
        }
        cnt += (r - l);
        acc &= ~ a[l];
    }
    return cnt;
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    REP (i, n) cin >> a[i];
    cout << solve(n, a) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;

using ll = long long;
const int N = 1e5+5;

int n;
ll solve(int x) {
    ll kotobar = n / x;
    return (ll)(x * (kotobar*(kotobar+1)/2));
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans += solve(i);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3656
puts gets.split.map(&:to_i).first.times.map{gets.chomp.chars.map{|c| c==?c ? 0 : -1}.each.with_object([]){|c,obj| obj<<(obj.empty? || obj.last==-1 ? c : (c==-1 ? obj.last+1 : c))}*" "}

Measured memory_bytes: 9012
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int t[n];
	for(int i=1;i<=n;i++)
		cin >> t[i-1];
	int m;
	cin >> m;
	int p[m];
	int x[m];
	for(int i=1;i<=m;i++)
		cin >> p[i-1] >> x[i-1];
	
	int ans = 0;
	for(int i=1;i<=n;i++)
		ans += t[i-1];
	
	for(int i=1;i<=m;i++)
	{
		int tmpans=ans-t[p[i-1]-1]+x[i-1];
		cout << tmpans << endl;
	}
}


Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
h,w,k=gsmi
c=h.times.map{gs}
(2**h).times do |i|
  rows=[]
  h.times do |ii|
    rows<<c[ii] if i[ii]==1
  end

  (2**w).times do |j|
    cnt=0
    col_i=[]
    w.times do |jj|
      col_i<<jj if j[jj]==1
    end
    rows.each do |row|
      col_i.each do |jj|
        cnt+=1 if row[jj]=='#'
      end
    end
    sum+=1 if cnt==k
  end
end
puts sum

Measured memory_bytes: 14340
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll N, M;
	priority_queue<ll> q;

	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		ll A;
		cin >> A;
		q.push(A);
	}

	for (int i = 0; i < M; i++) {
		ll a = q.top();
		a /= 2;
		q.pop();
		q.push(a);
	}
	ll ans = 0;
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int pop();
void push(int x);


int top;
int int_array[110];

int main(){

  char char_array[100];
  int a,b;
  int top;
  while(scanf("%s",char_array)!=EOF){

   
    if(char_array[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
      
    }
    

    else if(char_array[0]=='-'){

      b=pop();
      a=pop();
      push(a-b);
    }

    else if(char_array[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }

    else{push(atoi(char_array));
    }
  }
  
  printf("%d\n",pop());

  
  
  return 0;
}




int pop(){
  top--;
  return int_array[top+1];

}




void push(int x){
  int_array[++top]=x;
}




Measured memory_bytes: 2076
//---->JUST FOCUS ON YOUR GOAL
//-->BY UNBEATABLE BALORIA
//-->NEVER GIVE UP EVERYTHING IS POSSIBLE
//---------------------------------------------------------------------------------------------------//
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define pi 3.14159265358979323846
using namespace std;
//---------------------------------------------------------------------------------------------------//
typedef long long ll;
const unsigned int M = 1000000007;
//---------------------------------------------------------------------------------------------------//
bool isPrime(int n)
{
  for(int i=2;i*i<=n;i++)
    if(n%i==0) return false;
  return true;
}
int main(){
  ios::sync_with_stdio(false); 
  cin.tie(0);
  cout.tie(0);
     string s,t;
     cin>>s>>t;
     cin>>s>>t;
     int count=0;
     for(int i=0;i<s.size();i++)
     {
        if(s[i]!=t[i])
        {
          count++;
        }
     }
     cout<<count<<endl;
}

Measured memory_bytes: 3788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
count = 0
for X in range(0, K+1):
	for Y in range(0, K+1):
		Z = S - X - Y
		if 0 <= Z <= K:
			count += 1
print(count)

Measured memory_bytes: 3896
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  unordered_map<ll, bool> map;

  for (auto i = 0; i < N; i++) {
    ll x;
    cin >> x;
    if (map.find(x) == map.end()) map[x] = false;
    map[x] ^= true;
  }

  ll res = 0;
  for (auto x : map) {
    if (x.second) res++;
  }


  cout << res << endl;

  return 0;
}


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

int main() {
  char C;
  cin >> C;
 
  if ( C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u' ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int v[1001],w[1001],va[101][10001];
int main(void)
{
	int N,W,i,j,max;

	scanf("%d %d",&N,&W);
	for(i=0;i<N;i++) scanf("%d %d",&v[i],&w[i]);
	for(i=0;i<=N;i++){
		for(j=0;j<=W;j++){
			va[i][j]=-1;
		}
	}
	va[0][0]=0;
	for(i=0;i<N;i++){
		for(j=0;j<=W;j++){
			if(va[i][j]!=-1){
				if(va[i+1][j+w[i]]<va[i][j]+v[i] && j+w[i]<=W){
					va[i+1][j+w[i]]=va[i][j]+v[i];
				}
				if(va[i+1][j]<va[i][j]){
					va[i+1][j]=va[i][j];
				}
			}
		}
	}
	max=-1;
	for(i=0;i<=W;i++){
		if(max<va[N][i]) max=va[N][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 4972
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main(void){
  int N;
  cin>>N;
  int h[N];
  for(int i=0;i<N;i++){
      cin>>h[i];
  }
  int m=0;
  for(int i=0;i<N;i++){
    m=max(m,h[i]);  
  }
  int count=0;
  for(int i=0;i<m;i++){
      bool check=false;
      for(int j=0;j<N;j++){
        if(h[j]!=0&&!check)  {check=true;}
        else if(h[j]==0&&check){check=false; count++;}
        if(h[j]!=0){h[j]--;}
      }
      if(check){count++;}
  }
  cout<<count;
  return 0;
}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MOD = 998244353;

int modpow(int b, int e) {
    int res = 1;
    for (int p = 1; p <= e; p <<= 1) {
        if (p & e) {
            res = 1LL * res * b % MOD;
        }
        b = 1LL * b * b % MOD;
    }

    return res;
}

inline int inv(int x) {
    return modpow(x, MOD - 2);
}

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

    int n;
    cin >> n;

    int ans = modpow(3, n);
    int cur = 0;
    int term = 1;
    int p = 2;
    // n choose k * 2^k for k in range()
    for (int k = n; k > n / 2; --k) {
        cur += 1LL * term * p % MOD;
        if (cur >= MOD)
            cur -= MOD;
        // going from n!/k!(n-k)! to n!/(k-1)!(n-k+1)!
        // multiply by k/(n-k+1)
        term = 1LL * term * inv(n - k + 1) % MOD;
        term = 1LL * term * k % MOD;
        p += p;
        if (p >= MOD)
            p -= MOD;
    }

    int res = ans - cur;
    if (res < 0) res += MOD;
    cout << res << '\n';
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Matrix;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}

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

  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.length()) {
    mp[s[i]]++;
  }
  for(auto m: mp) {
    if (m.second != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(){
  int r, d, x;
  cin >> r >> d >> x;

  for(int i = 0; i < 10; i++){
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

map<ll,ll> make(ll *vl, ll *wl, int size, ll weight){
    map<ll,ll> mmap = {{0,0}};
    map<ll,ll> keep = {{0,0}};
    mmap.clear();
    mmap[0]=0;
    REP(i,size){
        keep = mmap;
        for(auto j : keep){
            if(j.first + wl[i] > weight)continue;
            else if(mmap.find(j.first + wl[i]) != mmap.end()){
                mmap[j.first + wl[i]] = max(mmap[j.first + wl[i]], j.second + vl[i]);
            }
            else{
                mmap[j.first + wl[i]] = j.second + vl[i];
            }
        }
        
    }
    ll maxv = 0;
    map<ll,ll> ansmap = {};
    for(auto i : mmap){
        maxv = max(maxv, i.second);
        ansmap[i.first] = maxv;
    }
    return ansmap;
}

int main(){
    ll n,weight;
    ll v[45]={};
    ll w[45]={};
    cin>>n>>weight;
    REP(i,n)cin>>v[i]>>w[i];
    ll anum = n/2;
    ll bnum = n-n/2;
    ll v1[25]={}; ll v2[25]={};
    ll w1[25]={}; ll w2[25]={};
    REP(i,anum){
        v1[i] = v[i];
        w1[i] = w[i];
    }
    for(int i=anum; i<n; i++){
        v2[i-anum] = v[i];
        w2[i-anum] = w[i];
    }
    map<ll,ll> map1 = make(v1, w1, anum, weight);
    map<ll,ll> map2 = make(v2, w2, bnum, weight);

    ll maxval = 0;
    auto iter2 = map2.rbegin();

    for(auto i=map1.begin(); i!=map1.end(); ++i){
        ll w11 = i->first;
        ll v11 = i->second;
        while(iter2->first + w11 > weight){
            iter2++;
        }
        ll sum = v11 + iter2->second;
        if(maxval < sum) maxval = sum;
    }
    cout<<maxval<<endl;
}


Measured memory_bytes: 232368
n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_i)
hs = gets.chomp.split(" ").map(&:to_i)
ts = []
hs.each do |h, index|
  ts << (a - (t - h * 0.006)).abs
end
puts ts.index(ts.min) + 1

Measured memory_bytes: 3836
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
H = sorted(iil(),reverse=True)[k::]
print(sum(H))


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

void rotate(int& h,int& w,vs& grid)
{
	vs tmp(w,string(h,' '));
	rep(i,h) rep(j,w) tmp[j][i]=grid[i][j];
	swap(h,w);
	rep(i,h) reverse(all(tmp[i]));
	swap(grid,tmp);
}

int solve_two_line(const string& a,const string& b)
{
	int n=a.size();
	vvi cost(n+1,vi(n+1));
	per(i,n) per(j,n)
		cost[i][j]=cost[i+1][j+1]+(a[i]==b[j]);
	vvi dp(n+1,vi(n+1,INF)); dp[0][0]=0;
	rep(i,n) rep(j,n){
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cost[i][j]);
		dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cost[i][j]);
	}
	rep(i,n){
		dp[i+1][n]=min(dp[i+1][n],dp[i][n]);
		dp[n][i+1]=min(dp[n][i+1],dp[n][i]);
	}
	return dp[n][n];
}

int solve(const vs& grid,const vi& costs,int i,int j,vvi& memo)
{
	if(memo[i][j]!=INF) return memo[i][j];
	if(j-i<=1) return memo[i][j]=0;
	int res=INF;
	repi(k,i+1,j){
		int tmp=solve(grid,costs,i,k,memo)+solve(grid,costs,k,j,memo)+costs[k-1];
		res=min(res,tmp);
	}
	return memo[i][j]=res;
}

int solve(const vs& grid,const vi& costs)
{
	int h=grid.size();
	vvi memo(h+1,vi(h+1,INF));
	return solve(grid,costs,0,h,memo);
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];

		// 扱いやすくするために回転させる．左へ向かって落ちる
		rotate(h,w,grid);

		vi costs(h-1);  // costs[i]: i,i+1の2行だけの場合のコスト
		rep(i,h-1) costs[i]=solve_two_line(grid[i],grid[i+1]);
		cout<<solve(grid,costs)<<endl;
	}
}


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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int x=a+b+c;
    int y=a*b*c;
    if(x==17 && y==175){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int bo[12560000];
int cal(int s)
{
	return s*(s+1)/2+1;
}
int main()
{
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int a,b,x;
		cin >> a >> b >> x;
		bo[cal(a)+b]=x+1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			bo[cal(i)+j]=max(max(bo[cal(i)+j],bo[cal(i-1)+j]-1),bo[cal(i-1)+j-1]-1);
			if(bo[cal(i)+j])ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50016
class Tree():
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append(e[1] - indexed)
            self.tree[e[1] - indexed].append(e[0] - indexed)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.order = []
        self.order.append(root)
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.order.append(adj)
                    stack.append(adj)

INF = 10**18

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

num = [None for _ in range(N)]

K = int(input())

for _ in range(K):
    v, p = map(int, input().split())
    num[v - 1] = p

tree = Tree(N, E)
tree.setroot(v - 1)

even = []
odd = []

for i in range(N):
    if num[i] is not None:
        if tree.depth[i] % 2 == 0:
            even.append(num[i] % 2)
        else:
            odd.append(num[i] % 2)

if not ((all(even) or not any(even)) and (all(odd) or not any(odd))):
    print('No')

else:
    I = [[-INF, INF] for _ in range(N)]
    for i in range(N):
        if num[i] is not None:
            I[i] = [num[i], num[i]]
    for node in tree.order[::-1]:
        lt, rt = I[node]
        for adj in tree.tree[node]:
            lt = max(lt, I[adj][0] - 1)
            rt = min(rt, I[adj][1] + 1)
        if lt > rt:
            print('No')
            break
        I[node] = [lt, rt]

    else:
        stack = [v - 1]
        visited = [0 for _ in range(N)]
        visited[v - 1] = 1
        while stack:
            node = stack.pop()
            for adj in tree.tree[node]:
                if visited[adj]:
                    continue
                visited[adj] = 1
                if I[adj][0] <= num[node] - 1 <= I[adj][1]:
                    num[adj] = num[node] - 1
                elif I[adj][0] <= num[node] + 1 <= I[adj][1]:
                    num[adj] = num[node] + 1
                else:
                    print('No')
                    break
                stack.append(adj)
            else:
                continue
            break
        else:
            print('Yes')
            print('\n'.join(map(str, num)))

Measured memory_bytes: 71656
from collections import Counter
N, K = map(int, input().split())
A = input().split()
A_dict = sorted(Counter(A).items(), key=lambda x: x[1])
must_dec = len(A_dict) - K
ans = 0
for i in range(must_dec):
    ans += A_dict[i][1]
print(ans)


Measured memory_bytes: 44056
// in the name of GOD
#include <bits/stdc++.h>
#define  S second
#define  F first
#define pb push_back
#define sz(cp) 1LL*cp.size()
#define tm are_you_now_tm_is_define_?
#define ta(c) c-'a'+1 
//#define int long long
using namespace std;
typedef long long ll ;
typedef long double ld ;
typedef pair < ll , ll > pii ;
const int maxn = 2e3 + 10 ;
int n , vj[maxn] , Ans , sub[maxn] , t[maxn] , dp[maxn] ;
vector<int>v[maxn] ;
string s ;
void dfs(int i , int j){
	sub[i] = 0 ;
	t[i] = vj[i] ;
	for(auto A : v[i])
	if(j-A)
	dfs(A,i) , t[i] += t[A] , sub[i] += sub[A] + t[A] ;
}
void get_dp(int i, int j){
	dp[i] = 0 ;
	int h1 , h2 , h3 ;
	h1 = h2 = 0 ;
	h3 = -1 ;
	for(int y = 0 ; y < sz(v[i]) ; y++){
		if(v[i][y]==j)
		continue ;
		int z = sub[v[i][y]] + t[v[i][y]] ;
		h1 += z ;
		if(z > h2)
		h2 = z , h3 = y ;
	} 
	if(h3 == -1)
	return ;
	get_dp(v[i][h3],i) ;
	if(h2 - dp[v[i][h3]] <= h1 - h2 )
	dp[i] = sub[i] - (sub[i]&1) ;
	else
	dp[i] = (h1-h2)*2 + dp[v[i][h3]] ;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> s ;
	Ans = 1e9 ;
	for(int y = 0 ; y < n ; y++)
	vj[y+1] = s[y] - '0' ;
	for(int y = 1 ; y < n ; y++){
		int i , j ;
		cin >> i >> j ;
		v[i].pb(j) ;
		v[j].pb(i) ;
	}
	for(int y = 1 ; y <= n ; y++){
		dfs(y,0) ;
		get_dp(y,0) ;
		if(dp[y] == sub[y])
		Ans = min(Ans,sub[y]);
	}
	if(Ans >= 1e9)
	Ans = -2 ;
	cout << Ans/2 ;
	return 0 ;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();++i)
    {
    	sum=sum+(s[i]-'0');
    	sum=sum%9;
        //	cout<<sum<<" ";
	}
	if(sum==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
    return 0;
}


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

long long N, K;
vector<long long> sumV(100001);

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

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A * B, C * D);
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
int arr[505], ans[300005], sz[505];
int main()
{
	// freopen("AGC008-D.in", "r", stdin);
	int n;
	scanf("%d", &n);
	std::for_each(arr, arr + n, [&] (int &x) { scanf("%d", &x); });
	for (int i = 1; i <= n * n; i++)
	{
		ans[i] = -1;
		for (int j = 0; j < n && -1 == ans[i]; j++)
		{
			if (arr[j] == i)
				ans[i] = j;
		}
		int mnp = -1;
		for (int j = 0; j < n && -1 == ans[i]; j++)
		{
			if (i < arr[j] && sz[j] < j && (mnp == -1 || arr[j] < arr[mnp]))
				mnp = j;
		}
		if (~mnp)
		{
			sz[mnp]++;
			ans[i] = mnp;
		}
		for (int j = 0; j < n && -1 == ans[i]; j++)
		{
			if (arr[j] < i && sz[j] < n - 1)
			{
				if (sz[j] < j)
				{
					puts("No");
					return 0;
				}
				ans[i] = j;
				sz[j]++;
			}
		}
		if (-1 == ans[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for (int i = 1; i <= n * n; i++)
		printf("%d%c", ans[i] + 1, " \n"[i == n * n]);
	return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b; cin >> a >> b;
  if (a * b % 2 == 0) {
    outl("Even");
  } else {
    outl("Odd");
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	int N = s.size();
	
	int ans = N;
	for(int i = 0; i < s.size()-1; i++){
		if(s[i] != s[i+1]){
			ans = min(ans, max(i+1, N-i-1));
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(raw_input())
M = int(raw_input())
target = map(int, raw_input().split())
score = []
for i in range(0, N):
	score.append(0)
for i in range(0, M):
	guess = map(int, raw_input().split())
	wrongcount = 0
	for j in range(0, N):
		if guess[j] == target[i]:
			score[j] += 1
		else: wrongcount += 1
	score[target[i]-1] += wrongcount
for i in range(0, N):
	print score[i]


Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
ll calc(ll n) {
  ll num = 1;
  for (ll i = 1; i <= 2; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}
 
int main() {
  ll n;
  cin >> n;
 
  vector<ll> v(n);
  rep(i, n) {
    cin >> v[i];
  }
 
  map<ll, ll> mm;
 
  rep(i, n) {
    mm[v[i]]++;
  }
  ll as = 0;
  for (auto x : mm) {
    if (x.second >= 2) {
      as += calc(x.second);
      debug(as);
    }
  }
 
  rep(i, n) {
    ll aiu = mm[v[i]];
    if (aiu == 2) {
      cout << as - calc(2) << endl;
    } else {
      cout << as - calc(aiu) + calc(aiu - 1) << endl;
    }
  }
 
  return 0;
}

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

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

ll dp[51][51][2501];

int main()
{
  int n, a;
  cin >> n >> a;
  vi x(n);
  rep(i, n) cin >> x[i];

  dp[0][0][0] = 1;
  rep(i, n) rep(j, n) rep(k, 2501){
    dp[i+1][j][k] += dp[i][j][k];
    if(k + x[i] <= 2500){
      dp[i+1][j+1][k+x[i]] += dp[i][j][k]; 
    }
  }

  ll ans = 0;
  repi(i, 1, n+1) rep(k, 2501){
    if(a*i == k){
      ans += dp[n][i][k];
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 50048
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;
    int[] a;
    int[] b;
    int[] c;
    int[][] dp;
    
    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        b = new int[n];
        c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        dp = new int[n][3];
        int ans = dp();
        System.out.println(ans);
    }
    
    private int dp() {
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                dp[0][0] = a[i];
                dp[0][1] = b[i];
                dp[0][2] = c[i];
            } else {
                dp[i][0] = a[i] + Math.max(dp[i - 1][1], dp[i - 1][2]);
                dp[i][1] = b[i] + Math.max(dp[i - 1][0], dp[i - 1][2]);
                dp[i][2] = c[i] + Math.max(dp[i - 1][1], dp[i - 1][0]);
            }
        }
        return Math.max(dp[n-1][0],Math.max(dp[n-1][1],dp[n-1][2]));
    }

    
}

Measured memory_bytes: 95864
#include <bits/stdc++.h>
using namespace std;
int main() {	
	int t=1;
	//cin >> t;
	while (t--) {
	   
	    int n;
       cin>>n;
       vector<vector<int>>arr(n,vector<int>(3));
       long long temp;
       for(int i=0;i<n;i++)
       {
       	 for(int j=0;j<3;j++)
       	 {
       	 	cin>>temp;
       	 	arr[i][j]=temp;
			}
	   }
	   long long dp[100001][3];
	   for(int i=0;i<n;i++)
	   {
	   	dp[0][i]=arr[0][i];
	   }
	   int k;
	    temp=0;
	   for(int i=1;i<n;i++)
	   {
	   	for(int j=0;j<3;j++)
	   	{
	   		k=i-1;
	   		temp=0;
	   		for(int p=0;p<3;p++)
	   		{
	   			if(p!=j&&dp[k][p]>temp)
	   			    temp=dp[k][p];
			   }
			dp[i][j]=arr[i][j]+temp;
		}
	   }
	   long long ans=0;
	   for(int i=0;i<3;i++)
	   {
	   	  if(dp[n-1][i]>ans)
	   	   ans=dp[n-1][i];
	   }
	   cout<<ans<<endl;
      }
	} 
	
	
	

Measured memory_bytes: 11112