akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vector<string> v;  // 解の候補の集合
    exrep(i, 0, n-m) {  // sのi文字目からm文字がtと一致できるかチェックする
        bool ok = true;
        rep(j, m) {  // tのj文字目をチェックする
            if(t[j] != s[i+j] && s[i+j] != '?') {
                ok = false;
                break;
            }
        }
        if(ok) {
            string x = s;
            rep(j, m) {
                x[i+j] = t[j];
            }
            rep(j, n) {
                if(x[j] == '?') {
                    x[j] = 'a';
                }
            }
            v.pb(x);
        }
    }

    if(v.size() == 0) {
        out("UNRESTORABLE");
        re0;
    }

    sort(all(v));
    
    out(v[0]);
    re0;
}

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

using ll = long long;

constexpr ll inf = 1e18;

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


    vector<vector<ll>> dp(n, vector<ll>(n, inf));
    function<ll(int, int)> rec = [&] (int l, int r) {
        if(l == r) return 0LL;
        if(dp[l][r] != inf) return dp[l][r];
        ll& res = dp[l][r];
        for(int mid = l; mid < r; ++mid) {
            res = min(res, rec(l, mid) + rec(mid + 1, r) + sum[r + 1] - sum[l]);
        }
        return res;
    };

    cout << rec(0, n - 1) << endl;
}


Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> integers = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            integers.add(Integer.valueOf(scanner.nextInt()));
        }
        int result = 0;
        for(int i = 0; i < integers.size() - 2; i++){
            int p1 = integers.get(i);
            int p2 = integers.get(i+1);
            int p3 = integers.get(i+2);
            if(p1 < p2 && p2 < p3 || p3 < p2 && p2 < p1)
                result++;
        }
        System.out.println(result);
    }
}

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

int a[105];

int maxi = -1;
int mini = 100000;

int main()
{
    int n;

    cin >> n;


    for(int i = 1 ; i<=n ; i++)
    {
        cin >> a[i];
        mini = min(mini , a[i]);
        maxi = max(maxi , a[i]);
    }

    cout << maxi-mini;


    return 0;
}


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

char A[101],B[101];
int al,bl,ok;

int main()
{
    scanf("%s%s",A,B);
    al=strlen(A);
    bl=strlen(B);

    if(al>bl)ok=1;
    else if(al<bl)ok=-1;
    else
	for(int i=0;i<al;++i)
	    if(A[i]!=B[i])
	    {
		ok=((A[i]>B[i])<<1)-1;
		break;
	    }

    if(ok==1)puts("GREATER");
    else if(ok)puts("LESS");
    else puts("EQUAL");
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;

  vector<int> a;
  int value = n;

  int first = value % 10;
  value /= 10;

  int second = value % 10;
  value /= 10;
  int third = value % 10;

  if (first == 7 || second == 7 || third == 7){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String s = sc.next();
		int w = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i += w) {
			sb.append(s.charAt(i));
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 21588
open System
open System.Collections.Generic
open System.Linq
open System

// Following contents are my library. The Main processes are on the bottom of this code.

let putn = Console.WriteLine : 'a -> unit
let put = Console.Write : 'a -> unit
let Read() = Console.ReadLine()
let Reads () = Console.ReadLine().Split()
let ReadInt () = Read() |> int
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])
let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)
let ReadIntTriple () = ReadTriple () |> FuncTriple int int int
let ReadIntDouble () = ReadDouble () |> FuncDouble int int
let ensmallen l = l % 1000000007L
let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)
let sayYESNO b = if b then putn "YES" else putn "NO"


// The main contents of this submission are below this line.

let n = ReadInt()
(if n % 2 = 0 then  n else n * 2) |> putn


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#define FOR(i,a,b) for(int i=(a);i<int(b);i++)
using namespace std;

const int MAX_V = 100000; // ???????????°????????§???
const int MAX_E = 500000; // ????????°????????§???
const int INF = INT_MAX;

struct E{
  int to, cost;
  E(int t, int c) : to(t), cost(c){};
};

typedef pair<int,int> pii;

int v; // ????????°
vector<E> g[MAX_V]; // ??£??\?????????
int d[MAX_V]; // ??????s????????????????????¢

void dijkstra(int s)
{
  fill(d,d+v,INF);
  d[s] = 0;
  priority_queue<pii,vector<pii>,greater<pii> > q;
  q.push(pii(0,s));

  // ??????s????????????????????????????????¢????¨????
  while(!q.empty()){
    /* ???????¢???????????????????????????????????????¢???????°???????????????¢??? */
    pii p = q.top();
    q.pop();
    int from = p.second;
    if(d[from] < p.first) continue; // ???????????¢??§???????????°??????
    
    FOR(i,0,g[from].size()){
      int to = g[from][i].to;
      int cost  = g[from][i].cost;

      if(d[to] > d[from] + cost){ // ???????????¢??¨??????????????´???
        d[to] = d[from] + cost;
        q.push(pii(d[to],to)); // ???????????¢???????£?????????????????????\
      }
    }
  }
}

int main()
{
  int gv, ge, gr; // gv???????????°???ge???????????°???gr????§????
  cin >> gv >> ge >> gr;
  v = gv;
  FOR(i,0,ge){
    int gs, gt, gd;
    cin >> gs >> gt >> gd; // ge??????????§???????gt??????????????????gd???????????????
    g[gs].push_back(E(gt,gd));
  }

  dijkstra(gr);

  FOR(i,0,v){
    if(d[i] != INF)
      cout << d[i] << endl;
    else // ??????i?????????????????´???
      cout << "INF" << endl;
  }
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    ll n;
    cin >> n;
    set<string>s;
    for (ll i = 0; i < n; i++) {
        string x;
        cin >> x;
        s.insert(x);

    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19144
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n,m,i,a[65000],b[65000],l,p,q,x;
int main(void)
{
	
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		p=0;q=n-1;
		for(i=0;i<n;i++) scanf("%d",&a[i]),p+=a[i];
		for(i=0;i<n-1;i++) scanf("%d",&b[i]);
		/*for(i=0;i<n-2;i++){
			for(l=i+1;l<n-1;l++){
				if(b[i]<b[l]){
					m=b[i];
					b[i]=b[l];
					b[l]=m;
				}
			}
		}*/
		sort(b-1,b+q);
		//for(i=n-2;i>=0;i--) printf("%d\n",b[i]);
		x=p*n;
		for(i=n-2;i>=0;i--){
			if(x<(p+b[i])*q) x=(p+b[i])*q;
			p+=b[i];
			//printf("%d\n",p);
			if(q>1) q--;
		}
		printf("%ld\n",x);
	}
	return 0;
}


Measured memory_bytes: 3808
s = input()
n = len(s)
d = int(input())
dp = [[[0,0] for _ in range(d)] for _ in range(n+1)]
mod = 10**9 + 7
dp[0][0][1] = 1

for i in range(n):
    for j in range(d):
        for k in range(10):
            dp[i+1][(j+k)%d][0] += dp[i][j][0]
            dp[i+1][(j+k)%d][0] %= mod
        for k in range(int(s[i])):
            dp[i+1][(j+k)%d][0] += dp[i][j][1]
            dp[i+1][(j+k)%d][0] %= mod
        dp[i+1][(j+int(s[i]))%d][1] += dp[i][j][1]
print((sum(dp[n][0])-1)%mod)


Measured memory_bytes: 129372
#include<cstdio>
using namespace std;
int main(){
  char s[2][4];
  scanf("%s",s[0]);
  scanf("%s",s[1]);
  if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0])
    printf("YES\n");
  else
    printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n;
string s;
set<string> st;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << '\n';
}


Measured memory_bytes: 19148
import sys
input = sys.stdin.readline
from collections import Counter, deque

INF = float('inf')


def main():
    S = input().rstrip()
    length = len(S)
    S_left = S[:length // 2]
    S_right = S[length // 2:][::-1]

    if S_left == S_right:
        print(0)
        exit()
    else:
        counter = 0
        for i in range(len(S_left)):
            if S_left[i] != S_right[i]:
                counter += 1
        print(counter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a;
  cin>>a;
  cout<<double(a/2+a%2)/a;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	int c[3]={};
	fori(n){
		ll a;cin>>a;
		if(a%2!=0){
			++c[0];
		}else if(a%4==0){
			++c[2];
		}else{
			++c[1];
		}
	}
	if(c[0]-1>c[2]||(c[0]-1==c[2]&&c[1]>0)){
		cout<<"No\n";
	}else{
		cout<<"Yes\n";
	}
}

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

void hurui(vector<bool> &primes){
  int n = primes.size();
  primes[0] = primes[1] = false;
  for(int i=2;i<n;i++){
    if(!primes[i])
      continue;
    for(int j=2;i*j<n;j++)
      primes[i*j] = false;
  }
  
}


int main(){
  vector<bool> primes(100001, true);
  hurui(primes);
  vector<int> ruiseki(100001, 0);
  for(int i=1;i<=100000;i++)
    ruiseki[i] = ruiseki[i-1] + ((i % 2 && primes[i]&&primes[(i+1)/2])?1:0);
  
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int l, r;
    cin >> l >> r;
  	cout << ruiseki[r] - ruiseki[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
dic = {}
for _ in range(N):
    S = input()
    if S[0] not in "MARCH":
        continue
    if S[0] not in dic:
        dic[S[0]] = 0
    dic[S[0]]+=1
ans = 0

for a in dic:
    for b in dic:
        for c in dic:
            if a == b or b == c or c == a:
                continue
            ans += dic[a] * dic[b] * dic[c]
print(ans // 6)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
const int maxn=(int)1e5+5;
int x[maxn];
int main() {
	int n,k;scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i) scanf("%d",&x[i]);
	int ans=0x3f3f3f3f;
	for(int i=0;i<n-k+1;++i) ans=std::min(ans,std::min((abs(x[i])+x[i+k-1]-x[i]),abs(x[i+k-1])+x[i+k-1]-x[i]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    p = IR(n)
    q = [None for i in range(n + 1)] + [-1]
    for i in range(n):
        q[p[i]] = i
    ans = 0
    tmp = 1
    for i in range(2, n + 2):
        if q[i - 1] < q[i]:
            continue
        ans = max(ans, i - tmp)
        tmp = i
    print(n-ans)
    return
#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 65756
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,N,M,K;
  double x=0,sum=0,ans;
  cin>>N;
  vector<double> v(N);
  rep(i,N){
    cin>>v[i];
  }
  vsort(v);
  x=v[0];
  rep1(i,N){
    x=(x+v[i])/2.0;
  }
  cout<<x<<endl;
  return 0;
}

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

inline bool check(int p, int q, int m, int n) {
	const int square_sum = m * m + n * n;
	return !((m * p + n * q) % square_sum || (m * q - n * p) % square_sum);
}

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

	const int MAX = 20000;

	int t;
	cin >> t;

	unordered_set<int> s;
	for(int i = 0; i * i < MAX; ++i) {
		const int rest = MAX - i * i;
		for(int j = (i ? i : 2); j * j < rest; ++j) {
			s.insert(i * i + j * j);
		}
	}

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

		const int square_sum_mn = m * m + n * n;
		for(int x = 0; x * x < square_sum_mn; ++x) {
			const int rest = square_sum_mn - x * x;
			for(int y = (x ? x : 2); y * y < rest; ++y) {
				const int square_sum_xy = x * x + y * y;
				if(square_sum_mn % square_sum_xy == 0
				   && s.find(square_sum_mn / square_sum_xy) != s.end()) {
					if(check(m, n, x, y) || check(m, n, -x, y)
					   || check(m, n, x, -y) || check(m, n, -x, -y)) {
						goto not_prime;
					}
				}
			}
		}

		cout << 'P' << endl;
		continue;

	not_prime:;
		cout << 'C' << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon\n";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon\n";
            break;
        case 3:
            cout<<"bon";
            break;
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

int n,k,cnt[2],ans;
string s;
int32_t main(){
    cin>>n>>s;
    ans=n;
    rep(i,0,n){
	cnt[1]+=s[i]=='E';
    }
    rep(i,0,n){
	cnt[1]-=s[i]=='E';
	ans=min(ans,cnt[0]+cnt[1]);
	cnt[0]+=s[i]=='W';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 900
#include <cstdio>
#include <algorithm>

int a[100001];
int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
  {
    int b;
    scanf("%d", &b);
    a[i + 1] = (a[i] + b) % m;
  }
  std::sort(a, a + n + 1);
  long long ans = 0;
  for (int l = 0; l < n + 1;)
  {
    int r = std::upper_bound(a + l, a + n + 1, a[l]) - a;
    long long p = r - l;
    ans += p * (p - 1) / 2;
    l = r;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
  int h, m, s;
  int S;

  cin >> S;
  h = S / (60 * 60);
  S %= (60 * 60);
  m = S / (60);
  s = S % 60;
  cout << h << ':' << m << ':' << s << endl;
  
  return  0;
}



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

int main(){
    int a,b;
    cin>>a>>b;

    if(a<b){
        for (size_t i = 0; i < b; i++)
        {
            cout << a;
        }
        
    } else {
        for (size_t i = 0; i < a; i++)
        {
            cout << b;
        }
        
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

const int MAX_N = 100005;

double add(double a,double b)
{
    if(abs(a+b) < EPS * (abs(a) + abs(b))){
        return 0;
    }
    return a + b;
}

struct P
{
    double x,y;
    P() {}
    P(double x,double y) : x(x),y(y) {}
    P operator + (P p){
        return P(add(x,p.x),add(y,p.y));
    }
    P operator - (P p){
        return P(add(x,-p.x),add(y,-p.y));
    }
    P operator * (double d){
        return P(x*d,y*d);
    }
    double dot(P p){
        return add(x*p.x,y*p.y);
    }
    double det(P p){
        return add(x*p.y,-y*p.x);
    }
};

int n;
P ps[MAX_N];

bool cmp_x(const P& p,const P& q)
{
    if(p.x != q.x){
        return p.x < q.x;
    }
    return p.y < q.y;
}

vector<P> convex_hull(P* ps,int n)
{
    sort(ps,ps+n,cmp_x);
    int k = 0;
    vector<P> qs(n*2);
    rep(i,n){
        while(k > 1 && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) < 0){   //????????????=?????\????????¨?????????????????????
            k--;
        }
        qs[k++] = ps[i];
    }
    for(int i = n-2,t=k;i >= 0;i--){
        while(k > t && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) < 0){
            k--;
        }
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

double dist(P p,P q)
{
    return (p-q).dot(p-q);
}

int main()
{
    scanf("%d",&n);
    rep(i,n){
        int a,b;
        scanf("%d%d",&a,&b);
        ps[i] = P(a,b);
    }
	vector<P> qs = convex_hull(ps,n);
    if(n <= qs.size()){   //???????????°??????????????´????????????
        cout << "1\n";
    }else{
        cout << "0\n";
    }
	return 0;
}

Measured memory_bytes: 3164
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 1e3 + 5;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;


int main()
{
    int a,b,w;
    cin>>w>>a>>b;
    int ans;
    if(a<b){
        ans=max(0,b-a-w);
    }
    else{
        ans=max(0,a-b-w);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int M, D;
  int count = 0;
  cin >> M >> D;
  for (int i = 4; i <= M; i++){
    for (int v = 22; v <= D; v++){
      int a, b;
      a = v / 10;
      b = v % 10;
      if (b <= 1){
        continue;
      }
      
      if (a*b == i){
        count += 1;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}


ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)


const long double pi = acos(-1);
const long double eps = 0.0000000001;

long double a, b, x;

void input(){
    cin >> a >> b >> x;
}

long double f(long double a, long double b, long double theta){
    if(theta > pi / 2.0 - eps) return 0.0;
    long double ret;
    if(a * tan(theta) <= b){
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    }
    else{
        ret = b * b * a / tan(theta) / 2.0;
    }
    return ret;
}

void solve(){
    input();
    long double ok = pi / 2.0;
    long double ng = 0.0;
    for(int _=0; _<100000; ++_){
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << setprecision(12) << ok * 180 / pi << endl;
}


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

    solve();
    
    return 0;
}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii3(a,b,c); ii2(x,y); int res;
    if(a+b > c*2){
        if(x > y){
            swap(x, y); swap(a, b);
        }
        res = x * c * 2;
        if(b > c*2) res += (y-x) * c * 2;
        else res += (y-x) * b; 
    }
    else{
        res = a*x + b*y;
    }
    out(res);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
/* にゃーん  */
int main(){
   char a[3];
   int x = 0;
    cin >> a;
    for(int i = 0;i < 3; i++){
        if(a[i] == 'o'){
            x++;
        }
    }
    cout << x*100+700 << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
used=[]
used.append(input())
chain=used[0][-1]
res="Yes"
for i in range(n-1):
    s=input()
    c=s[0]
    if s in used or chain!=c:
        res="No"
        break
    used.append(s)
    chain=s[-1]
    

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(S == "SSS") cout << 0 << endl;
  else if(S == "RRR") cout << 3 << endl;
  else if(S == "SRR") cout << 2 << endl;
  else if(S == "RRS") cout << 2 << endl;
  else cout << 1 << endl;
  
  return 0;
}



Measured memory_bytes: 3596
import sys


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


while 1:
    x = LI()
    if x[0] == 0 and x[1] == 0:
        break
    x.sort()
    print(x[0], x[1])



Measured memory_bytes: 5900
//package abc045a;

import java.util.*;
public class Main {

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


	}

}


Measured memory_bytes: 21716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};


typedef struct _state{
  int from,vis;
  double cost;
  bool operator<(const _state&r)const{
    return cost>r.cost;
  };
}state;

vector<PI> V[30];

main(){
  int n,m,p,a,b;
  while(cin>>n>>m>>p>>a>>b,n){
    --a,--b;
    int ti[n];
    rep(i,n)scanf("%d",ti+i);//cin>>ti[i];

    rep(i,m)V[i].clear();

    rep(i,p){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      //cin>>x>>y>>z;
      --x,--y;
      V[x].pb(mp(y,z));
      V[y].pb(mp(x,z));
    }

    priority_queue<state> Q;
    state st;
    st.cost=0;
    st.vis=0;
    st.from=a;
    Q.push(st);

    double cost[1<<n][m];
    rep(i,1<<n)rep(j,m)cost[i][j]=1<<26;
    double ans=-1;

    while(!Q.empty()){
      int from=Q.top().from,cti=Q.top().vis;
      double ccost=Q.top().cost;
      Q.pop();
      if(cost[cti][from]<=ccost)continue;
      cost[cti][from]=ccost;
      if(from==b){
	ans=ccost;
	break;
      }

      rep(i,n){
	if(cti>>i&1)continue;
	rep(j,V[from].size()){
	  int to=V[from][j].first;
	  int cc=V[from][j].second;
	  double ncost=ccost+1.0*cc/ti[i];
	  st.from=to;
	  st.vis=cti|1<<i;
	  st.cost=ncost;
	  Q.push(st);
	}
      }
    }
    if(ans<0)cout<<"Impossible"<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 7880
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = sum(A)
    d = Counter(A)
    Q = int(input())
    for i in range(Q):
        b, c = map(int, input().split())
        if b in d:
            s += (c - b) * d[b]
            d[c] = d.get(c, 0) + d[b]
            d[b] = 0
        print(s)
main()


Measured memory_bytes: 21288
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>


using namespace std;

ll gcd(ll q, ll r)
{
  if (r == 0)
  {
    return q;
  }
  return gcd(r, q % r);
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

    ll ans=gcd(A[0],A[1]);
    FOR(i,2,N){
        ans = gcd(A[i],ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200009);

mint c(int n,int k){
  mint a=1,b=1;
  rep(i,k){
    a*=n-i;
    b*=k-i;
  }
  return a/b;
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  mint ans=mint(2).pow(n)-1;
  ans-=c(n,a);
  ans-=c(n,b);
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<bitset>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////
ll N, M;

vector<vector<ll>> g;
vector<ll> con;

bool dfs(ll v) {
	bool ret = 1;

	for (ll w : g[v]) {
		ll x = (con[v] + 1) % 2;

		if (con[w] == -1) {
			con[w] = x;
			bool b = dfs(w);
			if (!b) { ret = 0; }
		}

		else if (con[w] != x) { ret = 0; }
	}

	return ret;
}

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

	g.resize(N + 1);
	repn(i, M) {
		ll u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	con.assign(N + 1, -1);

	ll od = 0, ev = 0, isol = 0;

	repn(v, N) {
		if (con[v] != -1) { continue; }

		if (g[v].size() == 0) { isol++; continue; }

		con[v] = 0;
		bool b = dfs(v);
		if (b) { ev++; }
		else { od++; }
	}

	ll ans = 2 * N*isol - isol * isol;
	ans += (ev + od)*(ev + od) + ev * ev;

	cout << ans << endl;
	
	system("PAUSE");
}

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

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    int x;
    if(a <= b){
        x = b - (a+w);
    }else{
        x = a - (b+w);
    }
    if(x < 0){
        cout << 0 << endl;
    }else{
        cout << x << endl;
    }

    return 0;
}



Measured memory_bytes: 256
N, M = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**5) * 2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    c = 0
    while n % i == 0:
      n /= i
      c+=1
    if c!=0:
        table.append(c)
    i += 1
  if n > 1:
    table.append(1)
  return table

xxs = prime_decomposition(M)

result = 1
for xx in xxs:
    result = mul(result, cmb(xx+N-1,xx,mod))
print(result)


Measured memory_bytes: 27040
#include <cstdio>

int main(void) {
	char s[5];
	scanf("%s", s);
	int result = 0;
	for(int i = 0; i < 4; i++) {
		for(int j = i + 1; j < 4; j++) {
			result += s[i] == s[j] ? 1 : 0;
		}
	}

	printf(result == 2 ? "Yes\n" : "No\n");
	return 0;
}

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

using namespace std;

int D[10000];
int A[105][105];
int main()
{
	int c = 1;
	int N, H, W;
	scanf("%d%d%d", &H, &W, &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	for(int i = 1; i <= H; i++){
		if( i&1 ){
			for(int j = 1; j <= W; j++){
				if( !D[c] ) c++; D[c]--;
				A[i][j] = c;
			}
		}
		else{
			for(int j = W; j >= 1; j--){
				if( !D[c] ) c++; D[c]--;
				A[i][j] = c;
			}
		}
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			printf("%d ", A[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll lcm = C * D / gcd(C, D);
    ll c = B / C - (A - 1) / C, d = B / D - (A - 1) / D, cd = B / lcm - (A - 1) / lcm;
    cout << B - A + 1 - c - d + cd << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(N):
    if visited[i]:
        continue
    ans += 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to)
print(ans)

Measured memory_bytes: 70176
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<ll>());
  ll i = 0;
  ll x1 = 0;
  ll x2 = 0;
  while (i+1 < N) {
    if (A.at(i) == A.at(i+1)) {
      if (x1 == 0) {
	x1 = A.at(i);
      }else {
	x2 = A.at(i);
	break;
      }
      i += 2;
    }else {
      i ++;
    }
  }
  cout << x1 * x2 << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

map<int64, int64> decomposition_factorical(int64 N) {
  map<int64, int64> result;
  for (int64 n = 2; n <= N; n++) {
    int64 tmp = n;
    int64 amari;
    for (int64 i = 2; i <= n; i++) {
      if (tmp == 1) {
        break;
      }
      amari = tmp % i;
      if (amari == 0) {
        if (!result.count(i)) {
          result[i] = 0;
        }
        while (amari == 0) {
          tmp /= i;
          result[i]++;
          amari = tmp % i;
        }
      }
    }
  }
  return result;
}

int main() {
  int64 divide_by = pow(10, 9) + 7;
  int64 N;
  cin >> N;
  map<int64, int64> factorical_decomposition_map = decomposition_factorical(N);
  int64 result = 1;
  for (auto p : factorical_decomposition_map) {
    auto value = p.second;
    result *= value + 1;
    result %= divide_by;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<string> split_sentence(string s){
  vector<string> res;
  REP(i, s.size()) if(s[i] == '.') s[i] = ' ';
  stringstream ss(s);
  string t;
  while(ss >> t){ res.push_back(t); }
  return res;
}

bool comp(string s, string t){
  if(s.size() != t.size()) return s.size() > t.size();
  return s > t;
}

class DFSError{};

bool answer_exist;
string answer;
int mem[80];
int match[26];
string sentence;
vector<string> words;
vector<string> ciphers;
void dfs(int k){
  if(k == ciphers.size()){
    if(answer_exist) throw DFSError();
    answer_exist = true;
    answer = sentence;
    REP(i, answer.size()) if(isupper(answer[i])) answer[i] = match[answer[i] - 'A'] + 'A';
  }else{
    string& cipher = ciphers[k];
    int save_match[26];
    memcpy(save_match, match, sizeof match);
    REP(i, words.size()) if(words[i].size() == cipher.size()){
      string& word = words[i];

      bool ok = true;
      REP(j, word.size()){
        int A = word[j] - 'A';
        int B = cipher[j] - 'A';
        if(match[A] == -1 && match[B] == -1){
          match[A] = B;
          match[B] = A;
        }else if(match[A] == B && match[B] == A){
        }else{
          //printf("match[%c] = %c, match[%c] = %c\n", A + 'A', match[A] + 'A', B + 'A', match[B] + 'A');
          ok = false;
          break;
        }
      }

      if(ok){
        mem[k] = i;
        dfs(k + 1);
      }

      memcpy(match, save_match, sizeof match);
    }
  }
}

int main(){
  int N;
  while(cin >> N && N){
    words.assign(N, "");
    REP(i, N) cin >> words[i];
    cin.ignore();

    getline(cin, sentence);
    ciphers = split_sentence(sentence);

    sort(words.begin(), words.end());
    words.erase(unique(words.begin(), words.end()), words.end());
    sort(ciphers.begin(), ciphers.end(), comp);
    ciphers.erase(unique(ciphers.begin(), ciphers.end()), ciphers.end());

    try{
      answer_exist = false;
      memset(match, -1, sizeof match);
      dfs(0);
      assert(answer_exist);
      cout << answer << endl;
    }catch(DFSError e){
      cout << "-." << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1308
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, K, vs[MAX_N];
  scanf("%d %d", &N, &K);
  // printf("N = %d, K = %d\n", N, K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &vs[i]);
    // printf("%d ", vs[i]);
  }
  // printf("\n");

  // solve try all
  int ans = -INF, us[MAX_N];
  for (int nl = 0; nl <= N; nl++) {
    for (int nr = 0; nl + nr <= min(N, K); nr++) {
      // take nl from the left and nr from the right
      const int n = nl + nr;
      for (int i = 0; i < nl; i++) {
        us[i] = vs[i];
      }
      for (int i = 0; i < nr; i++) {
        us[nl + i] = vs[N - 1 - i];
      }
      // printf("nl = %d, nr = %d\n", nl, nr);
      // for (int i = 0; i < n; i++) {
      //   printf("%d ", us[i]);
      // }
      // printf("\n");
      // sort us
      sort(us, us + n);
      // calculate ans_local, the max score after returning some elements
      int ans_local = 0;
      for (int i = 0; i < n; i++) {
        if (!(i < K - n && us[i] < 0)) {
          ans_local += us[i];
        }
      }
      // update ans
      ans = max(ans, ans_local);
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))

Measured memory_bytes: 12536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n;
        cin>>n;
        vector<lld>ar(n);
        for(i=0;i<n;i++)
            cin>>ar[i];
        lld ans=0;
        for(i=1;i<n;i++)
        {
            if(ar[i]<ar[i-1])
                ans+=ar[i-1]-ar[i],ar[i]=ar[i-1];
        }
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 4756