akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
buildings = list(map(int, input().split()))

ans = float('inf')
for i in range(2 ** n):
    res = 0
    cnt = 1
    prev_build = buildings[0]
    # 高くするビルをbitで管理
    for j in range(1, n):
        if (i >> j) & 1:
            cnt += 1
            if prev_build >= buildings[j]:
                res += prev_build - buildings[j] + 1
                prev_build += 1
            else:
                prev_build = buildings[j]
        else:
            if prev_build < buildings[j]:
                cnt += 1
                prev_build = buildings[j]

    if cnt >= k:
        ans = min(ans, res)

print(ans)


Measured memory_bytes: 9088
#include <iostream> // cout, endl, cin
#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
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) cin >> vec.at(i);
	ll ans = 1000;
	for (int i = 0; i < N-1; i++) {
		ll kabu = 0;
		if (vec.at(i) < vec.at(i + 1)) {
			kabu = ans / vec.at(i);
			ans = ans % vec.at(i);
		}
		ans += kabu * vec.at(i + 1);
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vi p(n), q(n);
    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        cin >> q[i];
    }

    bool f = true;
    rep(i, n){
        if(p[i] > q[i]){
            f = true;
            break;
        }else{
            f = false;
            break;
        }
    }


    bool f2 = false;
    int cnt = 0;
    if(f){
        do{
            rep(i, n){
                if(p[i] != q[i]){
                    f2 = false;
                    break;
                }else{
                    f2 = true;
                }
            }
            cnt++;
        } while(next_permutation(all(q)) && !f2);

    }else{
        do{
            rep(i, n){
                if(p[i] != q[i]){
                    f2 = false;
                    break;
                }else{
                    f2 = true;
                }
            }
            cnt++;
        } while(next_permutation(all(p)) && !f2);
   }

    cout << cnt-1 << endl;

    return 0;
}


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

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

    int n;cin>>n;
    vector<vector<pair<int,int>>> v(n);
    rep(i,n){
        int t;cin>>t;
        rep(j,t){
            int x,y;cin>>x>>y;x--;
            v[i].push_back(make_pair(x,y));
        }
    }
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool f=true;
        rep(i,n){
            if((bit>>i)&1){
                for(auto x:v[i]){
                    if(x.second){
                        int op=x.first;
                        if(!((bit>>op)&1)) f=false;
                    }else{
                        int op=x.first;
                        if( ((bit>>op)&1) ) f=false;
                    }
                }
            }
        }
        if(f) chmax(ans,__builtin_popcount(bit));
    }
    cout<<ans<<endl;
    return 0;
}


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

long long N, M, Q;
vector<long long> tree[100005];
long long v[100005];
long long d[100005];
long long c[100005];
long long ans[100005];


set<pair<long long, long long> > done;

void paint(long long node, long long dis, long long col){
	if(done.count(make_pair(node, dis)) != 0){
		return;
	}
	done.insert(make_pair(node, dis));
	if(ans[node] == 0){
		ans[node] = col;
	}
	if(dis == 0){
		return;
	}
	for(long long i = 0; i < tree[node].size(); i++){
		paint(tree[node][i], dis - 1, col);
	}
}


int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		long long a, b;
		cin >> a >> b;
		a--;b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
		//cin >> a[i] >> b[i];
	}
	cin >> Q;

	for(long long i = Q-1; i >= 0; i--){
		cin >> v[i] >> d[i] >> c[i];
	}

	for(long long i = 0; i < Q; i++){
		paint(v[i] - 1, d[i], c[i]);
	}

	for(long long i = 0; i < N; i++){
		cout << ans[i] << endl;
	}


}


Measured memory_bytes: 67316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N;
int A[212345];
ll sum[212345]; // 1-indexed

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	REP(i, N) sum[i + 1] = sum[i] + A[i];
	
	ll ans = INFL;
	
	int l = 1, r = 3;
	
	FOR(i, 2, N - 1) { // AB:[0,i), CD:[i,N)
		// A: [0, l)
		// B: [l, i)
		// C: [i, r)
		// D: [r, N)
		
		while (l + 1 < i && sum[l + 1] - sum[0] < sum[i] - sum[l + 1]) l++;
		while (r + 1 < N && sum[r + 1] - sum[i] < sum[N] - sum[r + 1]) r++;
		
		vector<pll> p[2];
		p[0].push_back(pll(sum[l] - sum[0], sum[i] - sum[l]));
		if (l + 1 < i) p[0].push_back(pll(sum[l + 1] - sum[0], sum[i] - sum[l + 1]));
		
		p[1].push_back(pll(sum[r] - sum[i], sum[N] - sum[r]));
		if (r + 1 < N) p[1].push_back(pll(sum[r + 1] - sum[i], sum[N] - sum[r + 1]));
		
		REP(j, p[0].size()) {
			if (p[0][j].fi > p[0][j].se) swap(p[0][j].fi, p[0][j].se);
			
			REP(k, p[1].size()) {
				if (p[1][k].fi > p[1][k].se) swap(p[1][k].fi, p[1][k].se);
				chmin(ans, max(p[0][j].se, p[1][k].se) - min(p[0][j].fi, p[1][k].fi));
			}
		}
	}
	
	cout << ans << endl;
}

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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	bool sama = 1;
	int l1 = s.length();
	for (int i = 0; i < l1; i++) {
		if (s[i] != t[i]) sama = 0;
	}
	if (sama) printf("Yes\n");
	else printf("No\n");
}

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

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

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

    if (r + x <= W && r + y <= H && r + x >= 0 && r + y >= 0 && x > 0 && y > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
//*/
using namespace std;
static const int _ = []() {
	ios::sync_with_stdio(false);
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	return 0;
}();
// I hate typing .first or .second
template<typename T, typename U>
struct par {
	T x;
	U y;
	par() :x(-1), y(-1) {}
	par(const T& x, const U& y) :x(x), y(y) {}
	bool operator<(const par& other) const {
		if (x == other.x) return y < other.y;
		return x < other.x;
	}
	bool operator==(const par& other) const {
		return x == other.x && y == other.y;
	}
	par operator-(const par& b) const {
		return { x - b.x, y - b.y };
	}
};
#define ll long long
#define ull unsigned long long
#define rep(i,a) for(ll i=0;i<(a);i++)
#define rp1(i,a) for(ll i=1;i<=(a);i++)
#define rng(i,a,b) for(ll i=(a);i<=(b);i++)
#define rev(i,a) for(ll i=(a)-1;i>=0;i--)
#define S size()
#define all(a) (a).begin(),(a).end()
#define any(i,a) for(auto& i:a)
#define pll par<ll,ll>
#define pii par<int,int>
#define X first
#define Y second
#define V vector
#define VL V<ll>
#define VVL V<VL>
#define VS V<string>
template<class T> inline vector<T> rv(ll n) { vector<T> v(n); rep(i, n) cin >> v[i]; return v; }
template<class T> inline void pv(const vector<T>& v) { rep(i, v.size()) cout << v[i] << " "; cout << endl; }
template<class T> inline void amax(T& a, const T& b) { if (a < b) a = b; }
template<class T> inline void amin(T& a, const T& b) { if (a > b) a = b; }
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
ll GCD(ll a, ll b) {
	while (b) {
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}

ll a[5007][5007];

int main(int argc, char** argv) {
	ll n, m, C;
	cin >> n >> m >> C;
	vector<ll> b(m); rep(i, m) cin >> b[i];
	//vector<vector<ll>> a(n, vector<ll>(m, 0));
	rep(i, n) rep(j, m) cin >> a[i][j];
	ll ans = 0;
	rep(i, n) {
		ll x = C;
		rep(j, m) {
			x += a[i][j] * b[j];
		}
		if (x > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  priority_queue<int64_t> q;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    q.push(a);
  }
  for (int64_t i = 0; i < M; ++i) {
    int64_t a = q.top();
    q.pop();
    a /= 2;
    q.push(a);
  }
  int64_t result = 0;
  while (q.size() > 0U) {
    const int64_t a = q.top();
    q.pop();
    result += a;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <map>
using namespace std;

int main(){
  int n;
  int l;
  for(;;){
    scanf("%d", &n);
    if(!n) { break; }
    map<char, char> dic;
    for(int i = 0; i < n; i++){
      char b[16], a[16];
      scanf("%s %s", b, a);
      dic[b[0]] = a[0];
    }
    scanf("%d", &l);
    for(int i = 0; i < l; i++) {
      char c[16];
      scanf("%s", c);
      char &p = dic[c[0]];
      if(p == 0)
	printf("%c", c[0]);
      else
	printf("%c", p);
    }
    printf("\n");
  }
}

Measured memory_bytes: 1000
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N;
vector<int> t, v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  t.resize(N + 1);
  t[0] = 0;
  for (int i = 1; i <= N; i++) {
    int ti;
    cin >> ti;
    t[i] = t[i - 1] + ti * 2;
  }
  v.resize(N + 1);
  for (int i = 0; i < N; i++) {
    int vi;
    cin >> vi;
    v[i] = vi * 2;
  }
  v[N] = 0;

  double ans = 0;
  int t_idx = 0;
  int speed = 0;
  for (int time = 0; time < t[N]; time++) {
    if (time >= t[t_idx + 1]) {
      t_idx++;
    }

    int next_speed = speed < v[t_idx] ? speed + 1 : speed;
    for (int i = t_idx + 1; i <= N; i++) {
      int ti = t[i];
      int vi = v[i];
      if (speed - (ti - time - 1) > vi) {
        next_speed = min(next_speed, speed - 1);
      } else if (speed - (ti - time - 1) == vi) {
        next_speed = min(next_speed, speed);
      } else {
        next_speed = min(next_speed, speed + 1);
      }
    }

    ans += 0.5 * (speed + next_speed);
    speed = next_speed;
  }

  cout << fixed << setprecision(15) << ans / 4.0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> s(n), t(n);
    for (int i = 0; i < n; i++) {
        s[i] = a[i];
        if (i - 2 >= 0) {
            s[i] += s[i - 2];
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        t[i] = a[i];
        if (i + 2 < n) {
            t[i] += t[i + 2];
        }
    }
    if (n % 2 == 0) {
        ll ans = max(s[n - 1], s[n - 2]);
        for (int i = 1; i < n - 2; i += 2) {
            ans = max(ans, s[i - 1] + t[i + 2]);
        }
        cout << ans << '\n';
        return 0;
    }
    ll ans = max({s[n - 3], s[n - 2], t[2]});
    for (int i = 1; i + 3 < n; i += 2) {
        ans = max(ans, s[i - 1] + t[i + 3]);
    }
    for (int i = 0; i + 3 < n; i++) {
        ans = max(ans, s[i] + t[i + 3]);
    }
    vector<vector<ll>> dp(3, vector<ll>(n, -1e16));
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            dp[0][i] = a[i] + (i ? dp[0][i - 2] : 0);
            if (i) {
                dp[2][i] = a[i] + dp[2][i - 2];
                if (i >= 3) dp[2][i] = max(dp[2][i], dp[1][i - 3] + a[i]);
            }
        } else if (i >= 3) {
            dp[1][i] = dp[1][i - 2] + a[i];
            dp[1][i] = max(dp[1][i], dp[0][i - 3] + a[i]);
        }
    }
    debug(dp[2][n - 1]);
    ans = max(ans, dp[2][n - 1]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 14284
import org.w3c.dom.ls.LSOutput;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String answer = "";
        for(int i = 0; i < s.length(); i++) {
            answer += "x";
        }
      System.out.println(answer);
    }
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n; cin >> n;
    vector<ll> s(n);
    rep(i,0,n) cin >> s[i];
     ll ans=0;
     int tmp=0;
     sort(all(s));
     ll ok = false;
     rep(i,0,n){
        ans += s[i];
        if(!ok && s[i]%10!=0){
            tmp=s[i];
            ok=true;
        }
     }
     if(ans%10==0) ans-=tmp;
     if(!ok) cout << "0" << endl;
     else cout << ans << endl;
     
}

Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
b_i = [0]*n
c_i = [0]*n
for i in range(n):
    b1 = bisect.bisect_left(a,b[i])
    if i==0:
        b_i[i]=b1
    else:
        b_i[i] = b_i[i-1]+b1
    c1 = bisect.bisect_left(b,c[i])
    c_i[i]= c1

ans = 0
for i in range(n):
    if c_i[i]<1:
        continue
    else:
        ans = ans + b_i[c_i[i]-1]
print(ans)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int k;
bool ban[10];

bool check(int x){
  while(x){
    int c = x%10;
    if(ban[c])
      return false;
    x /= 10;
  }
  return true;
}

int main(){
  scanf("%d%d",&n,&k);
  REP(i,k){
    int x;
    scanf("%d",&x);
    ban[x] = true;
  }
  FOR(x,n,1000000){
    if(check(x)){
      printf("%d\n",x);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string A;
    cin >> A;
    ll n = A.size();
    ll ans = 1;
    vector<ll> cnt(26);
    for (int i = 0; i < n; i++)
        cnt[A[i] - 'a']++;
    for (int i = 0; i < 25; i++) {
        for (int j = i + 1; j < 26; j++) {
            ans += cnt[i] * cnt[j];
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


li a[4];

int main(void)
{
	string s;
	cin >> s;
	rep(i, 4) {
		a[i] = s[i] - '0';
	}

	rep(i, 1 << 3) {
		bitset<5> bs(i);
		li now = a[0];
		rep(j, 3) {
			now += (bs[j] ? a[j + 1] : -a[j + 1]);
		}
		if (now == 7) {
			rep(j, 3) {
				cout << a[j] << (bs[j] ? "+" : "-");
			}
			cout << a[3] << "=7" << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class railroad
    {
        static void Main(string[] args)
        {
            Stack<int> cars = new Stack<int>();
            List<int> result = new List<int>();
            while(true)
            {
                string line = System.Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }
                int n = int.Parse(line);
                if(n==0)
                {
                    result.Add(cars.Pop());
                }
                else
                {
                    cars.Push(n);
                }
            }
            foreach(int x in result)
            {
                System.Console.WriteLine(x);
            }
        }
    }
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#define ll long long

#define sl(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define sf(n) scanf("%lf", &n)

#define PI 2*acos(0.0)
#define INF (1LL<<62)

#define pll pair<ll,ll>

#define pb push_back
#define fr first
#define sc second
#define srt(v) sort(v.begin(), v.end())
using namespace std;

char s[10];

map <string, ll> mp;

int main()
{
  //  freopen("input.txt", "r", stdin);

    ll n, i, j, k, x, y, z, cs = 0, ts, l, r;

    sl(ts);

    while(ts--)
    {
        ss(s);

        string str(s);

        mp[str]++;
    }

    printf("AC x %lld\n", mp["AC"]);
    printf("WA x %lld\n", mp["WA"]);
    printf("TLE x %lld\n", mp["TLE"]);
    printf("RE x %lld\n", mp["RE"]);

    return 0;
}


Measured memory_bytes: 3788
#include<cstdio>

int main() {
  //入力
  int a,b;
  std::scanf("%d%d",&a,&b);
  
  if(a < b) {
    std::printf("a < b");
  }
  else if(a > b) {
    std::printf("a > b");
  }
  else {
    std::printf("a == b");
  }
  std::printf("\n");
  
  return 0;
}


Measured memory_bytes: 2696
/* ITP1_7_D */;
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      String[] input = br.readLine().split(" ");
      int n = Integer.parseInt(input[0]);
      int m = Integer.parseInt(input[1]);
      int l = Integer.parseInt(input[2]);

      long[][] matrix_nm = new long[n][m];
      long[][] matrix_ml = new long[m][l];
      long[][] matrix_nl = new long[n][l];

      // input n*m
      for(int i = 0; i < n; i++){
        input = br.readLine().split(" ");
        for(int j = 0; j < m; j++){
          matrix_nm[i][j] = Integer.parseInt(input[j]);
        }
      }
      // input m*l
      for(int i = 0; i < m; i++){
        input = br.readLine().split(" ");
        for(int j = 0; j < l; j++){
          matrix_ml[i][j] = Integer.parseInt(input[j]);
        }
      }

      // calculation
      for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
          for(int k = 0; k < m; k++){
            matrix_nl[i][j] += matrix_nm[i][k] * matrix_ml[k][j];
          }
          sb.append(matrix_nl[i][j]).append(" ");
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append("\n");
      }
      System.out.print(sb);

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 33392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }
        if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]){
            ans++;
        }else{
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k;
  }else if(k <= a+b){
    cout << a;
  }else{
    cout << a -  (k-(a+b)) << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
const int SZ = 100005;
int a[SZ];
int main()
{
    //freopen("in.txt","r",stdin);
    const string no = "NO", yes = "YES";
    mint n,sm = 0;
    cin>>n;
    Rep(i,n)
    {
        scanf("%d",&a[i]);
        sm += a[i];
    }
    
    mint nn = ((n * (n + 1LL)) / 2);
    if(sm % nn)
    {
        cout << no <<endl;
        return 0;
    }
    //cout <<"holla" <<endl;
    mint smA = sm / nn;
    //cout << smA << endl;
    if(n == 1)
    {
        cout << yes << endl;
        return 0;
    }
    if(n == 2)
    {
        if(smA % 2 == Abs(a[0] - a[1]) % 2)
        {
            cout << yes <<endl;
            return 0;
        }
        cout << no << endl;
        return 0;
    }
    Rep(i,n)
    {
        mint cur = a[(i + 1)%n];
        mint prev = a[i];
        mint diff = cur - prev;
        //cout << diff << " " << smA<<endl;
        diff  = smA - diff;
        //cout << diff << endl;
        if(diff < 0 || diff % n)
        {
            cout << no << endl;
            return 0;
        }
    }
    cout << yes <<endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
h = list(map(int, input().split()))
ans = 0
p = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        p += 1
    else:
        ans = max(ans, p)
        p = 0
ans = max(ans, p)
print(ans)


Measured memory_bytes: 15020
#include<stdio.h>
#include<stdlib.h>
long long int a[200005], b[200005];
int asc(const void* x, const void* y)
{
	if (b[*(int*)x] > b[*(int*)y])return 1;
	if (b[*(int*)x] < b[*(int*)y])return -1;
	return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &a[i], &b[i]);
	int c[200005];
	for (i = 0; i < n; i++)
		c[i] = i;
	qsort(c, n, sizeof(int), asc);
	long long int now = 0;
	for (i = 0; i < n; i++)
	{
		now += a[c[i]];
		if (now > b[c[i]])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '1') {
            cout << 9;
        } else {
            cout << 1;
        }
    }
    cout << endl;
    return 0;
}

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


using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> yoko[h], tate[w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            char c; cin >> c;
            if (c == '#') {
                yoko[i].push_back(j);
                tate[j].push_back(i);
            }
        }
    }
    int lamp[h][w];
    for (int i=0; i<h; i++) {
        yoko[i].push_back(w);
        int now=-1;
        for (auto yij:yoko[i]) {
            for (int k=now+1; k<yij; k++) {
                lamp[i][k] = yij - now - 1;
            }
            now = yij;
            if (now < w) lamp[i][now] = 0;
        }
    }
    int best=0;
    for (int i=0; i<w; i++) {
        tate[i].push_back(h);
        int now=-1;
        for (auto tij:tate[i]) {
            for (int k=now+1; k<tij; k++)
                best = max(best, lamp[k][i] + tij - now - 1);
            now = tij;
        }
    }
    cout << best - 1 << '\n';
    return 0;
}



Measured memory_bytes: 50048
# N
N = int(input())
my_list = list(map(int, (input().split(maxsplit=N))))

sorted_list = sorted(my_list, reverse=True)

num = 0
for i in range(1, len(my_list)):
    num += sorted_list[i]

if sorted_list[0] < num:
    answer = 'Yes'
else:
    answer = 'No'

print(answer)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;//N軒の店でM本買いたい->最小でいくら必要か？
  cin >> N >> M;
  vector<pair<double, int>> A(N);
  int a,b;
  for(int i=0;i<N;i++){
    cin >> a >> b;//a円の栄養ドリンクを，b本まで買える
    A.at(i) = make_pair(a,b);
  }
  sort(A.begin(), A.end());

  
  /*for(int i=0;i<N;i++)
    cout << "(" << A.at(i).first << "," << A.at(i).second << ")" << endl;//*/

  double sum = 0;
  for(int i=0;i<N;i++){
    M-=A.at(i).second;
    sum+=A.at(i).second * A.at(i).first;
    if(M <= 0){
      sum+=M*A.at(i).first;
      break;
    }
  }
  cout << std::setprecision(20);
  cout << sum << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

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

    int cnt=0;
    rep(i,s.size()/2)
    {
        if(s[i]!=s[s.size()-1-i])cnt++;
    }
    cout<<cnt<<endl;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}


signed main(){
    int X;
    cin >> X;
    int money = 100, c = 0;
    while(money < X){
        money += money/100;
        c++;
    }
    cout << c << endl;
    return 0;
}


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

int main(){
  int N; scanf("%d", &N);

  int T = 0, X = 0, Y = 0;

  bool ans = true;

  for(; N--; ){
    int t, x, y; scanf("%d%d%d", &t, &x, &y);

    int dt = t - T;
    int dx = X > x ? X - x : x - X;
    int dy = Y > y ? Y - y : y - Y;

    if(dt < dx + dy || (dt - dx - dy) & 1){ ans = false; break; }

    T = t; X = x; Y = y;
  }

  puts(ans ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned LL
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector< PII >
#define VVI vector< VI >
#define PB push_back
#define F first
#define S second
const int INF=1e9;
const int MOD=1e9+7;
int n,m,k;
int main(){
    scanf("%d %d %d",&n,&m,&k);
    set<int> s;
    for(int i=0;i<=m;i++){
        int sum=i*n;
        for(int j=1;j<=n;j++){
            s.insert(sum);
            sum-=i;
            sum+=m-i;
        }
        s.insert(sum);
    }
    if(s.find(k)!=s.end())puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  if (n % 100 <= 12 && n % 100 > 0){
    if(n/100 <= 12 && n / 100 >0){
      cout << "AMBIGUOUS" << endl;
    }
    else cout << "YYMM" << endl;
  }
  else{
    if(n/100 <= 12 && n / 100>0){
      cout << "MMYY" << endl;
    }
    else cout << "NA" << endl;
  }
   return 0;
}

Measured memory_bytes: 3620
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
lcs = [[(0,0) for i in range(m+1)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,m+1):
    if dp[i-1][j]>=dp[i][j-1]:
      dp[i][j] = dp[i-1][j]
      lcs[i][j] = (i-1,j)
    else:
      dp[i][j] = dp[i][j-1]
      lcs[i][j] = (i,j-1)
    if s[i-1] == t[j-1] and dp[i-1][j-1]+1>=dp[i][j]:
      dp[i][j] = dp[i-1][j-1]+1
      lcs[i][j] = (i,j)
ans = []
x = dp[n][m]
a = n
b = m
while x:
  if dp[a][b] == dp[a-1][b-1]+1 and dp[a][b] > max(dp[a-1][b],dp[a][b-1]):
    ans.append(s[lcs[a][b][0]-1])
    a -= 1
    b -= 1
    x -= 1
  elif dp[a][b] == dp[a-1][b]:
    a -= 1
  else:
    b -= 1
ans = ans[::-1]
print(*ans,sep="")

Measured memory_bytes: 393352
//C

#include <bits/stdc++.h>

using namespace std;

char in[12];
string s;
map<string, int>mp;

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n; long long res = 0;
	for(int i = 1; i <= n; i++) {
		cin >> in;
		sort(in, in + 10);
		s = string(in);
		res += mp[s];
		mp[s]++;
	} cout << res << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>

class UnionFind {

public:
	using size_type = std::uint_fast32_t;

private:
	std::vector<std::pair<bool, size_type>> tree;

public:
	UnionFind(const size_type size) : tree(size, std::make_pair(1, 1)) {}
	size_type find(const size_type x) {
		assert(x < size());
		if (tree[x].first)
			return x;
		return tree[x].second = find(tree[x].second);
	}
	bool unite(size_type x, size_type y) {
		assert(x < size());
		assert(y < size());
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x].second < tree[y].second)
			std::swap(x, y);
		tree[x].second += tree[y].second;
		tree[y] = std::make_pair(0, x);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return tree[find(x)].second;
	}
	size_type size() const noexcept { return tree.size(); }
	bool empty() const noexcept { return tree.empty(); }
};

#include <cstddef>
#include <functional>
#include <utility>
#include <vector>

template <class GraphContainer, class UnionFindDataStructure>
std::vector<typename GraphContainer::size_type> TarjansOfflineLCA(
	const GraphContainer &graph, const typename GraphContainer::size_type root,
	const std::vector<std::pair<typename GraphContainer::size_type,
	typename GraphContainer::size_type>> &queries) {
	using size_type = typename GraphContainer::size_type;
	const size_type size_ = graph.size();
	UnionFindDataStructure uft(size_);
	std::vector<size_type> ret(queries.size(), size_), anc(size_);
	std::vector<std::vector<std::size_t>> qset(size_);

	for (std::size_t i = 0; i < queries.size(); ++i) {
		qset[queries[i].first].emplace_back(i);
		qset[queries[i].second].emplace_back(i);
	}

	std::function<void(const size_type, const size_type)> dfs =
		[&](const size_type v, const size_type prev) {
		anc[v] = v;
		for (const auto &e : graph[v]) {
			if (e.to != prev) {
				dfs(e.to, v);
				uft.unite(v, e.to);
				anc[uft.find(v)] = v;
			}
		}
		for (const auto e : qset[v])
			if (ret[e] == size_)
				ret[e] = v;
			else
				ret[e] = anc[uft.find(ret[e])];
	};
	dfs(root, size_);
	return ret;
}


#include <cstddef>
#include <vector>

struct edge {
	using cost_type = int;
	using size_type = std::size_t;

	std::size_t to;
	edge(size_type t):to(t){}
};

template <class Edge> using Graph = std::vector<std::vector<Edge>>;

#include<cstdio>
int main() {
	using uint = unsigned int;
	uint n;
	scanf("%u", &n);
	Graph<edge> g(n);
	for (uint i = 0;i < n;++i) {
		uint k, c;
		scanf("%u", &k);
		while (k--) {
			scanf("%u", &c);
			g[i].emplace_back(c);
		}
	}
	uint q;
	scanf("%u", &q);
	using S = typename Graph<edge>::size_type;
	std::vector<std::pair<S, S>> Q;
	Q.reserve(q);
	while (q--) {
		uint u, v;
		scanf("%u%u", &u, &v);
		Q.emplace_back(u, v);
	}
	const auto &&ans=TarjansOfflineLCA<Graph<edge>, UnionFind>(g, 0, Q);
	for (const auto e : ans)
		printf("%u\n", e);
	return 0;
}


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

int main() {
  int n, ma = -1, mi = 1001;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    ma = max(ma, a);
    mi = min(mi, a);
  }
  cout << ma - mi << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		int ans = 0;
		for (int i = 0; i < s.length(); i++)
			ans += s.charAt(i) - (char) '0';
		if (ans % 9 == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 40392
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
string ss[5];
int len[5];
bool com[4][4][8001];
bool fits(char aa,char bb){
	return ((aa=='?')||(bb=='?')||(aa==bb));
}
bool gen(int id1,int id2,int pos){
	if(pos>=len[id1])
		return true;
	for(int i=0;i<min(len[id1]-pos,len[id2]);i++){
		if(!fits(ss[id1][i+pos],ss[id2][i]))
			return false;
	}
	return true;
}
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>ss[1]>>ss[2]>>ss[3];
	for(int i=1;i<=3;i++){
		len[i]=ss[i].size();
	}
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			if(i==j)
				continue;
			for(int k=0;k<=8000;k++){
				com[i][j][k]=gen(i,j,k);
			}
		}
	}
	int res=1e9;
	int cand;
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			if(i==j)
				continue;
			for(int k=1;k<=3;k++){
				if(i==k)
					continue;
				if(j==k)
					continue;
				for(int p=0;p<=4000;p++){
					if(!com[i][j][p])
						continue;
					for(int q=0;q<=4000;q++){
						if(!com[j][k][q])
							continue;
						if(!com[i][k][p+q])
							continue;
						cand=len[i];
						cand=max(cand,len[j]+p);
						cand=max(cand,len[k]+p+q);
						res=min(res,cand);
					}
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n=read()
res=1
mod=10**18
a=list(reads())
if 0 in a:
  print("0")
  exit()
for i in range(n):   
    res*=a[i]
    #print(res)
    if res>mod:
        print("-1")
        exit()
print(res)

Measured memory_bytes: 21180
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct kouzou{
  char name[100];
  int t;
}K;
 
K Q[LEN];
int head,tail,n;
 
void enqueue(K x){
  Q[tail] = x;
  tail += 1;
  tail = tail % LEN;
}
 
K dequeue(){
  K x = Q[head];
  head += 1;
  head = head % LEN;
  return x;
}
 
int main(void){
  int min(int,int);
  int m = 0,a,i,q;
  K u;
  scanf("%d%d",&n,&q);
  for ( i = 1 ; i <= n ; i++ ){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;
  while ( head != tail ){
    u = dequeue();
    a = min(q,u.t);
    u.t -= a;
    m += a;
    if ( u.t > 0 ){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,m);
    }
  }
  return 0;
}
 
int min(int b, int c ){
  return b < c ? b:c;
}

Measured memory_bytes: 10756
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<n;i++) {
           String[] s=sc.next().split(":");
           double a=Double.parseDouble(s[0])*60;
           double b=Double.parseDouble(s[1])*11;
           double d=Math.min(Math.abs((a-b)/2),Math.abs((-a+b)/2));
           if(d>=180) d=360-d;
           System.out.println(0<=d&&d<30?"alert":90<=d&&d<=180?"safe":"warning");
        }
    }
}


Measured memory_bytes: 30216
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
#define print(x) cout << (x) << '\n'

void fastscan(int &number) {
    bool negative = false;
    int c;
    number = 0;
    c = getchar();
    if (c == '-') {
        negative = true;
        c = getchar();
    }
    for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
    if (negative) number *= -1;
}
     
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int N; fastscan(N);
    int A[N];
    for (int i = 0; i < N; ++i) fastscan(A[i]);
    sort(A, A + N, greater<int>());
     
    int point1 = -1; int point2 = -1;
    int len1, len2;
    for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]){
           point1 = i; len1 = A[i]; break;
        }
    }
    if (point1 < 0){
        print(0); return 0;
    }
    for (int i = point1 + 2; i < N - 1; ++i) {
        if (A[i] == A[i + 1]){
            point2 = i; len2 = A[i]; break;
        }
    }
    if (point2 < 0){
        print(0); return 0;
    }    
    int64 ans = 1LL * len1 * len2;
    print(ans);
     
    return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long H;
	scanf("%lld",&H);
	long long A;
	scanf("%lld",&A);

	cout << static_cast<ll>(ceil(static_cast<double>(H) / A)) << endl;

	return 0;
}


Measured memory_bytes: 256
function main(input) {
  //trimで文字列前後の空白を削除.
  input = input.trim().split(' ');
  //constキーワードでは、再代入できない変数の宣言とその変数が参照する値（初期値）を定義できます。
  //letキーワードでは、値の再代入が可能な変数を宣言できます。 letの使い方はconstとほとんど同じです。
  //varキーワードでは、値の再代入が可能な変数を宣言できます。 varの使い方はletとほとんど同じです。
  //今回はどれでもいける.
  var res = input[0] * input[1];
  //console.log()で出力.
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29472
#include <iostream>

int score_a, score_b;

int main(void)
{
    using namespace std;
    int n, data_a, data_b;

    while(1)
    {
        cin >> n;
        if(!n) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            cin >> data_a;
            cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        cout << score_a << " " << score_b << endl;
    }

    return 0;
}

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

int H, W, ans = 0;
vector<vector<char>> a(1002, vector<char>(1002, '#'));
vector<vector<int>> a_count(1002, vector<int>(1002, 0));
queue<pair<int, int>> q;

void push_q(int m, int n, int tmp_count)
{
  if (a_count[m][n] || a[m][n] == '#')
    return ;
  q.push(make_pair(m, n));
  a[m][n] = '#';
  a_count[m][n] = tmp_count + 1;
  ans = max(ans, a_count[m][n]);
}

int main()
{
  int m, n;
  pair<int, int> tmp;

  cin >> H >> W;
  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
    {
      cin >> a[i][j];
      if (a[i][j] == '#')
        q.push(make_pair(i, j));
    }
  }
  while (!q.empty())
  {
    tmp = q.front();
    q.pop();
    m = tmp.first;
    n = tmp.second;
    push_q(m + 1, n, a_count[m][n]);
    push_q(m - 1, n, a_count[m][n]);
    push_q(m, n + 1, a_count[m][n]);
    push_q(m, n - 1, a_count[m][n]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 13456
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int n,i;
    cin>>n;
    ll arr[n],ans=1e18,a,b,c,d,ps[n]={0};
    fr(i,0,n)
    cin>>arr[i];
    partial_sum(arr,arr+n,ps);
    fr(b,2,n)
    {
        ll beg=1,last=b-1,mid,himj=1e18;
        while(beg<=last)
        {
            mid=beg+last>>1;
            if(abs(ps[mid-1]-ps[b-1]+ps[mid-1])<himj)
            {
                himj=abs(ps[mid-1]-ps[b-1]+ps[mid-1]);
                a=mid;
            }
            if(ps[mid-1]<ps[b-1]-ps[mid-1])
                beg=mid+1;
            else
                last=mid-1;
        }
        beg=b+1,last=n-1,himj=1e18;
        while(beg<=last)
        {
            mid=beg+last>>1;
            if(abs(ps[n-1]-ps[mid-1]-ps[mid-1]+ps[b-1])<himj)
            {
                himj=abs(ps[n-1]-ps[mid-1]-ps[mid-1]+ps[b-1]);
                c=mid;
            }
            if(ps[mid-1]-ps[b-1]<ps[n-1]-ps[mid-1])
                beg=mid+1;
            else
                last=mid-1;
        }
        ll Arr[]={ps[a-1],ps[b-1]-ps[a-1],ps[n-1]-ps[c-1],ps[c-1]-ps[b-1]};
        sort(Arr,Arr+4);
        ans=min(ans,Arr[3]-Arr[0]);
    }
    cout<<ans;

    }
  return 0;
  }



Measured memory_bytes: 3328
n = int(input())
num_list = list(map(int, input().split()))
den_list = []
for num in num_list:
    if num % 2 == 0:
        if num % 3 != 0 and num % 5 != 0:
            den_list.append(num)
if len(den_list) == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060