akhauriyash/Code-Regression huggingface dataset:
class Node:
    def __init__(self, key, pri):
        self.key = key
        self.pri = pri
        self.left  = None
        self.right = None


def rightRotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s

def leftRotate(t):
    s = t.right
    t.right = s.left
    s.left = t
    return s

def insert(t, key, pri):
    if t == None:
        return Node(key, pri)

    if key == t.key:
        return t

    if key < t.key:
        t.left = insert(t.left, key, pri)
        if t.pri < t.left.pri:
            t = rightRotate(t)
    else:
        t.right = insert(t.right, key, pri)
        if t.pri < t.right.pri:
            t = leftRotate(t)

    return t


def delete(t, key):
    if   t == None:
        return None

    if   key < t.key:
        t.left  = delete(t.left , key)
    elif key > t.key:
        t.right = delete(t.right, key)
    else:
        return _delete(t, key)
    return t


def _delete(t, key):
    if t.left == None and t.right == None:
        return None
    elif t.left  == None:
        t = leftRotate(t)
    elif t.right == None:
        t = rightRotate(t)
    else:
        if t.left.pri > t.right.pri:
            t = rightRotate(t)
        else:
            t = leftRotate(t)
    return delete(t, key)


def find(t, key):
    if t == None:
        return False

    if key == t.key:
        return True

    if key < t.key:
        return find(t.left, key)
    else:
        return find(t.right, key)

def priorder(t):
    if t == None:
        return

    print(' ' + str(t.key), end='')
    priorder(t.left)
    priorder(t.right)

def inorder(t):
    if t == None:
        return

    inorder(t.left)
    print(' ' + str(t.key), end='')
    inorder(t.right)


m = int(input())
t = None

for _ in range(m):
    com = input().split()

    if com[0] == 'insert':
        t = insert(t, int(com[1]), int(com[2]))
    elif com[0] == 'find':
        if find(t, int(com[1])):
            print('yes')
        else :
            print('no')
    elif com[0] == 'delete':
        t = delete(t, int(com[1]))
    elif com[0] == 'print':
        inorder(t)
        print()
        priorder(t)
        print()



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
const int MC = 200010;
int N;
P2 T[MC],S[MC];
int R[MC];
int V[MC];
int mx[MC] , mn[MC];
LL ans[MC];

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		int x,v;
		scanf("%d%d" , &x , &v);
		T[i] = MP(x,v);
		R[i] = i;
	}
	sort(T,T+N);
	sort(R,R+N,[&](int a , int b){return T[a].second < T[b].second;});
	repp(i,0,N){
		V[R[i]] = i + 2;
	}
	mx[0] = V[0];
	repp(i,1,N) mx[i] = max(V[i],mx[i-1]);
	mn[N-1] = V[N-1];
	repm(i,N-2,-1) mn[i] = min(V[i],mn[i+1]);
	repp(i,0,N) S[i] = MP(mx[i],mn[i]);
	//repp(i,0,N) printf("  %d %d %d\n" , mn[i] , mx[i] , V[i]);
	sort(S,S+N);
	ans[1] = 1;
	int z = 1;
	repp(i,0,N){
		while(z<S[i].first){
			(ans[z+1] += ans[z]) %= mod;
			//printf(" %d %lld\n" , z+1 , ans[z+1]);
			++z;
		}
		(ans[z] += ans[z] - ans[S[i].second-2] + mod) %= mod;
	}
	while(z<N+1){
		(ans[z+1] += ans[z]) %= mod;
		++z;
	}
	printf("%lld\n" , (ans[N+1] - ans[N] + mod) % mod);
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>

using namespace std;

int main(void) {
	int w, h;
	
	while(1){
		cin >> h >> w;
		
		if(w == 0 && h == 0){
			break;
		}
		
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(j % 2 == 0 && i % 2 == 0 || j % 2 == 1 && i % 2 == 1){
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

const int MAX = 510000;
const int MOD = 1000000007;

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

vector<vector<int> > G;
int N,K;

void dfs(int u, int p, ll &res, int depth) {
  int num = 0;
  for (auto v : G[u]) {
    if (p == v) continue;
    num++;
    dfs(v,u,res,depth+1);
  }
  if (depth == 0) (res *=  COM(K-1,num) * fac[num] % MOD) %= MOD; //nPk = nCk * k!
  else (res *= COM(K-2,num) * fac[num] % MOD) %= MOD;
}
 
int main(){

  cin >> N >> K;
  G.resize(N);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  COMinit();
  ll res = 1;
  dfs(0,-1,res,0);
  cout << res * K % MOD << endl;
  return 0;
}

Measured memory_bytes: 23552
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();

           double r = double.Parse(s);


            double area = r * r * Math.PI;
            double rect = 2 * r * Math.PI;
            
            Console.WriteLine(area+" "+rect);
            
        }
    }
}

Measured memory_bytes: 5740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

ans = 0
for i in 1..(N-1) do
  for j in (i+1)..N do
    ans += lines[1][i-1] * lines[1][j-1]
  end
end

print ans

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

int n;
int a[100];
pii dp[100][2];// 0:cell, 1:buy //F:num, S:money 
int ans;

void solve(){
    cin >> n;
    rep(i,1,n+1)
        cin >> a[i];
    dp[1][0] = {0LL,1000};
    dp[1][1] = {1000/a[1],1000%a[1]};
    ans = 1000;
    rep(i,2,n+1){
        rep(j,1,i){
            dp[i][0] = max({dp[i][0],{0LL,dp[j][1].F*a[i]+dp[j][1].S},dp[j][0]});
            dp[i][1] = max({dp[i][1],{dp[j][0].S/a[i],dp[j][0].S%a[i]},dp[j][1]});
        }
        ans = max({ans,dp[i][0].S,dp[i][1].S});
    }
    cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[105][105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<pll> A(N);
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }

    REP(i, N + 1) {
        REP(j, N + 1) {
            dp[i][j] = INF;
        }
        dp[i][i] = 0;
    }

    FOR(len, N, 1) {
        REP(left, N) {
            if (left + len >= N)
                break;
            REP(i, len) {
                ll mul = dp[left][left + i] + dp[left + i + 1][left + len];
                mul += A[left].first * A[left + i].second * A[left + len].second;
                dp[left][left + len] = std::min(dp[left][left + len], mul);
            }
        }
    }

    cout << dp[0][N - 1] << endl;
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 long long int a,b,n;
 cin >> a >> b >> n;
 if(n<b)
 cout << (a*n)/b;
 else
 cout << (a*(b-1))/b;
 return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    char ch; cin >> ch;
    if(ch >= 'A' && ch <= 'Z')
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3636
import sys
 
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 10**5//1
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        til = A - y
        titen.append(til)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 # Uncomment before submission
main()

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

using namespace std;

typedef long long int lli;
int main(){
	lli x[2], y[2];
	cin >> x[0] >> x[1] >> y[0] >> y[1];
	vector<lli> ans;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			ans.push_back(x[i]*y[j]);
		}
	}
	sort(ans.begin(), ans.end());
	auto f = ans.back();
	cout <<  f << endl;
}


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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++) cin >> a.at(i);
    map<ll, ll> ma;
    for(int i = 0; i < N; i++) ma[a.at(i)]++;
    ll ans = 0;
    for (auto& it : ma) ans += it.second * (it.second - 1) / 2;
    for(int i = 0; i < N; i++) {
        ll val = ma[a.at(i)];
        ll before = val * (val - 1) / 2;
        ll after = (val - 1) * (val - 2) / 2;
        cout << ans + after - before << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Cell
{
    public int X { get; set; }
    public int Y { get; set; }
    public string CellType { get; set; }
    public int Step { get; set; }

    public static Cell[] GetCells(char[] row, int y)
    {
        var cells = Enumerable.Range(0, row.Length).Select(x => new Cell
        {
            X = x + 1,
            Y = y,
            CellType = Convert.ToString(row[x]),
            Step = -1,
        });
        return cells.ToArray();
    }

}


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var n = Read();
        var s = Console.ReadLine();
        long count = 0;
        for(int i = 0; i < n-1; i++)
        {
            if (s[i] != s[i + 1])
                count++;
        }
        Console.WriteLine(count+1);



        Console.Out.Flush();
    }
}

Measured memory_bytes: 13116
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T> T extgcd(T a, T b, T& x, T& y) {
	for (T u = y = 1, v = x = 0; a;) {
		T q = b / a;
		swap(x -= q * u, u);
		swap(y -= q * v, v);
		swap(b -= q * a, a);
	}
	return b;
}

template<class T> T md_inverse(T a, T m) {
	T x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

template<class T>
pair<T, T> liner_congruence(const vector<T>& B, const vector<T>& M) {
	T x = 0, m = 1; // x = 0(mod 1)
	for (int i = 0; i < sz(B); i++) {
		T a = m, b = B[i] - x;
		T d = gcd(M[i], a);
		if (b % d != 0) return pair<T, T>(0, -1); // no solution
		T t = b / d * md_inverse<T>(a / d, M[i] / d) % (M[i] / d);
		x = x + m * t;
		m *= M[i] / d;
		x = (x % m + m) % m;
	}
	return pair<T, T>(x, m);
}

int main() {
	ll n;
	int m, d; cin >> n >> m >> d;
	vector<ll> va(m);
	FOR(i, m) cin >> va[i];
	FOR(i, d) {
		vector<ll> B, M;
		FOR(j, m) {
			int a; cin >> a;
			if (a == -1) continue;
			B.push_back(a);
			M.push_back(va[j]);
		}
		auto kv = liner_congruence(B, M);
		if (kv.second == -1) {
			n = -1;
			break;
		}
		auto cur_rem = n % kv.second;
		if (cur_rem > kv.first) {
			n -= cur_rem - kv.first;
		} else if (cur_rem < kv.first) {
			n -= (cur_rem + (kv.second - kv.first));
		}
		if (n < 0) break;
	}

	if (n < 0) n = -1;
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1220
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    long[] ns;
    foreach (k; 3..10) {
        foreach (x; 0..3^^k) {
            int a, b, c;
            long n;
            foreach (_; 0..k) {
                n *= 10;
                if (x%3 == 0) {
                    n += 3;
                    ++a;
                } else if (x%3 == 1) {
                    n += 5;
                    ++b;
                } else {
                    n += 7;
                    ++c;
                }
                x /= 3;
            }
            if (a && b && c) ns ~= n;
        }
    }
    sort(ns);
    auto N = readln.chomp.to!long;
    int i;
    while (i < ns.length && ns[i] <= N) ++i;
    writeln(i);
}

Measured memory_bytes: 2428
//26/07/18 19:49
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=0,right=0;
			for(int j=0;j<i;j++)
				if(s[j]==c){
					left=1;
					break;
				}
			for(int j=i;j<n;j++)
				if(s[j]==c){
					right=1;
					break;
				}
			if(left&&right)
				cnt++;
		}
		if(ans<cnt)
			ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H, W, i, j, k;
	for (i = 0; i < 100000; i++){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break;
		}
		else{
			for (j = 0; j < H; j++){
				for (k = 0; k < W; k++){
				if(0<k&&k < W - 1&&0<j&&j<H-1){
						cout << ".";
					}
				else{ cout << "#"; }
				}
				cout << endl;
			}

			cout << endl;
				
				}
				
	}
	return 0;
}


Measured memory_bytes: 3080
defmodule Main do
  @limit 1000000000000000000
  def main do
    _ = IO.gets("")
    a = IO.gets("")
        |> String.trim()
        |> String.split(" ")
        |> Enum.map(&String.to_integer/1)

    a
    |> Enum.sort(:asc)
    |> calc(1)
    |> case do
      x when is_integer(x) -> IO.puts(x)
      y                    -> IO.puts(y)
    end

  end

  def calc([x | _], acc) when x*acc > @limit, do: "-1"
  def calc([x | _], _) when x == 0, do: 0
  def calc([], acc), do: acc
  def calc([x | tail], acc), do: calc(tail, x*acc)

end


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

int main(){
int N;
  cin>>N;
  
  int ans=0;
  for(int i=1; i<=N; i+=2){
     int count=0;
    for(int j=1; j<=i; j+=2){
     if(i%j==0){count++;} 
    }
   if(count==8){ans++;}
  }
  
  cout<<ans;
}

Measured memory_bytes: 384
import bisect

n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
m = aaa[-1]
ri = bisect.bisect(aaa, m // 2)
if ri == 0:
    print(m, aaa[0])
else:
    r1, r2 = aaa[ri - 1], aaa[ri]
    d1 = m - 2 * r1
    d2 = 2 * r2 - m
    if d1 <= d2:
        print(m, r1)
    else:
        print(m, r2)


Measured memory_bytes: 14052
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n, ans;
	double x1, y1, r1, x2, y2, r2, dis;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
		dis = hypot(x2 - x1, y2 - y1);
		ans = 0;

		if (dis < r1 - r2) { ans = 2; }
		else if (dis < r2 - r1) { ans =  -2; }
		else if (r1 + r2 >= dis) { ans = 1; }

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

Measured memory_bytes: 3280
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a , b ;
int main()
{
 //   freopen ("143A.inp","r",stdin) ;
 //   freopen ("143A.out","w",stdout) ;
    cin >>a >> b ;
    if (a- 2*b <= 0 )
        cout << 0  ;
    else cout << a - 2*b ;
    return 0;
}


Measured memory_bytes: 256
<?php
list($n) = ints();
$a = ints();
$c = 0;
for ($i = 0; $i < $n; ++$i) $c ^= $a[$i];
echo $c === 0 ? 'Yes' : 'No';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 26620
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int maxx=0;
	int a[25]={0};
	int b[25]={0};
	int n;
	cin >> n;
	int cnt=0;
	for (int i=0;i<n;i++)
	cin >> a[i];
	for (int i=1;i<n-1;i++)
	{
		if(a[i]>a[i-1]&&a[i]<a[i+1])
		{
			if(b[a[i]])
			continue;
			b[a[i]]++;
			cnt++;
		}
		else
		if(a[i]<a[i-1]&&a[i]>a[i+1])
		{
			if(b[a[i]])
			continue;
			b[a[i]]++;
			cnt++;
		}		
//		cout << minx;	
	} 
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const int MAX_V = 200001;
vector<vector<P>> G(MAX_V);

int prim() {
    vector<int> used(MAX_V, false);
    priority_queue<P, vector<P>, greater<P>> que;
    int ret = 0;
    que.push(P(0, 0));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (used[p.second]) continue;
        used[p.second] = true;
        ret += p.first;
        rep(i, G[p.second].size()) {
            que.push(P(G[p.second][i]));
        }
    }
    return ret;
}

int main()
{
    int N;
    cin >> N;
    vector<P> x(N), y(N);

    rep(i, N) {
        int ix, iy;
        cin >> ix >> iy;
        ix--; iy--;
        x[i] = P(ix, i);
        y[i] = P(iy, i);
    }

    sort(all(x));
    sort(all(y));

    rep(i, N - 1) {
        int px = x[i].first, index = x[i].second;
        int px2 = x[i + 1].first, index2 = x[i + 1].second;
        G[index].push_back(P(abs(px - px2), index2));
        G[index2].push_back(P(abs(px - px2), index));
    }
    rep(i, N - 1) {
        int py = y[i].first, index = y[i].second;
        int py2 = y[i + 1].first, index2 = y[i + 1].second;
        G[index].push_back(P(abs(py - py2), index2));
        G[index2].push_back(P(abs(py - py2), index));
    }

    cout << prim() << endl;
    return 0;
}

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

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

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

i64 f(i64 x) {
    return x ? 1 + f(x % __builtin_popcountl(x)) : 0;
}

void solve() {
    i64 n;
    cin >> n;
    string x;
    cin >> x;
    i64 cnt = count(all(x), '1');

    if (cnt == 1) {
        for (i64 i = 0; i < n; i++) {
            cout << (x[i] == '1' ? 0 : x.back() == '1' ? 2 : i == n - 1 ? 2 : 1) << endl;
        }
        return;
    }

    vector<i64> modc(n), modf(n);
    i64 ci = 1, fi = 1;
    for (i64 i = 0; i < n; i++) {
        modc[n - i - 1] = ci;
        modf[n - i - 1] = fi;
        ci = (ci << 1) % (cnt + 1);
        fi = (fi << 1) % (cnt - 1);
    }

    i64 sumc = 0, sumf = 0;
    for (i64 i = 0; i < n; i++) {
        if (x[i] == '0') continue;
        sumc = (sumc + modc[i]) % (cnt + 1);
        sumf = (sumf + modf[i]) % (cnt - 1);
    }

    for (i64 i = 0; i < n; i++) {
        i64 y = x[i] == '0'
            ? (sumc + modc[i]) % (cnt + 1)
            : (sumf - modf[i] + cnt - 1) % (cnt - 1);
        cout << 1 + f(y) << endl;
    }
}

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


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

int main() {
    int N, K;
    cin >> N >> K;
    int x, cnt;
    for (int i = 0; i < N; i++){
        cin >> x;
        cnt += min(x,abs(K-x));
    }
    cout << cnt*2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
	bool alp[26] = {};
	string str;
	cin >> str;
	bool flg = true;
	for (auto&& c : str) {
		if (alp[(int)(c - 'a')]) {
			flg = false; break;
		}
		else {
			alp[(int)(c - 'a')] = true;
		}
	}
	cout << (flg ? "yes" : "no") << endl;
	return 0;
}

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

/*動的計画法で解く*/
int main(){
	//入力1行目
	int a, b;
	while(std::cin >> a >> b){
		if(a == 0 && b == 0) break;
	//入力2行目
		int n;
		std::cin >> n;
		//二次元のベクタ用意(a*b) dpはパターン数をいれる 1で初期化しておく（結局上書き）
		std::vector<std::vector<int> > dp(a, std::vector<int>(b, 1));
		//工事中の点に0をいれる
		int x, y;
		for(int i = 0; i < n; ++i){
			std::cin >> x >> y;
			//端が工事中になればそのうえかみぎは全て0
			if(y == 1){
				for(int i = x - 1; i < a; ++i){
					dp[i][y - 1] = 0;
				}
			}
			else if(x == 1){
				for(int i = y - 1; i < b; ++i){
					dp[x - 1][i] = 0;
				}
			}
			else{
				dp[x - 1][y - 1] = 0;
			}
		}
		//求める処理　現在の点は左の点と下の点を足す
		for(int i = 1; i < a; ++i){
			for(int j = 1; j < b; ++j){
				if(dp[i][j] != 0){
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				}
			}
		}
		std::cout << dp[a - 1][b - 1] << std::endl;
	}
}

Measured memory_bytes: 1216
from collections import defaultdict,deque
n,m = map(int,input().split())
d = defaultdict(list)
for i in range(m):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)

visited = [False]*(n+1)
que = deque([1])
visited[1] = True
ans = [-1]*(n+1)

while que:
    v = que.popleft()
    vlist = d[v]
    for next in vlist:
        if not visited[next]:
            que.append(next)
            visited[next] = True
            ans[next] = v

if -1 in ans[2:]:
    print('No')
    exit()
print('Yes')
for i in range(2,n+1):
    print(ans[i])

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int N;
vector<string> out;

void dfs(int curr, deque<char>& cs) {
  if (cs.size() == N) {
    string s;
    rep(i, cs.size()) s.push_back(cs[i]);
    out.push_back(s);
    return;
  }
  rep(i, curr + 1) {
    cs.push_back('a' + i);
    dfs(max(i + 1, curr), cs);
    cs.pop_back();
  }
}

int main() {
  cin >> N;
  deque<char> cs;
  dfs(0, cs);
//  sort(out.begin(), out.end());
  rep(i, out.size()) {
    cout << out[i] << "\n";
  }
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];

    for(int i = 0; i < n; i++){
        int l = 1e9, index = 0;
        for(int j = 0; j < m; j++){
            if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < l){
                l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                index = j;
            }
        }
        put(index+1);
    }
}

Measured memory_bytes: 256
/*---> praveenojha33 <---> 01 September 2019 <--- > 17:36:57 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=0,cur=0,prev=a[0];
	for(int i=1;i<n;i++){
		if(a[i]<=prev){
			cur++;
			prev=a[i];
		}
		else{
			cur=0;
			prev=a[i];
		}
		ans=max(ans,cur);
	}
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict
N = int(input())
A = map(int,input().split())
dic = defaultdict(int)
for a in A: dic[a] += 1

ans = 0
for k in dic.keys():
    n = dic[k]
    if n < k: ans += n
    elif k < n: ans += n-k

print(ans)

Measured memory_bytes: 23660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef pair<ll,ll> P;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int tmp=0;
  rep(i,n)if(a[i]<0)tmp++;
  int mini=abs(a[0]);
  if(tmp%2==1)rep(i,n)mini=min(mini,abs(a[i]));
  else mini=0;
  ll tot=0;
  rep(i,n)tot+=abs(a[i]);
  tot-=abs(2*mini);
  cout<<tot<<endl;
  return 0;
  }


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

int main() {
	int w, h;
	do {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	} while (w != 0 || h != 0);
	return 0;
}


Measured memory_bytes: 3088
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   
    ll n,i;cin>>n;
    string s;cin>>s;
    if (n%2==1)	cout<<"No"<<endl;
    else
    {
    	ll flag=0;
    	for (i=0;i<n/2;i++)
    	{
    		if (s[i]!=s[i+n/2])
    		{
    			flag=1;
    			break;
    		}
    	}
    	if (flag)	cout<<"No"<<endl;
    	else	cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    bool flag = false;
    rep(i, S.size()) {
        if (S[i] == 'C') {
            flag = true;
        } else if (flag & S[i] == 'F') {
            yes;
            return 0;
        }
    }
    no;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> p(N);
    for (int i = 0; i < N; i++) { std::cin >> p[i]; }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (p[i] == i + 1) { std::swap(p[i], p[i + 1]), ans++; }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();

			if (s.charAt(0) != 'A') {
				System.out.println("WA");
				return;
			}

			if (s.charAt(1) < 'a' || 'z' < s.charAt(1)) {
				System.out.println("WA");
				return;
			}

			if (s.charAt(s.length() - 1) < 'a' || 'z' < s.charAt(s.length() - 1)) {
				System.out.println("WA");
				return;
			}

			boolean hasC = false;
			for (int i = 2; i < s.length() - 1; i++) {
				char c = s.charAt(i);

				if (c == 'C') {
					if (hasC) {
						System.out.println("WA");
						return;
					} else {
						hasC = true;
					}
				} else if (s.charAt(i) < 'a' || 'z' < s.charAt(i)) {
					System.out.println("WA");
					return;
				}
			}

			if (hasC) {
				System.out.println("AC");
			} else {
				System.out.println("WA");
			}
		}
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include<map>
#include<set>

#include <unordered_map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

void solver() {
    int n,k;
    cin>>n>>k;
    long long ans=k;
    for(int i=1;i<n;i++)
    {

            ans*=k-1;

    }
    cout<<ans;






}

int main() {
    int n=1;
    //cin >> n;
    while (n--) {
        solver();
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,h,a,b;
vector<P> vec;

int main(){
	cin >> n >> h;
	REP(i,0,n){
		cin >> a >> b;
		vec.push_back({a, 1});
		vec.push_back({b, 0});
	}
	sort(vec.rbegin(), vec.rend());
	
	ll c = 0;
	REP(i,0,vec.size()){
		if(vec[i].second == 0){
			h -= vec[i].first;
			c++;
		}else if(vec[i].second == 1){
			cout << c + (h + vec[i].first -1) / vec[i].first << endl;
			break;
		}
		
		if(h <= 0){
			cout << c << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2420
s=input()
v=1e9

for k in set(s):
  t=s
  c=0
  while len(set(t))>1:
    u=""
    for (i,j) in enumerate(t[:-1]):
      if t[i]==k or t[i+1]==k:
        u+=k
      else:
        u+=j
    c+=1
    t=u
  v=min(v,c)

print(v)

Measured memory_bytes: 3060
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = int> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

TPL<TNM T> using vec2 = decltype(make_v<T>(0, 0));
TPL<TNM T> using vec3 = decltype(make_v<T>(0, 0, 0));
TPL<TNM T> using vec4 = decltype(make_v<T>(0, 0, 0, 0));
TPL<TNM T> using vec5 = decltype(make_v<T>(0, 0, 0, 0, 0));


int main(void) {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	vector<int> xc, yc;
	xc.reserve(3000 * 3000);
	yc.reserve(3000 * 3000);

	for (int i = 0; i <= F; ++i) {
		for (int j = 0; j <= F; ++j) {
			int x = 100 * (A*i + B*j);
			int y = C*i + D*j;
			if (x <= F)xc.push_back(x);
			if (y <= F)yc.push_back(y);
		}
	}

	double ans = -1.0;
	int ansY = -1;
	int ansX = -1;
	REP(i, xc.size()) {
		int x = xc[i];
		REP(j, yc.size()) {
			int y = yc[j];
			if (x / 100 * E >= y && (x + y <= F)) {
				double con = 100.0 * y / (x + y);
				if (ans < con) {
					ans = con;
					ansX = x;
					ansY = y;
				}
			}
		}
	}

	cout << ansX + ansY << " " << ansY << endl;

	return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int A = 0,B = 0,x = 0;

		A = sc.nextInt();
		B = sc.nextInt();
		x = B % A;

		if(x == 0) {
			System.out.println(A + B);
		}else {
			System.out.println(B - A);
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef pair<long long,long long> pll;
typedef long long ll;
const int inf   = 1<<30-1;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int gcd(int x,int y){
  if(x>y)swap(x,y);
  if(y%x==0) return x;
  else return gcd(y%x,x);
  }
int main(){
  int n,k;
  cin>>n>>k;
  int a[n],ma=0;
  rep(i,n){
    cin>>a[i];
    ma=max(a[i],ma);
    }
  if(ma<k){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
    }
  int g=a[0];
  rep(i,n)
    g=gcd(g,a[i]);
  if(k%g==0)
    cout<<"POSSIBLE"<<endl;
  else
    cout<<"IMPOSSIBLE"<<endl;
  return 0;
  }


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int64_t n,sum=0,a=0;
	cin >> n;
	map<int64_t, int64_t> g;
	vector<int64_t> b;
	for(int i = 0; i < n; ++i) {
		cin >> a;
      	sum+=a;
		++g[a];
	}
	int q; cin >> q;
	for(int i = 0; i < q; ++i) {
		int x, y; cin >> x >> y;
		sum -= x * g[x];
		sum += y * g[x];
		g[y] += g[x];
		g[x] = 0;
		cout << sum << endl;
	}
}

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

int main(){
int N;
cin>>N;
int K;
cin>>K;
vector<long long> H(N);
for(int i=0;i<N;i++){
  cin>>H[i];
}
 sort(H.begin(), H.end()); 
 reverse(H.begin(), H.end()); 
 long long a=0;
 for(int i=K;i<N;i++){
   a+=H[i];
 }
 cout<<a<<endl;
 return 0;

}


Measured memory_bytes: 4788
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({ a * c, a * d, b * c, b * d });
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int maxn=3009;

int n,m,K;

int a[maxn][maxn];

long long f[maxn][maxn][4];

int main(){
	cin>>n>>m>>K;
	while(K--){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		a[x][y]=z;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			for(int k=0;k<=3;++k){
				long long t=max(max(f[i-1][j][0],f[i-1][j][1]),max(f[i-1][j][2],f[i-1][j][3]));
				f[i][j][k]=max(f[i][j-1][k],t);
				if(k)f[i][j][k]=max(f[i][j-1][k-1]+a[i][j],f[i][j][k]);
				if(k)f[i][j][k]=max(f[i][j][k],t+a[i][j]);
			}
		}
	}
	printf("%lld",max(max(f[n][m][0],f[n][m][1]),max(f[n][m][2],f[n][m][3])));
	return 0;
}

Measured memory_bytes: 321032
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,cnt[100005],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		cnt[a]++,ans=max(ans,cnt[a]);
		cnt[a+1]++,ans=max(ans,cnt[a+1]);
		if(a-1>=0) cnt[a-1]++,ans=max(ans,cnt[a-1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second0
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
int main() {
	ll v[3][3], difx[3][2], dify[3][2];
	bool b = 1;
	rep(i, 3)rep(j, 3)cin >> v[i][j];
	rep(i, 3)rep(j, 2)difx[i][j] = v[i][j + 1] - v[i][j];
	rep(i, 3)rep(j, 2)dify[i][j] = v[j + 1][i] - v[j][i];
	rep(i, 2) {
		if (difx[0][i] != difx[1][i] || difx[1][i] != difx[2][i] || difx[0][i] != difx[2][i])b = 0;
		if (dify[0][i] != dify[1][i] || dify[1][i] != dify[2][i] || dify[0][i] != dify[2][i])b = 0;
	}
	cout << yn(b) << endl;
	return 0;
}

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	char c;
	bool flag = false;
	cin >> n;
	
	while ((c = getchar())) {    //改行される、すなわちエンターキーが押されるまで
		if (flag && c == '\n')break;

		if (64 <= c && c <= 90)
		{
			c += n;
			if (c > 90)c -= 26;
			printf("%c", c);    //文字で出力
			flag = true;
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = function (r) {
    return Math.pow(r, 2) * 3;
};
var exec = function () {
    var r = require('fs').readFileSync('/dev/stdin', 'UTF-8');
    var res = exports.main(Number(r));
    console.log(res);
};
exec();


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    ll res=0;
    if("RRR"==s) res = 3;
    else if("RRS"==s || "SRR"==s) res = 2;
    else if("SSR"==s || "SRS"==s || "RSS"==s || "RSR"==s) res = 1;
    cout << res << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if (y % 2 || x * 2 > y || x * 4 < y) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
typedef long long ll;
const int maxn = 3e5 + 5;
using namespace std;
ll m,k;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int k, n;
	cin >> k >> n;
	rep(i, n - k + 1, n + k - 1)cout << i << ' ';

		cin >> n;
}

/*
3 7
*/

Measured memory_bytes: 256
#include <cstdio>
int a[100005];
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
	//freopen("aa.in","r",stdin);//freopen("");
	int i,j,_,n,k,b,A;
	scanf("%d%d",&n,&k);A=0;
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(i>1)b=gcd(b,a[i]);else b=a[i];
		if(a[i]>A)A=a[i];
	}
	if(k<=A&&k%b==0)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 512
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
int N;
cin >> N;
vector<int> A(N+2);
A[0]=0;
A[N+1]=0;
for(int i = 1;i<=N;i++){
	cin >> A[i];
}
long long S = 0;
for(int i = 0;i < N+1; i++){
	S += abs(A[i]-A[i+1]);
}
for(int i = 1;i<=N;i++){
	cout << S - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]) << endl;
}
}

Measured memory_bytes: 1664
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ans = True
x = [a,b,c,d,e]
dist = max(x) - min(x)
if dist > k:
    ans = False

print("Yay!" if ans else ":(")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll A, B;
    cin >> A >> B;
    if (A == 1) {
        A += 13;
    }
    if (B == 1) {
        B += 13;
    }

    if (A > B) {
        cout << "Alice" << endl;
    } else if (A < B) {
        cout << "Bob" << endl;
    } else if (A == B) {
        cout << "Draw" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636