akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    for(int i = 0;i < n;i++)
    {
        cin >> b[i];
    }
    for(int i = 0;i < n;i++)
    {
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    long long int ans = 0;
    for(int i = 0;i < n;i++)
    {
        long long int A = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        long long int C = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        ans += A * C;
    }
    cout << ans << "\n";
 
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  vector<vector<int>> dp(n + 1, vector<int>(h + 1, INF));
  dp[0][0] = 0;
  rep(i, n) {
    for (int j = 0; j <= h; ++j) {
      int nj = min(a[i] + j, h);
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
      dp[i + 1][nj] = min(dp[i + 1][nj], dp[i + 1][j] + b[i]);
    }
  }
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

ll fast(ll a, ll p){
    if(p == 0) return (ll)1;
    ll res = fast(a, p>>1);
    res = (res * res) % MOD;
    if(p&1) res = (res * a) % MOD;
    return res;
}

const int N = (int)1e6;

pll fact[N+5];
int start(){
    fact[0] = mp((ll)1, (ll)1);
    REP(i,1,N){
        fact[i].fi = (fact[i-1].fi * (ll)i) % MOD;
        fact[i].se = fast(fact[i].fi, MOD-2);
    }
    return 0;
}

ll nCk(int n, int k){
    ll num = fact[n].fi;
    ll denum = (fact[n-k].se * fact[k].se) % MOD;
    return (num * denum) % MOD;
}

int main(){
    start();
    //
    int n,m,k; scanf("%d %d %d", &n, &m, &k);
    //
    ll temp = 1, res = 0;
    REP(i,n,n+m+k){
        ll select_seat = nCk(i-1,i-n);
        ll combination = temp;
        ll random = fast(3, n+m+k - i);
        //
        ll ret = (select_seat * combination) % MOD;
        res += (ret * random) % MOD;
        // calc new temp
        temp = ((ll)2 * temp) % MOD;
        if(i-n > m-1){
            temp = (temp + MOD - nCk(i-n, m)) % MOD;
        }
        if(i-n > k-1){
            temp = (temp + MOD - nCk(i-n, k)) % MOD;
        }
    }
    // print
    printf("%lld\n", res % MOD);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
inline void nl(){std::cout<<std::endl;}
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <typename T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <typename T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <typename T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}
//------------------------main function-------------------------------
void Main(){
    ui n ,k , sum = 0;
    cin >> n >> k;
    priority_queue<ui> a;
    Rep(i, n){
        ui ff;
        cin >> ff;
        sum += ff;
        a.push(ff);
    }
    vector<ui> vec;
    for(ui i = 1; i*i <= sum ; i++)if(sum % i == 0){
        vec.push_back(i);
        vec.push_back(sum / i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    
    for(ui i: vec){
        priority_queue<ui> b;
        priority_queue<ui> a2 = a;
        ui sum2 = 0;
        while (!a2.empty()) {
            ui ff = a2.top() % i;
            sum2 += ff;
            b.push(ff);
            a2.pop();
        }
        ui times = sum2 / i ;
        ui sum3 = 0;
        //cout << "t " << times << endl;
        Rep(j, times){
            // cout << "bt " << b.top() << endl;
            sum3 += (i - b.top());
            b.pop();
        }
        //cout << "s3 " << sum3 << endl;
        if(sum3 <= k){
            cout << i << endl;
            return;
        }
    }
    
    
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H,W,M = map(int,input().split())
YX = [tuple(map(int,input().split())) for i in range(M)]
yxs = set(YX)

from collections import Counter
xc = Counter()
yc = Counter()
for y,x in YX:
    yc[y] += 1
    xc[x] += 1

ans = 0
for y,x in YX:
    ans = max(ans, yc[y] + xc[x] - 1)

xmc = xc.most_common()
ymc = yc.most_common()
xmx = xmc[0][1]
ymx = ymc[0][1]
for xk,xv in xmc:
    if xv < xmx: break
    for yk,yv in ymc:
        if yv < ymx: break
        if (yk,xk) in yxs: continue
        ans = max(ans, yv + xv)
        break
print(ans)

Measured memory_bytes: 200688
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;

  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << N * 2 << endl;

  return 0;
}


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

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

  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    if (d[a]) {
      d[a]--;
      continue;
    }

    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int n,r[N],c[N], dpos[2*N-1], dneg[2*N-1],A[N][N];

void initialize(){
  for(int i=0;i<N;i++){ r[i]=FREE; c[i]=FREE;}
  for(int i=0;i<2*N-1;i++){ dpos[i]=FREE; dneg[i]=FREE;}
}

void print(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i][j]){
	if(r[i]!=j) return;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(r[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  //printf("QTWRWY");
}
  
void putQueen(int i){
  int j;
  if(i==N){
    print();
    return;
  }
  for(j=0;j<N;j++){
    if(c[j] == NOT_FREE || dpos[i+j]== NOT_FREE
       || dneg[i-j+N-1]==NOT_FREE){
      continue;
    }
    r[i]=j;
    c[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putQueen(i+1);
    r[i]=c[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int r,c;
  initialize();
  

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      A[i][j]=0;
    }
  }
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    A[r][c]=1;
  }

  putQueen(0);
  
  return 0;
}

  



Measured memory_bytes: 2112
//参考https://atcoder.jp/contests/abc122/submissions/4700029
fun main(args: Array<String>) {
    //(T,A,G,C) = (0, 1, 2, 3)
    val mod = (1e9 + 7).toLong()
    val n = readLine()!!.toInt()

    //dp[i][3文字前][2文字前][1文字前]
    val dp = Array(n + 1) { Array(4) { Array(4) { LongArray(4) { 0L } } } }
    dp[0][0][0][0] = 1L
    for (i in 0 until n) for (a in 0..3) for (b in 0..3) for (c in 0..3) for (d in 0..3) {

        // 3文字NGパターン AGC, GAC, ACG
        if (isNg(b, c, d) || isNg(c, b, d) || isNg(b, d, c)) continue
        // 4文字NGパターン AXGC, AGXC
        if (isNg(a, c, d) || isNg(a, b, d)) continue

        // NGパターンがなければ遷移先に足す
        dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % mod
    }
    var sum = 0L
    for (a in 0..3) for (b in 0..3) for (c in 0..3) {
        sum = (sum + dp[n][a][b][c]) % mod
    }
    println(sum)
}

fun isNg(a: Int, b: Int, c: Int): Boolean {
    return (a == 1 && b == 2 && c == 3)
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string S, T;
    cin>> S >> T;
    int ans = 0;
    REP(i, 0, S.size()){
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll recur(ll i,vector<ll>&v)
{
   // if(i==v.size()) return INT_MAX;
    if(i==v.size()-1) return 0;
    ll m1=recur(i+1,v)+abs(v[i+1]-v[i]);
    ll m2=LLONG_MAX;
    if(i+2<v.size()) m2=recur(i+2,v)+abs(v[i+2]-v[i]);
    return min(m1,m2);
}
void solve()
{
   ll n; cin>>n;
   vector<ll>v(n);
   rep(i,n) cin>>v[i];
   ll dp[n];
   dp[0]=0;
   dp[1]=abs(v[0]-v[1]);
   for(int i=2;i<n;i++)
   {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
   }
   cout<<dp[n-1];
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 4768
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n + 2];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        a[n + 1] = 0;
        int sum = 0;
        for (int i = 1; i <= n + 1; i++) {
            sum += Math.abs(a[i] - a[i - 1]);
        }
        for (int i = 1; i <= n; i++) {
            if ((a[i] >= a[i - 1] && a[i] <= a[i + 1]) || (a[i] <= a[i - 1] && a[i] >= a[i + 1])) {
                System.out.println(sum);
            } else if (Math.abs(a[i] - a[i - 1]) < Math.abs(a[i] - a[i + 1])) {
                System.out.println(sum - 2 * Math.abs(a[i] - a[i - 1]));
            } else {
                System.out.println(sum - 2 * Math.abs(a[i] - a[i + 1]));
            }
        }
    }
}

Measured memory_bytes: 78380
def dividable(N,A):
    wareru = True
    for i in range(N):
        if A[i] % 2 != 0:
            wareru = False
            break
    return wareru

def divide(N,A):
    for i in range(N):
        A[i] = A[i] // 2
    return A


N = int(input())
A = [int(i) for i in input().split()]

times = 0

while dividable(N,A):
    divide(N,A)
    times += 1

print(times)


Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    rep(i,n){
        int p=i+1;
        int n=0;
        while(p*pow(2,n)<k){
            ++n;
        }
        ans+=pow(0.5,n);
    }
    cout<<fixed<<setprecision(9)<<ans/n<<endl;
}

        


Measured memory_bytes: 4088
<?php
fscanf(STDIN, "%d", $h);
$list[1]=1;
function attack($h){
  global $list;
  if (isset($list[$h])) return $list[$h];
  $list[$h] = attack(floor($h/2)) * 2;
  return $list[$h] + 1;
};
echo attack($h);

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    vector<ll> c(n), s(n), f(n);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n) {
        ll tm = 0;
        if (i == n-1) {
            cout << 0 << endl;
            continue;
        }
        for (int j = i; j < n-1; ++j) {
            if (j == i) {
                tm = s[i] + c[i];
            }
            else {
                if (tm < s[j]) {
                    tm += (s[j] - tm) + c[j];
                }
                else {
                    ll tmp = tm%f[j];
                    if (tmp == 0) tm += c[j];
                    else tm += (f[j] - tmp) + c[j];
                }
            }
        }
        cout << tm << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

char ltou(char c){
	c -= 'a';
	c += 'A';
	return c;
}

int main(void){
	int n,m,i;
	string a,b;
	bool flag = false;
	cin >> a >> b;
	n = a.l_ength();
	m = b.l_ength();
	if(n > m){
		cout << "GREATER" << endl;
		flag = true;
	}else if(n < m){
		cout << "LESS" << endl;
		flag = true;
	}else{
		for(i=0; i<n; ++i){
			if(a[i] > b[i]){
				cout << "GREATER" << endl;
				flag = true;
				break;
			}else if(a[i] < b[i]){
				cout << "LESS" << endl;
				flag = true;
				break;
			}
		}
	}
	if(!flag){
		cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int p[10],Q[10];
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>Q[i];
  vector<int> v(n);
  for(int i=0;i<=n;i++) v[i]=i+1;
  int a=0,b=0,count=1;
  do{
    bool flag=true;
    for(int i=0;i<n;i++){
      if(v[i]!=p[i]) flag=false;
    }
    if(flag) a=count;

    bool flag1=true;
    for(int i=0;i<n;i++){
      if(v[i]!=Q[i]) flag1=false;
    }
    if(flag1) b=count;
    count++;
  }while(next_permutation(v.begin(),v.end()));
  cout<<abs(a-b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

map<ll, ll> a;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll N,res=0;
    cin >> N;
    rep(i,0,N){
        ll temp;
        cin >> temp;
        a[temp]++;
    }
    for(auto x : a){
        if(x.first>x.second) res+=x.second;
        else if(x.second>x.first) res+=x.second-x.first;
    }
    COUT(res);
}



Measured memory_bytes: 6272
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_4-D: Search - Allocation

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
//#include <numeric>
using namespace std;

typedef unsigned int uint;

static pair<uint, uint> sum_max(const vector<uint>& ws) {
  auto ws_sum = 0u;
  auto max_w = 0u;
  for (auto w : ws) {
    ws_sum += w;
    max_w = max(max_w, w);
  }
  return make_pair(ws_sum, max_w);
}

static bool is_loaded(uint max_load, uint num, const vector<uint>& ws) {
  const auto last = ws.end();
  auto it = ws.begin();
  for (auto i = 0u; i < num; ++i) {
    auto capacity = max_load;
    while (it < last && *it <= capacity) {
      capacity -= *it++;
    }
    if (it == last) return true;
  }
  return false;
}

static uint min_load_capacity(uint num, const vector<uint>& ws) {
  const auto sum_max_ws = sum_max(ws);
  const auto ws_sum = sum_max_ws.first; // accumulate(ws.begin(), ws.end(), 0);
  const auto max_w = sum_max_ws.second; // *max_element(ws.begin(), ws.end());

  auto left = max(max_w, (ws_sum-1)/num+1);
  auto right = ws_sum;
  while (left < right) {
    const auto middle = (left+right)/2;
    if (is_loaded(middle, num, ws)) {
      right = middle;
    } else {
      left = middle+1;
    }
  }
  return right; // right == left;
}

int main(void) {
  uint n, k;
  cin >> n >> k;

  vector<uint> ws(n);
  for (auto i = 0u; i < n; ++i) {
    cin >> ws[i];
  }

  auto c = min_load_capacity(k, ws);
  cout << c << endl;

  return 0;
}
// end

Measured memory_bytes: 3124
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int n, c;
	cin >> n >> c;
	vector<vector<int>> d = vector<vector<int>>(c, vector<int>(c, 0));
	for (int i = 0; i < c; ++i) {
		for (int j = 0; j < c; ++j) {
			int dij;
			cin >> dij;
			d[i][j] = dij;
		}
	}
	vector<vector<int>> cmap = vector<vector<int>>(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int cij;
			cin >> cij;
			cij--;
			cmap[i][j] = cij;
		}
	}
	vector<vector<int>> result = vector<vector<int>>(3, vector<int>(c,0));
	for(int ct =0;ct<c;++ct){
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				int line = (i + j) % 3;
				int cc = cmap[i][j];
				if(cc!=ct)
					result[line][ct] += d[cc][ct];
			}
		}
	}
	int best = 500*500*1000+1;
	for (int call = 0; call < c*c*c; call++) {
		int c1 = call % c;
		int c2 = (call / c) % c;
		int c3 = (call / c / c) % c;
		if (c1 == c2 || c2 == c3 || c3 == c1) continue;
		best = min(best, result[0][c1] + result[1][c2] + result[2][c3]);
	}
	cout << best << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Handstand | diff Handstand.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Handstand.cpp && ./a.out

/*
 
 4/17/2019
 
 15:46-
 
 */

//const int MAX_N=1e6+1;
int N,K;
string S;

void solve() {
  vector<II> X;
  if(S[0]=='0') X.emplace_back(0,0);
  int l=-1;
  REP(i,N) {
    if(S[i]=='1'&&(i==0||S[i-1]=='0')) l=i;
    if(S[i]=='1'&&(i==N-1||S[i+1]=='0')) {
      assert(l!=-1);
      int r=i+1;
//      dump(l,r);
      X.emplace_back(l,r);
      l=-1;
    }
  }
  if(X.empty()||X.back().second!=N-1) X.emplace_back(N,N);
  int res=0;
  int M=SZ(X);
  REP(i,M) {
    int j=min(i+K,M-1);
    SMAX(res,X[j].second-X[i].first);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 1020
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int wide = sc.nextInt();

		char[][] masu = new char[height][wide];

		for (int i = 0; i < height ; i++) {
			String row = sc.next();
			for (int j = 0; j < wide ; j++) {
				masu[i][j] = row.charAt(j);
			}
		}

		ArrayList<Integer> deleteColumns = new ArrayList<>();
		ArrayList<Integer> deleteLines = new ArrayList<>();


		for (int i = 0; i < height ; i++) {
			boolean allWhileLine = true;
			for (int j = 0; j < wide ; j++) {
				if ("#".equals(String.valueOf(masu[i][j]))) {
					allWhileLine = false;
					continue;
				}

				boolean allWhileColumn = true;
				for (int k = 0; k < height ; k++) {
					if ("#".equals(String.valueOf(masu[k][j]))) {
						allWhileColumn = false;
						break;
					}
				}
				if (allWhileColumn) {
					deleteColumns.add(j);
				}

			}
			if (allWhileLine) {
				deleteLines.add(i);
			}
		}

		for (int i = 0; i < height ; i++) {
			if (deleteLines.contains(i)) {
				continue;
			}
			for (int j = 0; j < wide ; j++) {
				if (deleteColumns.contains(j)) {
					continue;
				}
				System.out.print(masu[i][j]);

			}
			System.out.println();
		}


	}
}


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


int main(){

    int a, b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a*b << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
program main
    implicit none
    integer(8) n, k 
    integer(8), allocatable, dimension(:) :: a,b
    integer(8) i,temp, rest, d
    read(*,*) n,k
    allocate(a(n))
    allocate(b(n))
    read(*,*) a

    do i = 1,n
        b(i) = 0
    end do

    temp = 1
    b(1) = 0
    rest = 0
    do i = 1, k
        temp = a(temp)
        if(b(temp) /= 0) then
            d = i - b(temp)
            rest = mod((k-i),d)
            exit
        else if (temp == 1) then
            d = i
            rest = mod((k-i),d)
            exit
        else
            b(temp) = i
        end if
    end do


    if (rest /= 0) then
        do i = 1, rest
            temp = a(temp)
        end do
    end if

    write(*,*) temp

end program

Measured memory_bytes: 6264
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<int> num(30);
	for (auto i = 0; i < H; ++i)
	{
		string a;
		cin >> a;
		for (auto j = 0; j < W; ++j)
		{
			++num[a[j] - 'a'];
		}
	}

	auto num1 = 0;
	auto num2 = 0;
	auto num4 = 0;
	if (H % 2 == 0)
	{
		if (W % 2 == 0)
		{
			num4 = H * W / 4;
		}
		else
		{
			num4 = (W - 1) * H / 4;
			num2 = H / 2;
		}
	}
	else
	{
		if (W % 2 == 0)
		{
			num4 = (H - 1) * W / 4;
			num2 = W / 2;
		}
		else
		{
			num4 = (W - 1) * (H - 1) / 4;
			num2 = (W - 1) / 2 + (H - 1) / 2;
			num1 = 1;
		}
	}

	for (auto i = 0; i < (int)num.size(); ++i)
	{
		auto temp = num[i] / 4;
		auto sub = min(temp, num4);
		num4 -= sub;
		num[i] -= sub * 4;
	}

	for (auto i = 0; i < (int)num.size(); ++i)
	{
		auto temp = num[i] / 2;
		auto sub = min(temp, num2);
		num2 -= sub;
		num[i] -= sub * 2;
	}

	auto remain = 0;
	for (auto i = 0; i < (int)num.size(); ++i)
	{
		remain += num[i];
	}

	if (num4 == 0 && num2 == 0 && num1 == remain)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

const int maxN = 55;
const int maxB = 18;
typedef long long ll;

int A[maxN], vis[maxN], as[maxB];
ll C[maxN][maxN], ans;
map<int, int> M;

void init(){
	int i, j;
	for(i = 0; i < maxN; ++i){
		C[i][0] = C[i][i] = 1;
		for(j = 1; j < i; ++j)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	for(i = 0; i < maxN; ++i){
		for(j = 2; j < maxN; ++j)
			C[i][j] += C[i][j - 1];
	}
}

int main (){
	int n, k, S, T, i, j, c = 0, b;
	scanf("%d%d%d%d", &n, &k, &S, &T);
	for(init(), i = 0; i < n; ++i) scanf("%d", A + i);
	for(i = 0; i < maxB; ++i){
		b = 1 << i;
		if(S & b){
			if(T & b) { for(j = 0; j < n; ++j) if(!(A[j] & b)) vis[j] = 1; }
			else { puts("0"); return 0; }
		}
		else{
			if(T & b) as[c++] = i;
			else { for(j = 0; j < n; ++j) if(A[j] & b) vis[j] = 1; }
		}
	}
	for(i = j = 0; i < n; ++i) if(!vis[i]) A[j++] = A[i]; n = j;
	for(b = 0; b < (1 << c); ++b){
		int sgn = 1, s = 0;
		for(i = 0; i < c; ++i) if(b & (1 << i)) s |= (1 << as[i]), sgn *= -1;
		for(M.clear(), i = 0; i < n; ++i) ++M[A[i] & s];
		for(auto it : M) ans += sgn * C[it.second][k];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3784
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    if(2 * x <= a * a * b){
        long double k = a * b * b / x / 2;
        printf("%.10Lf\n", atanl(k)*180.0/M_PI);
    }else{
        assert(2 * x > a * a * b);
        printf("%.10Lf\n", atanl((2 * b - 2 * x / a / a)/a)*180.0/M_PI);
    }
}


Measured memory_bytes: 256
H, W, D = map(int, input().split())
d, px, py = [0]*(H*W+1), [0]*(H*W+1), [0]*(H*W+1)

for i in range(H):
    a = list(map(int, input().split()))
    for j in range(W):
        px[a[j]] = i
        py[a[j]] = j

for i in range(D+1, H*W+1):
    d[i] = d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D])

# print(d)

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(d[r]-d[l])


Measured memory_bytes: 14300
#include<iostream>
#include<cmath>
#include<vector>
//#include<string>

using namespace std;

bool prime_judge(int x){
  if(x==2) return true;
  if(x<2||(x%2==0)) return false;
  int sqnum=(int)sqrt(x);
  for(int i=3;i<=sqnum;i+=2){
    if(x%i==0) return false;
  }
  return true;
}

int main(void){
  int size,num,total=0;
  cin>>size;

  for(int i=0;i<size;i++){
    cin>>num;
    if(prime_judge(num)) total++;
  }
  cout<<total<<endl;
  return 0;
}



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

int main() {

    int H, W;
    
    do {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1) {
                    cout << "#";
                }
                else {
                    if (j == 0 || j == W - 1) {
                        cout << "#";
                    }
                    else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    } while (1);
        
}


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

typedef long long int ll;
const int MAX = 105;
const int INF = 1000005;

int h,w;
int memo[MAX][MAX];
bool s[MAX][MAX];

int dfs(int r, int c){
  if(r >= h || c >= w) return INF;
  if(memo[r][c] != -1) return memo[r][c];
  if(r == h-1 && c == w-1) return memo[r][c] = (!s[r][c]);
  int x = dfs(r, c+1) + (!s[r][c] && s[r][c] != s[r][c+1]),
      y = dfs(r+1, c) + (!s[r][c] && s[r][c] != s[r+1][c]);
  return memo[r][c] = min(x, y);
}

int main(){
    cin>>h>>w;
    memset(memo,-1,sizeof memo);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char cc;
            cin>>cc;
            s[i][j] = (cc == '.');
        }
    }
    cout << dfs(0,0) << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
I = [[N + 1] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  I[a - 1].append(b - 1)
cut = 0
for i in range(N - 1):
  if min(I[i]) == i + 1:
    cut += 1
  else:
    I[i + 1].append(min(I[i]))
print(cut)

Measured memory_bytes: 22260
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

string s;

map<char,int> mp;

int32_t main(){
	cin>>s;
	int n = s.length();
	for(int i=0;i<n;i++){
		mp[s[i]]++;
	}
	char mex = 0;
	for(char c = 'a';c<='z';c++){
		if(!mp[c]){
			mex = c;
			break;
		}
	}
	if(!mex){
		mp.clear();
		string t = s;
		if(!next_permutation(all(s))){
			cout<<-1;
			return 0;
		}
		else {
			for(int i=0;i<s.length();i++){
				cout<<s[i];
				if(s[i]!=t[i]){
					return 0;
				}
			}
		}
	}
	cout<<s+mex;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  string s;

  cin >> s;

  string ss = s.substr(0,(s.size() - 1) / 2);
  string es = s.substr((s.size() + 3) / 2 - 1,s.size() - (s.size() + 3) / 2 + 1);
  
  vector<string> cs = {s, ss, es};
  REP(i,cs.size())reverse(cs[i].begin(), cs[i].end());

  if(s == cs[0] && ss == cs[1] && es == cs[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String one = sc.next();
        String two = sc.next();
        String three = sc.next();
        
        System.out.println(one.substring(0,1)+two.substring(1,2)+three.substring(2,3));
    }
}

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

int main() {
    int k, x;
    cin >> k >> x;

    if ( k == 1 ) {
        cout << x << endl;
    } else {
        int ans = x-k+1;
        for (int i = 0; i < (2*k-1); i++){
            cout << ans << " ";
            ans++;
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
function main() {
  input.forEach(function(line){
    if(line.trim() === '') return;
    var
    i;
    for(i = 1; i < 27; i++){
      line = line.split('').map(function(c){
        return c === ' ' || c === '.' ? c : c === 'z' ? 'a' : String.fromCharCode(c.charCodeAt(0) + 1);
      }).join('');
      if(line.indexOf('the')  !== -1 ||
         line.indexOf('this') !== -1 ||
         line.indexOf('that') !== -1){
           break;
       }
    }
    console.log(line);
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

typedef long long LL;
const int maxn=1e7+5, mod=998244353;
LL n, a, b, k, ans, jc[maxn], inv[maxn];
inline bool ok(int x){ return x>=0&&x<=n; }
int fpow(int a, int x){
    LL ans=1, base=a;
    for (; x; x>>=1, (base*=base)%=mod)
        if (x&1) (ans*=base)%=mod;
    return ans;
}
LL C(int n, int m){ return jc[n]*inv[n-m]%mod*inv[m]%mod; }
int main(){
    jc[0]=inv[0]=1;
    for (int i=1; i<maxn; ++i) jc[i]=jc[i-1]*i%mod;
    inv[maxn-1]=fpow(jc[maxn-1], mod-2);
    for (int i=maxn-2; i; --i) inv[i]=inv[i+1]*(i+1)%mod;
    scanf("%lld%lld%lld%lld", &n, &a, &b, &k); int y;
    if (!b){
        int x=k/a; if (x<=n) printf("%lld", n);
        else puts("0");
        return 0; }
    for (int x=0; x<=n; ++x){
        y=(k-a*x)/b;
        if (a*x+b*y!=k) continue;
        if (!ok(y)) continue;
        ans+=C(n, x)*C(n, y); ans%=mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 156416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int INF = 1e9+7;

int main(){
    ll h,ans=0; cin>>h;
    ll inc=1;

    while(h > 0){
        h /= 2;
        ans += inc;
        inc *= 2;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

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

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  if(s<t) puts("Yes");
  else puts("No");

  
	return 0;
}

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

int main() {

	int P = 0, W = 0, G = 0, Y = 0, N;
    cin >> N;
    string x;
    
  for (int i = 0; i < N; i++) {
    cin >> x;
    
    if (x == "P") {
      P += 1;
    }
    if (x == "W") {
      W += 1;
    }
    if (x == "G") {
      G += 1;
    }
    if (x == "Y") {
      Y += 1;
    }
  }
  if (P * W * G * Y == 0) {
      cout << "Three" << endl;
    }
  else {
    cout << "Four" << endl;
  }
}	

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int a[11],i,n,t,e,g,r;
	for(i=1;i<=10;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=9;i++){
	for(n=i+1;n<=10;n++){
		if(a[i]<a[n]){
			r=a[i];
			a[i]=a[n];
			a[n]=r;
		}}}
	printf("%d\n",a[1]);
	printf("%d\n",a[2]);
	printf("%d\n",a[3]);
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
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; }
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)


int main() {
	ll n;
	ll res = 0;
	static ll a[200001];
	static ll cnt[200001] = {0};
	scanf("%lld", &n);
	FOR(i, 1, n) {
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}
	ll opt_sum = 0;
	FOR(i, 1, n) {
		opt_sum += cnt[i] * (cnt[i] - 1) / 2;
	}
	FOR(k, 1, n) {
		res = opt_sum;
		ll num = a[k];
		res -= cnt[num] * (cnt[num] - 1) / 2;
		res += (cnt[num] - 1) * (cnt[num] - 2) / 2;
		printf("%lld\n", res);
	}
	return(0);
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int a[100000];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  ll s=0,l=0;
  rep(i,n-1){
    //if(a[i]==l) continue;
    if(a[i]==a[i+1]){
      s=l;
      l=a[i];
      i++;
    }
  }
  cout<<ll(s*l)<<endl;
  return 0;
}






Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <set>
#include <string>
#include <vector>

#include <cassert>
using namespace std;

const int MAX_A = 2e3;
const int MAX_N = 2e3;
const int MAX_S = MAX_A * MAX_N;

using TBitset = std::bitset<MAX_S + 1>;

int n;
vector<int> a;

void Solve() {
    TBitset cur;
    cur[0] = 1;
    for (int x : a) {
        cur |= (cur << x);
    }
    int sum = 0;
    for (int x : a) {
        sum += x;
    }
    if (sum % 2 == 0 && cur[sum / 2]) {
        cout << sum / 2 << endl;
        return;
    }
    int last = 0;
    for (int i = 1; i <= MAX_S; ++i) {
        if (cur[i] && i <= sum / 2) {
            last = i;
        }
    }
    for (int j = last + 1; j <= MAX_S; ++j) {
        if (cur[j]) {
            cout << j << endl;
            return;
        }
    }
    assert(false);
}

bool Read() {
    if (!(cin >> n)) {
        return false;
    }
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    return true;
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

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

    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    double whole = (double)W * (double)H / 2;
    int way = 0;
    if(2 * x == W && 2 * y == H) {
      way = 1;
    }

    System.out.println(whole + " " + way);
    
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int main(){
    string s;   cin >> s;
    map<char,int> a;
    rep(i,s.size()){
        a[s[i]]++;
    }

    for(auto mp : a){
        if(mp.second%2!=0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int dfs(vector<int> ar, vector<int> a, vector<int> b, vector<int> c, vector<int> d, int n, int m, int q) {
    if(ar.size() == n) { //末端なので、ここで条件判定する
        int sum=0;
        REP(i, q) {
            if(ar[b[i]-1] - ar[a[i]-1] == c[i]) sum += d[i];
        }
        return sum;
    }
    //末端でなければ展開して、最大値を返す
    int max_sum = 0;
    FOR(i, ar.back(), m)  {
        vector<int> br = ar;
        br.push_back(i);
        int sum = dfs(br, a, b, c, d, n, m, q);
        max_sum = max(max_sum, sum);
    }
    return max_sum;
}

int main(void){
    int n, m, q;
    //string s;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    
    //最初の1つ目
    int max_sum = 0;
    FOR(i, 1, m) {
        vector<int> ar;
        ar.push_back(i);
        int sum = dfs(ar, a, b, c, d, n, m, q);
        max_sum = max(max_sum, sum);
    }
    cout << max_sum << endl;
    return 0;
}

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

int main()
{
    string s,ans;
    while(getline(cin,s) )   
    {
        for(int i=0;i<s.length()-4;i++)
        {
            if(s[i]=='a')
            {
                if(s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e')
                {
                    s[i]='p';
                    s[i+1]='e';
                    s[i+2]='a';
                    s[i+3]='c';
                    s[i+4]='h';
                    continue;
                }
                continue;
            }
            if(s[i]=='p')
            {
                if(s[i+1]=='e'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='h')
                {
                    s[i]='a';
                    s[i+1]='p';
                    s[i+2]='p';
                    s[i+3]='l';
                    s[i+4]='e';
                    continue;
                }
                continue;
            }
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const ll INF = ll(1e18);
const int MOD = 1000000007;
// const int MOD = 998244353;

int n;
ll dp[500][500], sum[500];
bool fg[500][500];
int a[500];
ll dfs(int l, int r) {
   if (l == r) return 0;
   if (fg[l][r]) return dp[l][r];

   ll af = INF;
   rep(i, l, r) af = min(af, dfs(l, i) + dfs(i + 1, r));
   fg[l][r] = true;
   return dp[l][r] = af + sum[r + 1] - sum[l];
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   cin >> n;
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, n) sum[i + 1] = sum[i] + a[i];
   ll ans = dfs(0, n - 1);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n+1) ans += i;
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a <= b*2) {
		System.out.println(0);
	} else {
		System.out.println(a-b*2);
	}
	}
}


Measured memory_bytes: 21844
n = int(input())
s = input()
for ans in ('SS', 'SW', 'WS', 'WW'):
    for i in range(n - 1):
        if (s[i + 1] == 'o') ^ (ans[-1] == 'S'):
            if ans[-2] == 'S':
                ans += 'W'
            else:
                ans += 'S'
        else:
            ans += ans[-2]
    if ans[0] == ans[-1] and (((s[0] == 'o') ^ (ans[0] == 'S')) ^ (ans[1] == ans[-2])):
        print(ans[:-1])
        break
else:
    print(-1)


Measured memory_bytes: 212332
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        r: usize
    };

    let res = r * r;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2228
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main(void) {
    int n, m;
    cin >> n >> m;
    
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256