akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

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

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            String s=in.next();
            int max=0;
            int count=0;
            for(char c:s.toCharArray()){
                if(c=='S'){
                    max=Math.max(max,count);
                    count=0;
                }
                else
                count++;
            }
            if(count>0)
            max=Math.max(count,max);
            out.println(max);
        }
    }
}

Measured memory_bytes: 32412
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Collecting Balls (Easy Version)
	var N, K int
	fmt.Scanf("%d\n%d", &N, &K)

	var x int
	var sum int = 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &x)
		sum += 2 * int(math.Min(float64(x), float64(K-x)))
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1840
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
typedef long long LL;
int a[200010];
int main(void){
	int n;
	LL res=100000000000000000ll,sum=0,tmp=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for (int i=1;i<n;i++){
		tmp+=a[i];
		res=min(res,abs(sum-tmp-tmp));
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 1024
class Node:
    def __init__(self,name):
        self.name=name
        self.root=None
        self.left=None
        self.right=None



def Preorder(node,order):
    order.append(node.name)
    try:
        Preorder(node.left,order)
    except:
        pass
    try:
        Preorder(node.right,order)
    except:
        pass

def Inorder(node,order):
    try:
        Inorder(node.left,order)
        order.append(node.name)
    except:
        order.append(node.name)
    
    try:
        Inorder(node.right,order)
    except:
        pass

def Postorder(node,order):
    try:
        Postorder(node.left,order)
    except:
        pass
    try:
        Postorder(node.right,order)
    except:
        pass
    order.append(node.name)





n=int(input())
Tree=[]
for i in range(n):
    Tree.append(Node(i))


for loop in range(n):
    name,left,right=map(int,input().split())
    if(left!=-1):
        Tree[name].left=Tree[left]
        Tree[left].root=Tree[name]
    if(right!=-1):
        Tree[name].right=Tree[right]
        Tree[right].root=Tree[name]



for i in range(n):
    if(Tree[i].root is None):
        root=Tree[i]


p_order=[]
Preorder(root,p_order)

i_order=[]
Inorder(root,i_order)

po_order=[]
Postorder(root,po_order)

print("Preorder")
print("",end=" ")
print(" ".join(list(map(str,p_order))))

print("Inorder")
print("",end=" ")
print(" ".join(list(map(str,i_order))))

print("Postorder")
print("",end=" ")
print(" ".join(list(map(str,po_order))))


Measured memory_bytes: 5616
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int array[] = new int[n + 1];
        for (int i = 0; i < m; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            if (ai == 1) {
                array[bi]++;
            }
            if (bi == n) {
                array[ai]++;
            }
        }
        for (int num : array) {
            if (num == 2) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 60576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
map<string,int > mark;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    int ac=0,tle=0,re=0,wa=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mark[s]++;
    }
    cout<<"AC x "<<mark["AC"]<<endl;
    cout<<"WA x "<<mark["WA"]<<endl;
    cout<<"TLE x "<<mark["TLE"]<<endl;
    cout<<"RE x "<<mark["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; string s; cin >> n >> s;
    int res = 0;

    for(int num=0; num<1000; num++){
        bool ok = false;
        int index = 0;
        rep(i, n){
            int tmp, m = s[i] - '0';
            if(index==0)tmp = num/100;
            else if(index==1)tmp = num/10%10;
            else if(index==2)tmp = num%10;
            if(tmp== m){
                index++;
            }
            if(index==3){
                ok = true;
                break;
            }
        }
        if(ok)res++;
    }
    cout << res << ln;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
string S;
int w[200001], b[200001];

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

    int ans=1001001001;
    rep(i,N){
        w[i+1]=w[i], b[i+1]=b[i];
        if(S[i]=='.') w[i+1]++;
        else b[i+1]++;
    }
    rep(i,N+1){
        ans=min(ans,b[i]+(w[N]-w[i]));
    }

    cout<<ans<<endl;
}

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

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  for (int i = 0; i <= N; ++i) {
    int p = i * M;
    for (int j = 0; j <= M; ++j) {
      int q = j * N;
      int ans = p + q - i * j * 2;
      if (ans == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 3588
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	long long int N, A, B, C, X;
	vector <int >data;
	while (1)
	{
		int count = -1;
		data.clear();
		cin >> N >> A >> B >> C >> X;
		if (N == 0)break;
		data.resize(N);
		for (size_t i = 0; i < N; i++)
		{
			cin >> data[i];
		}
		while (data.size())
		{
			
			if (*data.begin()==X)
			{
				data.erase(data.begin());
			}
			X = (A*X + B) % C;
			count++;
			if (count > 10000)
			{
				count = -1;
				break;
			}
		}
		cout << count<< endl;
	}
}

Measured memory_bytes: 1224
#include <stdio.h>
void QQ(int a,int b){
	if( a >= 10 ){
		return ;
	}else if( b < 10 ){
		printf("%dx%d=%d\n",a,b,a*b);
		QQ(a,b+1);
	}else{
		QQ(a+1,1);
	}
}

int main(){
	QQ(1,1);
}

Measured memory_bytes: 0
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn upper_bound(A: &Vec<usize>, x: usize) -> usize {
    let (mut l, mut r): (i64,i64) = (-1, A.len() as i64);

    while r - l > 1 {
        let mid = (l + r) / 2;
        if A[mid as usize] >= x {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r as usize;
}

fn search(ans: &mut Vec<usize>, now: usize, pr: usize, edges: &Vec<Vec<usize>>, A: &Vec<usize>, dp: &mut Vec<usize>) {
    ans[now] = upper_bound(dp, INF - 1);

    for &to in &edges[now] {
        if to == pr {
            continue;
        }
        let i = upper_bound(dp, A[to]);
        let old = dp[i];
        dp[i] = A[to];
        search(ans, to, now, edges, A, dp);
        dp[i] = old;
    }
}

fn main() {
    input! {
        N: usize,
        A: [usize; N],
    }

    let mut edges = vec![vec![]; N];
    for _ in 0..N-1 {
        input! {
            fr: Usize1,
            to: Usize1,
        }
        edges[fr].push(to);
        edges[to].push(fr);
    }

    let mut dp = vec![INF; N];
    dp[0] = A[0];
    let mut ans = vec![0; N];
    search(&mut ans, 0, 0, &edges, &A, &mut dp);

    for &a in &ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 38036
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int a[200000];
signed main() {
	int ans = LLONG_MAX;
	int n; cin >> n;
	int y = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		y += a[i];
	}
	int x = 0;
	for (int i = 0; i < n - 1; i++) {
		x += a[i]; y -= a[i];
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
inline void yes(){cout<<"Yes\n";}
inline void no(){ cout<<"No\n";}
inline void notposs(){cout<<-1<<endl;}
bool tests = 0;


void solve(){
	ll h, n;
	cin>>h>>n;
	vl arr(n);
	for0(i, n)cin>>arr[i];
	if(accumulate(all(arr), 0LL) >= h) return yes();
	no();
}
 
int main(){
	
	motherfucker
	ll t = 1;
	if(tests) cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int c[200005];
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    
    ll memo[200005] {1};
    int last[200005];
    for(int i = 0; i <= 200000; i++){
        last[i] = -1;
    }    
    int pre = -1;

    for(int i = 1; i <= n; i++){
        if(i == 1){
            memo[1] = 1;
        }
        if(c[i] == pre){
            memo[i] = memo[i - 1];
        }
        else{
            if(last[c[i]] == -1){
                memo[i] = memo[i - 1];
            }
            else{
                memo[i] = (memo[i - 1] + memo[last[c[i]]]) % MOD;
            }
        }
        last[c[i]] = i;
        pre = c[i];
    }
    cout << memo[n] << endl;
}

Measured memory_bytes: 3328
#import<iostream>
#define r(i,n) for(int i=0;i<n;i++)
int main(){
    int n;while(std::cin>>n,n){int a[10]={0};r(i,n){int t;std::cin>>t;a[t]++;}r(i,10){if(!a[i])std::cout<<"-"<<"\n";else {{r(j,a[i])std::cout<<"*";}std::cout<<"\n";}}}}

Measured memory_bytes: 3096
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n f <*> getLine >>= print
  where
    f =(\[x, y] -> (x, read y)) <$> words <$> getLine

solve :: [(String, Int)] -> String -> Int
solve xs s = let Just t = lookup s $ snd db in t
  where
    db = foldr f (0, []) xs
    f (mn, i) (t, ls) = (t + i, (mn, t):ls)


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
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; }
int main() {
	ll n;
	cin >> n;
	ll ans = (n / 11) * 2;
	n %= 11;
	if (n && n <= 6) ans++;
	else if (n && n <= 11) ans += 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N);
	vector<ll> B(N);
	vector<ll> C(M);
	vector<ll> D(M);
	rep(i, N) {
		cin >> A.at(i) >> B.at(i);
	}
	rep(i, M) {
		cin >> C.at(i) >> D.at(i);
	}
	ll k = 0;
	ll d = 9999999999999999;
	rep(i, N) {
		k = -1;
		d = 9999999999999999;
		rep(j, M) {
			if (d > abs(A.at(i) - C.at(j)) + abs(B.at(i) - D.at(j))) {
				d = abs(A.at(i) - C.at(j)) + abs(B.at(i) - D.at(j));
				k = j + 1;
			}
		}
		cout <<k << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
int main()
{
    std::string a,b,c;
    std::cin>>a>>b>>c;
    if(a.back()==b.front()&&b.back()==c.front()){
        std::cout<< "YES";
    }
    else{
        std::cout<<"NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

vector<pair<ll, ll>> enum_divors(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back({i, n / i});
        }
    }
    sort(all(res));
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll res = INF;
    vector<pair<ll, ll>> resv = enum_divors(N);
    for (auto p : resv) {
        string a = to_string(p.first);
        string b = to_string(p.second);
        ll min_comp = max(a.size(), b.size());
        res = min(res, min_comp);
    }

    cout << res << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
  int num() { // 異なる集合の数
    int res = 0;
    REP(i, data.size()) res += root(i) == i;
    return res;
  }
};

struct P {
  int id, x, y;
};

struct E {
  int a, b, c;
};

int main2() {
  int N = nextInt();
  vector<P> ps;
  REP(i, N) {
    int x = nextInt();
    int y = nextInt();
    ps.push_back({i, x, y});
  }

  vector<E> es;

  sort(ALL(ps), [](const P& a, const P& b) -> bool {
    return a.x < b.x;
  });

  REP(i, N-1) {
    int c = min(
        abs(ps[i].x - ps[i+1].x),
        abs(ps[i].y - ps[i+1].y));
    es.push_back({ps[i].id, ps[i+1].id, c});
  }

  sort(ALL(ps), [](const P& a, const P& b) -> bool {
    return a.y < b.y;
  });
  REP(i, N-1) {
    int c = min(
        abs(ps[i].x - ps[i+1].x),
        abs(ps[i].y - ps[i+1].y));
    es.push_back({ps[i].id, ps[i+1].id, c});
  }
  sort(ALL(es), [](const E& a, const E& b) -> bool {
    return a.c < b.c;
  });

  UnionFind uf(N);
  ll ans = 0;
  REP(i, es.size()) {
    if (!uf.same(es[i].a , es[i].b)) {
      uf.link(es[i].a , es[i].b);
      ans += es[i].c;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 6132
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>

std::vector<int> graph[100010];

int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;
	int iti;
	static int route1[100010];
	static int route2[100010];
	static int come[100010];
	int route1len,route2len;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	long int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for(i=0;i<100010;i++){
		come[i]=0;
	}

//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	route1[0]=1;
	iti=1;
	j=0;
	come[1]=1;
	while(flag==0){
		flag=1;
		for(i=0;i<graph[iti].size();i++){
			if(come[graph[iti][i]]==0){
				come[graph[iti][i]]=1;
				iti=graph[iti][i];
				j++;
				route1[j]=iti;
				flag=0;
				break;
			}
		}
	}
	route1len=j+1;

	flag=0;
	route2[0]=1;
	iti=1;
	j=0;
	while(flag==0){
		flag=1;
		for(i=0;i<graph[iti].size();i++){
			if(come[graph[iti][i]]==0){
				come[graph[iti][i]]=1;
				iti=graph[iti][i];
				j++;
				route2[j]=iti;
				flag=0;
				break;
			}
		}
	}
	route2len=j+1;

	printf("%d\n",route1len+route2len-1);

	for(i=route1len-1;i>=0;i--){
		if(i!=route1len-1) printf(" ");
		printf("%d",route1[i]);
	}

	for(i=1;i<route2len;i++){
		printf(" %d",route2[i]);
	}


//	printf("計算部分終了\n");
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

int main() {
    int N, M;
    cin >> N >> M;
    // nCr(N, 2) & nCr(M, 2)
    int case_1 = N * (N - 1) / 2;
    int case_2 = M * (M - 1) / 2;
    cout << case_1 + case_2 << endl;
}

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

struct union_find{
    vector<int> par;
    vector<int> rank;
    vector<int> club;
    union_find(int sz){
        par.resize(sz);
        rank.assign(sz,0);
        club.assign(sz,0);
        for(int i = 0;i < sz;++i) par[i]=i;
    }
    int find(int a){
        if(par[a]==a) return a;
        else return par[a] = find(par[a]);
    }
    bool unite(int a,int b){
        bool ans;
        int root_a,root_b;
        root_a = find(a),root_b = find(b);
        if(club[root_a]==0 || club[root_b]==0 || club[root_a]==club[root_b]){    
            if(rank[root_a]>rank[root_b]){
                par[root_b] = root_a;
                if(club[root_a]==0) club[root_a]=club[root_b];
            }else if(rank[root_a]<rank[root_b]){
                par[root_a] = root_b;
                if(club[root_b]==0) club[root_b]=club[root_a];
            }else{
                rank[root_a]++;
                par[root_b] = root_a;
                if(club[root_a]==0) club[root_a]=club[root_b];   
            }
            return 1;
        }
        return 0;
    }
    bool same(int a,int b){return find(a)==find(b);}
};

int main(){
	int n, m, k; cin >> n >> m >> k;
    union_find tree(n+1);
    int tmp1, tmp2, tmp3;
	for(int i=1; i<=k; i++){
        cin >> tmp1 >> tmp2 >> tmp3;
        if(tmp1==1){
            if(!tree.unite(tmp2, tmp3)){
                cout << i << endl;
                return 0;
            }
        }else{
            int r=tree.find(tmp2);
            if(tree.club[r]!=0 && tree.club[r]!=tmp3){
                cout << i << endl;
                return 0;
            }else{
                tree.club[r]=tmp3;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3900
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

char s[12];
int main() {
	scanf("%s",s+1);
	if(s[3]==s[4]&&s[5]==s[6]) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
result = 'No'
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            result = 'Yes'
            break
    else:
        count = 0

print (result)



Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, A, B;
  cin >> N;
  A=0;
  B=0;
  vector<int> vec(N+5);
 for(int i=0;i<N;i++){
 cin >> vec.at(i);
 }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for(int j=0;j<N-1;j++){
  if(vec.at(j)==vec.at(j+1)){if(A==0){A=vec.at(j);}else{B=vec.at(j); break;}
                            j++;}
  }
  long long C;
  C=A*B;
  cout << C << endl;
}

Measured memory_bytes: 640
// problem: "https://atcoder.jp/contests/abc125/tasks/abc125_c"

#include<iostream>
#include<vector>

using namespace std;

int gcd(int a,int b)
{
    if(b==0)
        return a;

    if(a>b)
        return gcd(b,a%b);
    else
        return gcd(a,b%a);
}

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

    vector<int>V(n);
    vector<int>L(n);
    vector<int>R(n);

    int i;
    for(i=0;i!=n;i++)
        cin>>V[i];

    L[0] = V[0];
    R[n-1] = V[n-1];
    for(i=1;i!=n;i++)
    {
        L[i] = gcd(L[i-1],V[i]);
        R[n-i-1] = gcd(R[n-i],V[n-i-1]);
    }

    int m;
    m = L[n-2];
    for(i=1;i!=n-1;i++)
        m = max(m,gcd(L[i-1],R[i+1]));

    m = max(m,R[1]);

    cout<<m;

    return 0;
}


Measured memory_bytes: 1408
// contest.go
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n uint64
	n = nextInt()
	var d uint64
	if n == 1 {
		d = 1
		fmt.Println(d)
		return
	}
	d = sqr(n)
	fmt.Println(d)

}
func nextInt() uint64 {
	sc.Scan()
	i, e := strconv.ParseUint(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func sqr(n uint64) uint64 {
	var a uint64
	var d uint64
	d = n
	for i := n; i != (d * d); i-- {
		for d = 0; i != (d * d); d++ {
			a = i
			if i <= (d * d) {
				break
			}
		}
		if i == (d * d) {
			a = i
			break
		}
		if i < 0 {
			break
		}
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;

    int a[n+1];
    a[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        cin >> a[i];
    }
    
    int b[n+1];
    memset(b,0,sizeof(int)*(n+1));

    for (int i = 2; i <= n; i++)
    {
        b[a[i]]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << b[i] << endl;
    }
    return 0;
}

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

const int maxn = 2e5 + 5;
int a[maxn], b[maxn];

int main(int argc, char const *argv[])
{
//    freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &a[i]);
        b[i] = a[i];
    }sort(b+1, b+n+1);
    for(int i=1; i<=n; i++){
        if(a[i] == b[n]){
            printf("%d\n", b[n-1]);
        }else {
            printf("%d\n", b[n]);
        }
    }

    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    ll x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
current = 0
visited = {0:0} # key => town, value => index
route = [0]
for i in range(1, k+1):
    n = a[current]
    if n in visited.keys():
        index = visited[n]
        remain = k - i
        circle = route[index:i]
        finish = remain % len(circle)
        current = circle[finish]
        break
    else:
        visited[n] = i
        route.append(n)

    current = n

print(current+1)

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

int main(){
    long long X;
    cin>>X;
    long long r=X%500;
    long long p=X/500;
    long long ans=p*1000+(r/5)*5;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		System.out.println( a < c ? a < b ? "Yes" : "No" :"No");

		scan.close();
	}
}

Measured memory_bytes: 26232
#include<iostream>
#include<vector>
using namespace std;
#define P pair<int,int>
int main(){
  int N,T,H,L;
  int remainder;
  int winner;
  cin>>N>>T>>H>>L;
  vector<P>member(N);
  for(int i=0;i<N;i++)cin>>member[i].first>>member[i].second;
  winner=0;
  remainder=0;
  while(1){
    if(member[winner].first + member[winner].second == 0)break;
    bool broken=false;
    if(member[winner].first){
      member[winner].first--;
      remainder+=10;
      T++;
    }else{
      member[winner].second--;
      remainder+=100;
      H++;
    }
    if(T>L)broken=true;
    if(remainder>=90){
      remainder-=90;
      if(remainder/10 > T){
        broken=true;
      }else{
        member[winner].first+=remainder;
        T-=remainder/10;
        remainder=0;
      }
    }
    if(broken)break;
    winner = (winner+1)%N;
  }
  cout<<winner+1<<endl;
}

Measured memory_bytes: 1200
n=int(input())
l=list(map(int,input().split()))
c=[0]
for i in range(1,n):
  if l[i]<l[i-1]:
    k=l[i-1]-l[i]
    l[i]=l[i]+k
    c.append(k)
print(sum(c))
  
  

Measured memory_bytes: 32236
import java.util.Scanner;

public class Main {

   
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.nextLine();
    int count = 0 ;
    for(int i =0 ;i<s.length();i++){
    if(s.charAt(i) == '1'){
    count++;
    }
    }
        System.out.println(count);
}
}

Measured memory_bytes: 23764
#include <iostream>
#include <map>

using namespace std;
 
int main(){
    int N,M;
    map<int, int> m;
  
    cin >> N >> M;

    for(int i = 1; i <= N; i++){
        m.insert(make_pair(i, 0));
    }

    for(int i = 0; i < 2*M; i++){
        int a;
        cin >> a;
        m.at(a)++;
    }

    for(int i = 1; i <= N; i++){
        cout << m.at(i) << endl;
    }

    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  for ( int i = 1; i <= b; i++){
    if ( a * i % b == c ){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

int main() {
	int x, k; scanf("%d%d", &k, &x);
	for (int i = max(x - k + 1, -1000000); i < min(x + k, 1000000); ++i)
		printf("%d ", i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <set>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string s;
    int k;
    cin >> s >> k;
    vector<string> str;
    set<string> st;
    int n = s.length();
    reps(i,1,6){
        rep(j,n-i+1){
            if(st.count(s.substr(j,i)) == 0){
                str.push_back(s.substr(j,i));
                st.insert(s.substr(j,i));
            }
        }
    }

    sort(str.begin(),str.end());
    //for(auto e : str) cout << e << endl;

    cout << str[k-1] << endl;

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, i, q, sum = 0, b, c;
	cin >> n;
	int a[n];
	map<ll, ll> cnt;
	rep(i, 0, n)
	{
		cin >> a[i];
		sum += a[i];
		cnt[a[i]]++;
	}
	cin >> q;
	rep(i, 0, q)
	{
		cin >> b >> c;
		sum += ((c - b) * cnt[b]);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 9932
N = int(input())
A_list = [int(e) for e in input().split()]
B_list = [int(e) for e in input().split()]

#B-Aで過剰/不足を取得
#過剰を並び替え、大きいものから不足に割り当てていく

shortage_list = list()
surplus_list = list()

for i in range(N):
    C = B_list[i]-A_list[i]
    if C > 0:
        shortage_list.append(C)
    elif C < 0:
        surplus_list.append(-C)
        
if sum(surplus_list) < sum(shortage_list):
    print(-1)
elif len(shortage_list) == 0:
    print(0)
else:
    surplus_list.sort(reverse=True)
    sum_shortage = sum(shortage_list)
    for i in range(len(surplus_list)):
        sum_shortage -= surplus_list[i]
        if sum_shortage <= 0:
            print(i + 1 + len(shortage_list))
            break

Measured memory_bytes: 18356
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i = 0, temp, sorted, minimum, sum = 0, ans = 0;
		Scanner sc = new Scanner(System.in);
		while (true) {
			sum = 0;
			ans = 0;
			int n = sc.nextInt();
			int[] score = new int[100];
			if (n == 0)
				break;
			for (i = 0; i < n; i++)
				score[i] = sc.nextInt();

			for (sorted = 0; sorted < n; sorted++) {
				minimum = sorted;
				for (i = sorted + 1; i < n; i++) {
					if (score[i] < score[minimum]) {
						minimum = i;
					}
				}
				temp = score[minimum];
				score[minimum] = score[sorted];
				score[sorted] = temp;
			}
			score[0] = 0;
			score[n - 1] = 0;
			for (i = 0; i < n; i++)
				sum += score[i];
			ans = sum / (n - 2);
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 28668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < 10; ++j)
            cin >> F[i][j];
    for(int i = 0; i < N; ++i)
        for(int j = 0; j <= 10; ++j)
            cin >> P[i][j];

    int ans = -INF;
    for(int i = 1; i < (1 << 10); ++i) {
        int sum = 0;
        for(int j = 0; j < N; ++j) {
            int cnt = 0;
            for(int k = 0; k < 10; ++k) {
                if(i & (1 << k))
                    cnt += F[j][k];
            }
            sum += P[j][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x,y,z,w;
    x = c - (d-b);
    y = d + (c-a);
    z = x - (c-a);
    w = y - (d-b);
    printf("%d %d %d %d\n", x, y, z, w);
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	string t;cin>>t;
	string ans="";
	repi(i,t.size()){
		if(t[i]=='?'){
			ans+='D';
		}
		else ans+=t[i];
	}
	db(ans);
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
long long a[100001],n,t1,t2,f=1,t3;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		if(a[i]==a[i-1]&&f==0)
		{
			t2=a[i];
			break;
		}
		if(a[i]==a[i-1]&&f==1)
		{
			t1=a[i];
			i--;
			f=0;
		}
	}
	cout<<t1*t2; 
}	


Measured memory_bytes: 1024
class Stack:
    def __init__(self, full_idx=10):
        self.stack = [None] * full_idx
        self.top = 0
        self.MAX = full_idx

    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.MAX - 1

    def push(self, x):
        if self.is_full():
            raise IndexError

        self.top += 1
        self.stack[self.top] = x

    def pop(self):
        if self.is_empty():
            raise IndexError

        self.top -= 1
        return self.stack[self.top+1]


def main():
    s = input()
    s1, s2 = Stack(20000), Stack(20000)
    pond = [0]
    area = 0

    for i in range(len(s)):
        if s[i] == "\\":
            s1.push(i)
            s2.push([i, 0])

        elif s[i] == "/":
            if not s1.is_empty():
                area += i - s1.pop()
            if not s2.is_empty():
                tup = s2.pop()
                area2 = 0

                while tup[1] != 0:
                    tup2 = s2.pop()
                    tup, tup2 = tup2, tup
                    area2 += tup2[1]

                tup[1] = i - tup[0] + area2

                if s2.is_empty():
                    pond.append(tup[1])
                else:
                    s2.push(tup)

    s3 = Stack(20000)
    while not s2.is_empty():
        ss = s2.pop()
        if ss[1] != 0:
            s3.push(ss)

    while not s3.is_empty():
        pond.append(s3.pop()[1])

    pond[0] = len(pond) - 1
    print(area)
    print(" ".join([str(i) for i in pond]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 8232
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S,T; cin>>S;
    ll N=S.size();
    vector<ll> A;
    ll ct=0;
    rep(i,N){
        if(S[i]!='x') {T+=S[i];A.emplace_back(ct);ct=0;}
        else ++ct;
    }
    A.emplace_back(ct);
    ll nt=T.size();
    rep(i,nt){
        if(T[i]!=T[nt-1-i]) dame;
    }
    ll ans=0;
    rep(i,A.size()){
        ans+=abs(A[i]-A[A.size()-1-i]);
    }
    cout<< ans/2 <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1608
from collections import deque
s=deque(input())
q=int(input())
cnt=0
for i in range(q):
    query=list(input().split())
    if query[0]=="1":
        cnt+=1
    else:
        if (cnt+int(query[1]))%2==1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
if cnt%2==1:
    s=reversed(s)
print("".join(s))

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

using ll = long long;
using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define Min(a,b) a=min(a,b)

const ll oo = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n,m,t;
	cin>>n>>m>>t;
	vi ord[m];	
	f(i,0,m) ord[i].pb(n);
	f(_,0,t) {
		int x,y; cin>>x>>y;
		ord[--y].pb(--x);
	}
	f(i,0,m) sort(all(ord[i]));	
	int ans = oo;
	int i = 0;
	f(j,0,m) {
		auto it = upper_bound(ord[j].begin(),ord[j].end(),i);
		Min(ans,*it);
		if (*it == i+1 || j == m-1) break;
		i++;
		while (i+1<*it && *lower_bound(all(ord[j+1]),i) == i)
			i++;
		if (*lower_bound(all(ord[j+1]),i) == i)
			break;
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 11648
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
int s[100000];
map<P, ll> dp;
int main() {
	int N;
	cin >> N;
	rep(i, N) cin >> s[i];
	ll ans = 0;
	for (int C = 1; C < N - 1; C++) {
		dp[P(C, 0)] = 0;
		set<int> S;
		S.insert(0);
		S.insert(N - 1);
		for (int k = 1; (k + 1)*C < N - 1; k++) {
			if ((N - 1) - k * C == k * C || S.count(k*C) > 0 || S.count((N - 1) - k * C) > 0) break;
			S.insert(k*C);
			S.insert((N - 1) - k * C);
			dp[P(C, k)] = dp[P(C, k - 1)] + s[k*C] + s[(N - 1) - k * C];
			ans = max(ans, dp[P(C, k)]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 74752
n = int(input())
l = [int(x) for x in input().split()]
l1 = [0 for x in range(n)]
for i in range(n-1):
	if l[i] > max(l1[i], l1[i+1]):
		if i == 0:
			l1[i] = l[i]
			l1[i+1] = l[i]
		else:
			l1[i+1] = l[i]
	else:
		l1[i] = l[i]
		l1[i+1] = l[i]
	
print(sum(l1))

Measured memory_bytes: 3064