akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string N;
	std::cin >> N;
	std::cout << "ABC" << N << "\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   ll x, k, d;
   cin >> x >> k >> d;
   x = abs(x);
   ll initmoves = x/d;
   if(k >= initmoves) {
      k -= initmoves;
      x -= initmoves*d;
      if(k % 2 == 0) {
         cout << x << "\n";
      } else {
         cout << min(abs(x-d), abs(x+d));
      }
   } else {
      x -= k*d;
      cout << x << "\n";
   }
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int M=4e5+5;
long long ans=1;
int si[N],vm[N],md[N],sd[N];
int n,now,cnt,v[M],vi[N],nex[M],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
void dfs(int x,int fa){
	if(vi[x])	si[x]=1;
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa){
			dfs(v[i],x);
			si[x]+=si[v[i]];
			if(md[v[i]]+1>md[x])	vm[x]=v[i],sd[x]=md[x],md[x]=md[v[i]]+1;
			else	sd[x]=max(sd[x],md[v[i]]+1);
		}
}
void Dfs(int x,int fa){
	int dep=md[fa]+1;
	if(vm[fa]==x)	dep=sd[fa]+1;
	if(x!=1){
		if(dep>md[x])	vm[x]=fa,sd[x]=md[x],md[x]=dep;
		else	sd[x]=max(sd[x],dep);
	}
	if(vi[x]){
		ans+=min(sd[x]+1,md[x]-1)+1;
	}
	else{
		int se=n;
		for(int i=head[x];i;i=nex[i])
			if(v[i]!=fa&&si[v[i]])
				se=min(se,md[v[i]]+1);
		if(si[x]!=cnt)	se=min(se,dep);
		int r=min(sd[x]+1,md[x]-1);
		if(r>=se)	ans+=r-se+1;
	}
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa)	Dfs(v[i],x);
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	for(int x,y,i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		addedges(x,y);
		addedges(y,x);
	}
	for(int i=1;i<=n;i++){
		char ch=getchar();
		while(ch!='0'&&ch!='1')	ch=getchar();
		if(ch=='1')	++cnt;
		vi[i]=ch^48;
	}
	dfs(1,0),Dfs(1,0);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 15232
# n = gets.split.map(&:to_i)
# array = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
#
#

a,b = gets.split.map(&:to_i)

res = -1
1000.times do |i|
  if (0.08*(i+1)).floor == a && (0.1*(i+1)).floor == b
    res = i+1
    break;
  end
end

puts res


Measured memory_bytes: 1788
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cut = []
for _ in range(M):
    a, b = map(int, input().split())
    cut.append([a, b])

cut = sorted(cut, key=lambda x: x[0])

ans = 1
ind = 0


s = cut[ind][0]
e = cut[ind][1]
while ind < M:
    n_s, n_e = cut[ind]
    if n_s < e:
        e = min(e, n_e)
    else:
        s = n_s
        e = n_e
        ans += 1
    ind += 1


print(ans)


Measured memory_bytes: 22124
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    for i in k..n {
        if a[i - k] < a[i] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine($"ABC{N}");
        }
    }
}


Measured memory_bytes: 27516
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	r := readInt()

	fmt.Println(r * r)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}
void solve()
{ ll x1,x2,x3,x4,x5;
  in x1>>x2>>x3>>x4>>x5;
  if(x1==0)
    out 1<<en;
  else if(x2==0)
    out 2<<en;
  else if(x3==0)
    out 3<<en;
  else if(x4==0)
    out 4<<en;
  else
    out 5<<en;
}


int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
           //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3652
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  #startline-------------------------------------------
    a = int(input())
    print(a+a**2+a**3)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 22000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int h, w;
    cin >> h >> w;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    auto dist = make_vec<int>(h, w);
    fill_v<int>(dist, INT_MAX);
    dist[sy][sx] = 0;
    using P = pair<int, int>;
    deque<P> dq;
    dq.push_front(P(sy, sx));

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

    while (!dq.empty()) {
        auto [y, x] = dq.front();
        dq.pop_front();
        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (s[ny][nx] == '#') continue;
            if (chmin(dist[ny][nx], dist[y][x])) dq.push_front(P(ny, nx));
        }
        for (int ny = y - 2; ny < h && ny <= y + 2; ++ny) {
            if (ny < 0) continue;
            for (int nx = x - 2; nx < w && nx <= x + 2; ++nx) {
                if (nx < 0) continue;
                if (s[ny][nx] == '#') continue;
                if (chmin(dist[ny][nx], dist[y][x] + 1)) dq.push_back(P(ny, nx));
            }
        }
    }
    cout << (dist[gy][gx] == INT_MAX ? -1 : dist[gy][gx]) << '\n';
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll odd = 0;
    for(int i=0; i<n+1; i++) {
        if(i%2!=0){
            odd++;
//            dbg(i);
        }
    }

    double ans=0;
    ans = (double)odd/n;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
  int q;
  for(;cin>>q;)
    {
      for(;q--;)
	{
	  int c,a,n;
	  int ans=0;
	  cin>>c>>a>>n;
	  while(n>0&&a>0&&c>0)
	    {
	      c--;a--;n--;
	      ans++;
	    }
	  while(a>0&&c>1)
	    {
	      c-=2;a--;
	      ans++;
	    }
	  while(c>2)
	    {
	      c-=3;
	      ans++;
	    }
	  cout<<ans<<endl;
	}
    }
}

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

int main(){
  int N,count;
  cin >> N;
  count = 0;
  int a[N];
  string flg;
  flg = "True";
  for(int i=0; i<N; i++){
    cin >> a[i];
    if(a[i]%2 == 1){
      flg="False";
    }
  } 
  while(flg == "True"){
    for(int i=0; i<N; i++){
      a[i] /= 2;
      if(a[i]%2 == 1){
        flg="False";
      }
    }
    count += 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
x=0
key = min(A)
while x==0:
    for i in range(N):
        if int(A[i]%key)==0:
            A[i]=key
        else:
            A[i]=A[i]%key
            
    if min(A)==key:
        print(key)
        break
    else:
        key = min(A)

Measured memory_bytes: 14228
//#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

const int nmax = 100;

int v[ 2 ][nmax + 1];

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

    for (int i = 1; i <= 2; ++ i) {
        for (int j = 1; j <= n; ++ j)
            cin >> v[ i ][ j ];
    }

    int s = 0;
    for (int i = 1; i <= n; ++ i)
        s += v[ 2 ][ i ];

    int ans = 0;
    for (int i = 1; i <= n; ++ i) {
        s += v[ 1 ][ i ];
        s -= v[ 2 ][i - 1];

        ans = max(ans, s);
    }
    cout << ans << "\n";
    return 0;
}


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

int a[200010];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 1;
	vector<int>s;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			count++;
		}
		else {
			s.push_back(count);
			count = 1;
		}
		if (i == n - 1) {
			s.push_back(count);
		}
	}
	sort(s.begin(), s.end());
	int ans = 0;
	int indexmax = s.size() - k;
	for (int i = 0; i < indexmax; i++) {
		ans += s[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {


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

    int coins = 0;

    if (A >= B) {
        coins += A;
        A  = A - 1;
    }

    else{
        coins += B;
        B = B -1 ;
    }


    if (A >= B) {
        coins += A;
        A  = A - 1;
    }

    else{
        coins += B;
        B = B -1 ;
    }


    cout << coins << endl;

}


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


int64_t L(int N,vector<int64_t> &Lucas){
    if (N==0) return 2;
    if (N==1) return 1;
    if (Lucas.at(N)>0) return Lucas.at(N);
    Lucas.at(N) = L(N-1,Lucas)+L(N-2,Lucas);
    return Lucas.at(N);
}


int main(){
    int N;
    cin >> N;
    vector <int64_t> Lucas(N+1);

    for (int i=0;i<=N;i++){
        Lucas.at(i)=-1;
    }

    cout << L(N,Lucas) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    // r * m + r = N (r <= m - 1)
    for(ll r = 1; r * (r + 2) <= N; r ++){
        if(N % r == 0){
            ans += N / r - 1;
        }

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


Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

ll dp[N],ar[N];
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n;
        cin>>n;
        for(int i=1; i<=n; ++i) {
            cin>>ar[i];
        }
        for(int i=2; i<=n; ++i) {
            if(i==2) {
                dp[i]=dp[i-1]+abs(ar[i]-ar[i-1]);
            } else {
                dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
            }
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}



Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long a,b,c,d,A,B,C,D,ans;
  cin>>a>>b>>c>>d;
  
  A=a*c;
  B=a*d;
  C=b*c;
  D=b*d;
  
  ans  = max(A,max(B,max(C,D)));
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#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;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
int N, M, Q;
vector<int> a, b, c, d;
vector<int> A;

ll dfs(int memo) {
    ll ans = 0;
    if (A.size() == N) {
        rep(i, Q){
            //if (i < N) cout << A[i] << " ";
            if (A[b[i]-1] - A[a[i]-1] == c[i]) ans += d[i];
        }
        //cout << endl;
        //if (ans) cout << ans << endl;
        return ans;
    }
    A.push_back(memo);
    int tmp = A[A.size()-1];
    while(tmp <= M) {
        vector<int> A2(A.size());
        copy(ALL(A), A2.begin());
        chmax(ans, dfs(tmp));
        swap(A, A2);
        tmp++;
    }
    return ans;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    ll ans = 0;
    rep2(i, 1, M+1) {
        A.clear();
        chmax(ans, dfs(i));
    }
    cout << ans << endl;
}


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

#define ONLINE_JUDGE

using namespace std;
#ifndef ONLINE_JUDGE
#define wi(x) cerr << #x << ": " << (x) << '\n';
#else
#define wi(x)
#endif


typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
template<typename T>
inline T getNum() {
    T k = 0;
    int c = getchar(), f = 1;
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for (; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}
#define gn() getNum<int>()
#define gl() getNum<ll>()
clock_t opt, edt;
inline void init() {
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
//    freopen("../input.txt", "w", stdout);
    opt = clock();
#endif
}

inline void tini() {
#ifndef ONLINE_JUDGE
    edt = clock();
    cerr << "\n#cost: " <<  (double)(edt - opt) / CLOCKS_PER_SEC << "s\n";
#endif
}

bool ish(int l, int r, string s) {
    for (int i = l, j = r; i < j; i++, j--) {
        if (s[i] != s[j]) return false;
    }
    return true;
}

int main() {
    init();
///////////////////////////////////////////////////////////////////////////////

    string s;
    cin >> s;
    int n = s.size();
    if (ish(0, n - 1, s) and ish(0, (n - 3 ) / 2, s) and ish((n + 1) / 2, n - 1, s))
        cout << "Yes";
    else
        cout << "No";









///////////////////////////////////////////////////////////////////////////////
    tini();
}



/*
char Ma[MAXN*2];
int Mp[MAXN*2];
void Manacher(char s[],int len){
    int l=0;
    Ma[l++]='$';
    Ma[l++]='#';
    for(int i=0;i<len;i++){
        Ma[l++]=s[i];
        Ma[l++]='#';
    }
    Ma[l]=0;
    int mx=0,id=0;
    for(int i=0;i<l;i++){
        Mp[i]=mx>i?min(Mp[2*id−i],mx−i):1;
        while(Ma[i+Mp[i]]==Ma[i−Mp[i]])Mp[i]++;
        if(i+Mp[i]>mx){
            mx=i+Mp[i];
            id=i;
        }
    }
}
*/
 /*
 * * abaaba
 * * i:     0 1 2 3 4 5 6 7 8 9 10 11 12 13
 * * Ma[i]: $ # a # b # a # a # b  #  a  #
 * * Mp[i]: 1 1 2 1 4 1 2 7 2 1 4  1  2  1
 */
 /*
char s[MAXN];
int main(){
    while(scanf("%s",s)==1){
        int len=strlen(s);
        Manacher(s,len);
        int ans=0;
        for(int i=0;i<2*len+2;i++)
            ans=max(ans,Mp[i]−1);
        printf("%d\n",ans);
    }
    return 0;
}
*/

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



int main(){
    //input
    /*
    int A = 5;
    int B = 4;
    */
    int N ;
    cin >> N;
    vector<int> H(N,0);
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }
    int tmp = H[0];
    int ans = 0;
    for (int i = 0; i < N; i++){
        if (H[i] >= tmp){
            tmp = H[i];
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int dis[100001][2];
vector<vector<int>> g;
void dfs(int c,int pr,int d,int ind)
{
	dis[c][ind]=d;
	for(auto x:g[c])
	{//cout<<c<<" "<<x<<endl;
		if(x!=pr)
		dfs(x,c,d+1,ind);
	}
	
}
int main()
{	
    
  
	int a,b,n,u,v;
    memset(dis,0,sizeof(dis));

	cin>>n>>u>>v;
	    u--;v--;
	g.assign(n,vector<int>());
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
			
	}
	dfs(u,u,0,0);
	dfs(v,v,0,1);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(dis[i][0]<dis[i][1])
		ans=max(ans,dis[i][1]-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11648
n = gets.chomp.to_i
numbers = gets.chomp.split.map(&:to_i)

count = 0

catch(:break) do
  loop do
    numbers = numbers.map do |number|
      if number.even?
        number / 2
      else
        throw :break
      end
    end
    count += 1
  end
end

puts count


Measured memory_bytes: 14244
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int N=2e5+5,b=1e9+7;
typedef unsigned long long ull;
ull a[N],k;
char c[N];
int n,s=1;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		k=0;
		scanf("%s",c);
		int l=strlen(c);
		for(int j=0;j<l;++j)	k=k*b+c[j];
		a[i]=k;
	}
	sort(a,a+n);
	for(int i=1;i<n;++i)	if(a[i]^a[i-1])	s++;
	printf("%d",s);
	return 0;
} 

Measured memory_bytes: 3300
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1000+20
#define ll long long
ll a[4];
int main()
{
	int flag = 1;
	cin >> a[0]>>a[1]>>a[2];
	sort(a, a + 3);
	for (int i = 0; i < 3; i++)
	{
		if (!(a[i] % 2))
		{
			flag = 0;
			break;
		}
	}
	if (flag)
		cout << a[0] * a[1] << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 3576
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+10;
LL ds[L];

void mul(vector<int>& a,vector<int>& b,vector<int>& c)
{
	assert(a.size()==b.size()&&a.size()==c.size());
	for(int i=0;i<c.size();i++){
		assert(0<=a[i]&&a[i]<a.size());
		c[i]=b[a[i]];
	}
}
vector<int> pw(vector<int> a,LL n)
{
	vector<int> p(a.size());
	vector<int> buf(a.size());
	for(int i=0;i<p.size();i++){
		p[i]=i;
	}

	while(n){
		if(n&1){
			mul(a,p,buf);
			buf.swap(p);
		}
		mul(a,a,buf);
		buf.swap(a);
		n/=2;
	}
	return p;
}

int main() {
	int N;
	cin >> N;
	LL p0;
	cin >> p0; 
	LL pre=p0;
	for(int i=0;i<N-1;i++){
		LL v;
		cin >> v;
		ds[i]=v-pre;
		pre=v;
	}
	vector<int> p(N-1);
	for(int i=0;i<N-1;i++){
		p[i]=i;
	}
	LL M,K;
	cin >> M >> K;
	for(int i=0;i<M;i++){
		int a;
		cin >> a;
		a--;
		swap(p[a-1],p[a]);
	}
	p=pw(p,K);
	assert(p.size()==N-1);
	cout << p0 << endl;
	pre=p0;
	for(int i=0;i<N-1;i++){
		pre+=ds[p[i]];
		cout << pre << endl;
	}

	return 0;
}



Measured memory_bytes: 2560
#include <iostream>

int main()
{
	long long h, w;
	std::cin >> h >> w;
	
	if (h == 1 || w == 1) {
		std::cout << 1 << std::endl;
	}
	else {
		std::cout << (h * w + 1) / 2 << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	int n;
	read(n);
	if(n<=999)puts("ABC");
	else puts("ABD");
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in sorted(A_dict.keys(), reverse=True):
    if key2 > 0:
        break

    if A_dict[key] > 3:
        if key1 == 0:
            key1 = key
        if key2 == 0:
            key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)

Measured memory_bytes: 18728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main() {
	int N, K;
	int d;
	cin >> N >> K;
	vector<int> D(K);
	vector<vector<int>> A(N, vector<int>(K, 0));
	for (int i = 0; i < K; i++){
		cin >> D[i];
		for(int j = 0; j < D[i]; j++){
			cin >> d;
			A.at(d - 1).at(i) = 1;
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < K; j++){
			if(A[i][j] == 1){
				ans++;
				break;
			}
		}
	}
	cout << N - ans;

	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;
int main() 
{
  long N = 0;

  cin >> N;

  double doubleN = (double)N;

  double sqrtN = floor(sqrt(doubleN));
  long intSqrt = (int)sqrtN;

  long cnt = 0;

  for (int i = intSqrt; i > 0; i--) {
    if (N % i == 0) {
      cnt = (i + (N / i)) - 2;
      cout << cnt << endl;
      return 0;
    }
  }
 
  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<vector<int> >cost(n,vector<int>(n));
		rep(i,n)rep(j,n)cost[i][j]=inf;
		while(m--){
			int a,b,c;
			cin>>a;
			if(a){
				cin>>a>>b>>c;
				a--;b--;
				cost[a][b]=cost[b][a]=min(c,cost[a][b]);
			}else{
				cin>>b>>c;
				b--;c--;
				vector<int>d(n,inf);
				d[b]=0;
				vector<bool>used(n);
				while(1){
					int v=-1;
					rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
					if(v==-1)break;
					used[v]=true;
					rep(i,n)d[i]=min(d[i],d[v]+cost[v][i]);
				}
				if(d[c]==inf)cout<<-1<<endl;
				else cout<<d[c]<<endl;
			}
		}
	}
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
typedef long long ll;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,b[N];
    ll ans = 0;
    cin >> n;
    for(int i = 1;i < n; ++i) cin >> b[i];
    for(int i = 2;i < n; ++i){
        ans += min(b[i-1],b[i]);
    }
    cout << ans + b[1] + b[n-1];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    std::vector<int> p(n);
    for(int i=0; i<n; i++)
    {
        std::cin >> p[i];
    }
    int cnt = 0;
    for(int i=0; i<n; i++) if(p[i] != i + 1) cnt++;
    if(cnt<=2) std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
// Selection Sort  選択ソート

#include <stdio.h>

// 標準出力にarrayを出力する関数
void printArray(int *A, int N){
    for(int i = 0; i < N; i++) {
        printf("%d", A[i]);
        if(i < N-1) printf(" ");  // 最後の要素以外は空白を挟む
    }
    printf("\n");
}

// Selection Sort  選択ソート
int selectionSort(int A[], int N){
    int count = 0;
    for (int i=0; i<N; i++){
        int minj = i;  // 最小値のidx
        for (int j=i; j<N; j++){
            if (A[j] <A[minj])
                minj = j;
        }
        if (minj != i){
            // [minj]の要素と[i]の要素を交換する
            int tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;

            count++;
        }
    }
    return count;
}

int main(int argc, char const *argv[])
{
    const int MAX = 100;
    int A[MAX];
    int N;
    int count;

    scanf("%d", &N);

    for(int i = 0; i < N; i++)
        scanf("%d", &A[i]);

    count = selectionSort(A, N);

    printArray(A, N);
    printf("%d\n", count);

    return 0;
}



Measured memory_bytes: 2092
#include <cstdio>
#include <algorithm>
#include <vector>
int main(){
  int i,x;
  std::vector<int>v;
  for(i=0;i<10;i++)scanf("%d",&x),v.push_back(x);
  std::sort(v.begin(),v.end());
  printf("%d\n%d\n%d\n",v[9],v[8],v[7]);
}

Measured memory_bytes: 2744
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
int main(){
    std::string S;

    std::cin>>S;

    long long K;
    std::cin>>K;

    if(S.length()==1){
        std::cout<<S<<std::endl;
        return 0;
    }

    int count=0;

    for(int i=0;S[i]=='1';i++){
        count++;
    }

    //std::cout<<count<<std::endl;


    if(count>=K) std::cout<<"1"<<std::endl;
    else std::cout<<S[count]<<std::endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
    int n;
    float ans;
    cin >> n;
    if (n % 2 == 0){
        ans = ((n/2) / (n*1.0));
    } else {
        ans = ((n/2 +1) / (n*1.0));
    }

    printf("%.10f", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);

int n;
int A[200];

int main()
{
  int i,m,q,judge1;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    judge1=solve(0,m);
    if(judge1==1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i,int m)
{
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 2672
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
    int ans=0;
    if(a>b)ans+=b;
    else ans+=a;
    if(c>d)ans+=d;
    else ans+=c;
    printf("%d",ans);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		long[] H = GetLongs(N);

		Array.Sort(H);
		long ans = 0;
		for(int i = 0; i < N - K; i++)
			ans += H[i];

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int in=0;in<n;in++){
		cin >> a[in];
	}

	int b[n];
	b[0] = a[0];
	for(int in=0;in<n/2;in++){
		b[0] -= a[2*in+1]-a[2*in+2];
	}
	for(int in=0;in<n-1;in++){
		b[in+1] = 2*a[in]-b[in];
	}

	for(int in=0;in<n;in++){
		cout << b[in]<< " ";
	}


	return 0;
}

Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 100228
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1)*100 + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            rest_g = g - (tot - P[i]*t - C[i])
            p = max(0, (rest_g+t-1)//t) # round up
            ans = min(ans, cnt - (P[i] - p))
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <map>

using namespace std;

class Counter
{
public:
    void Add(int num)
    {
        count_[num] += 1;
        UpdateBest(num);
    }

    int Count(int num) const
    {
        return count_.count(num) == 0 ? 0 : count_.at(num);
    }

    int FirstCommon() const { return first_; }
    int SecondCommon() const { return second_; }

private:
    void UpdateBest(int num)
    {
        if (first_ == -1 || count_[num] > count_[first_]) {
            second_ = first_;
            first_ = num;
        } else if (num != first_ && (second_ == -1 || count_[num] > count_[second_])) {
            second_ = num;
        }
    }

    map<int, int> count_;
    int first_ = -1;
    int second_ = -1;
};

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

    Counter evens;
    Counter odds;

    for (int i = 0; i < n; i += 1) {
        int num;
        cin >> num;
        (i % 2 == 0 ? evens : odds).Add(num);
    }

    pair<int, int> e = {evens.FirstCommon(), evens.SecondCommon()};
    pair<int, int> o = {odds.FirstCommon(), odds.SecondCommon()};

    int res = 0;
    if (e.first != o.first) {
        res = n - evens.Count(e.first) - odds.Count(o.first);
    } else {
        res = n - evens.Count(e.first) - odds.Count(o.second);
        res = min(res, n - evens.Count(e.second) - odds.Count(o.first));
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int h, w;
  cin >> h >> w;
  char c[h][w];
  rep(i, h){
    rep(j, w) cin >> c[i][j];
  }
  
  for(int i = 0; i < h + 2; i++) {
    for(int j = 0; j < w + 2; j++) {
      if(i == 0 || i == h + 1 || j == 0 || j == w + 1) cout << '#';
      else cout << c[i - 1][j - 1];
    }
    cout << endl;
  }
  return 0;
}


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

inline int lcm(int a,int b){
    if(a<b) swap(a,b);
    int n=a,m=b;
    while(a%b!=0){
        int t=b;
        b=a%b;
        a=t;
    }
    return n/b*m;
}

signed main(){
    int n; cin>>n;
    vector<int> t(n);
    rep(i,n) cin>>t.at(i);
    int ans=1;
    rep(i,n) ans=lcm(ans,t.at(i));
    cout<<ans<<endl;
}

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

class Program {
    static void Main(string[] args) {
        int N = Cin.Ni();
        int K = Cin.Ni();
        int total = 0;
        for (int i = 0; i < N; i++) {
            int x = Cin.Ni();
            total += Math.Min(x, K - x) * 2;
        }
        Console.WriteLine(total);
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


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

int main(){
    int a;
    int b;

    cin >> a >> b;
    if (a == b) cout << "a == b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else if(a < b) cout << "a < b" << endl;

    return 0;
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
   vector<int> a(3);
   for(auto &it:a)cin>>it;
   sort(all(a));
   cout<<a[0]+a[1]<<endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    int C = sc.nextInt();
	    
	    int remain = 0;
	    
	    if (A - B < C) {
	    	remain = C - (A - B);
	    }
	    System.out.println(remain);
	}	
}	

Measured memory_bytes: 22740
//abc075_a.cpp
//Sat Jul 21 20:54:29 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (a==b){
		cout << c << endl;
	}else if (a==c){
		cout << b << endl;
	}else if (b==c){
		cout << a << endl;
	}
}

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

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

Measured memory_bytes: 256
N = int(input())

plus = []
minus = []
for _ in range(N):
    x,y = map(int,input().split())
    plus.append(x+y)
    minus.append(x-y)

ans1 = max(plus) - min(plus)
ans2 = max(minus) - min(minus) 

print(max(ans1,ans2))

Measured memory_bytes: 24904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const ll mod = 1e6+7;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
    // cin >> tt;
    while((tt)--){
        ll n,k; cin  >> n >> k;
        ll cnt =0;
        while(n!=0){
            n/=k; cnt++;
        }
        cout << cnt << endl;
    }
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;
vector<ull> v[200001];
ull ans[200001];

int main(void) {
    ull n, q;
    int i, a, b;
    cin >> n >> q;
    for (i = 0; i < n-1; i++) {
        cin >> a >> b;
        v[b].push_back(a);
    }
    for (i = 0; i < q; i++) {
        cin >> a >> b;
        ans[a] += b;
    }
    for (i = 1; i <= n; i++) {
        for (auto it = v[i].begin(); it != v[i].end(); it++) {
            ans[i] += ans[*it];
        }
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0);
#define rep(I,x,n) for(int I=x;I<=n;I++)
using namespace std;
const int M=2019;
int main()
{
    int l,r;
    cin>>l>>r;
    int a=r-l;
    int mn=2019;
    l%=M,r%=M;
    if(r-l<a)
    {
        cout<<0;
        goto end;
    }
    rep(i,l,r-1)
    {
        rep(j,i+1,r)
        {
            int  r=(i%M)*(j%M);
            r%=M;
            mn=min(mn,r);
        }
    }
    cout<<mn;
    end:
    return 0;
}


Measured memory_bytes: 256