akhauriyash/Code-Regression huggingface dataset:
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
			double x1 = scan.nextDouble();
			double y1 = scan.nextDouble();
			double x2 = scan.nextDouble();
			double y2 = scan.nextDouble();
			double ans =Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
			System.out.println(ans);

	}

}

Measured memory_bytes: 28124
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int N;
  int X;
  int L[100000];
  int S;
  int i;
  int n;
  n=1;
  S=0;
  
  cin >> N;
  cin >> X;
  for(i=0;i<N;i++){
    cin >> L[i];
  }
  for(i=0;i<N;i++){
      S=S+L[i];
     if(S<=X){
       n=n+1;
    }
  }
  cout << n;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [a, b, c] <- sortOn Down <$> readInt
  put $ a * 10 + b + c


Measured memory_bytes: 380
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

// int next_lunlun(ll n){
//     vector<int> digits;
//     while(n){
//         digits.pb(n%10);
//         n /= 10;
//     }
//     // reverse(digits.begin(),digits.end());
//     ll num_digits = digits.size(); 
//     int count_9 = 0;
//     for(int i: digits)
//         if(i == 9)
//             count_9++;
//     if(count_9 == num_digits)
//         return ;
//     for(int i=0;i<(num_digits-1);i++){
//         if(digits)
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n, x, y;
        cin>>n>>x>>y;
        x--;y--;
        // cout<<x<<" "<<y<<"\n";
        vector<ll> dist(n,0);
        for(ll i=0;i<n;i++){
            for(ll j=i+1;j<n;j++){
                ll new_dist = 1 + abs(x-i) + abs(j-y);
                // cout<<i<<" "<<j<<" "<<j-i<<" "<<new_dist<<"\n";
                dist[min(j-i,new_dist)]+=1;
            }
        }
        for(int i=1;i<n;i++){
            cout<<dist[i]<<"\n";
        }
    }
}

Measured memory_bytes: 3596
<?php

$num=trim(fgets(STDIN));
$numbers=explode(" ",trim(fgets(STDIN)));
$original=$numbers;

sort($numbers);
$replaced=$numbers;

$count=0;

foreach ($original as $k=>$v){
    if ($original[$k]!=$replaced[$k]){
     $count++;    
    }
    
}

echo ($count==0||$count==2) ? "YES":"NO";

?>

Measured memory_bytes: 4728
#include <stdio.h>



const int MAX_V = 1000000;
int prime[1000001];



int main(){
    int i,k,v;
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    
    for(i = 2; i*i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i; k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    
    
    while(1){
        scanf("%d", &v);
        for(i = v; i > 1; i--){
            if(prime[i] == 1 && prime[i-2] == 1){
                printf("%d %d\n", i-2, i);
                break;
            }
        }
        if(v == 0 || v == 1)break;
    }
    
    return 0;
}

Measured memory_bytes: 4504
n,x,y = map(int,input().split())
k = [0]*(n-1) #k-1に対応
for i in range(1,n):
    for j in range(i+1,n+1):
        s = min(abs(j-i),abs(j-y)+abs(i-x)+1)
        k[s-1] += 1
for i in k:
    print(i)

Measured memory_bytes: 9252
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N, W = MAP()
    VW = [LIST() for i in range(N)]

    dp = [[0] * (W + 1) for _ in range(N+1)]
    for i in range(N-1, -1, -1):
        for j in range(W+1):
            if j < VW[i][1]:
                dp[i][j] = dp[i+1][j]
            else:
                dp[i][j] = max(dp[i+1][j], dp[i+1][j-VW[i][1]] + VW[i][0])

    print(dp[0][W])


if __name__ == '__main__':
    main()


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

int main(){
    string s,t;
    cin>>s>>t;
    int num=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            num++;
            
        }
    }
    cout<<num<<endl;
    
   
}
    
    

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

int main(void){
    string S; cin >> S;
    int i, flag;

    for (i = 0, flag = 0; i < 3; i++){
        if (S.at(i) == S.at(i + 1)) flag = 1;
    }
    if (flag == 0) {
        cout << "Good" << endl;
    }else {
        cout << "Bad" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)

int main()
{
	string s;
	cin >> s;
	int n,w;
	cin >> w;
	n = s.length();
	int i=0;
	while(i*w < n)
	{
		cout << s[i*w];
		i++;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string x, y; cin >> x >> y;
    cout << ((x<y) ? "<" : ((x==y) ? "=" : ">")) << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    string a, b;
    cin >> a >> b;
    if(a.size() != b.size()){
        cout << (a.size() > b.size() ? "GREATER" : (a.size() < b.size()) ? "LESS" : "EQUAL");
        return;
    }
    int n = a.size();
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            cout << "GREATER";
            return;
        }
        else if(a[i] < b[i]){
            cout << "LESS";
            return;
        }
    }
    cout << "EQUAL";
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int temp;
void dfs(int x,vector<ll> v[],int visited[])
{
    visited[x]=1;
    temp++;
    for(int i=0;i<v[x].size();i++)
    {
        if(visited[v[x][i]]==0)
        {
            dfs(v[x][i],v,visited);
        }
    }
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
int main()
{
    fastio();
   
    ll n;
    cin>>n;
    ll a[n];
    cn(a,n);
    int f=0;
    map<ll,ll> m;
    for(int i=0;i<n;i++)
    {
        ll x = a[i];
        for(int j=2;j*j<=x;j++)
        {
            if(x%j==0)
            {
                if(m[j]==1)
                {
                    f=1;
                    break;
                }
                m[j]=1;
                while(x%j==0)
                {
                    x=x/j;
                }
            }
        }
        if(x>1)
        {
            if(m[x]==1)
            {
                f=1;
                break;
            }
            m[x]=1;
        }
        if(f==1)
            break;
    }
    if(f==0)
    {
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    f=0;
    int g = a[0];
    for(int i=1;i<n;i++)
    {
        g = gcd(g,a[i]);
    }
    if(g==1)
    {
        cout<<"setwise coprime"<<endl;
    }
    else
    {
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 11424
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

#define ld long double

ld fastExp(ld base, int power){
	if(power == 0) return 1.0;
	ld aux = fastExp(base, power/2);
	aux = aux*aux;
	if(power%2 == 1) aux = aux*base;
	return aux;
}

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	ld p = 1.0/(ld)n;
	ld ans = 0.0;
	int lim = ceil(log2(k));
	for(int i = 1; i <= n; i++){
		if(i >= k) ans += p;
		else{
			int aux = i, cnt = 0;
			while(aux < k){
				cnt++;
				aux *= 2;
			}
			ans += p*fastExp(0.5, cnt);
		}
		//else ans += p*fastExp(0.5, lim-ceil(log2(i)));
	}
	printf("%.15Lf\n", ans);
	return 0;
}

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

int main() {
	int w, h, n; cin >> w >> h >> n;
	

	int wide[2] = {0,w}, height[2] = {0,h};
	for (int i = 0; i < n; i++) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) wide[0] = max(wide[0], x);
		else if (a == 2)wide[1] = min(wide[1], x);
		else if (a == 3)height[0] = max(height[0], y);
		else height[1] = min(height[1], y);
	}
	cout << max(0,(wide[1] - wide[0])) * max(0,(height[1]-height[0])) << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll A,B,C;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>A>>B>>C;
    cout<<((A==B && B==C)? "Yes":"No")<<endl;
}


Measured memory_bytes: 256
s = input()
s = s.replace("BC", "D")
#print(s)

ans = 0
cnt_a = 0
for i in range(len(s)):
    if s[i] in ["B", "C"]:
        cnt_a = 0
    elif s[i] == "A":
        cnt_a += 1
    elif s[i] == "D":
        ans += cnt_a

print(ans)


Measured memory_bytes: 3500
a = [1, 0, 0, 0]
MOD = 10**9 + 7
gets.chomp.chars.each do |c|
  case c
  when ?A
    a[1] += a[0]
  when ?B
    a[2] += a[1]
  when ?C
    a[3] += a[2]
  when ??
    a = [
      a[0] * 3,
      a[1] * 3 + a[0],
      a[2] * 3 + a[1],
      a[3] * 3 + a[2]
    ]
  else
    raise
  end
  (0..3).each{|i| a[i] %= MOD}
end
p a[3]

Measured memory_bytes: 12540
N = int(raw_input())
ans = 100000
for i in range(N+1):
  a = i
  b = N -i
  da = 0
  db = 0
  while a > 0:
    da += a % 9
    a /= 9
  while b > 0:
    db += b % 6
    b /= 6
  ans = min(ans, da+db)
print ans


Measured memory_bytes: 5764
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

puts A.map.with_index { |a, index| [a, index+1] }.sort { |a, b| a[0] <=> b[0] }.map { |x| x[1] }.join(' ')



Measured memory_bytes: 25124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;
#define pi 3.14159265359

int main(){
   double R;
   cin >> R;

cout << 2*R*pi <<endl;
}

Measured memory_bytes: 3776
#include <stdio.h>
int main()
{
    int r, c = 0;
    int a, b, d, e = 0;
    int f, g, h, i = 0;
    int j, k, l = 0;
    int A[101][101] = {0};
    scanf("%d %d", &r, &c);
    for (a = 0; a < r; a++)
    {
        for (b = 0; b < c; b++)
        {
            scanf("%d", &A[a][b]);
        }
    }
    for (d = 0; d < r; d++)
    {
        for (e = 0; e < c; e++)
        {
            A[d][c] = A[d][c] + A[d][e];
        }
    }
    for (f = 0; f < c; f++)
    {
        for (g = 0; g < r; g++)
        {
            A[r][f] = A[r][f] + A[g][f];
        }
    }
    for (i = 0; i < r; i++)
    {
        for (j = 0; j < c; j++)
        {
            A[r][c] = A[r][c] + A[i][j];
        }
    }
    for (k = 0; k <= r; k++)
    {
        for (l = 0; l <= c; l++)
        {
            if (l == c)
            {
                printf("%d\n", A[k][l]);
            }
            else
            {
                printf("%d ", A[k][l]);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2108
def main():
    a,b = map(int,input().split())
    pictureList = [ input() for _ in range(a)]
    row = b+2

    print(row*'#')
    for i in pictureList:
        print('#'+i+'#')
    print(row*'#')
    


if __name__== "__main__":
    main() 






Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int sum;
int main() {
	int n,k;
	cin>>n>>k;
	vector<int>vec(n);
	for(int i=0;i<n;i++){
		cin>>vec.at(i);
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	for(int i=0;i<k;i++){
		sum+=vec.at(i);
	}
	cout<<sum<<endl;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int d, x; cin>>d>>x;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    vector<int> c(n,1);
    REP(i,n){
        int cnt = a[i]+1;
        while(cnt<=d){
            cnt+=a[i];
            c[i]++;
        }
    }
    int ans = accumulate(all(c),0) + x;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import sys

def wantp(n):

    wpq = []
    while n != p[n]:
        wpq.append(n)
        n = p[n]

    for i in wpq:
        p[i] = n

    return n


N , M = map(int,input().split())

a = list(map(int,input().split()))


p = [i for i in range(N)]
rank = [1] * N

dic = {}

ans = 0

for i in range(M):

    x,y = map(int,input().split())

    xp = wantp(x)
    yp = wantp(y)

    if xp != yp:

        if rank[xp] < rank[yp]:
            p[xp] = yp
        elif rank[xp] > rank[yp]:
            p[yp] = xp
        else:
            p[yp] = xp
            rank[yp] += 1

for i in range(N):

    now = i
    np = wantp(now)

    if np not in dic:
        dic[np] = []

    dic[np].append(a[i])

    """

    if np not in dic:
        dic[np] = [float("inf"),float("inf"),float("inf")]

    if dic[np][1] > a[i]:
        dic[np][2] = dic[np][1]
        dic[np][1] = a[i]

    elif dic[np][2] > a[i]:
        dic[np][2] = a[i]

    if dic[np][2] == float("inf"):
        dic[np][0] = dic[np][1]
    else:
        dic[np][0] = dic[np][1] + dic[np][2]

    """



ans = 0
able = []
#print(dic)

for i in dic:
    dic[i].sort()
    ans += dic[i][0]

    for j in range(len(dic[i])-1):
        able.append(dic[i][j+1])
    

able.sort()

if len(dic) == 1:
    print (0)
    sys.exit()

elif len(dic) - 1 > N // 2:
    print ("Impossible")
    sys.exit()

for i in range(len(dic)-2):

    ans += able[i]

print (ans)

    


Measured memory_bytes: 87192
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c;
  while(cin>>a>>b){
    c = a+b;
    int ans=1;
    while(c>=10){
      c/=10;
      ans++;
    }
    cout<<ans<<endl;
  } 
  
  return 0;
}


Measured memory_bytes: 3076
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
  
#たて
if True in [A[0][i]==A[1][i] and A[1][i]==A[2][i] for i in range(3)]:
  print("Yes")
#よこ
elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")
#ななめ
elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")
#ダメ
else:
  print("No")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N, A;
    cin >> N >> A;

    ll change = N % 500;
    cout << ((change <= A) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;
int main(){

	ll n; cin >>n;
	ll ans=0;
	if(n==1){cout <<0 << endl;return 0;}
	if(n==2){cout << 0 << endl;return 0;}
	for(int i=1;i<sqrtl(n);i++){
		if(n%i==0)
          if(n/i!=i+1 &&n/i!=i-1)ans+=(n/i-1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e10
using namespace std;

int main(){
	long long n,t,high,low;
	cin>>n>>t;
	long long a[n],tmp[n];
	rep(i,n){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i--){
		if(i==n-1)tmp[i]=a[i];
		else{
			if(tmp[i+1]<a[i])tmp[i]=a[i];
			else tmp[i]=tmp[i+1];
		}
	}
	long long cnt=0,diff=0;
	int er;
	rep(i,n){
		if((tmp[i]-a[i])>diff){
			diff=tmp[i]-a[i];
			cnt=1;
		}else if((tmp[i]-a[i])==diff){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  ll n,w;cin>>n>>w;
  vector<vector<ll>> v(n,vector<ll>(2));
  rep(i,n){
    cin>>v[i][0]>>v[i][1];
  }
  vector<vector<ll>> dp(n,vector<ll> (100000+1,10000000000000));
  rep(i,v[0][1]+1)dp[0][i]=v[0][0];
  dp[0][0]=0;
  rep(i,n-1){
    rep(j,100001){
      if(j-v[i+1][1]>=0)dp[i+1][j]=min(dp[i][j],dp[i][j-v[i+1][1]]+v[i+1][0]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  // rep(i,n){
  //   rep(j,30)cout<<dp[i][j]<<" ";
  //   cout<<endl;
  // }
  ll ans=100000;
  while(dp[n-1][ans]>w)ans--;
  cout<<ans<<endl;

}

Measured memory_bytes: 82376
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 30 , 2019
 * 
 */

#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto (i)=0 ; (i)<(x); ++(i))
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;






auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 


    vi v(3);
    iv(v);
    sort(all(v));
    cout<<v[0]+v[1]<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	int N;
	set<int> d;
	cin >> N;
	REP(i, N) {
		int val;
		cin >> val;
		d.insert(val);
	}
	cout << d.size() << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph  = vector<vector<int>>;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n,vector<int>(0));
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<int>dist(n,-1);
    queue<int> que;
    dist[0]=0;
    que.push(0);
    vector<int>ans(n);
    rep(i,n)ans[i]=-1;
    ans[0]=0;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv:G[v]){
            if(dist[nv]!=-1)continue;
            dist[nv]=dist[v]+1;
            ans[nv]=v;
            que.push(nv);
            //cout << "q" << nv << "v" << v << endl;
        }
    }
    bool ok = true;
    rep(i,n){
        if(ans[i]==-1){
            ok = false;
            //cout << "yatu" << i << endl;
            }
    }
    if(ok){
        cout << "Yes" << endl;
        rep(i,n-1)cout << ans[i+1]+1 << endl;
    }else cout << "No" << endl;
    //cout << "hello" << endl;
    return 0;
}

Measured memory_bytes: 10652
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

cnt = 0
0.upto(n - 1) do |i|
  minj = i

  (i + 1).upto(n - 1) do |j|
    if a[j] < a[minj]
      minj = j
    end
  end

  if i != minj
    tmp = a[i]
    a[i] = a[minj]
    a[minj] = tmp

    cnt += 1
  end
end
puts a.map(&:to_s).join(' ')
puts cnt


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

int main(void) {
    int n = 0;
    vector<int> a;
    vector<int> b;
    while (true) {
        int x, y;
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
        if (a.at(n) == 0 && b.at(n) == 0) {
            break;
        }
        n++;
    }
    for (int i = 0; i < n; i++) {
        if (a.at(i) < b.at(i)) {
            cout << a.at(i) << " " << b.at(i) << endl;
        }
        else {
            cout << b.at(i) << " " << a.at(i) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
L, R = map(int, input().split())
  
min = 2018

for i in range(L, R):
  for j in range(L + 1, R + 1):
    result = (i * j) % 2019
    if (result < min):
      min = result
      if min == 0:
        break
  if min == 0:
    break
    
print(min)

Measured memory_bytes: 38896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int X = in.Int();
            out.println(lcm(X, 360) / X);
        }

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

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

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int  main()
{
	long n; cin >> n;
	long sum = 0;
	vector<long> v(n);
	long total = 0;
	rep(i, n)
	{
		cin >> v[i];
		total += v[i];
	}
	// sort(v.begin(), v.end());
	priority_queue<long, vector<long>, greater<long> > q;
	long ans = LONG_MAX;
	rep(i, n-1)
	{
		sum+=v[i];
		q.push(labs(total - 2*sum));
		ans = min(ans,labs(total- 2*sum));
	}
	cout << q.top() << endl;
	// cout << ans << endl;
	return (0);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, M, K;
    cin >> N >> M >> K;

    REP(i, N+1){
    	REP(j, M+1){
    		if((N-i)*j + (M-j)*i == K){
    			cout << "Yes" << endl;
    			return 0;
    		}
    	}
    }
    cout << "No" <<endl; 
    return 0;
}

Measured memory_bytes: 256
from heapq import*
I=float("inf")
def m():
 n=int(input())
 A=[]
 for _ in[0]*n:
  e=list(map(int,input().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()


Measured memory_bytes: 40092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int a, b;
    cin >> a >> b;
    cout << a*b;

    return 0;
}


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

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

        string str = Console.ReadLine ();

        int flg = 0;
        int flg2 = 0;
        
        for(int i=1;i<4;i++){
            if(str[0].Equals(str[i])){
                flg++;
            }
        }
        if(flg == 1)flg2 ++;
        flg = 0;
        for(int i=0;i<4;i++)
        {
            if(i != 1){
            if(str[1].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 1)flg2 ++; 
        flg = 0;
        for(int i=0;i<4;i++)
        {
            if(i != 2){
            if(str[2].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 1)flg2 ++; 
        flg = 0;
        for(int i=0;i<4;i++)
        {
            if(i != 3){
            if(str[3].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 1)flg2 ++; 

        string ans = "No";
        if(flg2 == 4 && !(str[0].Equals(str[1]) && str[0].Equals(str[2])&&str[0].Equals(str[3]))) ans = "Yes"; 

       
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: usize = scan(tokens);
    let b: usize = scan(tokens);
    let mut x = a;
    let mut y = b;
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    println!("{}", a * (b / x));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = l; i <= r; i ++)
#define task "abc065"
#define fi first
#define se second
#define int long long
using namespace std;
typedef pair < int, int > pii;
typedef pair < int, pii > data;
const int maxn = 1e5 + 11;
int n;
pii a[maxn];
int b[maxn];
priority_queue < data, vector < data >, greater < data > > q;
int operator *(pii x, pii y)
{
    return min(abs(x.fi - y.fi), abs(x.se - y.se));
}
vector < int > par;
int Find(int u)
{
    return (par[u] == u)? u : (par[u] = Find(par[u]));
}
bool dsu(int u, int v)
{
    u = Find(u);
    v = Find(v);
    if(u == v) return 0;
    par[v] = u;
    return 1;
}
int ans = 0;
main()
{
    //freopen(task".inp", "r", stdin);
    //freopen(task".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    FOR(i, 1, n)
    {
        cin >> a[i].fi >> a[i].se;
        b[i] = i;
    }
    sort(b + 1, b + 1 + n, [](int u, int v)
    {
        return ((a[u].fi < a[v].fi) || (a[u].fi == a[v].fi && a[u].se < a[v].se));
    });
    FOR(i, 1, n - 1)
    {
        int u = b[i];
        int v = b[i + 1];
        q.push({a[u]*a[v], {u, v}});
    }
    sort(b + 1, b + 1 + n, [](int u, int v)
    {
        return ((a[u].se < a[v].se) || (a[u].se == a[v].se && a[u].fi < a[v].fi));
    });
    FOR(i, 1, n - 1)
    {
        int u = b[i];
        int v = b[i + 1];
        q.push({a[u]*a[v], {u, v}});
    }
    par.resize(n + 5);
    FOR(i, 1, n) par[i] = i;
    int tmp = 0;
    while(!q.empty())
    {
        if(tmp == n - 1) break;
        int u = q.top().se.fi;
        int v = q.top().se.se;
        int len = q.top().fi;
        q.pop();
        if(dsu(u, v))
        {
            tmp ++;
            ans += len;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 10864
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, a[100010], f[100010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "Draw";
        return 0;
    }
    if (a == 1) {
        cout << "Alice";
        return 0;
    }
    if (b == 1) {
        cout << "Bob";
        return 0;
    }
    if (a > b) cout << "Alice";
    else cout << "Bob";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 666666
inline __int128 read()
{
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
  
inline void write(__int128 x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
__int128 arr[N];
int main()
{
    int n;
    int g=0,f=1;
    n = read();
    for(int i=1;i<=n;i++) {
	arr[i]=read();if(!arr[i]) g=1;
	}
	if(g){
		cout<<"0";return 0;
	}
    __int128 ans=1;
    
   for(int i=1;i<=n;i++){
         ans*=arr[i];
         if(ans>1000000000000000000){
         	f=0;
         	break;
		 }
    }
    if(!f) cout<<"-1";else write(ans);
    return 0;
}

Measured memory_bytes: 5152
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;

	co(A <= B ? "unsafe" : "safe");





	Would you please return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const ll MAX_N = 2e5 + 10;
ll n;
ll fenSum[MAX_N];
ll cnt[MAX_N];
pii Query[MAX_N];

ll Arr[MAX_N];
ll ind;

ll Map (ll d) {
	return lower_bound(Arr, Arr + ind, d) - Arr + 1;
}

void upd (ll d) {
	ll tmp = d;
	for (; tmp < MAX_N; tmp += tmp & -tmp) {
		fenSum[tmp] += Arr[d - 1];
		cnt[tmp]++;
	}
}

ll getNum (ll d) {
	ll c = 0, pointer = 0;
	for (ll i = 20; ~i; i--)
		if ((pointer | (1 << i)) < MAX_N && c + cnt[pointer | (1 << i)] < d) {
			pointer |= (1 << i);
			c += cnt[pointer];
		}

	return pointer + 1;
}

ll getSum (ll d) {
	ll res = 0;
	for (; d; d -= d & -d)
		res += fenSum[d];

	return res;
}

ll getCnt (ll d) {
	ll res = 0;
	for (; d; d -= d & -d)
		res += cnt[d];

	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		ll type;
		cin >> type;

		Query[i] = {-1, -1};
		if (type == 1) {
			ll a, b;
			cin >> a >> b;

			Query[i] = {a, b};
			Arr[ind++] = a;
		}
	}

	sort(Arr, Arr + ind);
	ind = unique(Arr, Arr + ind) - Arr;

	ll num = 0;
	ll val = 0;

	for (ll i = 0; i < n; i++) {
		if (Query[i].first != -1) {
			upd(Map(Query[i].first));
			val += Query[i].second;
			num++;
		}
		else {
			ll tmp = getNum((num + 1) / 2);
			ll calc = getCnt(tmp) * Arr[tmp - 1] - getSum(tmp);
			calc += (getSum(MAX_N - 1) - getSum(tmp)) - (num - getCnt(tmp)) * Arr[tmp - 1];
			cout << Arr[tmp - 1] << " " << val + calc << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>
using namespace std;
char s[10];
int main()
{
    scanf("%s",s);
    int cnt = 0;
    for(int i = 0; i < 3; i++)
    {
        s[i] == 'o' ? cnt++:cnt;
    }
    printf("%d\n",700 + cnt*100);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=(1<<18)+5,mo=998244353;
int n,s;
int a[N],f[N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
void up(int &x){x+=(x>>31)&mo;}
void fwt(int *a,int sig){
	int A;
	for(int i=1;i<1<<n;i<<=1)for(int j=0;j<1<<n;j+=i*2)
		fo(k,0,i-1)A=a[j+k],up(a[j+k]+=a[i+j+k]-mo),up(a[i+j+k]=A-a[i+j+k]);
	if(sig){
		int y=ksm(1<<n,mo-2);
		fo(i,0,(1<<n)-1)a[i]=(ll)a[i]*y%mo;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	fo(i,0,(1<<n)-1)cin>>a[i],s+=a[i];
	s=ksm(s,mo-2);
	f[0]=(1<<n)-1;
	fo(i,1,(1<<n)-1)f[i]=mo-1;
	fo(i,0,(1<<n)-1)a[i]=(ll)a[i]*s%mo;
	up(a[0]-=1);
	fwt(a,0);fwt(f,0);
	fo(i,0,(1<<n)-1)a[i]=(ll)f[i]*ksm(a[i],mo-2)%mo;
	fwt(a,1);
	int dt=a[0];
	fo(i,0,(1<<n)-1)up(a[i]-=dt),printf("%d\n",a[i]);
}

Measured memory_bytes: 4864