akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAXN = 1e6 + 7;
const int INF = 1e9;
vector<pii>vec;
char s[MAXN];
stack<char>stk;
int N, a[MAXN], v[MAXN];
    
#define lson (rt << 1)
#define rson (rt << 1 | 1)
struct node{int val, pos;} T[MAXN << 2];
node merge(node &x, node &y) {
    if (x.val > y.val) return x;
    else return y;
}
void pushup(int rt) {T[rt] = merge(T[lson], T[rson]);}
void build(int rt, int l, int r) {
    if (l == r) {T[rt] = {v[l], l}; return;}
    int mid = (l + r) >> 1;
    build(lson, l, mid);
    build(rson, mid + 1, r);
    pushup(rt);
}
void update(int rt, int l, int r, int pos, int v) {
    if (l == r) {T[rt] = {v, l}; return;}
    int mid = (l + r) >> 1;
    if (pos <= mid) update(lson, l, mid, pos, v);
    else update(rson, mid + 1, r, pos, v);
    pushup(rt);
}
node query(int rt, int l, int r, int L, int R) {
    if (L <= l && r <= R) return T[rt];
    int mid = (l + r) >> 1;
    node resl = {-INF, -1}, resr = {-INF, -1};
    if (L <= mid) resl = query(lson, l, mid, L, R);
    if (mid <  R) resr = query(rson, mid + 1, r, L, R);
    return merge(resl, resr);
}
    
int main() {
    int n; scanf("%d", &n);
    int sum1 = 0, sum2 = 0;
    for (int k = 1; k <= n; k++) {
        scanf(" %s", s);
        int len = strlen(s);
        for (int i = 0; i < len; i++) {
            if (s[i] == '(') stk.push(s[i]);
            else {
                if (stk.size() && stk.top() == '(') stk.pop();
                else stk.push(s[i]);
            }
        }
        pii item = {0, 0};
        while (stk.size()) {
            if (stk.top() == '(') item.second++;
            else item.first++;
            stk.pop(); 
        }
        if (item.first == 0) sum1 += item.second;
        else if (item.second == 0) sum2 += item.first;
        else vec.push_back(item);
    }
    sort(vec.begin(), vec.end());
    N = vec.size();
    for (int i = 1; i <= N; i++) {
        a[i] = vec[i - 1].first;
        v[i] = vec[i - 1].second - vec[i - 1].first;
    }
    if (N > 0) build(1, 1, N);
    for (int i = 1; i <= N; i++) {
        int p = upper_bound(a + 1, a + 1 + N, sum1) - a - 1;
        if (!p) {puts("No"); return 0;}
        node res = query(1, 1, N, 1, p);
        if (res.val == -INF || sum1 < a[res.pos]) {puts("No"); return 0;}
        sum1 += v[res.pos];
        update(1, 1, N, res.pos, -INF);
    }
    sum1 == sum2 ? puts("Yes") : puts("No");
    return 0;
}

Measured memory_bytes: 10368
import sys
A,B,C = map(int, input().split())
K=int(input())
c=0
while A>=B:
  B=B*2
  c+=1
  if c>K:
    print("No")
    sys.exit()
while B>=C:
  C=C*2
  c+=1
  if c>K:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 61624
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int h, w, d[1010][1010], res;
string s[1010];
queue<pair<int,int> > q;

signed main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) d[i][j] = 1<<30;
    rep(i,h) {
        cin >> s[i];
        rep(j,w) if (s[i][j]=='#') d[i][j] = 0, q.push({i,j});
    }
    while (!q.empty()) {
        int x = q.front().first, y = q.front().second; q.pop();
        rep(i,4) {
            int xx = x+dx[i], yy = y+dy[i];
            if (ool(xx,yy,h,w)) continue;
            if (s[xx][yy]=='#' || d[xx][yy]<=d[x][y]+1) continue;
            d[xx][yy] = d[x][y]+1, q.push({xx,yy});
        }
    }
    rep(i,h) rep(j,w) chmax(res, d[i][j]);
    cout << res << endl;
}

Measured memory_bytes: 13456
A,B,C,D,E,F=map(int,input().split())
ansS = 0
ansT = 0
rate = -1
for a in range(F // (A*100)+1):
    di_a = F - A*a*100
    for b in range(di_a // (B*100) + 1):
        di_b = di_a - B*b*100
        for c in range(di_b//C+1):
            di_c = di_b - c*C
            for d in range(di_c //D+1):
                if (a+b != 0 and E*(a*A+b*B) >= c*C+d*D):
                    total = 100*(A*a+B*b)+c*C+d*D
                    sugers = c*C+d*D
                    if(rate < sugers/total and total <= F):
                        rate = sugers/total
                        ansT = total
                        ansS = sugers

print(ansT, ansS)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> switches(m);
    rep(i,m){
        int k; cin >> k;
        switches[i] = vector<int>(k);
        rep(j,k){
            cin >> switches[i][j];
            switches[i][j]--;
        }
    }
    
    vector<int> p(m);
    rep(i,m) cin >> p[i];
    
    int ans = 0;
    bitset<10> b;
    rep(i,1<<n){
        b = i;
        bool ok = true;
        rep(j,m){ //for all light bulb
            int on = 0;
            for(int sw: switches[j]) on += b[sw];
            if(on % 2 != p[j]){
                ok = false;
                break;
            }
        }
        ans += ok;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n;
    int ans =1;    
    int ps=2;
    while(ps<=n){
        ans=ps;    
        ps*=2;
    }
    pri(ans);
    


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  double ans;
  if(n%2==0){
    cout<<0.500000<<endl;
    return 0;
  }
  double m=n/2+1;
  ans=m/(double)n;
  cout<<ans<<endl;
}


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

main() {
  int N; cin >> N;
  vector<int> a(3 * N);
  priority_queue<int, vector<int>, greater<int>> pq1, pq2;
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
    if (i < N) pq1.push(a[i]);
    if (i >= 2 * N) pq2.push(-a[i]);
  }

  vector<ll> acc1(N + 1, accumulate(begin(a), begin(a) + N, 0LL));
  vector<ll> acc2(N + 1, -accumulate(end(a) - N, end(a), 0LL));
  for (int i = 0; i < N; i++) {
    pq1.push(a[N + i]);
    acc1[i + 1] = acc1[i] + a[N + i] - pq1.top();
    pq1.pop();
  }
  for (int i = N; i > 0; i--) {
    pq2.push(-a[N + i - 1]);
    acc2[i - 1] = acc2[i] + -a[N + i - 1] - pq2.top();
    pq2.pop();
  }

  ll ans = -1e18;
  for (int i = 0; i < N + 1; i++) ans = max(ans, acc1[i] + acc2[i]);
  cout << ans << endl;
}


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

int main() {
	int n, nn, sum = 0;
	cin >> n;
	nn = n;

	for (int i = 0; i < 10; i++) {
		sum += n % 10;
		n /= 10;
		if (n == 0) 
			break;
	}
	if (nn%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//lcm of two given numbers//
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int cnt=0;
for(int i=0;i<n;i++)
if(a[i]>=k)
cnt++;
cout<<cnt;


return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	int flg = 0x00;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == 'a') flg |= 0x01;
		if (s[i] == 'b') flg |= 0x02;
		if (s[i] == 'c') flg |= 0x04;
	}
	if (flg == 0x07) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[1 for i in range(n+1)]
for i in range(m):
    a[int(input())]=0
dp=[0 for i in range(n+1)]
dp[0]=1
for i in range(n):
    if a[i]:
        if i+1<n+1 and a[i+1]:
            dp[i+1]+=dp[i]
        if i+2<n+1 and a[i+2]:
            dp[i+2]+=dp[i]
print(dp[-1]%1000000007)

Measured memory_bytes: 469044
L, R = map(int, input().split())
if L // 2019 < R // 2019:
    print(0)
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)

Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public int mod = 1000000007;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TaskA.Event[] evs = new TaskA.Event[2 * n];
            for (int i = 0; i < n; i++) {
                evs[i] = new TaskA.Event(in.nextInt(), +1);
            }
            for (int i = 0; i < n; i++) {
                evs[i + n] = new TaskA.Event(in.nextInt(), -1);
            }
            Arrays.sort(evs);
            int curcount = 0;
            long nways = 1;
            for (int i = 0; i < 2 * n; i++) {
                if (evs[i].b == +1) {
                    if (curcount < 0) {
                        nways = nways * (-curcount) % mod;
                    }
                    curcount++;
                } else {
                    if (curcount > 0) {
                        nways = nways * curcount % mod;
                    }
                    curcount--;
                }
            }
            out.println(nways);
        }

        static class Event implements Comparable<TaskA.Event> {
            public int a;
            public int b;

            public Event(int a, int b) {
                this.a = a;
                this.b = b;
            }

            public int compareTo(TaskA.Event other) {
                return a - other.a;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 31236
package main

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

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)
	s := Scan()
	pre := ""
	ans := 0
	for i := 0; i < len(s); i++ {
		if string(s[i]) == pre {
			if i != len(s)-1 {
				ans++
				pre = s[i : i+2]
				i++
			}
		} else {
			pre = s[i : i+1]
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2484
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,K,h[1001010],m1,g[1001010],f[1001010];
int siz[1001010],ans;
struct edge{
	int next,to;
	edge(int next=0,int to=0):
	next(next),to(to){}
}q[2020200];
void Addedge(){
	int x,y; scanf("%d %d",&x,&y);
	q[++m1]=edge(h[x],y); h[x]=m1;
	q[++m1]=edge(h[y],x); h[y]=m1;
}
void Dfs1(int x,int fa){
	siz[x]=1;
	for (int i=h[x];i;i=q[i].next){
		int y=q[i].to;
		if (y==fa) continue;
		Dfs1(y,x); siz[x]+=siz[y];
	}
}
void Dfs2(int x,int fa){
	int Max1=-21001010,Max2=-21001010;
	for (int i=h[x];i;i=q[i].next){
		int y=q[i].to;
		if (y==fa) continue;
		Dfs2(y,x);
		if (siz[y]>=K) f[x]++;
		if (f[y]-g[y]>Max1) Max2=Max1,Max1=f[y]-g[y];
		else if (f[y]-g[y]>Max2) Max2=f[y]-g[y];
	}
	
	if (siz[x]>=K) g[x]=1;
	ans=max(ans,f[x]+Max1+(n-siz[x]>=K)); 
	ans=max(ans,f[x]+Max1+Max2+(n-siz[x]>=K));
	f[x]=max(f[x],f[x]+Max1);
}
int main(){
	scanf("%d %d",&n,&K);
	for (int i=1;i<n;i++) Addedge();
	Dfs1(1,0); Dfs2(1,0);
	cout<<ans<<endl;
}


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

#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) (v.begin(),v.end())
#define vi vector<int>
int ans = 0;
vi xa = {0,-1,1,0};
vi ya = {1,0,0,-1};
int h,w;
vector<vector<char>> s;


void dfs(int x,int y){
    vector<vector<bool>> vis(h,vector<bool>(w));
    queue<pair<int,pair<int,int>>> q;
    q.push({0,{x,y}});
    vis[x][y] = true;
    while(!q.empty()){
        x = q.front().second.first;
        y = q.front().second.second;
        int dist = q.front().first;
        q.pop();
        for(int i = 0;i < 4; ++i){
            int nx = x + xa[i];
            int ny = y + ya[i];
            if((nx < h) && (ny < w) && (nx >= 0 && ny >= 0) && (!vis[nx][ny]) && (s[nx][ny] != '#')){
                q.push({dist + 1,{nx,ny}});
                ans = max(ans,dist + 1);
                vis[nx][ny] = true;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin >> h >> w;
    s.resize(h,vector<char>(w));
    ffor(i,h){
        ffor(j,w){
            cin >> s[i][j];
        }
    }

    for(int i = 0;i < h;++i){
        for(int j = 0;j < w; ++j){
            if(s[i][j] == '#') continue;
            dfs(i,j);
        }
    }

    cout << ans;
}


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

int main()
{
	int N;
	cin >> N;
	
	int a[2 + 1 ][N + 1] = {0};
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= N; j++) {
			cin >> a[i][j];
		}		
	}


	int answer = 0;
	
	// 横
	for (int j_down = 1; j_down <= N; j_down++) {
		
		int tmpSum = 0;


		// 1段目
		for (int k = 1; k <= j_down; k++) {
			tmpSum += a[1][k];
		}

		// 2 段目 
		for (int k = j_down; k <= N; k++) {
			tmpSum += a[2][k];
		}

		answer = max(answer, tmpSum);
	}
	
	cout << answer << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

#define REP(i, N) for (ll i = 0; i < N; ++i)
#define pll pair<ll, ll>
#define F first
#define S second

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input
    ll N, M;
    ll node1, node2;
    cin >> N >> M;
    vector<pll> A(M);
    for (ll i = 0; i < M; i++) {
        cin >> node1 >> node2; --node1, --node2;
        A[i].F = node1;
        A[i].S = node2;
    }
    
    // calculation
    vector<ll> ans(M);
    ans[M-1] = (N*(N-1))/2;  // 全ての頂点が孤立している状態
    
    UnionFind uf(N);
    for (ll i = M-1; i >= 1; --i) {
        node1 = A[i].F, node2 = A[i].S;
        if (uf.issame(node1, node2)) {
            ans[i-1] = ans[i];
        } else {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i-1] = ans[i] - (uf.size(node1) * uf.size(node2));
            uf.merge(node1, node2);
        }
    }
    
    REP(i, M) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 5248
N, M = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

for i in make_divisors(M):
    if i <= M // N:
        ans = i 

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int ara[n],bra[n];
    int res=0;
    for(i=0;i<n;i++)
        cin>>ara[i];
    for(i=0;i<n;i++)
        cin>>bra[i];
    for(i=0;i<n;i++)
    {
        if(ara[i]>bra[i])
            res+=(ara[i]-bra[i]);
    }
    cout<<res<<endl;
    return 0;
}


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

signed main() {
  int n;
  cin>>n;
  int c=0;
  int ans=0;
  int h[n];
  cin>>h[0];
  for(int i=1;i<n;i++){
    cin>>h[i];
    if(h[i]<=h[i-1])c++;
    else{
      ans=max(ans,c);
      c=0;
    }
  }
  ans=max(ans,c);
  cout<<ans;


    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long 
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
  int n,m,z=0;
  string a,b,c;
  cin>>a>>b;
  n=a.size();
  m=b.size();
  for(int i=0;i<n+m;i+=2){
    c[i]=a[z];
    c[i+1]=b[z];
    z++;
  }
  for(int i=0;i<(n+m);i++){
    cout<<c[i];
  }
  cout<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    string s;
    cin >> s;
    int start,end;
    REP(i,s.length()){
        if(s[i]=='A'){
            start = i;
            break;
        }
    }
    REP(i,s.length()){
        if(s[i]=='Z'){
            end = i;
        }
    }
    cout << end-start+1;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> ans;
    vector<bool> visited(N);
    bool fin = false;
    function<void(int)> dfs = [&](int cur) {
        if(fin) return;
        visited[cur] = true;
        ans.push_back(cur);
        bool ok = true;
        for(auto &to : G[cur]) {
            if(!visited[to]) {
                ok = false;
                dfs(to);
            }
        }
        if(ok) fin = true;
    };
    dfs(0);
    reverse(ans.begin(), ans.end());
    ans.pop_back();
    fin = false;
    visited[0] = false;
    dfs(0);
    cout << ans.size() << endl;
    for(auto &a : ans) cout << a + 1 << " ";
    return 0;
}


Measured memory_bytes: 11128
#include <iostream>
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 if (a == b)
		{
			cout << "a == b" << endl;
		}
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;
int main(){
	double n;
	double count=0;
	cin>>n;
	double ans;
	for (int i = 1; i <= n; ++i)
	{
		if(i%2==1){
			count++;
//			printf("%d %f\n",i,count );
		}
		/* code */
	}
	cout<<count/n<<endl;
//	printf("%f\n", ans );
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    ll a;
    vector<ll> ruiseki1(n + 1), ruiseki2(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        ruiseki1[i + 1] = ruiseki1[i] + a;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        ruiseki2[i + 1] = ruiseki2[i] + a;
    }
    ll ans = -INFLL;
    for (int i = 1; i <= n; i++)
    {
        chmax(ans, ruiseki1[i] + ruiseki2[n] - ruiseki2[i - 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val w = sc.next()

  val all = w.groupBy { it }.keys.size
  val tmp = w.groupBy { it }.values.map { it.size }.filter { it % 2 == 0 }.size

  var ans = "No"
  if (tmp == all) ans = "Yes"

  println(ans)
}


Measured memory_bytes: 29468
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




 
    
void test_case() {

    int a , b , c;
    cin>>a>>b>>c;

    swap(a,b);
    swap(a,c);


    cout<<a<<" "<<b<<" "<<c<<endl;







}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3660
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: usize = read!();
    let mut sum: usize = 0;
    for i in 0..a {
        let b: usize = read!();
        sum+=b
    }
    println!("{}",sum-a)
}

Measured memory_bytes: 2160
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) r1eturn cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e8, M = 1000007, P = 6151, sq = 1e3, lg = 60;
typedef pair <int, int> pii;

int32_t main() {
	use_fast;
	int n, m;
	cin >> n >> m;
	m *= 2;
	cout << max((int)0, n - m) << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>a, b, v;
map<int, int>ma, mb;//数字→個数

int main() {
	int n;
	cin >> n;
	REP(i, 0, n) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		if (i % 2 == 0) {
			ma[tmp]++;
		}
		else {
			mb[tmp]++;
		}
	}
	pair<int, int>pa, pb;
	pa = mp(0, 0);//(個数が最大の数字、その個数)
	pb = mp(0, 0);
	REP(i, 0, n) {
		if (i % 2 == 0) {
			if (ma[v[i]] != 0) {
				if (ma[v[i]] > pa.second) {
					pa = mp(v[i], ma[v[i]]);
				}
				a.push_back(ma[v[i]]);
				ma[v[i]] = 0;
			}
		}
		else {
			if (mb[v[i]] != 0) {
				if (mb[v[i]] > pb.second) {
					pb = mp(v[i], mb[v[i]]);
				}
				b.push_back(mb[v[i]]);
				mb[v[i]] = 0;
			}
		}
	}
	a.push_back(0);
	b.push_back(0);
	sort(all(a));
	sort(all(b));
	int ans;
	if (pa.first == pb.first) {
		ans = n - max(a[a.size() - 1] + b[b.size() - 2], a[a.size() - 2] + b[b.size() - 1]);
	}
	else {
		ans = n - a[a.size() - 1] - b[b.size() - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    string s;
    ll K;
    cin >> s;
    cin >> K;
    ll len = s.size();
    ll ans = 0;
    if (K == 1){
        REP(i, len) rep(j, 1, 10){
            string ss(len, '0');
            ss[i] = '0' + j;
            if (ss <= s) ans++;
        }
    }else if (K == 2){
        rep(i, 0, len) rep(j, i + 1, len)rep(a1, 1, 10)rep(a2, 1, 10){
                string ss(len, '0');
                ss[i] = '0' + a1;
                ss[j] = '0' + a2;
                if (ss <= s) ans++;
            }
    }else {
        if (len > 3) {
            ans += (len - 1) * (len - 2) * (len -3) / 6 * 9 * 9 * 9;
            ans += (s[0] - '1') * (len - 1) * (len - 2) / 2 * 9 * 9;
            rep(i, 1, len) rep(j, i + 1, len)rep(a1, 1, 10)rep(a2, 1, 10){
                string ss(len, '0');
                ss[0] = s[0];
                ss[i] = '0' + a1;
                ss[j] = '0' + a2;
                if (ss <= s) ans++;
            }
        }else{
                ans += (s[0] - '1') * (len - 1) * (len - 2) / 2 * 9 * 9;
                rep(a1, 1, 10)rep(a2, 1, 10){
                string ss(len, '0');
                ss[0] = s[0];
                ss[1] = '0' + a1;
                ss[2] = '0' + a2;
                if (ss <= s) ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	char a;
	scanf("%c", &a);
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') {
		printf("vowel\n");
	}
	else {
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N) : par(N),size(N){ //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i]=1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry]+=size[rx];
        size[rx]=size[ry];
        return;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int show_size(int x){
        return size[root(x)];
    }
};

int main(){
int N;
cin>>N;
multimap<long long,int>A;
long long a[N];//並び替える前
multimap<long long,int >B;
long long b[N];//並び替える前

rep(i,N){
cin>>a[i];
A.insert(make_pair(a[i],i));
}

rep(i,N){
cin>>b[i];
B.insert(make_pair(b[i],i));
}
auto it=A.begin();
auto bit=B.begin();
int correct[N];
int Bv[N];
rep(i,N){

    if(it->first>bit->first){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        correct[i]=bit->second;//A[i]にとっての理想の相手はb[correct[i]];
        Bv[bit->second]=it->second;//B[p]にとっての理想の相手はBv[p];
    }
    it++;
    bit++;
}
UnionFind tree(N);
int good=0;

rep(i,N){
    if(tree.same(i,Bv[i])){
        good++;
    }
    else {
        tree.unite(i,Bv[i]);
    }
}
/*
it=A.begin();
bit=B.begin();
rep(i,N){
int t=it->second;//並び替える前の番号
//auto l=B.lower_bound(it->first);
    if(t==correct[t]){
    good++;
    }
it++;
bit++;
}
*/

if(good>=2){
    cout<<"Yes"<<endl;
}
else{
    it=A.begin();
    bit=B.begin();
    it++;
    good=0;
    rep(i,N-1){
        if(bit->first>=it->first){
            cout<<"Yes"<<endl;
            return 0;
        }
        it++;
        bit++;
    }
    cout<<"No"<<endl;
}

 return 0;
}
/*

*/


Measured memory_bytes: 15872
if __name__ == '__main__':
    s = str(input())

    A_indexes = []
    Z_indexes = []

    for i in range(len(s)):
        if s[i] == "A":
            A_indexes.append(i)
        if s[i] == "Z":
            Z_indexes.append(i)

    print(max(Z_indexes)-min(A_indexes)+1)

Measured memory_bytes: 11180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> G[100100];

int dfs(int v, int p) {
  int x = 0;
  for (int u: G[v]) {
    if (u == p) continue;
    x ^= dfs(u, v);
  }
  return x + 1;
}

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

  int n;
  cin >> n;
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  cout << (dfs(0, -1) != 1 ? "Alice" : "Bob") << '\n';

  




  
  return 0;
}

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

int isprime(int x);

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

    int ans=0;

    for(int i=0;i<n;i++){
        ans += isprime(num[i]);    
    }
    

    cout<<ans<<endl;

    return 0;
}

//{{{
int isprime(int x){
    if(x==2)return 1;
    else if(x<2 || x%2==0)return 0;
    else if(x>=3){
        int i=3;
        while(i<=sqrt(x)){
            if(x%i==0)return 0;
            i+=2;
        }
    }

    return 1;
}
//}}}



Measured memory_bytes: 3080
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<math.h>

using namespace std;

int solve(int m){

	if (m == 2){
		//printf("?´???°??§???%d\n",m);
		return 1;
	}
	if (m < 2 || m % 2 == 0) return 0;
	int e = 0;
	for (int j = 3; j<=sqrt(m); j++){
		if (m%j == 0){
			return 0;
		}
	}

	if (e == 0){
		//printf("?´???°??§???%d\n", m);
		return 1;
	}

}


int main(){



	int n;
	int p = 0;
	cin >> n;
	for (int i = 0; i<n; i++){
		int m;
		cin >> m;

		int j = solve(m);
		if (j == 1)p++;
	}

	cout << p << endl;
	return 0;

}

Measured memory_bytes: 1160
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextInt();
        long s = 0;
        long s2 = 0;
        for (int a=0; a<=A; a++) {
        	if(a % 3 == 0 || a % 5 == 0){
        		s2 = a + s2;
        	}
        	else {
        		s = a + s;
        	}
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 35820
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.buffer.readline
def dfs(G,v,p):
    for nv in G[v]:
        if(nv==p):
            continue
        point[nv]+=point[v]
        dfs(G,nv,v)

N,Q=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
point=[0]*N
for i in range(Q):
    p,x=map(int,input().split())
    point[p-1]+=x
dfs(G,0,-1)
print(*point)

Measured memory_bytes: 230904
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

map<LL, int> cnt;

int main(void) {
    int n;
    scanf("%d", &n);
    REP(i, n) {
        LL a;
        scanf("%lld", &a);
        cnt[a]++;
    }
    VL v, v2;
    FORE(e, cnt) {
        if (e.second >= 2) {
            v.EB(e.first);
        }
        if (e.second >= 4) {
            v2.EB(e.first);
        }
    }
    LL ans = 0;
    SORT(v);
    SORT(v2);
    if (v2.size() >= 1) {
        chmax(ans, v2.back() * v2.back());
    }
    DEBUG(ans)
    if (v.size() >= 2) {
        chmax(ans, v.back() * v[v.size() - 2]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));sort(all(c));
  ll sum=0;
  rep(i,n){
    sum+=(lower_bound(all(a),b[i])-a.begin())*(c.end()-upper_bound(all(c),b[i]));
  }
  cout<<sum;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 2560
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, K; cin >> N >> K;

    int ans = N - K;
    if (K == 1) ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "Impossible" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int a;
    vector<int> A;
    int B[114]={};
    cin >> N;
    REP(i,N){
        cin >> a;
        A.push_back(a);
        B[a]++;
    }
    sort(A.begin(),A.end());
    int K=A[N-1];
    if(B[K]<2)GOODBYE;
    for(int i=K;i>(K+1)/2;i--){
        B[i]-=2;
        if(B[i]<0)GOODBYE;
    }
    B[(K+1)/2]--;if(K%2==1){B[(K+1)/2]--;}
    if(B[(K+1)/2]<0)GOODBYE;
    
    REP(i,N){
        if(i<=(K+1)/2 && B[i]>0)GOODBYE;
    }
    
    cout << "Possible" << endl;
    
    return 0;
}



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


int main(){

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

  int mn = a[0],mx = a[0];
  long long sum = 0;
  for(int i=0;i<n;i++){
    mn = min(mn,a[i]);
    mx=max(mx,a[i]);
    sum += a[i]; // sum = sum + a[i];
      
  }
  cout<<mn<<" "<<mx<<" "<<sum<<endl;
  return 0;
}



Measured memory_bytes: 3144
/*
  -> Ossan
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define Hiraishin                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);                                                            \
  cout.tie(nullptr);
using namespace std;

void solve() {
    int x, y;
    cin >> x >> y;
    bool f = false;
    for(int i = 0; i <= x; i++){
        int j = x - i;
        if(2 * i + 4 * j == y)
        {
            f = true; break;
        }
    }
    cout << (f ? "Yes\n" : "No\n");
}

signed main() {
    Hiraishin
        solve();
    return 0;
}

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

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

int w, h;
//vector< vector<int> > field( h, vector<int>(w) );
int field[90][90];

int saiki( int x, int y, int d ){
	int res = d;
	for( int i = 0; i < 4; i++ ){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if( 0 <= nx && nx < w && 0 <= ny && ny < h && field[nx][ny] ){
			field[nx][ny] = 0;
			res = max( res, saiki( nx, ny, d + 1 ) );
			field[nx][ny] = 1;
		}
	}
	return res;
}
int main(){
	while( cin >> w >> h && w ){
		for( int i = 0; i < h; i++ ){
			for( int j = 0; j < w; j++ ){
				cin >> field[i][j];
			}
		}
		int result = 0;
		for( int i = 0; i < h; i++ ){
			for( int j = 0; j < w; j++ ){
				if( field[i][j] ){
					field[i][j] = 0;
					result = max( result, saiki( i, j, 1 ) );
					field[i][j] = 1;
				}
			}
		}
		cout << result << endl;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<ll> T1(N, 0), T2(N, 0);

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll b = B[i];
        auto itr = upper_bound(C.begin(), C.end(), b);
        if(itr == C.end()) continue;
        ll id = distance(C.begin(), itr);
        T2[i] = N-id;
    }
    for(int i = N-2; i >= 0; i--) T2[i] += T2[i+1];

    for(int i = 0; i < N; i++){
        ll a = A[i];
        auto itr = upper_bound(B.begin(), B.end(), a);
        if(itr == B.end()) continue;
        ll id = distance(B.begin(), itr);
        ans += T2[id];
    }
    cout << ans << endl;
}


Measured memory_bytes: 7164
#include<cstdio>
#include<cstring>
#define maxn 3005
using namespace std;
int dp[maxn][maxn],last[maxn][maxn];
char s[maxn],t[maxn],w[maxn];
int main(){
    scanf("%s%s",s+1,t+1);
    int n=strlen(s+1),m=strlen(t+1);
    for (int i=1;i<=n;i++)
    for (int j=1;j<=m;j++){
        if (s[i]==t[j]) {
            if (dp[i][j]<dp[i-1][j-1]+1) dp[i][j]=dp[i-1][j-1]+1,last[i][j]=1;
        }
        if (dp[i-1][j]>dp[i][j]) dp[i][j]=dp[i-1][j],last[i][j]=2;
        if (dp[i][j-1]>dp[i][j]) dp[i][j]=dp[i][j-1],last[i][j]=3; 
    }
    int x=n,y=m;
    while (dp[x][y]){
        if (last[x][y]==1) w[dp[x][y]]=s[x],x--,y--;else
        if (last[x][y]==2) x--;else y--;
    }
    for (int i=1;i<=dp[n][m];i++)
    printf("%c",w[i]);
    printf("\n");
    return 0;
}



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

using namespace std;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string i;
    cin >> i;

    cout << (i.compare("ABC") == 0 ? "ARC" : "ABC");

    return 0;
}


Measured memory_bytes: 3100