akhauriyash/Code-Regression huggingface dataset:
difficulties, goal = map(int, input().split())

pcs = [list(map(int, input().split())) for _ in range(difficulties)]

dp = [[0] * 1102 for _ in range(difficulties + 1)]

total_problem = 0
for d, pc in enumerate(pcs, 1):
    problem, complete = pc
    total_problem += problem

    score = {x: x*100*d for x in range(problem)}
    score[problem] = problem * 100 * d +complete

    for i in range(1, total_problem + 1):
        for j in range(0, i + 1):
            if i - j > problem:
                dp[d][i] = max(dp[d][i], dp[d - 1][j])
            else:
                dp[d][i] = max(dp[d][i], dp[d-1][j] + score[i-j])

for i, a in enumerate(dp[difficulties]):
    if a >= goal:
        print(i)
        exit()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,c=0;
    cin >> n;
    string s;
    cin >> s;
    for (ll i=0;i<n;i++){
        if (s[i]=='R')c++;
    }
    if (c>n/2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int x;
    cin>>x;
    cout<<360/__gcd(x,360)<<endl;
}



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

int main(){
    int H, W;
while(1){
    cin>>H>>W;
if(H==0 && W==0)break;
else
    for(int i=1;i<=H;i+=1){
        for(int j=1;j<=W;j+=1){
            if(i!=1 && i!=H && j!=1 && j!=W)
              cout<<".";
            else cout<<"#";
           }
        cout<<endl;
       }
    cout<<endl;
}
    return 0;
}


Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			string s = Console.ReadLine();
			int q = int.Parse(Console.ReadLine());
			bool rev = false;
			for (int i = 0; i < q; i++) {
				string input = Console.ReadLine();
				if (input == "1") {
					rev = !rev;
				} else {
					if (input[2] == '1' ^ rev) {
						a.Append(input[4]);
					} else {
						b.Append(input[4]);
					}
				}
			}
			string a2 = a.ToString();
			string b2 = b.ToString();
			if (rev) {
				s = string.Join("", s.Reverse());
				b2 = string.Join("", b2.Reverse());
				s = b2 + s + a2;
			} else {
				a2 = string.Join("", a2.Reverse());
				s = a2 + s + b2;
			}
			Console.WriteLine(s);
			Console.Out.Flush();
		}
	}
}


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




int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += i <= 9;
    ans += 100 <= i and i <= 999;
    ans += 10000 <= i and i <= 99999;
    ans += 1000000 <= i and i <= 9999999;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		int mina = s.length();
		int maxz = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(a[i] == 'A') {
				mina = Math.min(mina, i);
			}
			if(a[i] == 'Z') {
				maxz = Math.max(maxz, i);
			}
		}
		System.out.println((maxz - mina) + 1);

	}

}


Measured memory_bytes: 26524
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a + b) * (h >> 1);
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

int main(){
	int n;
	cin>>n;
	vector<bool>dp(120,false);
	dp[0]=true;
	rep(i,110)if(dp[i]==true)dp[i+4]=true;
	rep(i,110)if(dp[i]==true)dp[i+7]=true;
	
	if(dp[n])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: i64 = read();
    let A: i64 = read();
    let B: i64 = read();
    let max = std::cmp::max(A, B);
    let min = std::cmp::min(A, B);
    if (max - min) % 2 == 0 {
        println!("{}", (max - min) / 2);
        return;
    }
    if (N - max) > min - 1 {
        println!("{}", min + (max - min - 1) / 2);
    } else {
        println!("{}", N - max + 1 + (max - min - 1) / 2);
    }
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int a,b,k; cin>>a>>b>>k;
    cout<<max(0ll,a-k);
    k=k-min(a,k);
    cout<<" "<<max(0ll,b-k);
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


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

using namespace std;

int main()
{
	char c[5][5];
	for (size_t i = 0; i < 3; i++)
	{
		cin >> c[i];
	}

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}

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

using namespace std;

int main()
{
  int x[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
        if (x[i] == 0)
        {
            cout << i + 1;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3596
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    t = min(b[i], a[i])
    ans += t
    b[i] -= t
    t2 = min(b[i], a[i+1])
    a[i+1] -= t2
    ans += t2
print(ans)

Measured memory_bytes: 19648
from math import gcd

K = int(input())
t = 0
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a == b == c:
                t += a
            elif a == b:
                t += gcd(a,c)*3
            elif b == c:
                t += gcd(a,c)*3
            elif a == c:
                t += gcd(a,b)*3
            else:
                t += gcd(gcd(a,b), c) * 6
print(t)

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

int main(void){
  int x, y, ans = 2100000000;
  cin >> x >> y;
  // x < y
  if(x<=y) ans = min(ans,y-x);
  //-x < y
  if(-x<=y) ans = min(ans, y+x+1);
  //x < -y
  if(x<=-y) ans = min(ans, -y-x+1);
  //-x < -y
  if(-x<=-y) ans = min(ans, -y+x+2);
  cout << ans << endl;
  return 0;
}


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


int main()
{
    string s;
    cin>>s;
    int a = s[0] -'0';
    int b = s[1] -'0';
    int c = s[2] -'0';
    int d = s[3] -'0';

    if( a+b+c+d == 7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    }
    else if( a+b+c-d == 7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    }
    else if( a+b-c+d == 7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    }
    else if( a-b+c+d == 7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    }
    else if( a+b-c-d == 7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7;
    }
    else if( a-b+c-d == 7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    }
    else if( a-b-c+d == 7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    }
    else if( a-b-c-d == 7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7;
    }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

ll f[N];
ll inv[N];

ll get(ll a, ll b) {
  ll res = 1ll;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1;
    a = (a * a) % MOD;
  }
  return res;
}

ll ncr(ll n, ll r) {
  if(n < r or n < 0 and r < 0) return 0;
  ll cur = f[n];
  cur = (cur * inv[r]) % MOD;
  cur = (cur * inv[n - r]) % MOD;
  return cur;
}

int main() {
  int n, x; cin >> n >> x;
  vector <int> a(n);
  for(auto &k : a) {
    cin >> k;
  }
  sort(a.begin(), a.end());
  int gcd = 0;
  for(int i = 0; i < n - 1; i++) {
    gcd = __gcd(gcd, a[i + 1] - a[i]);
  }
  int ans = 0;
  for(auto k : a) {
    ans = max(ans, __gcd(abs(x - k), gcd));
  } 
  print(ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  rep2(i, k, n+2){
    ll l = (ll)i * (i-1)/2;
    ll r = (ll)i * ((n-i+1)+n)/2;
    ans += (r-l+1);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    map<char, vector<int>> idx;
    rep(i, n) {
        idx[s[i]].push_back(i);
    }
    rep(i, 1000) {
        string ns = to_string(i);
        if (i < 10) ns = "0" + ns;
        if (i < 100) ns = "0" + ns;
        int pos = -1;
        bool f = true;
        rep(ii, 3) {
            auto it = upper_bound(all(idx[ns[ii]]), pos);
            if (it == idx[ns[ii]].end()) {
                f = false;
                break;
            }
            pos = *it;
        }
        // if (f) printf("%s\n", ns.c_str());
        if (f) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import Control.Exception (assert)

main = do
  n <- readLn
  s <- BS.getLine
  assert (BS.length s == 2 * n) $ return ()
  let loop :: N -> Int -> Int -> N
      loop !acc !k !i | BS.length s == i = if k == 0 then acc else 0
                      | BS.index s i == 'W' = if even k
                                              then loop (acc * fromIntegral k) (k-1) (i+1)
                                              else loop acc (k+1) (i+1)
                      | otherwise = if even k
                                    then loop acc (k+1) (i+1)
                                    else loop (acc * fromIntegral k) (k-1) (i+1)
  print $ loop (product $ map fromIntegral [1..n]) 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

fromIntegral_Int64_N :: Int64 -> N
fromIntegral_Int64_N n | 0 <= n && n < modulo = N n
                       | otherwise = N (n `mod` modulo)

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}

{-# RULES
"fromIntegral/Int->N" fromIntegral = fromIntegral_Int64_N . fromIntegral
"fromIntegral/Int64->N" fromIntegral = fromIntegral_Int64_N
 #-}


Measured memory_bytes: 892
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
int A, B, C, D;

cin >> A;
cin >> B;
cin >> C;
cin >> D;

for (int i = 0; i < 65535; i++)
{
    if(i % 2 == 0){
       // 高橋君の攻撃
       // cout << "高橋君の攻撃" << endl;
       C = C - B;
       if (C<=0){
           cout << "Yes" << endl;
           break;
       }
       
    }
    else{
        //青木君の攻撃
        // cout << "青木君の攻撃" << endl;
        A = A - D;
        if (A<=0){
            cout <<"No" << endl;
            break;
        }
    }
    /* code */
}


return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 10

int main()
{
    int i, j, n, a=0;
    int A[N];

    for(i=0;i<10;i++){
        scanf("%d", &n);
        A[i] = n;
    }
    for(i=0;i<3;i++){
        n = 0;
        for(j=i;j<N;j++){
            if(n<A[j] && 0<=A[j] && A[j]<=10000){
                n = A[j];
                a = j;//max_index
            }
        }
        n = A[i];
        A[i] = A[a];
        A[a] = n;
        printf("%d\n",A[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool done[2*100000+1];
vector<int>cycle;
void dfs(int node,vector<int>&adj)
{
    cycle.push_back(node);
    if (done[node]==1)
        return;
    done[node]=1;
    dfs(adj[node]-1,adj);
    return;
}
void solve()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<int>arr(n);
  for (int c=0;c<n;c++)
    cin >> arr[c];
  dfs(0,arr);
  if (k<=cycle.size()-1)
        for (int c=0;c<cycle.size();c++)
            if (c+1==k)
                {cout << 1+cycle[c+1] << endl;return;}
  k-=(cycle.size()-1);
  int index=cycle.size()-1;
  for (int c=cycle.size()-2;c>=0;c--)
    {
        if (cycle[c]==cycle[cycle.size()-1])
            {index=c;break;}
    }
    for (int c=0;c<index;c++)
        cycle.erase(cycle.begin());
     cout << cycle[(k)%(cycle.size()-1)]+1 << endl;

}

int main ()
{
      
     int t;
     t=1;//cin >> t;
     for (int tt=1;tt<=t;tt++)
     {
         solve();

     }

    return 0;
     
     
     
     
 }


Measured memory_bytes: 11084
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

ll mod = 1000000007;

void solve(){
    int n; cin >> n;
    vector<int> l(n*2);
    rep(i,n*2) cin >> l[i];
    VSORT(l);
    int ans = 0;
    for(int i = 0; i < n * 2; i = i + 2){
        ans += min(l[i],l[i+1]);
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-01 15:43:52
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, k; cin >> n >> k;
  if (n > k) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}


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

#define MAXN (100010)
#define ll long long

int n;
ll a[MAXN], b[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%lld%lld", a + i, b + i);
	}
	ll ans = 0;
	for(int i = n; i >= 1; -- i){
		ll tmp = (a[i] + ans) / b[i] * b[i];
		if(tmp < a[i] + ans){
			tmp += b[i];
		}
		ans += tmp - (a[i] + ans);
	}
	std::cout << ans << std::endl;
	return 0;
}

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

struct union_find_tree{

    vector<ll> par;

    union_find_tree(ll n) {
        par.resize(n);
        for(ll i=0;i<n;i++) {
            par[i] = i;
        }
    }

    ll find(ll a) {
        if(par[a] == a)return a;
        return par[a] = find(par[a]);
    }

    void unite(ll a,ll b) {
        par[find(a)] = find(b);
    }

    bool same(ll a,ll b) {
        return find(a) == find(b);
    }

};

int main() {
    ll n,q;
    cin >> n >> q;
    union_find_tree uni(n);
    for(ll i=0;i<q;i++) {
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0) {
            uni.unite(x,y);
        }else {
            if(uni.same(x,y)) {
                cout << 1 << endl;
            }else {
                cout << 0 << endl;
            }
        }
    }
}




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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    priority_queue<
        double,
        std::vector<double>, 
        std::greater<double> > u;
    rep(i,n){
        double uu;
        cin >> uu;
        u.push(uu);
    }
    while(u.size() != 1){
        double a, b;
        a = u.top(); u.pop();
        b = u.top(); u.pop();
        u.push((a+b)/2);
    }
    double answer = u.top();
    cout << answer << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct node{
	int x;
	int l;
}a[100000];
bool cmp(node a,node b){
	int sa=a.x+a.l;
	int sb=b.x+b.l;
	return sa<sb;
}
int main(){
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i].x>>a[i].l;
	int max=0,last=-2147483648;
	sort(a,a+n,cmp);
	for(int i=0;i<n;++i){
		if(a[i].x-a[i].l<last)
			continue;
		++max;
		last=a[i].x+a[i].l;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> as(n);
    for (auto& a : as)
    {
        cin >> a;
    }
    sort(as.begin(), as.end());

    cout << as.back() << " " << *min_element(as.begin(), as.end() - 1, [&](int v1, int v2) {
        return abs(as.back() - v1 * 2) < abs(as.back() - v2 * 2);
    }) << endl;
}


Measured memory_bytes: 640
/*  ex3_2
    hangan2020 */

#include <stdio.h>
int main(void){
    int number, final_digit;
    scanf("%d", &number);
    final_digit = number % 10;
    switch (final_digit)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
int n, a, k, x, l, r, mid, d;
int win = 0;
int sg(int a, int k)
{
	while (a % k && a > k)
	{
		if (a / k < k)
		{
			d = a / k + 1;
			a -= max(0, (a % k / d - 1)) * d;
		}
		a = a / k * (k - 1) + a % k - 1;
	}
	if (a < k) return 0;
	return a / k;
}
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d%d", &a, &k);
		win ^= sg(a, k);
	}
	if (win) puts("Takahashi");
	else puts("Aoki");
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0)
#define MAXX 1005

int n , k;
string s;

int main()
{
    _FastIO;
    cin >> n;
    cin >> s;
    cin >> k;
    char c = s[k - 1];
    for(int i = 0; i < n; i++){
        if(s[i] != c){
            cout << "*";
        }
        else
            cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3656
/// #RAIYAN_MAHIN
//////b**l er problem
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    ll n,r; cin >> n >> r;
    if(n <= 10)
    {
       ll d = 100 * (10 - n);
       cout << d + r << '\n';
    }
    else cout << r << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll s1 = 0, s2 = 0;
    for (int i = 0; i < n; ++i) {
        ll b; cin >> b;
        ll c = b - a[i];
        if (c < 0) s1 += -c;
        else s2 += c / 2;
    }
    cout << (s1 <= s2 ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
    vector<pair<int, int>> l;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        l.push_back(make_pair(a, 1));
    }
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        l.push_back(make_pair(a, -1));
    }
    sort(l.begin(), l.end());
    long long ans = 1, mod = 1000000007, k = 0;
    for (int i = 0; i < n+n; i++) {
        if (k / l[i].second < 0) {
            ans *= abs(k);
            ans %= mod;
        }
        k += l[i].second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
//Bismillahir Rahmanir Rahim 
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

    int n;
    cin >> n;

    ll k;
    cin >> k;

    ll a[n];

    for(int i=0; i<n; i++)
    	cin >> a[i];

    ll ans=0;

    for(int i=1; i<n; i++)
    {
    	if(a[i]+a[i-1]<=k)
    		continue;
    	ll val=a[i]+a[i-1];
    	ll need=val-k;
    	ans+=need;

    	a[i]=max(0LL, a[i]-need);
    }

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

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi V(N),C(N);
  rep(i,N) {
    cin >> V[i];
  }
  rep(i,N) {
    cin >> C[i];
  }
  int ans = 0;
  rep(i,N) {
    if(C[i]<V[i]) {
      ans += V[i] - C[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int selectionSort(int A[], int N){
	int i, j, t, sw =0, minj;
	for(i=0;i<N-1;i++){
		minj = i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]) minj = j;
		}
		t=A[i]; A[i]=A[minj]; A[minj]=t;
		if(i!=minj) sw++;
	}
	return sw;
}
int main(void){
	int A[100], N, i, sw;
	
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	sw = selectionSort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}


Measured memory_bytes: 2104
local n, s = io.read("l","l")
local cnt = {}
for i = 1, n do
    local ch = string.sub(s, i, i)
    cnt[ch] = (cnt[ch] or 1) + 1
end
local ans, mof = 1, 1000000007
for _, v in pairs(cnt) do
    ans = ans * v % mof
end
print((ans + mof - 1) % mof)


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int n; cin >> n;
	int ans = (n+1)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    cout << (m >= n ? "Yes" : "No");
    return 0;
}

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

int main(){
    int w,h,x,y,r;
    
    cin>>w>>h>>x>>y>>r; 
    if(((x-r)>=0)*((x+r)<=w)*((y-r)>=0)*((y+r)<=h)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;

    }
    
   
    return 0;
}


Measured memory_bytes: 3104
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }
        .mapIndexed { index, i -> i - (index + 1) }
        .sorted()

    val mid = aList[aList.size / 2]

    val answer = aList.map { Math.abs(it - mid) }.sum()

    println(answer)
}


Measured memory_bytes: 81448
#include<cstdio>


int main(){
	int a,b,c,d;
	int area1,area2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	area1=a*b;
	area2=c*d;
	if(area1>area2){
        printf("%d\n",area1);
	}
	else {
        printf("%d\n",area2);
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (998244353l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> D(N);
  rep (i, N) cin >> D[i];

  if (D[0] != 0) {
    cout << 0 << endl;
    return;
  }

  map<long, long> mp;
  long last_num = 0;
  for (long i = 1; i < N; i++) {
    if (D[i] == 0) {
      cout << 0 << endl;
      return;
    }
    mp[D[i]]++;
    last_num = max(last_num, D[i]);
  }

  long ans = 1;
  long cand = 1;
  for (long i = 1; i <= last_num; i++) {
    if (mp[i] == 0) {
      cout << 0 << endl;
      return;
    }
    long tmp = 1;
    rep (x, mp[i]) {
      tmp *= cand;
      tmp %= MOD;
    }
    ans *= tmp;
    ans %= MOD;
    cand = mp[i];
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

// dfs
// p は親
void dfs(int i, int p, vector<vector<int>> &graph, vector<ll> &sum) {
  int x = sum.at(i);
  vector<int> children = graph.at(i);
  for (int child : children) {
    if (child == p) {
      continue;
    }
    sum.at(child) += x;
    dfs(child, i, graph, sum);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> graph(n, vector<int>());
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  vector<P> px(q);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    px.at(i) = make_pair(p, x);
  }
  // 頂点pにのみ追加
  vector<ll> sum(n, 0);
  for (auto v : px) {
    int p = v.first;
    int x = v.second;
    sum.at(p) += x;
  }
  // 最後にまとめて部分木にも追加
  dfs(0, -1, graph, sum);
  // 出力
  for (int i = 0; i < n; i++) {
    if (i != 0) {
      cout << " ";
    }
    int x = sum.at(i);
    cout << x;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 39156
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	long long K;
	cin >> N >> K;

	map<int, long long> mp;
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;

		mp[a] += b;
	}
	
	long long count = 0;
	for (auto x : mp) {
		count += x.second;
		if (K <= count) {
			cout << x.first << endl;
			return 0;
		}
	}

	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (B / A >= C)
		cout << C << endl;
	else
		cout << B / A << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

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

	int r; cin >> r;
	cout << (r * r) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  for(int i = 0; i <= n; ++i) {
    int nn = i * 1.08;
    if(nn == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a); i < (b); ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1); i >= (b); --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) RP(__i,n)
template<class T>
void cmax(T & a, T b) {a = max(a, b);}
template<class T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		for (char x : "([{") c += *s == x;
		for (char x : ")]}") c -= *s == x;
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD() {return 1;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<class T, class ... TT>
bool RD(T & a, TT & ... b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define DR(T,...) T __VA_ARGS__; RD(__VA_ARGS__)
#define RI(...) DR(int,__VA_ARGS__)

/* For it's time for you to fulfill your output. */
void PT(const char & a) {putchar(a);}
void PT(char const * const & a) {fputs(a, stdout);}
void PT(const double & a) {printf("%.16f", a);}
void PT(const int & a) {printf("%d", a);}
void PT(const ll & a) {printf("%lld", a);}

/* The line will last forever! */
template<char s = ' ', char e = '\n'>
void PL() {if (e) PT(e);}
template<char s = ' ', char e = '\n', class T, class ... TT>
void PL(const T & a, const TT & ... b)
{PT(a); if (sizeof...(b) && s) PT(s); PL<s,e>(b...);}

/* Good Luck && Have Fun ! */
const int N = 1e5 + 87;
int s[N];
int main()
{
	RI(n);
	RP(i,n) {RI(x); ++s[x], --s[x+3];}
	int ans = s[0];
	REP(i,1,N) cmax(ans, s[i] += s[i-1]);
	PL(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int main(){

  ll R=0;

  cin >> R;

  cout << setprecision(20) << fixed;
  cout << R*6.28318530717958623200 << endl;

  return 0;
}


Measured memory_bytes: 3748
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] field = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                field[i][j] = sc.nextInt();
            }
        }
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = IntStream.of(Arrays.copyOfRange(field[0], 0, i + 1)).sum();
            array[i] += IntStream.of(Arrays.copyOfRange(field[1], i, n)).sum();
        }
        System.out.println(Arrays.stream(array).max().getAsInt());
    }
}

Measured memory_bytes: 27092
def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if a < b:
        x = a + t * v
        y = b + t * w
        if x >= y:
            print("YES")
        else:
            print("NO")
    else:
        x = a - t * v
        y = b - t * w
        if x <= y:
            print("YES")
        else:
            print("NO")

main()

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

int main(){

    int N;
    string S;
    cin >> N >> S;

    vector<int> sum_R(N+1); 
    vector<int> sum_G(N+1);
    vector<int> sum_B(N+1);

    int i, j, temp;

    //  累積和  
    for (i=0; i<N; i++){
        if (S.at(i) == 'R'){
            sum_R.at(i+1) = 1 + sum_R.at(i);
            sum_G.at(i+1) = sum_G.at(i);
            sum_B.at(i+1) = sum_B.at(i);
        }
        if (S.at(i) == 'G'){
            sum_R.at(i+1) = sum_R.at(i);
            sum_G.at(i+1) = 1 + sum_G.at(i);
            sum_B.at(i+1) = sum_B.at(i);
        }
        if (S.at(i) == 'B'){
            sum_R.at(i+1) = sum_R.at(i);
            sum_G.at(i+1) = sum_G.at(i);
            sum_B.at(i+1) = 1 + sum_B.at(i);
        }
    }

    int64_t count = 0;
    int diff = 0;

    for (i=0; i<N; i++){
        for (j=i+1; j<N; j++){
            temp = 0;
            diff = j - i;
            if ( (S.at(i) == 'G' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'G') ){
                temp += (sum_R.at(N) - sum_R.at(j+1));
                if ( ((j+diff)<N) && (S.at(j+diff) == 'R') ){
                    count += temp-1;
                }
                else{
                    count += temp;
                }
            }
            if ( (S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R') ){
                temp += (sum_G.at(N) - sum_G.at(j+1));
                if ( ((j+diff)<N) && (S.at(j+diff) == 'G') ){
                    count += temp-1;
                }
                else{
                    count += temp;
                }
            }
            if ( (S.at(i) == 'G' && S.at(j) == 'R') || (S.at(i) == 'R' && S.at(j) == 'G') ){
                temp += (sum_B.at(N) - sum_B.at(j+1));
                if ( ((j+diff)<N) && (S.at(j+diff) == 'B') ){
                    count += temp-1;
                }
                else{
                    count += temp;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3656
let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun n k -> n, k) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let sum = memoize (n - k + 1) (fun sum -> function
    | 0 -> Array.fold_left ( + ) 0 (Array.init k (fun i -> as_.(i)))
    | i -> sum (i - 1) - as_.(i - 1) + as_.(i - 1 + k)) in
  let pos = memoize (n - k + 1) (fun pos -> function
    | 0 -> Array.fold_left ( + ) 0 (Array.init k (fun i -> max 0 as_.(i)))
    | i -> pos (i - 1) - max 0 as_.(i - 1) + max 0 as_.(i - 1 + k)) in
  let positives = Array.fold_left ( + ) 0 (Array.map (max 0) as_) in
  Array.init (n - k + 1) (fun i -> max 0 (sum i) + positives - pos i)
  |> Array.fold_left max min_int
  |> Printf.printf "%d\n"

Measured memory_bytes: 12544
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	a=a*3+b;
	cout<<a/2<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char str[100100] = {0};
int main(){
	scanf("%s",str+1);
	int len = strlen(str+1);
	int ans1 = 0,ans2 = 0;
	int now = 1;
	for(int i = 1;i <= len;i++){
		if(str[i] != '0' + now)ans1++;
		now ^= 1;
	}
	now = 0;
	for(int i = 1;i <= len;i++){
		if(str[i] != '0' + now)ans2++;
		now ^= 1;
	}
	printf("%d\n",min(ans1,ans2));
	return 0;
} 

Measured memory_bytes: 256