akhauriyash/Code-Regression huggingface dataset:
import numpy as np
X = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
div = make_divisors(X)
for i in range(len(div)):
    x = div[i]
    z = x**4 - X/x
    if z%5 == 0:
        s = z / 5
        if x**4 - 4*s >=0:
            y1 =( -x**2 + np.sqrt(x**4 - 4 * s)) / 2
            y2 =( -x**2 - np.sqrt(x**4 - 4 * s)) / 2 
            B1 = (-x + np.sqrt(x**2 + 4*y1))/2
            if B1.is_integer():
                B = B1
                A = B + x
                break
            B12 = (-x + np.sqrt(x**2 + 4*y2))/2
            if B12.is_integer():
                B = B12
                A = B + x
                break
            B2 = (-x - np.sqrt(x**2 + 4*y1))/2
            if B2.is_integer():
                B = B2
                A = B + x
                break
            B21 = (-x - np.sqrt(x**2 + 4*y2))/2
            if B21.is_integer():
                B = B21
                A = B + x
                break
print(int(A),int(B))


Measured memory_bytes: 27176
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


DIV = 998244353

def main():
    X = iRaw()
    dp = [0]*(X+1)
    dp[0] =1
    for x in range(100,X+1):
        for d in range(100,106):
            if dp[x-d]==1:
                dp[x] = 1
                break
    return dp[X]

if __name__ == "__main__":
    print(main())


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

using namespace std;

int main() {
    string s;
    cin >> s;
    long long int k;
    cin >> k;

    char c = '1';
    for (int i = 0; i < k; i++) {
        if (s[i] != '1') {
            c = s[i];
            break;
        }
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
def reconstruct(preorder, inorder)
	return [] if !preorder || preorder.empty?
	return [] if !inorder || inorder.empty?

	root = preorder.shift
	separate_point = inorder.index(root)
	unless separate_point
		raise "Unexpected state #{preorder}, #{inorder}"
	end

	left = inorder.shift(separate_point) # 副作用でinorderは右部分木になる
	inorder.shift # separate_pointを取り除く

	result = []
	result.concat(reconstruct(preorder, left))
	result.concat(reconstruct(preorder, inorder))
	result << root
end

n = STDIN.gets.to_i
preorder = STDIN.gets.split[0...n].map(&:to_i)
inorder  = STDIN.gets.split[0...n].map(&:to_i)
puts reconstruct(preorder, inorder).join(" ")

Measured memory_bytes: 6112
from sys import stdin
from math import sqrt


def is_prime(q, primes):
    if len(primes) == 0:
        return True

    maxq = int(sqrt(q))
    for prime in primes:
        if prime > maxq:
            break
        if q % prime == 0:
            return False
    return True

def get_primes(n):
    if n < 2:
        return []
    if n == 2:
        return [2]

    max = int(sqrt(n))
    primes = [2]
    for q in range(3, max+1):
        if is_prime(q, primes):
            primes.append(q)

    return primes

def breakdown_to_primes_as_dic(n, primes):
    prime_dic = {}
    for prime in primes:
        if n % prime != 0:
            continue
        prime_dic[prime] = 0
        while n % prime == 0:
            prime_dic[prime] += 1
            n = n // prime
    if n >= 2:
        prime_dic[n] = 1
    return prime_dic

def get_int_sums(n):
    int_sums = [0]
    for i in range(1, n+1):
        int_sums.append(int_sums[i-1] + i)
    int_sums.pop(0)
    return int_sums


def main():
    for line in stdin:
        n = int(line)
        break

    primes = get_primes(n)
    prime_dic = breakdown_to_primes_as_dic(n, primes)

    if len(prime_dic.keys()) == 0:
        print(0)
        return

    max_prime_occurance = max(prime_dic.values())
    int_sums = get_int_sums(max_prime_occurance + 1)

    answer = 0
    for prime in prime_dic.keys():
        occr = prime_dic[prime]
        for i in range(1, len(int_sums)):
            if occr >= int_sums[i-1] and occr < int_sums[i]:
                answer += i
                break

    print(answer)


main()

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

using namespace std;

int main() {

	int pa,pb,pab, suma, sumb;
	scanf("%d %d %d %d %d", &pa, &pb, &pab, &suma, &sumb);
	int s;
	long long total = 0;
	if(suma > sumb) {
		s = sumb;
	} else {
		s = suma;
	}

	if(2 * pab < pa + pb) {
		total += s * (2 * pab);
		suma -= s;
		sumb -= s;
		if(suma == 0) {
			if(2 * pab < pb) {
				total += sumb * (2 * pab);
				printf("%lld\n", total);
			} else {
				total += sumb * pb;
				printf("%lld\n", total);
			}
		} else {
			if(2 * pab < pa) {
				total += suma * (2 * pab);
				printf("%lld\n", total);
			} else {
				total += suma * pa;
				printf("%lld\n", total);
			}
		}
	} else {
		total += suma * pa;
		total += sumb * pb;
		printf("%lld\n", total);
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
#include<cstring>
#include<list>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}


long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	//freopen("hussien.in", "r", stdin);
	string x, y;
	cin >> x >> y;
	x += y[y.size() - 1];
	if (x == y)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inpuS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

from itertools import permutations

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
P = list(permutations(XY))
ans = 0
count = 0
for p in P:
  for i in range(1,len(p)):
    dist = ((p[i-1][0]-p[i][0])**2 + (p[i-1][1]-p[i][1])**2)
    ans += dist**0.5
print(ans/len(P))  
  

Measured memory_bytes: 8052
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	a := make([][]int, N)
	for i := range a {
		sc.Scan()
		for _, s := range strings.Split(sc.Text(), " ") {
			n, _ := strconv.Atoi(s)
			a[i] = append(a[i], n)
		}
	}

	count := 0
	for _, ints := range a {
		if ints[0] == ints[1] {
			count++
		}else {
			count = 0
		}
		if count >= 3 {
			break
		}
	}
	if count >= 3 {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   int ans=0;

   rep(i,n){
      int a,b;
      cin>>a>>b;
      ans+=b-a+1;
   }
   
   cout<<ans;
   return 0;
}

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i

  v = [false] * n
  n.times do |i|
    (d1, d2) = InputLine.to_ia
    v[i] = d1 == d2
  end

  flag = false
  (2...n).each do |i|
    flag |= v[i] && v[i - 1] && v[i - 2]
  end
  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

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

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

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define F "Fennec"
#define S "Snuke"

int n;
vector<int> es[100000];
int pa[100000], sz[100000], dpt[100000];

void dfs(int v, int p, int d) {
	pa[v] = p;
	sz[v] = 1;
	dpt[v] = d;
	REP(i, es[v].size()) if (es[v][i] != p) {
		dfs(es[v][i], v, d + 1);
		sz[v] += sz[es[v][i]];
	}
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		es[a].push_back(b);
		es[b].push_back(a);
	}
	dfs(0, -1, 0);
	int v = n - 1;
	REP(i, (dpt[n - 1] - 1) / 2) v = pa[v];
	cout << (n - sz[v] > sz[v] ? F : S) << endl;
	return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll mod=1e9+7;
static ll f[(ll)1e5+10];
int main(void){
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0;
        return 0;
    }
    f[0]=1;
    rep(1,i,max(n,m)+1)f[i]=f[i-1]*i%mod;
    cout<<((abs(n-m)==1)?1:2)*f[n]%mod*f[m]%mod;
}


Measured memory_bytes: 4336
max=0
s=[]
t=[]

n=gets.to_i
n.times do|i|
  s[i]=gets.chomp
end
m=gets.to_i
m.times do|i|
  t[i]=gets.chomp
end
(s+t).uniq.each do|s0|
  x=0
  x+=s.count(s0)
  x-=t.count(s0)
  if max<x then max=x end
end
p max


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> H(N + 1);
  for (int i = 1; i <= N; i++)
    cin >> H[i];
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (H[i] < H[i + 1])
      res += H[i + 1] - H[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>

using namespace std;

int main() {
	int N, K;
	cin >> N;
	cin >> K;
	int h[N], dp[N];
	for (int i = 0; i < N; ++i) cin >> h[i];

	dp[0] = 0;
	for(int i = 1; i < N; ++i) {
		dp[i] = INT_MAX;
		for(int j = 1; j <= K; ++j) {
			if (i-j >= 0) {
				dp[i] = min(abs(h[i]-h[i-j])+dp[i-j], dp[i]);
			}
		}
	}
	cout << dp[N-1] << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  int b = 0,n = s.size();
  rep(i,n){
    if(s[i] == 'B') b++;
    else ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int main(){
  string o,n;
  cin>>o>>n;
  for(int i=0;i<o.size()-1;++i){
    cout<<o[i]<<n[i];
  }
  cout<<o[o.size()-1];
  if(o.size()==n.size()) 
    cout<<n[n.size()-1];
  cout<<endl;
}

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

using namespace std;

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= m; ++i) cin >> b[i];
    for(int i = 1; i <= n; ++i) a[i] += a[i-1];
    for(int i = 1; i <= m; ++i) b[i] += b[i-1];

    int cnt = upper_bound(all(b), k) - b.begin() - 1, ans = 0;
    for(int i = cnt; i >= 0; --i){
        int tmp = upper_bound(all(a), k - b[i]) - a.begin() - 1;
        ans = max(ans, i + tmp);
    }
    cout << ans << "\n";


    return 0;
}


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

int p=0;
int formula(string& s);

int num(string& s){
    int res=0;
    int op=1;
    if(s[p]=='-'){
        op=-1;
        p++;
    }
    else if(s[p]=='+'){
        op=1;
        p++;
    }
    while(isdigit(s[p])){
        res*=10;
        res+=s[p]-'0';
        p++;
    }
    return op*res;
}

int term(string & s){
    if(s[p]=='('){
        p++;
        int res=formula(s);
        p++;
        return res;
    }
    return num(s);
}

int section(string& s){
    int res=term(s);
    while(p!=s.size() && s[p]!=')' && s[p]!='+' && s[p]!='-'){
        char op=s[p];
        p++;
        int next=term(s);
        if(op=='*') res*=next;
        else res/=next;
    }
    return res;
}

int formula(string& s){
    int res=section(s);
    while(p!=s.size() && s[p]!=')'){
        char op=s[p];
        p++;
        int next=section(s);
        if(op=='+') res+=next;
        else res-=next;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        s.pop_back();
        p=0;
        cout<<formula(s)<<endl;
    }
    return 0;
}


Measured memory_bytes: 2976
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    for(int i=0;i<=50000;++i) {
        if(int(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

}


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

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

struct S
{
	string s;
	int p, id;
	bool operator < (const S&s) const{
		return s.p == p ? id < s.id : p > s.p;
	}
};

int main(){
	int n;
	bool l = false;
	while(cin>>n&&n){
		if(l) cout<<endl;
		else l =true;
		vector<S> v;
		string s;
		int a, b,c;
		rep(i, n){
			cin>>s>>a>>b>>c;
			v.pb({s, a*3+c, i});
		}
		sort(all(v));
		rep(i, n){
			cout<<v[i].s<<","<<v[i].p<<endl;
		}
	}
}

Measured memory_bytes: 3156
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int temp = i;
		int num = 0;
		while(temp > 0){
			num += temp % 10;
			temp /= 10;
		}
		if( a <= num && num <= b){
			ans += i;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > GQint;
typedef priority_queue<int> PQint;
typedef priority_queue<PA, vector<PA>, greater<PA> > GQpair;
typedef priority_queue<PA> PQpair;
typedef	set<int> Sint;
typedef	set<PA> SPA;
typedef map<int, int> MAP;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 100000
#define MAXN 200005
#define MAXC 100000000000014
#define MAXV 1000000009

ll n, a[MAXN], c , k, ans;


int main()
{
    cin >> n;
    a[0] = 0;
    REP(i, 1, n + 1){
        cin >> k;
        a[i] = a[i - 1] + k;
    }
    sort(a, a + n + 1);
    REP(i, 0, n){
        if(a[i] == a[i + 1]){
            c++;
        }
        else if(c > 0){
            ans += c * (c + 1) / 2;
            c = 0;
        }
    }
    if(c > 0){
        ans += c * (c + 1) / 2;
    }
    cout << ans << endl;

    return 0;
}
















Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[10000],b[10000];
	
	while(cin>>n && n!=0){
		int point_a=0;
		int point_b=0;

		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i] > b[i]){
				point_a+=(a[i] + b[i]);
			}else if(a[i] == b[i]){
				point_a+=a[i];
				point_b+=b[i];
			}else{
				point_b+=(a[i] + b[i]);
			}
		}
		cout<<point_a<<" "<<point_b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//浮動小数点処理用
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;
//using Bint = boost::multiprecision::cpp_int;
//using Real = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr u64 MOD = 1'000'000'007LL;
constexpr f80 PI = 3.14159265358979323846;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef pair<int,int> P;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << max(0, (H2 * 60 + M2) - (H1 * 60 + M1) - K ) << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3640
N = int(input())
aList = list(map(int, input().split()))

counter = 0
breaknum = 0

flag = False

for i in list(aList):
    if(i == counter+1):
        counter += 1
    else:
        breaknum += 1
    
if(counter == 0):
    print(-1)
else:
    print(breaknum)

Measured memory_bytes: 24744
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll x,t;cin>>x>>t;
    cout<<mmax(0,x-t)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b, c;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c;
	cout << (a+b==c || b+c==a || c+a==b ? "Yes" : "No") << endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()


int main() {
	int n, d;
	cin >> n >> d;
	int res = (n+2*d)/(2*d+1);
	pv(res)
	return(0);
}

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

using namespace std;

int n;
int a[1005];

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

	cin >> n;

	int ans = 0;
	int p;

	cin >> a[0] ;
	p = a[0];
	bool f = true;

	for (int i = 1;i < n;i++){
		cin >> a[i];
		if(a[i] == p && f){ans++;f = false;}
		else if(a[i] == p)f = true;
		else f = true;
		p = a[i];
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
import sys


def log(s):
    print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    s = input()
    n = len(s) - 1
    sum = 0
    for k in range(2 ** n):
        q = list(s)
        i = n
        while k > 0:
            if k & 1:
                q.insert(i, "+")
            k >>= 1
            i -= 1
        sum += eval("".join(q))
    print(sum)


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
  
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
  
using namespace std;
  
class Point{
public:
  double x,y;
  
  Point(double x = 0,double y = 0): x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  bool operator < (const Point& p) const{ return !equals(x,p.x)?x<p.x:(!equals(y,p.y)&&y<p.y); }
  bool operator == (const Point& p)const{ return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }
  
};
  
Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }
  
const double DINF = 1e20;
int n;
Point ps[2][1010],tmp[1010];
  
inline double getDist(Point p){ return sqrt(p.x*p.x+p.y*p.y); }
  
bool comp_arg(const double &a,const double &b) { return !equals(fabs(a),fabs(b)) && fabs(a) < fabs(b); }
  
void compute(){
  Point grv[2] = {Point(),Point()};
  rep(i,2) rep(j,n) grv[i] = grv[i] + ps[i][j];
  rep(i,2) grv[i] = grv[i] / (double)n;
  rep(i,2) rep(j,n) ps[i][j] = ps[i][j] - grv[i];
  sort(ps[0],ps[0]+n);
  sort(ps[1],ps[1]+n);
  
  vector<double> arg_buf;
  rep(i,min(10,n)) rep(j,n) {
    double dist[2] = { getDist(ps[0][i]), getDist(ps[1][j]) };
    if( !equals(dist[0],dist[1]) ) continue;
    arg_buf.push_back( atan2(ps[0][i].y,ps[0][i].x) - atan2(ps[1][j].y,ps[1][j].x) );
  }
  
  sort(arg_buf.begin(),arg_buf.end(),comp_arg);
  arg_buf.erase(unique(arg_buf.begin(),arg_buf.end()),arg_buf.end());
  
  rep(i,(int)arg_buf.size()){
    double arg = arg_buf[i];
    rep(j,n) tmp[j] = rotate(ps[1][j],arg);
    sort(tmp,tmp+n);
    bool failed = false;
    rep(j,n) if( !( tmp[j] == ps[0][j] ) ) { failed = true; break; }
    if( !failed ) { printf("%.10lf\n",fabs(arg)); break; }
  }
  
}
  
int main(){
  while( cin >> n, n ){
    rep(i,2) rep(j,n) cin >> ps[i][j].x >> ps[i][j].y;
    compute();
  }
  return 0;
}

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

const int DIM = 1e5 + 5;

int arr[DIM];

int main(void) {
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    
    int val = 1;
    while (val * 2 <= x)
        val *= 2;
    
    cout << val;
    return 0;
}


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


ans = 0

def calc(i):
    bb = 1
    while i * (2 ** bb) < K:
        bb +=1    
    return bb

for i in range(1, N + 1):
    if i >= K:
        ans += 1 / N
    else:
        y = calc(i)
        ans += 1 / N * (1/2) ** y

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double R = 6.0*m;
    double r = 30.0*h+0.5*m;
    double theta = (R>r?R-r:r-R);
    double ans = a*a+b*b-2.0*a*b*cos(2.0*PI*theta/360.0);
    cout<<setprecision(20)<<sqrt(ans)<<endl;
}

Measured memory_bytes: 4212
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[5000];//??????????????¨????????????.
int main(){
	int N;
	int ans = 0;
	while(cin>>N&&N){
		int index=0;
		ans = INT_MIN;//????????§??????????????¨????????????.
		FOR(i,0,N){
			cin>>sum[i];
			sum[i] += sum[i-1];
		}
		FOR(i,0,N){
			FOR(j,i,N){
				ans = max(ans,sum[j]-sum[i-1]);
			}
		}
		cout<< ans <<endl;
	}
}

Measured memory_bytes: 2992
N, M, X = map(int,input().split())
A = [[int(x) for x in input().split()] for _ in range(N)]
 
INF = float('inf')
ans = INF

#print(A)
for i in range(2**N):
    tmp = [0 for _ in range(M+1)]
    b = bin(i)[2:].zfill(N)
    #print(b)
    
    for n in range(N):
        for m in range(M+1):
            tmp[m] += A[n][m] * int(b[N-1-n])
    #print(tmp[1:])
 
    if min(tmp[1:]) >= X:
        ans = min(ans, tmp[0])
 
if ans == INF:
    ans = -1
print(ans)

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

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

int showAll(vector<char> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int main() {
  int n;
  cin >> n;
  int a[n + 2];
  a[0] = 0;
  a[n + 1] = 0;
  rep (i, n) {
    cin >> a[i + 1];
  }
  long total = 0;
  rep (i, n + 1) {
    total += abs(a[i] - a[i + 1]);
  }
  // cout << total << endl;
  for (int i = 1; i <= n; ++i) {
    cout << total - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) + abs(a[i - 1] - a[i + 1]) << endl;
  }
  return 0;
}



Measured memory_bytes: 1664
n = gets.to_i
a = Array.new(n).map{Array.new(n,0)}
n.times do
  j = gets.split().map(&:to_i)
  i = 2
  while i < j.size
    a[j[0]-1][j[i]-1] = 1
    # a[j[0]][j[i]] = 1
    i += 1
  end
end
a.each{|i| puts i.join(" ")}


Measured memory_bytes: 6984
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif		
	LL a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)
		cout<<0<<endl;
	else
	{
		vector<LL > vec(3);
		vec[0]=a;
		vec[1]=b;
		vec[2]=c;
		sort(vec.begin(), vec.end());
		cout<<vec[0]*vec[1]<<endl; 
	}
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
 
const ld pi=acos(-1);

ll segtree[5000009],h[500009],w[500009],a[500009],b[500009],n,m,k,t,q,p,res,i,j;
vector<ll> h2[500009];

void init(ll id,ll l,ll r) {
    if (l!=r) {
        ll mid=(r+l)/2;
        init(id*2,l,mid);
        init(id*2+1,mid+1,r);
        segtree[id]=max(segtree[id*2],segtree[id*2+1]);
    }
    else {
        segtree[id]=w[l];
    }
}

ll get(ll id,ll l,ll r,ll u,ll v) {
    if ((l>r)||(l>v)||(r<u)) {
        return -oo;
    }
    if ((u<=l)&&(r<=v)) {
        return segtree[id];
    }
    ll mid=(r+l)/2;
    return max(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
}

void update(ll id,ll l,ll r,ll u,ll gt) {
    if ((r<u)||(l>u)) {
        return;
    }
    if ((l==u)&&(r==u)) {
        segtree[id]+=gt;
        return;
    }
    ll mid=(r+l)/2;
    update(id*2,l,mid,u,gt);
    update(id*2+1,mid+1,r,u,gt);
    segtree[id]=max(segtree[id*2],segtree[id*2+1]);
}

int main() {
    IO;
    cin>>n>>m>>k;
    for (i=1;i<=k;i++) {
        cin>>a[i]>>b[i];
        h[a[i]]++;
        h2[a[i]].push_back(b[i]);
        w[b[i]]++;
    }
    init(1,1,m);
    for (i=1;i<=n;i++) {
        for (j=0;j<h2[i].size();j++) {
            update(1,1,m,h2[i][j],-1);
            //cout<<h2[i][j]<<' '<<get(1,1,m,1,m)<<'\n';
        }
        res=max(res,h[i]+get(1,1,m,1,m));
        //cout<<i<<' '<<h[i]<<' '<<get(1,1,m,1,m)<<'\n';
        for (j=0;j<h2[i].size();j++) {
            update(1,1,m,h2[i][j],1);
        }
    }
    cout<<res<<'\n';
}
    

Measured memory_bytes: 42308
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;
 
int main() {
 
	//数字
	int A,B,C;
	cin >> A >> B >> C;

	if(A+B+C>=22){
    cout << "bust" << endl;
    }else{
    cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int X;
    cin >> X;
    if (400 <= X && X < 600) cout << 8 << endl;
    if (600 <= X && X < 800) cout << 7 << endl;
    if (800 <= X && X < 1000) cout << 6 << endl;
    if (1000 <= X && X < 1200) cout << 5 << endl;
    if (1200 <= X && X < 1400) cout << 4 << endl;
    if (1400 <= X && X < 1600) cout << 3 << endl;
    if (1600 <= X && X < 1800) cout << 2 << endl;
    if (1800 <= X && X < 2000) cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3620
<?php

fscanf(STDIN, "%d", $N);
$h = explode(' ', trim(fgets(STDIN)));

$count = 1;
$max_height = $h[0];
for ($i = 1; $i < $N; $i++ ) {
    if ($h[$i] >= $max_height) {
        $max_height = $h[$i];
        $count++;
    }
}
echo $count . "\n";


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,a,b;cin >> k >> a >> b;
	if(b<=a+2 || k<=a) cout << k+1 << endl;
	else{
		k++;
		k-=a;
		cout << a+k/2*(b-a)+k%2 << endl;
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    lli len=0;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
        len+=a[i];
    }
    rep(i,n-1){
        a[i+1]=a[i]+a[i+1];
    }
    
    lli ans=INF;
    rep(i,n){
        ans=min(ans, abs(len-2*a[i]));
    }
    out(ans);
}

Measured memory_bytes: 4772
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;


int main()
{
  	int n,d,c = 0;
    cin >> n >> d;
    while(n--)
    {
        ll a,b;
        cin >> a >> b;
        if(sqrt((a*a) +(b*b))  <= d)
            c++;
    }
    cout << c;
    return 0;
}


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


int main(){
    int a,b;
    cin >> a >> b;
    cout << "a ";
    if(a<b) cout << "< ";
    if(a==b) cout << "== ";
    if(a>b) cout << "> ";
    cout <<  "b" << endl;
    
    
    return 0;
}


Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N + 100);
	for (ll i = 0; i < N; i++)
		cin >> a[i];
	map<ll, ll>mp;
	vector<ll>v;
	for (ll i = 0; i < N; i++) {
		mp[a[i]]++;
		if (mp[a[i]] >= 2)
		{
			v.push_back(a[i]);
			mp[a[i]] = 0;
		}
	}
	ll ans = 0;

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	if (v.size() >= 2)ans = v[0] * v[1];

	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    string s; cin >> s;
    if (s[0] == 'A' and s[1] == 'A' and s[2] == 'A'){
        cout << "No" << endl;
    }else if (s[0] == 'B' and s[1] == 'B' and s[2] == 'B'){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
using System;

class C
{
	static void Main()
	{
		int k = int.Parse(Console.ReadLine()), t = 7;
		for (int i = 0; i < 1000000; i++)
		{
			if (t % k == 0)
			{
				Console.WriteLine(i + 1);
				return;
			}
			t = (t * 10 + 7) % k;
		}
		Console.WriteLine(-1);
	}
}

Measured memory_bytes: 27540
#include <iostream>
#include <algorithm>
#include <climits>
#define INF INT_MAX >> 1

using namespace std;

int n;
int t[17][17];
int dp[1<<17];

int solve(int state){
	if(state == (1 << n) - 1) return 0; 
	if(dp[state] != -1) return dp[state];
	int res = INF;
	for(int i=0; i<n; i++) {
		if((state >> i) % 2 == 0){
			int min_cost = t[i][0];
			for(int j=0; j<=n; j++) {
				if((state >> (j - 1)) % 2 == 1) {
					min_cost = min(min_cost, t[i][j]);
				}
			}
			res = min(res, min_cost + solve(state + (1 << i)));
		}
	}
	return dp[state] = res;
}

int main(void){
	while(1){
		cin >> n;
		if(!n) break;
		for(int i=0; i<n; i++){
			for(int j=0; j<n+1; j++){
				cin >> t[i][j];
			}
		}
		fill(dp, dp+(1<<17), -1);
		cout << solve(0) << endl;
	}
	return 0;
}


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

int n;
bool s0;
char s[10];

inline bool query(int p) {
	printf("%d\n", p);
	fflush(stdout);
	scanf("%s", s);
	if(s[0] == 'V') exit(0);
	if(s[0] == 'M') return true;
	return false;
}

int main() {

	scanf("%d", &n);
	int L = 1, R = n-1;
	s0 = query(0);
	while(L < R) {
		int mid = (L+R)>>1;
		bool c = query(mid);
		if(((mid&1)^c) != s0) R = mid-1;
		else L = mid+1;
	}
	query(L);
	return 0;
}


Measured memory_bytes: 852
#include <stdio.h>

int sort(const void* a, const void* b) {
  return *( int * )a - *( int * )b;
}

int main(void) {
    	int i,j,k,n,q,t;
	int S[100000];
	int T[50000];
	int R[500];
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &S[i]);
	}

	scanf("%d\n", &q);
	for(i=0;i<q;i++) {
		scanf("%d", &T[i]);
	}
	
	qsort((void*)S, n, sizeof(S[0]), sort);
	qsort((void*)T, q, sizeof(T[0]), sort);
	
	i=j=k=0;
	while(i<n&&j<q) {
		if(S[i] == T[j]) {
			R[k] = S[i];
			i++;j++;k++;
		} else if(S[i] > T[j]) {
			j++;
		} else if(S[i] < T[j]) {
			i++;
		}
	}
	printf("%d\n", k);

	return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef complex<double> pt;
typedef pair<pt,pt> L;
typedef vector<P> poly;
const double EPS = 1e-9;
#define x real()
#define y imag()
bool eq(double a,double b){
  return (-EPS < a-b && a-b < EPS);
}
double dot(pt a,pt b){
	return (conj(a)*b).x;
}
double cross(pt a,pt b){
	return (conj(a)*b).y;
}
int ccw(pt a,pt b,pt c){
	b -= a; c -= a;
	if(cross(b,c) > EPS) return 1; // counter clockwise
	if(cross(b,c) < -EPS) return -1; // clockwise
	if(dot(b,c) < -EPS) return 2; //c-a-b
	if(norm(b) < norm(c)) return -2; //a-b-c
	return 0; //a-c-b
}
bool cmp(const pt& a,const pt& b){
	if(-EPS < a.x-b.x && a.x-b.x < EPS) return a.y < b.y;
	else return a.x < b.x;
}
bool on_segment(pair<pt,pt> a,pt p){
  return eq(abs(a.first-a.second)-abs(a.first-p)-abs(a.second-p),0);
}
vector<pt>convex_hull(vector<pt>ps){
	sort(ps.begin(),ps.end(),cmp);
	int k=0,n = ps.size();
	vector<pt>qs(n*2);
	for(int i=0;i<n;i++)
	{
		while(k>1 && ccw(qs[k-2],qs[k-1],ps[i]) == -1) k--;
		qs[k++] = ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--)
	{
		while(k>t && ccw(qs[k-2],qs[k-1],ps[i]) == -1) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k-1);
	return qs;
}
bool contain_point(vector<pt>ps,pt p){
	double sum = 0;
	//arg no sum wo keisan
	for(int i=0;i<ps.size();i++){
		if(on_segment(mp(ps[i],ps[ (i+1)%ps.size() ]),p)) return 1;
		sum += arg( (ps[ (i+1)%ps.size() ]-p) / (ps[i]-p) );
	}
	return (abs(sum) > 1);
}
bool intersect(pt a,pt b,pt c,pt d){
	return (ccw(a,b,c)*ccw(a,b,d) <= 0 && ccw(c,d,a)*ccw(c,d,b) <= 0);
}
int n,m;
int main(){
	while(1){
		cin >> n >> m; if(!n) return 0;
		vector<pt>A,B;
		for(int i=0;i<n;i++){
			double xx,yy; scanf("%lf%lf",&xx,&yy);
			A.pb(pt(xx,yy));
		}
		for(int i=0;i<m;i++){
			double xx,yy; scanf("%lf%lf",&xx,&yy);
			B.pb(pt(xx,yy));
		}
		if(A.size() >= 3) A = convex_hull(A);
		if(B.size() >= 3) B = convex_hull(B);
		bool ok = 1;
		rep(i,A.size()){
			if(contain_point(B,A[i])) ok = 0;
		}
		rep(i,B.size()){
			if(contain_point(A,B[i])) ok = 0;
		}
		if(A.size()>=2 && B.size()>=2){
    		rep(i,A.size()){
    		    rep(j,B.size()){
    		        if(intersect(A[i],A[(i+1)%A.size()],B[j],B[(j+1)%B.size()])) ok = 0;
    		    }
    		}
		}
		puts(ok?"YES":"NO");
	}
}

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

int main(){
    int n, y;
    cin >> n >> y;
    bool flag = false;
    int ax = -1, ay = -1, az = -1;
    for(int b=0;b<=4000;++b){
        for(int c=0;c<=2000;++c){
            int a = n - b - c;
            if(a >= 0 && 1000*a + 5000*b + 10000*c == y){
                flag = true;
                ax = a;
                ay = b;
                az = c;
                break;
            }
        }
        if(flag)break;
    }
    cout << az << " " << ay << " " << ax << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<sstream>
#include<map>

using namespace std;

int dx[4]={1,-1,4,-4};
map<string,int>res;


void solve(void){
  queue<string>que;

  que.push("01234567");

  while(!que.empty()){

    string v=que.front();

    que.pop();

    int pos=0;
    for(int i=0;i<8;i++)
      if(v[i]=='0')pos=i;

    for(int i=0;i<4;i++){
      if(0 <= pos+dx[i] && pos+dx[i]<8 && 
	 !(pos==3 && i==0) && !(pos==4 && i==1)){
	string u=v;
	swap(u[pos],u[pos+dx[i]]);

	if(res[u]==0){
	  que.push(u);
	  res[u]=res[v]+1;
	}
      }
    }
  }

}

string itos(int i){
  ostringstream s;
  s << i;
  return s.str();
}

int main(void){
  int in;
  
  res["01234567"]=1;

  solve();

  while(true){
    string s;
    for(int i=0;i<8;i++){
      if(!(cin >> in))return 0;
      s+=itos(in);
    }

    cout << res[s]-1 << endl;
  }

  return 0;
}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans;
    if (k % 2 == 1)
        ans = pow(n / k, 3);
    else
        ans = pow(n / k, 3) + pow((n + k / 2) / k, 3);
    cout << ans << endl;
}

Measured memory_bytes: 384