akhauriyash/Code-Regression huggingface dataset:
inf = 10**9

def main():
  N = int(input())
  h = list(map(int,input().split()))
  memo = [inf]*N
  memo[0] = 0
  
  def calcCost(start,goal,h):
    return abs(h[goal]-h[start])
  
  for i in range(1,N):
    memo[i] = min(memo[i],memo[i-1]+calcCost(i-1,i,h))
    if i > 1:
      memo[i] = min(memo[i],memo[i-2]+calcCost(i-2,i,h))
  print(memo[-1])

main()

Measured memory_bytes: 20580
fn main() {
  let nmk = read::<usize>();
  let (n, m, k) = (nmk[0], nmk[1], nmk[2] as i64);
  let mut a = read::<i64>();
  let mut b = read::<i64>();
  
  // aとbを累積和にする
  a.insert(0, 0);
  for i in 1..=(n as usize) {
    a[i] += a[i-1];
  }
  b.insert(0, 0);
  for j in 1..=(m as usize) {
    b[j] += b[j-1];
  }

  // しゃくとり
  let mut i = a.iter().rposition(|x| x <= &k).unwrap_or(0);
  let mut j = b.iter().rposition(|y| &a[i] + y <= k).unwrap_or(0);
  let mut max = i + j;
  while j <= m && i > 0 {
    i -= 1;
    while j < m && a[i] + b[j+1] <= k {
      j += 1;
    };
    if i + j > max {
      max = i + j;
    };
  };

  println!("{}", max);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


Measured memory_bytes: 7880
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto s = read!string;
    writeln("2018", s[4..$]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

template<typename T>
struct SegmentTree{
private:
    int n;
    vector<T> node;
    using F=function<T(T,T)>;
    F op;
    T id;
    T get(int a,int b,int k,int l,int r){
        if(b<=l||r<=a)return id;
        if(a<=l&&r<=b){
            return node[k];
        }
        else{
            return op(get(a,b,2*k+1,l,(l+r)/2),get(a,b,2*k+2,(l+r)/2,r));
        }
    }
public:
    SegmentTree(int sz,F op,T id):op(op),id(id){
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1,id);
    }
    SegmentTree(const vector<T> & v, F op,T id):SegmentTree(v.size(),op,id){
        for(int i=0;i<v.size();++i){
            node[i+n-1]=v[i];
        }
        for(int i=n-2;i>=0;--i){
            node[i]=op(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int a,T x){
        a+=n-1;
        node[a]=x;
        while(a>0){
            a=(a-1)/2;
            node[a]=op(node[2*a+1],node[2*a+2]);
        }
    }
    T get(int a){
        return node[a+n-1];
    }
    T get(int a,int b){
        return get(a,b,0,0,n);
    }
};

int main(){
    int n,q;
    string s;
    cin>>n>>s>>q;
    auto f=[](int a,int b)->int{
        return (a|b);
    };
    int sz=s.size();
    vector<int> v(sz);
    rep(i,sz){
        int c=s[i]-'a';
        v[i]=(1<<c);
    }
    SegmentTree<int> seg(v,f,0);
    rep(j,q){
        int id;
        cin>>id;
        if(id==1){
            int i;
            char c;
            cin>>i>>c;
            int v=c-'a';
            --i;
            int t=(1<<v);
            seg.update(i,t);
        }
        else{
            int l,r;
            cin>>l>>r;
            --l;
            int t=seg.get(l,r);
            int cnt=0;
            rep(k,26){
                if(t&(1<<k)){
                    ++cnt;
                }
            }
            cout<<cnt<<endl;
        }
    }
}


Measured memory_bytes: 6916
s = input()
x = int(s[:2])
y = int(s[2:])
if 0<x<=12 and 0<y<=12:
  print('AMBIGUOUS')
elif 0<x<=12:
  print('MMYY')
elif 0<y<=12:
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <sstream>
#include <algorithm>
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef long long ll;
using namespace std;


int main(){
    int n; cin >> n;
    int k; cin >> k;
    vector < double > v(n);

    for(auto &i: v){
        cin >> i;
        i = (1/i)*((i*(i+1))/2);
    }
    int start = 0, end = 0;
    double sum = 0;
    while(end!=k){
        sum += v[end];
        end++;
    }
    double com = sum;
    double mx = sum;
    while(end < n){
        com -= v[start];
        com += v[end];
        mx = max(mx, com);
        start++; end++;
    }

    
    cout << setprecision(12) << fixed << mx << endl;

}


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

int main() {
  int n; cin >> n;
  for (int i = 0; i <= 25; i++) {
    for (int j = 0; j <= 15; j++) {
      int m = 4 * i + 7 * j;
      if (m == n) {
        cout << "Yes" << endl;
        return 0;
      }
      if (m > 100) break;
    }
  }
  cout << "No" << endl;
}

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

# nは行で押したボタンの数、mは列で押したボタンの数。
for n in range(N+1):
    for m in range(M+1):
        if n * (M - m) + m * (N - n) == K:
            print("Yes")
            exit()
else:
    print("No")

Measured memory_bytes: 9112
#include <stdio.h>
int main(void){
  double height,max=-1,min=100001;
  while(scanf("%lf",&height)!=EOF){
    if(max<height)
      max=height;
    if(min>height)
      min=height;
  }
  printf("%.1f\n",max-min);
  return 0;
}

Measured memory_bytes: 652
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int a,b,c;
int i,j;
int ec;
int main(){
	cin >> a >> b >> c;
	if (c>a+b){
		ec=a+b+1;
	}
	else{
		ec=c;
	}
	cout << ec+b << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
x,y = li()

command = s.split("T")

lr = len(command[0])
ud = 0

lr_cm = [len(cm) for cm in command[2::2]]
ud_cm = [len(cm) for cm in command[1::2]]

lr_cm.sort(reverse=True)
ud_cm.sort(reverse=True)

for cm in lr_cm:
    if lr > x:
        lr -= cm
    else:
        lr += cm
        
for cm in ud_cm:
    if ud > y:
        ud -= cm
    else:
        ud += cm
        
if lr == x and ud == y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int mx = 1e9;
int check(string a, string b)
{
    int cnt = 0;
    for (size_t i = 0; i<a.size(); i++)
    {
        if(a[i]!=b[i])
        {
            cnt++;
        }
    }
    return cnt;
}           
int main ()
{
    string s,t;
    cin>>s>>t;
    int n = s.size(), m =t.size();
    for (int i = 0; i<n-m+1; i++)
    {
        mx = min(mx,check(s.substr(i,m),t));
    }
    cout<<mx<<endl;
    return 0;
}
 

Measured memory_bytes: 3628
def solve():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adjL = [[] for _ in range(N)]
    outdegs = [0] * N
    for _ in range(M):
        s, t = map(int, input().split())
        s, t = s-1, t-1
        adjL[s].append(t)
        outdegs[s] += 1

    probs = [0] * N
    probs[0] = 1
    for v in range(N):
        for v2 in adjL[v]:
            probs[v2] += probs[v] / outdegs[v]

    dp = [0] * N
    for v in reversed(range(N-1)):
        dp[v] = sum([dp[v2] for v2 in adjL[v]]) / outdegs[v] + 1

    ans = dp[0]
    for vRem in range(N):
        if outdegs[vRem] == 1: continue
        sumDP, maxDP = 0, -1
        for v2 in adjL[vRem]:
            sumDP += dp[v2]
            if dp[v2] > maxDP:
                maxDP = dp[v2]
        dp2 = (sumDP-maxDP) / (outdegs[vRem]-1) + 1
        decre = dp[vRem] - dp2
        ans2 = dp[0] - decre * probs[vRem]
        ans = min(ans, ans2)

    print(ans)


solve()


Measured memory_bytes: 9460
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if( b <= a){
        cout << "delicious" << endl;
    }else if( b <= a + x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

}


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

int f(int s){
    if(s > 5) return 5;
    int result = 1;
    for(int i = 1; i <= s; i++){
        result *= i;
    }
    return result;
}

int main(void){
    string s;
    int K;
    cin >> s >> K;
    map<char, int> memo;
    int m = 0;
    for(int i = 0; i < s.length(); i++){
        memo[s[i]]++;
        if(memo[s[i]] == 1) m++;
    }
    vector<int> count = vector<int>(m);
    for(auto it = memo.begin(); it != memo.end(); it++){
        memo[memo.begin()->first] += it->second;
    }

    string result = "";
    char barr = 'z';

    map<string, bool> answer;
    for(auto it = memo.begin(); it != memo.end(); it++){
        for(int i = 0; i < s.length(); i++){
            string cur = "";
            for(int j = i; j < i + 5 && j < s.length(); j++){
                cur += s[j];
                //cout << cur << endl;
                if(answer.find(cur) == answer.end()) {
                    answer[cur] = true;
                }
            }
        }
    }
    int i = 1;
    for(auto it = answer.begin(); i <= K; i++, it++){
        if(i == K) {
            cout << it->first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main(){
  int A[100];
  int N;
  int i, j, count=0;

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

  for(i = 0 ; i < N ; i++){
    int min = i;
    for(int j = i ; j < N ; j++){
      if(A[j] < A[min]){
        min = j;
      }
    }
    int temp = A[i];
    A[i] = A[min];
    A[min] = temp;
    if(i != min) count++;
  }

  for(i = 0 ; i < N ; i++){
    if(i < N-1) printf("%d ",A[i]);
    else printf("%d",A[i]);
  }

  printf("\n");
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <vector>
using namespace std;
int g(int a, int b){
    if(a%b==0)return b;
    return g(b, a%b);
}
int main(void){
    int n;
    vector<int> v;
    cin>>n;
    v.push_back(2);
    v.push_back(3);

    if(n==3){
        v.push_back(25);
    }else{
        v.push_back(4);
        v.push_back(9);
        int m=4,e=8,t=15,z=6;
        while(m<n){
            bool f=true;
            if(m<n-1&&e+2<30000){
                v.push_back(e);
                v.push_back(e+2);
                e+=6;
                m+=2;
                f=false;
            }
            if(m<n-1&&t+6<30000){
                v.push_back(t);
                v.push_back(t+6);
                t+=12;
                m+=2;
                f=false;
            }
            if(f){
                v.push_back(z);
                z+=6;
                m++;
            }
        }
    }




    for(int i=0;i<n;i++){
        cout<<v[i];
        if(i<n-1)cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s; 
	int x = s.size();
	while( x-- ){
		cout << 'x';
	} cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;

int main() {
	int N, M;
	cin >> N >> M;
	vector<P> vec;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		vec.push_back({ b,a });
	}
	sort(vec.begin(), vec.end());
	int prev = -1;
	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (vec[i].second > prev || prev >= vec[i].first) {
			ans++;
			prev = vec[i].first - 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int root(vector<int>& g, int x) {
    if (g[x] != x) {
        g[x] = root(g, g[x]);
    }

    return g[x];
}

void merge(vector<int>& g, int x, int y) {
    g[root(g, x)] = root(g, y);
}

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

    vector<int> g(n);
    iota(g.begin(), g.end(), 0);

    for (int _ : irange(0, m)) {
        int x, y, z;
        cin >> x >> y >> z;

        --x;
        --y;
        merge(g, x, y);
    }

    unordered_set<int> s;
    for (int i : irange(0, n)) {
        s.insert(root(g, i));
    }

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

Measured memory_bytes: 4772
MOD = 10**9 + 7


def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    for i in range(K, N+2):
        # lower = (i-1)*i//2
        # upper = N*i - (i-1)*i//2
        # ans += upper - lower + 1
        ans += i*(N-i+1)+1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63112
H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

AM = 0
for i in range(N):
    AM = max(AM,magic[i][0])
#print(AM)


dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
print(dp[H])


Measured memory_bytes: 42988
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))

    i = 1
    res = 0
    for _ in range(n):
        i = A[i - 1]
        res += 1
        if i == 2:
            break
    else:
        print(-1)
        exit()

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 7072
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
int power(int x, unsigned int y){
	int res=1;
	while(y>0){
		if(y&1)res*=x;
		y=y>>1;
		x*=x;
	}
	return res;
}
int32_t main(){
 	fastIO;
 	int k;cin>>k;
 	queue<int> q;
 	for(int i=1;i<=9;i++)q.push(i);
 	int cnt=0;
 	while(cnt<k){
 		int tp=q.front();q.pop();
 		cnt++;
 		if(cnt==k){
 			cout<<tp<<endl;
 			break;
 		}else{
 			if(tp%10==0){
 				q.push(tp*10+(tp%10));
 				q.push(tp*10+(tp%10)+1);
 			}else if(tp%10==9){
 				q.push(tp*10+(tp%10)-1);
 				q.push(tp*10+(tp%10));
 			}else{
 				q.push(tp*10+(tp%10)-1);
 				q.push(tp*10+(tp%10));
 				q.push(tp*10+(tp%10)+1);
 			}
 		}
 	}
} 	

Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count = 1;
        for (int i = 1; i * 1000 - n < 0; i++) {
            count = i + 1;
        }
        if (n == 0) {
            System.out.println(0);
        } else {
            System.out.println(count * 1000 - n);
        }
    }
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
const int MAX = 2000010;
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

  int N;cin >> N;
  map<ll,int, greater<ll>> mp;
  REP(i,N){
    ll a; cin >> a;
    mp[a]++;
  }

  ll a=-1,b=-1;
  for(auto e: mp){
    if(e.second >= 4){
      if(a != -1){
        cout << a * e.first << endl;
        return 0;
      }else{
        cout << e.first * e.first << endl;
        return 0;
      }
    }else if(e.second >= 2){
      if(a == -1){
        a = e.first;
      }else{
        cout << a * e.first << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 9756
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String c=sc.next();
        char a=c.charAt(0);
        if((a=='a')||(a=='e')||(a=='i')||(a=='o')||(a=='u')){
            System.out.println("vowel");
        }else{
            System.out.println("consonant");
        }
        
        
        
}
        
        
    }


Measured memory_bytes: 21844
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();
// const int N = 1e5 + 5 ;



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while(t--){
	string s , t ;
	cin >> s >> t ;
	int ans = 0 ;
	for (int i = 0 ; i < s.length() ; i++) {
		if (s[i] != t[i]) ans++ ;
	}
	cout << ans << "\n";







	// }







	return 0 ;
}

Measured memory_bytes: 3764
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d",&a);
  d=a%10;
  c=a/10%10;
  b=a/100%10;
  a=a/1000;
  if(a+b+c+d==7){
    printf("%d+%d+%d+%d=7\n",a,b,c,d);
  }
  else if(a-b+c+d==7){
    printf("%d-%d+%d+%d=7\n",a,b,c,d);
  }
  else if(a+b-c+d==7){
    printf("%d+%d-%d+%d=7\n",a,b,c,d);
  }
  else if(a+b+c-d==7){
    printf("%d+%d+%d-%d=7\n",a,b,c,d);
  }
  else if(a-b-c+d==7){
    printf("%d-%d-%d+%d=7\n",a,b,c,d);
  }
  else if(a-b+c-d==7){
    printf("%d-%d+%d-%d=7\n",a,b,c,d);
  }
  else if(a+b-c-d==7){
    printf("%d+%d-%d-%d=7\n",a,b,c,d);
  }
  else if(a-b-c-d==7){
    printf("%d-%d-%d-%d=7\n",a,b,c,d);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

#define MUL(a, b) (((a) * (b)) % 1000000007)

using namespace std;

int main(){
  int p[100001] = {3};
  long long int ans  = 1;
  int a, n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    ans = MUL(p[a], ans);
    p[a] --; p[a+1] ++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int a,b,c,d,j,k;
string e = "Balanced";

int main()
{
    cin >> a >> b >> c >> d;
    j=a+b;
    k=c+d;
//    if(j>k)
//        cout << "Left";
//    else if(j<k)
//        cout << "Right";
//    else
//        cout << "Balanced";

    if(j>k)
        e="Left";
    else if(j<k)
        e="Right";
    cout << e;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
l = 0
r = s[1:].count('E')
ans = l + r

for i in range(1, n):
    if s[i-1] == 'W':
        l += 1
    if s[i] == 'E':
        r -= 1
    if l + r < ans:
        ans = l + r
print(ans)


Measured memory_bytes: 3700
import math


def _run(n, a_list):
    buy_bool = [False] * n
    sell_bool = [False] * n
    for i in range(n - 1):
        today_low = a_list[i] < a_list[i + 1]
        tomorrow_low = a_list[i + 1] < a_list[i]
        # 今日の方が安いなら今日買う
        buy_bool[i] = today_low
        # 今日の方が高いなら今日売る
        sell_bool[i] = tomorrow_low
    sell_bool[n - 1] = True
    money = 1000
    stock = 0
    for i in range(n):
        if sell_bool[i]:
            money += a_list[i] * stock
            stock = 0
        elif buy_bool[i]:
            buy_stock = money // a_list[i]
            money = money - a_list[i] * buy_stock
            stock += buy_stock
    print(money)


def _main():
    N = int(input())
    A_list = list(map(int, input().split()))
    _run(N, A_list)


if __name__ == "__main__":
    _main()


Measured memory_bytes: 9100
import std.stdio, std.array, std.range, std.conv, std.algorithm, std.string;

void main()
{
  auto s = readln.strip;
  long x;
  readf("%d", &x);

  int[string] dict;
  foreach (i; 0..s.length) {
    foreach (j; (i+1)..(i+6)) {
      if (j > s.length) {break;}
      dict[s[i..j]] = 1;
    }
  }
  auto subs = dict.keys.sort().array();
  writeln(subs[x-1]);
}


Measured memory_bytes: 3708
#include <stdio.h>
int main()
{
  
  
  int a,b,c;
  

  scanf("%d%d%d",&a,&b,&c);
  if ( (1<=a<=13)&&(1<=b<=13)&&(1<=c<=13))
  if ( a+b+c  >= 22){
    printf ("bust");
  }
  
  else {
    printf ("win");
  }
  return 0;
  
  
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

void solve(){

	string strs[] = { "SAFE", "SUSPICIOUS" };

	int h, w;
	cin >> h >> w;

	vector< string > screen( h );
	vector< bool > flg( 26, false );

	for( int i = 0; i < h; i++ )
		cin >> screen[ i ];
	
	bool fig = true;

	while( fig ) {

		fig = false;

		for( int x = 0; x < w; x++ ) {
			for( int y = 0; y < h; y++ ) {
				char ch = screen[ y ][ x ];

				if( ch == '.' || ch == '*' ) continue;
				if( flg[ ch - 'A' ] ) continue;

				int stx = w, sty = h, edx = -1, edy = -1;
				for( int tx = 0; tx < w; tx ++ ) {
					for( int ty = 0; ty < h; ty ++ ) {
						if( screen[ty][tx] == ch ) {
							stx = min( stx, tx );
							sty = min( sty, ty );
							edx = max( edx, tx );
							edy = max( edy, ty );
						}
					}
				}

				bool fillflg = true;
				for( int tx = stx; tx <= edx && fillflg; tx ++ ) {
					for( int ty = sty; ty <= edy && fillflg; ty ++ ) {
						fillflg &= ( screen[ ty ][ tx ] == ch || screen[ ty ][ tx ] == '*' );
					}
				}
				fig |= fillflg;
				if( fillflg ) {
					flg[ ch - 'A' ] = true;
					for( int tx = stx; tx <= edx; tx ++ ) {
						for( int ty = sty; ty <= edy; ty ++ ) {
							screen[ ty ][ tx ] = '*';
						}
					}
				}
			}
		}
	}

	bool b = false;
	for( int x = 0; x < w; x++ ) {
		for( int y = 0; y < h; y++ ) {
			b |= ( screen[ y ][ x ] != '.' && screen[ y ][ x ] != '*' );
		}
	}
	cout << strs[ b ] << endl;
}

int main( void ) {

	int n;
	cin >> n;

	for( int i = 0; i < n; i++ )
		solve();

	return 0;
}

Measured memory_bytes: 3040
import bisect
a=int(input())
b=list(map(int,input().split()))
b.sort()
ans=0
for i in range(a):
  for j in range(i+1,a):
    k=bisect.bisect_right(b,b[i]+b[j]-1)
    ans+=k-j-1
print(ans)

Measured memory_bytes: 3188
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True


ans=0

n,m=LI()
g=[[] for i in range(n)]
p=[[] for i in range(n)]
for i in range(n+m-1):
    a,b=LI_()
    g[a].append(b)
    p[b].append(a)


def topological_sort(g):
    n=len(g)
    rt=[]
    indeg=[0]*n  # counter for in-degree of vertices
    for i in range(n):
        for j in g[i]:
            indeg[j]+=1
    
    # gather vertices with 0 in-degree
    q=deque()
    for i in range(n):
        if indeg[i]==0:
            q.append(i)
    
    while q:
        c=q.popleft()
        rt.append(c)
        for nb in g[c]:
            indeg[nb]-=1
            if indeg[nb]==0:
                q.append(nb)
    return rt

topos=topological_sort(g)
root=topos[0]

dc={}
for i,j in enumerate(topos):
    dc[j]=i

v=[-1]*n
def dfs(x):
    v[x]=1
    q=[x]
    while q:
        c=q.pop()
        for nb in g[c]:
            if v[nb]==-1:
                v[nb]=1
                q.append(nb)
                
                if p[nb]:
                    prs=sorted(p[nb],key=lambda x:-dc[x])
                    par[nb]=prs[0]+ 1
    return

par=[0]*n
par[root]=0

dfs(root)

for i in par:
    print(i)


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

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

ll calc(ll a, ll b){
  if(a > b) return calc(b, a);
  if(a == 1) return 2*b - 1;
  return 2*(b/a)*a + calc(b % a, a);
}

int main(){
  ll n, x; cin >> n >> x;

  ll ans = 0;
  ans += x + (n-x);

  ll g = gcd(x, n-x);

  ans += g * calc(x/g, (n-x)/g);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
while True:
  max_price=0
  x,y,s=map(int,input().split())
  if x==y==s==0:
    break
  else:
    for i in range(1,s//2 + 1):
      p_1=math.floor(i*(100+x)/100) 
      z=s-p_1         
      ori_z=math.ceil(z*100/(100+x))
      if math.floor(ori_z *(100+x)/100)+p_1 ==s:
          neo_i=math.floor(i*(100+y)/100)
          neo_z=math.floor(ori_z*(100+y)/100)
          neo_sum=neo_i+neo_z
          if neo_sum > max_price:
            max_price=neo_sum
    print(max_price)


Measured memory_bytes: 5656
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

fn main() {
    let (n, c): (usize, i64) = read();
    let mut sushi: Vec<(i64, i64)> = readn(n);

    let mut a = solve(&sushi, c);
    sushi.reverse();
    for i in 0..n {
        let (p, v) = sushi[i];
        sushi[i] = (c-p, v);
    }
    let mut b = solve(&sushi, c);
    println!("{}", max(a, b));
}

fn solve(sushi: &Vec<(i64, i64)>, c: i64) -> i64 {
    let n = sushi.len();
    let mut imo_value = vec![];

    {
        imo_value.push(0);
        let mut sum = 0;
        for &(pos, val) in sushi.iter() {
            sum += val;
            imo_value.push(sum);
        }
    }

    let mut imo_back_reverse = vec![];
    imo_back_reverse.push((0, 0, 0));
    for i in (0..n).rev() {
        let &(_, sum, best) = imo_back_reverse.last().unwrap();
        let to_dist = (c - sushi[i].0) * 2;
        let value = sum + sushi[i].1;
        imo_back_reverse.push((to_dist, value, max(best, value - to_dist)));
    }

    let mut max_value = 0;
    for i in 0..n+1 {
        let (_, _, back) = imo_back_reverse[n-i];
        let mut go = imo_value[i];
        if i >= 1 {
            go -= sushi[i-1].0;
        }
        max_value = max(max_value, back + go);
    }
    max_value
}


Measured memory_bytes: 12268
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

	
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 1e9 + 7; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {	 ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 5e3 + 10;

int n, m, nq, nk;
string str;
int a[maxn][maxn];
ll dp[maxn][maxn][4];
void task() {
	int r, c, k;
	cin >> r >> c >> k;
	re(k) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		a[x][y] = z;
	};
	dp[0][0][0] = 0;
	dp[0][0][1] = a[0][0];
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) 
		  for (int k = 0; k < 4; ++k) {
				if (j < c - 1)  ckmax(dp[i][j+1][k], dp[i][j][k]);
				if (j < c - 1 && k < 3)  ckmax(dp[i][j+1][k+1], dp[i][j][k]+a[i][j+1]);				
				if (i < r - 1) ckmax(dp[i+1][j][0], dp[i][j][k]);
				if (i < r - 1) ckmax(dp[i+1][j][1], dp[i][j][k] + a[i+1][j]);
			}
	}
	ll ans = 0;
	re(4) ckmax(ans, dp[r-1][c-1][i]);
	ps(ans);
	//Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
  //cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 342864
import java.io.*;
import static java.lang.System.out;

public final class Main {
	public static void main(String[] args) throws IOException {
		try (var istr = new InputStreamReader(System.in);
			 var br = new BufferedReader(istr)) {
			long k = Long.parseLong(br.readLine());
			double i = 100;
			int years = 0;
			while (i < k) {
				i = Math.floor(i * 1.01);
				years += 1;
			}
			out.printf("%d%n", years);
		}
	}
}


Measured memory_bytes: 34176
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	/* ABC128 B
	 *
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] strs = new String[n];
		
		for (int i = 0; i < n; i++) {
			strs[i] = sc.next() + "_" + (1100-sc.nextInt()) + "_" + (i+1);
		}
		sc.close();
		
		Arrays.sort(strs);
		
		for (String s : strs) {
			System.out.println(s.split("_")[2]);
		}
		
	}

}

Measured memory_bytes: 21716
#include "bits/stdc++.h"
//mapの使い方
#include <map>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  map<string, long long> nums;
  ll ans=0;
  cin >> n ;
  string s;
  REP(i,n) {
    cin>>s;
    nums[s]++;
  }



  long long maxsi=0;
  for (auto it : nums) {
      maxsi = max(maxsi,it.second); // it.first が it.second 個ある
  }

  
  for (auto it : nums) {
      if (maxsi == it.second) // it.first が it.second 個ある
        cout<<(it.first)<<endl;
  }

  return 0;
/*
*/
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2104
N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
tmp = T[0]
ans = 0
cnt = 1
for i in range(1, N):
    cnt += 1
    if T[i]-tmp>K:
        ans += 1
        cnt = 1
        tmp = T[i]
    elif cnt>C:
        ans += 1
        cnt = 1
        tmp = T[i]
print(ans+1)

Measured memory_bytes: 7384
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n,k=map(int,stdin.readline().rstrip().split())
a=[int(i) for i in stdin.readline().rstrip().split()]
print(math.ceil((n-1)/(k-1)))

Measured memory_bytes: 56304
M, D = map(int, input().split())
count = 0
for m in range(1, M+1):
    for i in range(2, 10):
        for j in range(2, 10):
            if (i*10 + j) > D:
                break
            if (i * j) == m:
                count += 1
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

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

struct Prime {
    int n;
    vector<bool> used;
    vector<int> pr;
    vector<ull> bpr;
    Prime(int n) : n(n) {
        used = vector<bool>(n+1, false);
        for (int i = 2; i <= n; i++) {
            if (used[i]) continue;
            pr.push_back(i);
            bpr.push_back(((__int128(1)<<64)+i-1) / i);
            for (int j = 2*i; j <= n; j += i) {
                used[j] = true;
            }
        }
    }    
    map<ll, int> fact(ll x) {
        assert(x <= (ll)n*n);
        int pc = (int)pr.size();
        map<ll, int> mp;
        for (int i = 0; i < pc; i++) {
            ll d = pr[i]; ull rd = bpr[i];
            if (x < d*d) break;
            while (true) {
                ll xd = __int128(x)*rd >> 64;
                if (xd * d != x) break;
                x = xd;
                mp[d]++;
            }
        }
        if (x > 1) mp[x]++;
        return mp;
    }
};

const int MP = 100100;

ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}

int main() {
    Prime pr(MP);
    using P = pair<ll, ll>;
    map<ll, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = pr.fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[d0].first++;
        } else {
            g[d1].second++;
        }
    }

    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  
  vector<int> mochis(N);
  rep(i, N){
    cin >> mochis.at(i);
  }
  sort(mochis.begin(), mochis.end());
  
  int counter = 0;
  int before = 0;
  rep(i, N){
    int processing = mochis.at(i);
    if(processing != before)
      counter++;
    before = mochis.at(i);
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
     ll n,k,i;
     cin>>n>>k;

     ll arr[n];
     unordered_map<ll,ll>mp;
     for(i=0;i<n;i++)
     {
         cin>>arr[i];
         mp[arr[i]]++;
     }

     if(mp.size()<=k)
     {
         cout<<0<<endl;
     }
     else
     {
         vector <pair<ll,ll> >v;
         for(auto it:mp)
         {
             v.pb({it.se,it.fi});
         }
         ll ans=0;
         sort(v.begin(),v.end());
         for(i=0;i<v.size()-k;i++)
         {
             ans+=v[i].fi;
         }

         cout<<ans;
     }
}


Measured memory_bytes: 16836
using System;
using System.Linq;

namespace _0346
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            if (x[0] == x[1] && x[0] == x[2] && x[0] == x[3] && x[4] == x[5] && x[4] == x[6] && x[4] == x[7] && x[8] == x[9] && x[8] == x[10] && x[8] == x[11])
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9524
def main():
    N = int(input())
    S, T = input().split()
    ans = [None] * 2 * N
    for i in range(N):
        ans[i*2] = S[i]
        ans[i*2+1] = T[i]
    print("".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
    int n=read(),ans=0;
    while (n)
    {
        ans+=(n%10);n/=10;
    }
    if (ans==1) ans=10;
    printf("%d",ans);
    return 0;
}

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

using namespace std;

const int INF = 1000000000;

int w, h;
int d[20][20];

bool out(int x, int y) {
  return x < 0 || y < 0 || x >= w || y >= h;
}

bool goal(int x, int y) {
  return d[y][x] == 3;
}

bool contact(int x, int y) {
  return d[y][x] == 1;
}

int search(int X, int Y, int counter) {
  if (counter >= 11) return INF;
  //printf("%d,%d,%d\n",X,Y,counter);
  int ans = INF;
  for (int i = 0; i < 4; i++) {
    int x = X, y = Y;
    if (i == 0 && (out(x+1, y) || contact(x+1, y))) continue;
    if (i == 1 && (out(x-1, y) || contact(x-1, y))) continue;
    if (i == 2 && (out(x, y+1) || contact(x, y+1))) continue;
    if (i == 3 && (out(x, y-1) || contact(x, y-1))) continue;
    while (1) {
      if (i == 0) x++;
      if (i == 1) x--;
      if (i == 2) y++;
      if (i == 3) y--;
      if (out(x, y)) break;
      if (goal(x, y)) return counter;
      if (contact(x, y)) {
        int tempX = x, tempY = y;
        if (i == 0) tempX--;
        if (i == 1) tempX++;
        if (i == 2) tempY--;
        if (i == 3) tempY++;
        d[y][x] = 0;
        ans = min(ans, search(tempX, tempY, counter + 1));
        d[y][x] = 1;
        break;
      }
    }
  }
  return ans;
}

int main() {
  while (1) {
    scanf("%d%d", &w, &h);
    if (w == 0) break;
    int x, y;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        scanf("%d", &d[i][j]);
        if (d[i][j] == 2) x = j, y = i;
      }
    }
    int ans = search(x, y, 1);
    if (ans == INF) ans = -1;
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 2568