akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

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

    int trans[26][26];
    memset(trans, 0, sizeof(trans));
    rep(i, s.size()){
        trans[s[i]-'a'][t[i]-'a'] = 1;
    }

    rep(i, 26){
        int tmp1 = 0, tmp2 = 0;
        rep(j, 26) tmp1 += trans[i][j];
        rep(j, 26) tmp2 += trans[j][i];
        if(tmp1 > 1 || tmp2 > 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 776
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)

	for i := 1; i <= 3; i++ {
		if A != i && B != i {
			fmt.Println(i)
		}
	}
}


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

int main(void){
    int N, div, sum{0};
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i{0}; i<N; ++i){
        cin >> V[i];
    }
    for(int i{0}; i<N; ++i){
        cin >> C[i];
    }
    for(int i{0}; i<N; ++i){
        div = V[i] - C[i];
        if(div>0)
            sum += div;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector< vector<int> > edg;
vector<bool> usd;
void use(int x){
    usd[x] = true;
    for(int i=0;i<edg[x].size();i++){
        if(!usd[edg[x][i]])use(edg[x][i]);
    }
}
int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    edg.assign(n, vector<int>());
    usd.assign(n, false);
    for(int i=0;i<m;i++){
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        edg[x].push_back(y);
        edg[y].push_back(x);
    }
    for(int i=0;i<n;i++){
        if(!usd[i]){
            ans++;
            use(i);
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n, j, i;
  cin>>n;
  int a[n];
  int b[n];
  for(i = 0; i<n; i++)
  {
      cin>>a[i];
      b[a[i]-1] = i+1;
  }
  for(i = 0; i<n; i++)
  {
      cout<<b[i]<<" ";
  }

return 0;
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

const int inf = 1e15;
const int N = 301;
int n, m, l;

int32_t main() {
	boost;
	cin >> n >> m >> l;
	int g[n + 1][n + 1], ng[n + 1][n + 1];
	memset(g, 0x3f, sizeof g);
	memset(ng, 0 ,sizeof ng);
	for(int i = 1; i <= n; i++)
		g[i][i] = 0;

	for(int i = 0, u, v ,w; i < m; i++) {
		cin >> u >> v >> w;
		if(w > l)
			continue;
		g[u][v] = g[v][u] = w;
	}

	for(int k = 1; k <= n; k++) {
		for(int j = 1; j <= n; j++) {
			for(int i = 1; i <= n; i++ ) {
				g[i][j] = min(g[i][j] , g[i][k] + g[k][j]);
			}
		}
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++){
			if(g[i][j] <= l)
				ng[i][j] = 1;
			else
				ng[i][j] = inf;
		}
	}

	for(int k = 1; k <= n; k++) {
		for(int j = 1; j <= n; j++) {
			for(int i = 1; i <= n; i++ ) {
				ng[i][j] = min(ng[i][j] , ng[i][k] + ng[k][j]);
			}
		}
	}
	
	int q;
	cin >> q;
	while(q--) {
		int u, v;
		cin >> u >> v;
		int ans = ng[u][v];
		if(ans >= inf)
			ans = 0;
		cout << ans - 1 << endl;
	}
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

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

	int maxa=0;
	rep(i,n)chmax(maxa,a[i]);
	int sum=0;
	int cnt=0;
	sort(all(b));
	rep(i,n)if(maxa<b[n-i-1]){
		sum+=b[n-1-i];
		cnt++;
		if(sum>=h){
			cout<<cnt<<endl;
			return 0;
		}
	}
	// cout<<"sum="<<sum<<endl;
	h-=sum;
	cout<<cnt+(h+maxa-1)/maxa<<endl;

	return 0;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int all = accumulate(a.begin(), a.end(), 0);
    int c = 0;
    for (int j = 0; j < m; j++)
    {
        if (a[j] * (4 * m) >= all)
            c++;
        else
            break;
    }
    if (c == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val a = readLine()!!.split(" ").map { it.toInt() }
    val n = a[0].let { if (it == 0) 1 else it }
    val m = a[1].let { if (it == 0) 1 else it }

    println(n*(n-1)/2 + m*(m-1)/2)
}

Measured memory_bytes: 37908
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){
  int n;
  int h = 0;
  long long ans = 0;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  rep(i, n){
    h = max(h, a[i]);
    ans += h - a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3984
#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 whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n);
  rep(i, n) b[i] = a[i];
  sort(b.begin(), b.end());
  int x = b[n-1];
  int y = b[n-2];
  
  rep(i, n) {
    if (a[i]==x) cout << y << endl;
    else cout << x << endl;
  }
  
  return 0;
}

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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    if (a[0] > a[1]) {
        swap(a[0], a[1]);
    }
    if (a[1] > a[2]) {
        swap(a[1], a[2]);
    }
    if (a[0] > a[1]) {
        swap(a[0], a[1]);
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m;
string a,b;
map<int,char>mp;
inline int lcm(int x,int y){return x / __gcd(x,y) * y;}

signed main(signed argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    cin >> a >> b;
    int l = lcm(n,m);
    rep(i,0,n-1) mp[l/n*i] = a[i];
    int flg = 1;
    rep(i,0,m-1) if (mp[l/m*i]) flg &= mp[l/m*i] == b[i];
    if (flg) printf("%lld\n",l);
    else puts("-1");
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int inf = INT_MAX / 2;
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; }


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

    string S;
    cin >> S;

    int l[10];
    rep(i, 10) l[i] = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = i; j < S.size(); j++) {
            if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T') break;
            l[i]++;
        }
    }

    int ans = 0;
    rep(i, 10) if (ans < l[i]) ans = l[i];
    cout << ans << endl;
}

Measured memory_bytes: 3656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        x: usize,
    }
    let mut money = 100;
    let mut i = 1;
    loop {
        let inte = money as f64 * 0.01;
        money = money + inte as usize;
        if money >= x {
            println!("{}", i);
            break;
        }
        i = i + 1;
    }
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
int next(string s) {
    string max_s=s,min_s=s;
    sort(max_s.begin(),max_s.end(),greater<int>());
    sort(min_s.begin(),min_s.end());
    return stoi(max_s)-stoi(min_s);
}
int main() {
    int a,L;
    while(scanf("%d %d",&a,&L),a!=0||L!=0) {
        map<int,int> m;
        int idx=0;
        while(1) {
            m[a]=idx++;
            string s=to_string(a);
            s=string(L-s.size(),'0')+s;
            a=next(s);
            if(m.find(a)!=m.end()) {
                printf("%d %d %d\n",m[a],a,idx-m[a]);
                break;
            }
        }
    }
}

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

void dfs(int vertex,vector <vector <int>>& adj, vector <int>& colour, int present_colour, int& count, vector <int> &visited)
{
	if (present_colour != colour[vertex])
	{
		count++;
		present_colour = colour[vertex];
	}
	for (int i = 0; i < adj[vertex].size(); i++)
	{
		int child = adj[vertex][i];
		if (visited[child] == 0)
		{
			visited[child] = 1;
			dfs(child, adj, colour, present_colour, count, visited);
		}
	}
}

int main() {

	string s, t;
	cin >> s >> t;
	int ns = s.size();
	int ts = t.size();
	int min_moves = ts;

	for (int offset = 0; offset <= ns - ts; offset++)
	{
		int moves = ts;
		for (int i = 0; i < ts; i++)
		{
			if (t[i] == s[i + offset]) moves--;
		}
		if (moves < min_moves) min_moves = moves;
	}
	cout << min_moves;

	return 0;
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int A[200][200], D[200], X[200];
int 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));
    }
    return 0;
}



Measured memory_bytes: 3596
#include <stdio.h>

int main(void){

    int d,t,s;


    scanf("%d %d %d",&d,&t,&s);

    float x = d/s;
    float y = d%s*10;
    float z = y/s*0.1;

    if(z+x<=t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define inf 1000000000
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef  double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
typedef pair<ld , ld> pdd;
typedef vector<pdd> vdd;
typedef vector<ld> vd;
const int MOD = 1e9 + 7; //998244353;

int dp[1005][1005];
string grid[1005];
int main(){
    boost;
    int n , m ;
    cin >> n >>m ;
    memset(dp ,  0, sizeof dp);
    for(int i = 0;i<n;i++)cin >> grid[i];
    dp[0][0] = grid[0][0] == '.';
    for(int i = 0;i<n;i++)for(int j = 0;j<m;j++){
        if(i == 0 && j == 0)continue;
        if(i)dp[i][j] += dp[i-1][j];
        if(j)dp[i][j] += dp[i][j-1];
        if(grid[i][j] == '#')dp[i][j] = 0;
        dp[i][j] %= MOD;
    }
    cout << dp[n-1][m-1];
}


Measured memory_bytes: 8620
#include <iostream>
#include <cmath>
#define MAX_DIMENTION 100
#define DIMENSION_INFINIT -1
using namespace std;

double distance(int p, int vector1[], int vector2[], int dimension) {
  if(p == DIMENSION_INFINIT) {
    double max = vector1[0] - vector2[0];
    if (max < 0) {
      max = -max;
    }

    for(int i = 1; i < dimension; i++) {
      int each_distance = vector1[i] - vector2[i];
      if(each_distance < 0) {
        each_distance = -each_distance;
      }

      if(max < each_distance) {
        max = each_distance;
      }
    }

    return max;
  }


  double sum = 0;
  for(int i = 0; i < dimension; i++) {
  int elem_distance = vector1[i] - vector2[i];
  if (elem_distance < 0) {
    elem_distance = -elem_distance;
  }

    sum += pow(elem_distance , p);
  }

  return pow(sum, 1 / (double)p);
}

int main() {
  int dimension;
  int vector1[MAX_DIMENTION], vector2[MAX_DIMENTION];

  cin >> dimension;
  for(int i = 0; i < dimension; i++) {
    cin >> vector1[i];
  }
    for(int i = 0; i < dimension; i++) {
    cin >> vector2[i];
  }

  double p1_distance = distance(1, vector1, vector2, dimension);
  double p2_distance = distance(2, vector1, vector2, dimension);
  double p3_distance = distance(3, vector1, vector2, dimension);
  double p4_distance = distance(DIMENSION_INFINIT, vector1, vector2, dimension);

  printf("%f\n", p1_distance);
  printf("%f\n", p2_distance);
  printf("%f\n", p3_distance);
  printf("%f\n", p4_distance);
}



Measured memory_bytes: 3352
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        a[i] = b[i] = x;
    }
    sort(all(b));
    reverse(all(b));
    for(int i = 0;i<n;i++){
        if(a[i] == b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
using namespace std;
const int N=1e5+5,MOD=1e9+7;
int ans,n,x;
int fac[N],rev[N],f[N],s[N];
int pw(int x,int y){
	int s=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)s=1ll*s*x%MOD;
	return s;
}
int main(){
	scanf("%d",&n);
	fac[0]=1;rep(i,n)fac[i]=1ll*fac[i-1]*i%MOD;
	rev[n]=pw(fac[n],MOD-2);
	for(int i=n-1;~i;--i)rev[i]=1ll*rev[i+1]*(i+1)%MOD;
	rep(i,n)f[i]=(1ll*f[i-1]*i+fac[i-1])%MOD;
	rep(i,n)s[i]=(1ll*f[i]*rev[i]+1ll*f[n-i+1]*rev[n-i+1]+MOD-1)%MOD*fac[n]%MOD;
	rep(i,n)scanf("%d",&x),ans=(ans+1ll*x*s[i])%MOD;
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int H, W, h, w;
  while(cin >> H >> W >> h >> w){
    if(H % h == 0 and W % w == 0){
      cout << "No" << endl;
    }else{
      auto ans = vector<vector<int>>(H, vector<int>(W));

      if(W % w != 0){
        vector<int> s(W+1);

        FOR(i,1,w) s[i] = 100000;

        FORE(i,w,W){
          if(i-w >= 0) s[i] = s[i-w] - w;
        }

        vector<int> a(W);
        REP(i,W) a[i] = s[i+1] - s[i];

        REP(i,H) ans[i] = a;
      }else{
        vector<int> s(H+1);

        FOR(i,1,h) s[i] = 100000;

        FORE(i,h,H){
          if(i-h >= 0) s[i] = s[i-h] - h;
        }

        vector<int> a(H);
        REP(i,H) a[i] = s[i+1] - s[i];

        REP(i,H) REP(j,W) ans[i][j] = a[i];
      }

      cout << "Yes" << endl;
      REP(i,H){
        join(cout, ALL(ans[i]));
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3072
// In The Name Of God
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 1e2;
int t[maxn];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		ans += (min(t[i] - 0, k - t[i]) * 2);
	}
	return cout << ans << endl, 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};


int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll P[5555], C[5555];
  for(i=0; i<N; i++) {
    cin >> P[i];
    P[i]--;
  }
  for(i=0; i<N; i++) cin >> C[i];
  
  unionFind uf=unionFind(N);
  map<ll, set<ll>> mp;
  
  for(i=0; i<N; i++) uf.unite(i, P[i]);
  
  for(i=0; i<N; i++) {
    ll u=uf.find(i);
    if(mp[u].empty()) mp[u]=set<ll>();
    mp[u].insert(i);
  }
  
  ll ans=-INF;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    set<ll> st=it->sc;
    ll n=st.size();
    ll c=0;
    for(auto ptr=st.begin(); ptr!=st.end(); ptr++) c+=C[*ptr];
    
    ll tK=K;
    ll t=0;
    if(c>0) {
      t=tK/n*c;
      tK%=st.size();
    }else {
      chmin(tK, n);
    }
    
    vector<ll> v;
    ll now=*st.begin();
    v.push_back(now);
    for(i=1; i<n; i++) {
      now=P[now];
      v.push_back(now);
    }
    for(i=0; i<n; i++) v.push_back(v[i]);
    
    ll sum[v.size()+10];
    for(i=0; i<v.size(); i++) sum[i+1]=sum[i]+C[v[i]];
    
    ll S=-INF;
    for(k=1; k<=tK; k++) for(i=1; i<=(ll)v.size()-k+1; i++) chmax(S, sum[i+k-1]-sum[i-1]);
    
    t+=S;
    chmax(ans, t);
    
    
    if(c>0) {
      tK=K;
      ll tt=max(0LL, (tK/n-1)*c);
      ll SS=0;
      tK-=max(0LL, (tK/n-1)*n);
      for(k=1; k<=tK; k++) for(i=1; i<=(ll)v.size()-k+1; i++) chmax(SS, sum[i+k-1]-sum[i-1]);
      tt+=SS;
      chmax(ans, tt);
    }
    
  }
  
  pt(ans);
  
}
 
 




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

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

  if(x<0) x*=(-1);

  if(x/d>=k){
    cout << x-d*k << endl;
    return 0;
  }

  k-=x/d;
  x=x%d;
  long long ans;
  if(k%2==0) ans = x;
  else ans = abs(x-d);
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#define int long long
using namespace std;
list<int>l;
signed main() {
	auto i = l.end();
	int m; cin >> m;
	for (int p = 0; p < m; p++) {
		int c; cin >> c;
		if (c == 0) {
			int x; cin >> x;
			i = l.insert(i, x);
		}
		else if (c == 1) {
			int d; cin >> d;
			if (d > 0)for (int j = 0; j < d; j++)i++;
			else for (int j = 0; j < -d; j++)i--;
		}
		else {
			i = l.erase(i);
		}
	}
	for (int p : l)cout << p << endl;
}


Measured memory_bytes: 18572
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := make([][]int, n)
	for i := 1; i <= n; i++ {
		a[i-1] = []int{iScan(), i}
	}
	sort.Slice(a, func(i, j int) bool { return a[i][0] < a[j][0] })
	ans := make([]int, 0, n)
	for _, v := range a {
		ans = append(ans, v[1])
	}
	fmt.Println(strings.Trim(fmt.Sprint(ans), "[]"))
}


Measured memory_bytes: 10112
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;
    int tmp = 0;
    scanf("%d %d %d", &a, &b, &c);

    if (a > c)
    {
        tmp = a;
        a = c;
        c = tmp;
    }
    if (b > c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    
    printf("%d %d %d\n", a, b, c);

    return 0;
}


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

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

  int u[n],k;
  int a[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    cin>>u[i];
    cin>>k;
    for(int j=0;j<k;j++){
      int v;
      cin>>v;
      a[i][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      cout<<a[i][j]<<" ";
    }
    cout<<a[i][n-1]<<"\n";
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

  sort(all(a));
  vector<int> cnt;
  int res = 1;
  for(int i = 1; i < n; i++){
    if(a[i] == a[i-1]){
      res++;
    }else{
      cnt.push_back(res);
      res= 1;
    }
    if(i == n-1){
        cnt.push_back(res);
    }
  }

  sort(all(cnt));

  int ans = 0;
  if(cnt.size() > k){
    for(int i = 0; i < cnt.size() - k; i++){
      ans += cnt[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2168
import java.util.*; 

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

  		int[][] a=new int[n][d];
		for(int c=0;c<n;c++){
          for(int e=0;e<d;e++){
    		a[c][e]=sc.nextInt();
          }
    	}
  		int ans=0;
  		int c=0;
  		for(int f=0;f<n-1;f++){
          for(int e=f+1;e<n;e++){
          for(int g=0;g<d;g++){
          	c+=Math.pow((a[f][g]-a[e][g]),2);
          }
          
        	if(Math.sqrt(c)==(int)Math.sqrt(c)){
              ans++;
            }
           c=0;
          }
        }
    

    	System.out.println(ans);
    }
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i) ans += (n-1)/i;
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(){
  int n=0;
  scanf("%d",&n);
  int suretsu[n];
  int i=0;
  for(i=0;i<n;i++){
    scanf("%d",&suretsu[i]);
  }
  int answer[n];
  for(i=0;i<n+1;i++){
    answer[i]=suretsu[n-i-1];
  }

  for(i=0;i<n;i++){
    printf("%d", answer[i]);

    if(i==n-1){
        printf("\n");
    }else{
        printf(" ");
    }
  }
  return 0;
}

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

int main(){
    int A,B,C,D;
    int E,F;
    cin >> A >> B >> C >> D;
    if(B <= C || D <= A){
        cout << "0";
        return 0;
    }
    if(A<=C){
        E = C;
    }else{
        E = A;
    }
    if(B<=D){
        F = B;
    }else{
        F = D;
    }

    cout << F-E;
    return 0;


}

Measured memory_bytes: 256
y500_count = gets.chomp.to_i
y100_count = gets.chomp.to_i
y50_count = gets.chomp.to_i
x = gets.chomp.to_i

products = (0..y500_count).to_a.product((0..y100_count).to_a, (0..y50_count).to_a)
count = products.count do |y500, y100, y50|
  y500 * 500 + y100 * 100 + y50 * 50 == x
end
puts count

Measured memory_bytes: 8316
#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int main() {
    int N, M, s, c, ans = 0;
    map<int, int> m;
    cin >> N >> M;
    while (M--) {
        cin >> s >> c;
        if (m.count(s)) {
            if (m[s] != c) {
                cout << "-1" << endl;
                return 0;
            } else {
                continue;
            }
        }
        m.insert(make_pair(s, c));
        ans += c * (int) (pow(10, N - s) + 0.5);
    }

    if (N > 1 && m.count(1) && m[1] == 0) {
        cout << "-1" << endl;
        return 0;
    }
    if (N > 1 && !m.count(1)) {
        ans += 1 * (int) (pow(10, N - 1) + 0.5);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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) begin(v),end(v)
#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; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

using pll = pair<ll, ll>;

pll dp[51][2]; // i, max, zero
ll x;
ll sum[51];

pll dfs(int i, int mx) {
	if (i == -1) return pll(1, 0);
	pll &res = dp[i][mx];
	if (res.fi != -1) {
		sum[i] += res.se;
		return res;
	}
	
	res = pll(0, 0);
	REP(d, 2) {
		if (mx && d > (x >> i & 1)) continue;
		pll cur = dfs(i - 1, mx && d == (x >> i & 1));
		if (d == 1) {
			res.se += cur.fi;
			sum[i] += cur.fi;
		}
		res.fi += cur.fi;
	}
	return res;
}

ll f(ll X) {
	memset(dp, -1, sizeof(dp));
	memset(sum, 0, sizeof(sum));
	x = X;
	dfs(50, true);
	ll res = 0;
	REP(i, 50) if (sum[i] & 1) res |= 1ll << i;
	return res;
}

int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = f(B);
	if (A > 0) ans ^= f(A - 1);
	cout << ans << endl;
	return 0;
}


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


vector<int> g[300010];
bool used[300010];

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> u(m), v(m); rep(i, m) cin >> u[i] >> v[i];
	rep(i, m) u[i]--, v[i]--;
	int s, t; cin >> s >> t;
	s--, t--;

	rep(i, m) {
		rep(j, 3)
			g[u[i] * 3 + j].push_back(v[i] * 3 + ((j + 1) % 3));
	}

	queue<pair<int, int>> q;
	q.push(make_pair(3 * s, 0));
	used[3 * s] = true;
	while (!q.empty()) {
		int d = q.front().first, cost = q.front().second;
		q.pop();

		if (d == 3 * t) {
			printf("%d\n", cost / 3);
			return 0;
		}
		for (auto nd : g[d]) {
			if (!used[nd]) {
				used[nd] = true;
				q.push(make_pair(nd, cost + 1));
			}
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].first;
  }
  for(int i=0;i<n;++i) {
    cin >> v[i].second;
  }
  sort(v.begin(), v.end());
  vector<P> a(n), b(n);
  for(int i=0;i<n;++i) {
    a[i].first = v[i].first;
    a[i].second = i;
  }
  for(int i=0;i<n;++i) {
    b[i].first = v[i].second;
    b[i].second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool ok = true;
  for(int i=0;i<n;++i) {
    if(a[i].first > b[i].first) {
      ok = false;
      break;
    }
  }
  if(!ok) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=1;i<n;++i) {
    if(a[i].first <= b[i-1].first) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  int cnt = 0;
  int pos = b[0].second;
  while(pos != 0) {
    cnt++;
    pos = b[pos].second;
  }
  if(cnt != n-1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 2560
W,H,N = map(int,input().split())
S = [0,0,W,H]
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1 and x > S[0]:
        S[0] = x
    elif a == 2 and x <  S[2]:
        S[2] = x
    elif a == 3 and y > S[1]:
        S[1] = y
    elif a == 4 and y < S[3]:
        S[3] = y
if (S[2]-S[0])*(S[3]-S[1]) < 0 or S[0] >= S[2] or S[1] >= S[3]:
    print(0)
else:
    print((S[2] - S[0]) * (S[3] - S[1]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    int mi=INF;
    int sum=0;
    REP(i,n){
        int t;
        cin>>t;
        chmin(mi,t);
        sum+=t;
    }
    cout<<n+(m-sum)/mi<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split(" "))

a = [0]+list(map(int, input().split(" ")))
b = [0]+list(map(int, input().split(" ")))

for i in range(1, n+1):
    a[i] += a[i - 1]
for i in range(1, m+1):
    b[i] += b[i - 1]

j,mx= m,0
for i in range(n+1):
    if a[i]>k:
        break
    while(b[j]>k-a[i]):
        j-=1
    if (i+j>mx):
        mx=i+j
print(mx)

Measured memory_bytes: 39748
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	int sum = 0, max = 0;
	for (int i = 0; i < N; ++i){
		int tmp;
		scanf("%d", &tmp);
		sum += tmp;
		if(tmp > max) max = tmp;
	}
	if(max < sum - max) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

N=int(input())
A=list(map(int,input().split()))

c = Counter(A)
mc=[]
for k in c.keys():
  if c[k]>=2:mc.append(k)
    
if len(mc)==0:
  print(0)
  exit()

elif len(mc)==1:
  if c[mc[0]]<4:
    print(0)
    exit()
  else:
    print(mc[0]**2)
    exit()
  
mc = sorted(mc,reverse=True)
if c[mc[0]] < 4:print(mc[0]*mc[1])
else:print(mc[0]**2)

Measured memory_bytes: 22172
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

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

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}


void solve() {
    int n;
    cin >> n;
    ll a[n+1];
    ll b[n];
    for(int i = 0;i < n+1;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = 0;i < n;i++){
        int tmp = a[i]-b[i];
        int tmp2;
        if(tmp >= 0){
            ans+=b[i];
        }else{
            tmp2 = a[i+1]-(b[i]-a[i]);
            if(tmp2 >= 0){
                a[i+1]-=(b[i]-a[i]);
                ans+=b[i];
            }else{
                ans+=(a[i]+a[i+1]);
                a[i+1]=0;
            }
        }
    }
    cout << ans << endl;
    
}
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
int main()
{
    std::ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;  cin >> n;
  vector<ll> p(n+1);
  for(int i=1; i<=n; i++)  cin >> p.at(i);
  int cnt=0;

  for(int i=1; i<n; i++){
    if(p[i]!=i) continue;
    swap(p[i], p[i+1]);
    cnt += 1;
  }
  if(p[n]==n) cnt += 1;
  
  cout << cnt << endl;
  

}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)


int main() {
    int n,t,a;
    cin >> n >> t >> a;
    int h[n],ans;
    double cur=1000;
    rep(i,n) cin >> h[i];
    rep(i,n){
        double tmp=t-h[i]*0.006;
        if(cur > abs(tmp-a)){
            cur = abs(tmp-a);
            ans = i+1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    string valid = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < 16; ++i) {
        if (s[i] != valid[i]) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int gcds(int a, int b){
    int c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll h, w, m; cin >> h >> w >> m;
    vector<ll> arh(h,0);
    vector<ll> arw(w,0);
    vector<PL> ar(m);
    rep(i,m){
        ll a, b; cin >> a >> b;
        arh[a-1]++;
        arw[b-1]++;
        ar[i].first = a-1;
        ar[i].second = b-1;
    } 
    ll ansh = 0LL; ll ch = 0;
    ll answ = 0LL; ll cw = 0;
    rep(i,h) ansh = max(ansh,arh[i]);
    rep(i,w) answ = max(answ,arw[i]);
    rep(i,h) if (ansh == arh[i]) ch++;
    rep(i,w) if (answ == arw[i]) cw++;
    ll cnt = 0;
    rep(i,m){
        if (arh[ar[i].first] == ansh && arw[ar[i].second] == answ){
            cnt++;
        }
    }
    if (cnt < ch * cw) cout << ansh + answ << endl;
    else cout << ansh + answ - 1 << endl;
}

Measured memory_bytes: 12736
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    LL a, b, c; cin>>a>>b>>c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout<<0;
    }
    else cout<<min(min(b * c, a * c), a * b);
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    p.at(i) = make_pair(b - 1, a - 1);
  }
  sort(p.begin(), p.end());
  int ans = 0, bmax = -1;
  for (int i = 0; i < m; i++) {
    if (p.at(i).second > bmax) {
      ans++;
      bmax = p.at(i).first - 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else cout << "a == b" << endl;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    vector<ll>d(n+1);
    map<ll,ll>mp;
    mp[0] = 1;
    ll ans = 0;
    rep(i,n) {
        d[i+1] = d[i] + a[i];
        ans += mp[d[i+1]];
        mp[d[i+1]]++;
    }
    cout << ans << endl;
    
}
    




Measured memory_bytes: 18820
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    vi a;
    while (true)
    {
        int e;
        cin >> e;
        if (e == 0)
        {
            break;
        }
        else
        {
            a.push_back(e);
        }
    }
    for (int i = 1; i < a.size() + 1; i++)
    {
        cout << "Case"
             << " " << i << ": " << a[i - 1] << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3204