akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();

    let mut count = vec![0; 26];
    for _ in 0..h {
        let v: Vec<char> = sc.read::<String>().chars().collect();
        for c in &v {
            let c = (*c as usize) - ('a' as usize);
            count[c] += 1;
        }
    }

    let mut required = vec![0; 5];
    if h % 2 == 1 {
        required[2] += (w / 2);
    }
    if w % 2 == 1 {
        required[2] += (h / 2);
    }
    if h % 2 == 1 && w % 2 == 1 {
        required[1] += 1;
    }
    required[4] = (h * w - required[2] * 2 - required[1]) / 4;

    let mut merged_count = vec![0; 5];
    for i in 0..26 {
        let mut c = count[i];
        if c % 2 == 1 {
            c -= 1;
            merged_count[1] += 1;
        }
        if c % 4 == 2 {
            c -= 2;
            merged_count[2] += 1;
        }
        merged_count[4] += c / 4;
    }

    if merged_count[1] != required[1] {
        println!("No");
        return;
    }
    if merged_count[4] < required[4] {
        println!("No");
        return;
    }
    merged_count[4] -= required[4];
    merged_count[2] += merged_count[4] * 2;
    assert_eq!(merged_count[2], required[2]);
    println!("Yes");
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc);

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

vector<int> agrega(vector<int> vc, const vector<int>& ot) {
	assert(vc.size() == ot.size());
	for(int i = 0; i < vc.size(); i++)
		vc[i] += ot[i];
	return vc;
}

bool vld(const vector<int>& vc, int x) {
	return *min_element(vc.begin(), vc.end()) >= x;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> vcs(n, vector<int>(m)), cln(1 << n, vector<int>(m));
	vector<int> csts(n);
	map<int, int> mp;
	for(int i = 0; i < n; i++) {
		mp[1 << i] = i;
		cin >> csts[i];
		for(int j = 0; j < m; j++) cin >> vcs[i][j];
	}

	vector<int> msks(1 << n), gd;
	for(int i = 1; i < (1 << n); i++) {
		auto w = mp[i&-i];
		msks[i] = msks[i - (i&-i)] + csts[w];
		cln[i] = agrega(cln[i - (i&-i)], vcs[w]);
	}

	debug(msks);
	debug(cln);
	for(int i = 1; i < (1 << n); i++)
		if(vld(cln[i], x)) gd.push_back(msks[i]);
	if(gd.empty()) cout << "-1\n";
	else cout << *min_element(gd.begin(), gd.end()) << '\n';
}



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

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << ' ' << i + 1 + 1 << endl;
            return 0;
        }
        if (i > 0) {
            if (S[i - 1] == S[i + 1]) {
            cout << i - 1 + 1 << ' ' << i + 1 + 1 << endl;
            return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int h, w;
int hw(vector<vector<char>> &a,int x,int y) {
	if (a.at(y).at(x) == '#') return 0;
	int dx[] = { -1,0,1 }, dy[] = { -1,0,1 };
	int count = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (x + dx[j] >= 0 && x + dx[j] < w && y + dy[i] < h && y + dy[i] >= 0) {
				if (a.at(y + dy[i]).at(x + dx[j]) == '#')count++;
			}
		}

	}
	char c = count + '0';
	a.at(y).at(x) = c;
	return 0;
}
int main() {
	cin >> h >> w;
	vector<vector<char>> s(h,vector<char>(w));
	for (int i = 0; i < h; i++) {
		rep(j, w) {
			cin >> s.at(i).at(j);
		}
	}
	rep(i, h) {
		rep(j, w) {
			hw(s, j, i);
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << s.at(i).at(j);
		}
		cout << endl;
	}
	
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    ll x,y;cin>>x>>y;
    ll tmp=x;
    ll ans=0;
    while(tmp<=y){
        tmp*=2;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

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

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

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

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

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

def get_int
  gets.chomp.to_i
end

A, B, C, D = get_ints

ac = A / C - ((A % C == 0) ? 1 : 0)
bc = B / C

ad = A / D - ((A % D == 0) ? 1 : 0)
bd = B / D

cdd = C.lcm(D)
acd = A / cdd - ((A % cdd == 0) ? 1 : 0)
bcd = B / cdd

puts B - A + 1 - (bc - ac + bd - ad - (bcd - acd))



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    ll h,n;
    cin>>h>>n;

    while(n--) {
        ll attack;
        cin>>attack;

        h-=attack;
    }

    if(h<=0) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}




Measured memory_bytes: 3636
def getval():
    return int(input())

def main(x):
    for i in range(-200,201):
        flag = False
        for j in range(-200,201):
            if i**5-j**5==x:
                print("{a} {b}".format(a=str(i),b=str(j)))
                flag = True
                break
        if flag:
            break
                
                

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

Measured memory_bytes: 9204
n = int(input())
arr = [input().split() for _ in range(n)]
ans = [[-1 for _ in range(3)] for _ in range(n)]
for i in range(3):
    for j in range(n-1):
        if ans[j][i] == -1:
            for k in range(j+1,n):
                if arr[j][i] == arr[k][i]:
                    ans[j][i] = 0
                    ans[k][i] = 0
        if ans[j][i] == -1:
            ans[j][i] = int(arr[j][i])
    if ans[n-1][i] == -1:
        ans[n-1][i] = int(arr[n-1][i])
[print(x[0]+x[1]+x[2]) for x in ans]

Measured memory_bytes: 7672
#include<iostream>
#include<bitset>
#include<string>
#include<vector>
#include<sstream>

using namespace std;

int main(){
    long long sum = 0;
    string s;
    cin >> s;
    int size = s.size();
    for (int bit = 0; bit < (1 << size - 1); ++bit){
        vector<int> str;
        for(int i = 0; i < size; ++i){
            if(bit & (1 << i)){
                str.push_back(i);
            }
        }
        int strsize = str.size();
        int j = 0;
        if(strsize != 0){
            for (int i = 0; i < strsize + 1; ++i){
                if(strsize != i){
                    sum += stoll(s.substr(j,str[i] - j + 1));
                    j = str[i] + 1;
                }
                else{
                    sum += stoll(s.substr(j, size - j));
                }
            }
        }
        else{
            sum += stoll(s);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int S;
	cin >> S;
	for(int i = 1;i < 100010;i++) {
		if(S == 1 || S == 2 || S == 4) {
			cout << i + 3 << endl;
			break;
		}
		if(S % 2 == 0) {
			S = S / 2;
		}
		else {
			S = 3 * S + 1;
		}
	}
}


Measured memory_bytes: 256
using System;

namespace ABC079_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            Console.WriteLine(N[0] == N[1] && N[0] == N[2] || N[1] == N[2] && N[1] == N[3] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int debt = 100000;
	int n;
	cin >> n;
	for(int i=0; i < n; i++){
		debt *= 1.05;
		if(debt % 1000 > 0){
			debt = debt +1000 - (debt % 1000);
		}
	}
	cout << debt << endl;
	return(0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 777;

int a[MAXN], n, R[MAXN], L[MAXN];
int stack[MAXN], head = 0;

void solve() {
	cin >> n;

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

		R[i] = n;
		L[i] = -1;
	}

	for(int i = 0; i < n; ++i) {
		while(head > 0 && a[stack[head - 1]] > a[i]) {
			R[stack[--head]] = i;
		}

		stack[head++] = i;
	}

	head = 0;

	for(int i = n - 1; i >= 0; --i) {
		while(head > 0 && a[stack[head - 1]] > a[i]) {
			L[stack[--head]] = i;
		}

		stack[head++] = i;
	}

	ll answ = 0;

	for(int i = 0; i < n; ++i) {
		answ += (R[i] - i) * 1LL * (i - L[i]) * 1LL * a[i];
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

	vector<int> a(n);
	int b;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> b;
		
		if (b > n) {
			ans++;
		} else {
			a[b - 1]++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (a[i] >= i + 1) {
			ans += a[i] - i - 1;
		} else {
			ans += a[i];
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300010;
int n,k;
int ans[N];
ll g[N];
int main(){
	scanf("%d%d",&k,&n);
	if(k%2==0){
		printf("%d",k/2);
		for(int i =1;i<n;i++) printf(" %d",k);
		puts("");
		return 0;
	}
	if(k==1){
		for(int i = 1;i<=(n+1)/2;i++) printf("%d ",k);
		puts("");
		return 0;
	}
	if(n==1){
		printf("%d\n",k/2+1);
		return 0;
	}
	if(n==2){
		printf("%d %d\n",k/2+1,k/2);
		return 0;
	}
	int delta = 0;
	int down;
	ll tot;
	g[0] =1;
	for(tot = 1,down = 0;tot<=2*n;tot = tot*k+1,down++){
		g[down+1] = g[down]*k+1;
	}
	//cout<<down<<endl;
	down = min(down,n-1);
	tot = 1;
	ans[1] = k/2+1;
	for(int i = n-1;i>down;i--){
		if((i-1)%2==0) delta++; 
		ans[++tot] = k/2+1;
	}
	ll now = (g[down]+1)/2-delta;
	if(now<1) while(1);
	for(int j = down;j>0;j--){
		if(now==1) break;
		now--;
		for(int i = 1;i<=k;i++) if(now-g[j-1]>0) now-=g[j-1];
		else{
			ans[++tot] = i;
			break;
		}
	}
	for(int i =1;i<=tot;i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll << 60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};





int main() {
    string S; cin >> S;

    char pre=S[0];
    for(int i=1; i<S.size(); i++){
        if(pre==S[i]){
            cout << i << ' ' << i+1 << endl;
            return 0;
        }
        pre=S[i];
    }

    for(int i=0; i<S.size()-2; i++){
        if(S[i]==S[i+2]){
            cout << i+1 << ' ' << i+3 << endl;
            return 0;
        }
    }


    cout << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

s = sr()
t = sr()
n = len(s)
dic = {chr(ord('a')+i):[] for i in range(26)}
for i,c in enumerate(s):
    dic[c].append(i+1)
for c in t:
    if not dic[c]:
        print('-1')
        sys.exit()
ans = 0
pre = 0
for c in t:
    ind = bisect.bisect_left(dic[c],pre+1)
    if ind == len(dic[c]):
        ans+=(n-pre)
        pre = dic[c][0]
        ans+=pre
    else:
        ans+=(dic[c][ind]-pre)
        pre = dic[c][ind]
print(ans)

Measured memory_bytes: 85184
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) v[i] = file.nextInt();
		for (int i = 0; i < n; i++) c[i] = file.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i <= 1 << n; i++) {
			int a = 0, b = 0;
			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) > 0) {
					a += v[j];
					b += c[j];
				}
			}
			ans = Math.max(ans, a - b);
		}
		System.out.println(ans);
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


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

int main()
{
    std::string S;
    std::cin >> S;

    for (int i = 0; i < S.length(); i++) {
        std::cout << ((S[i] == '1') ? '9' : '1');
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k;
int main()
{
	ll n = 50;
	cin >> k;
	ll x = k / n, t = k - x * n;
	cout << n << endl;
	for(int i = 1; i <= n; ++i)
	{
		if(i <= t) cout << x + 50 << " ";
		else cout << x - t + 49 << " ";
	}
	return 0;
} 

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

def f(D, S, T):
    close = [[False] * N, [False] * N, [False] * N]
    Q = []
    index = 0
    Q.append((S, 0, 0))

    while len(Q) > index:
        p, c, l = Q[index]
        index += 1
        
        if close[l][p]:
            continue
        
        if l == 0 and p == T:
            return c // 3
        close[l][p] = True

        l, c = (l + 1) % 3, c + 1
        for n in D[p]:
            if close[l][n]:
                continue
            Q.append((n, c, l))
    return -1

if __name__ == "__main__":
    D = {n: set() for n in range(N)}
    for m in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        D[u].add(v)

    S, T = list(map(int, input().split()))
    S -= 1
    T -= 1

    print(f(D, S, T))


Measured memory_bytes: 73624
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, k = sc.nextInt
  val ans = (1 to math.min(a, b))
    .map(math.min(a,b) - _ + 1)
    .filter{ i =>
      a % i == 0 && b % i == 0
    }(k - 1)

  println(ans)

}

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

using namespace std;

//#define FILE_IO

int N, M;
int l[200005], r[200005];
int c[200005];
int ord[200005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
        ord[i] = i;
    }

    int cnt = 0;

    sort(ord + 1, ord + N + 1,
         [](int a, int b) { if(l[a] == l[b]) return r[a] > r[b]; return l[a] < l[b]; } );

    int id = 1;
    for(int x = 1; x <= N; x++)
    {
        int i = ord[x];
        if(id <= l[i] && !c[i])
        {
            c[i] = id;
            id++;
            cnt++;
        }
    }

    sort(ord + 1, ord + N + 1,
         [](int a, int b) { if(r[a] == r[b]) return l[a] < l[b]; return r[a] > r[b]; } );

    int idst = id - 1;
    id = M;
    for(int x = 1; x <= N; x++)
    {
        if(idst == id)  break;
        int i = ord[x];

        if(id >= r[i] && !c[i])
        {
            c[i] = id;
            id--;
            cnt++;
        }
    }

    printf("%d\n", N - cnt);

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int x = 0;
	int y = 0;

	int a, b, c;
	char d;
	while( cin >> a >> d >> b >> d >> c ) {
		if( a == b ) {
			x += 1;
		}
		else if( a*a + b*b == c*c ) {
			y += 1;
		}
	}

	cout << y << '\n' << x << '\n';
}



Measured memory_bytes: 3056
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//ld dis(ll a,ll b,ll c,ll d){return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll g(n*3,vll(0)) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g.at(a).emplace_back(n+b) ;
		g.at(n+a).emplace_back(n+n+b) ;
		g.at(n+n+a).emplace_back(b) ;
	}
	ll s,t ;
	cin >> s >> t ;
	s-- ; t-- ;
	vll cnt(n*3,INF);
	queue<ll> q ;
	cnt.at(s) = 0 ;
	q.push(s) ;
	while(!q.empty()){
		ll p = q.front() ;
		q.pop() ;
//		cout << p << endl ;
		for(int i=0;i<g.at(p).size();i++){
			if(cnt.at(g.at(p).at(i))>cnt.at(p)+1){
				cnt.at(g.at(p).at(i)) = cnt.at(p)+1 ;
				q.push(g.at(p).at(i)) ;
			}
		}
	}
	ll ans = cnt.at(t) ;
	cout << (ans==INF?-1:ans/3) << endl ;
//	for(int i=0;i<3;i++){
//		for(int j=0;j<n;j++) cout << cnt.at(n*i+j) << (j==n-1?'\n':' ') ;
//	}
}


Measured memory_bytes: 18944
package main

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

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()

	fmt.Println(max(max(a*c, a*d), max(b*c, b*d)))

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//Bismillahirrahmanirrahim
#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 4000005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k,diz[li];
string s;
vector<int> v;

int main(){
	scanf("%lld %lld %lld",&n,&m,&b);
	for(lo i=1;i<=m;i++){
		scanf("%lld",&diz[i]);
	}
	FOR{
		lo tut=0;
		for(lo i=1;i<=m;i++){
			scanf("%lld",&k);
			tut+=k*diz[i];
		}
		if(tut+b>0) cev++;
	}
	printf("%lld\n",cev);
	return 0;
}


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

int main(){
  int d, t, v;
  cin >> d >> t >> v;
  if(t * v >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

struct p {
    ll x, y, id;
    p(ll x = 0, ll y = 0, ll id = 0): x(x), y(y), id(id){}
};

int main() {
    ll N;
    cin >> N;
    vc<p> P(N);
    rep(i, N) cin >> P[i].x >> P[i].y, P[i].x--, P[i].y--, P[i].id = i;

    sort(all(P), [](p a, p b) { return a.x < b.x; });

    UF uf(N);
    auto comp = [](p a, p b) { return a.y < b.y; };
    set<p, decltype(comp)> st{comp};

    st.emplace(P[0]);

    repe(i, 1, N){
        auto [x, y, id] = P[i];
        bool merged = false;

        for (auto it = st.begin(); it != st.lower_bound(P[i]); ){
            auto [tx, ty, tid] = *it;
            uf.unite(id, tid);
            if (merged)
                it = st.erase(it);
            else
                it++;
            merged = true;
        }
        if (!merged) st.emplace(P[i]);
    }

    rep(i, N) cout << uf.size(i) << '\n';
}

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


string solve(long long N, long long Y){
    for (int i = 0; i <= N; i++) {
        for (int j = 0; (i + j) <= N; j++) {
            int k = N - (i + j);
            if (1'000 * i + 5'000 * j + 10'000 * k == Y) {
                return to_string(k) + " " + to_string(j) + " " + to_string(i);
            }
        }
    }
    return "-1 -1 -1";
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Y;
    scanf("%lld",&Y);
    string ans = solve(N, Y);
    cout << ans << endl;
    return 0;
}


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

struct activity{
    int A,B,C;
};

int main() {
    int n;
    cin>>n;
    vector<activity> ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i].A;
        cin>>ar[i].B;
        cin>>ar[i].C;
    }

    int dp[n+1][3];
    dp[1][0]= ar[1].A;
    dp[1][1]= ar[1].B;
    dp[1][2]= ar[1].C;

    for(int i=2;i<=n;i++)
    {
        dp[i][0]=ar[i].A + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=ar[i].B + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=ar[i].C + max(dp[i-1][0],dp[i-1][1]);
    }    

    cout<<max(dp[n][0] , max(dp[n][1], dp[n][2]));
    return 0;
}


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

using namespace std;

const int nax=3333;
double dp[nax][nax];

int main()
{
    int n; cin>>n;
    double a[nax];
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-a[i]);
            if(j>0) dp[i][j]+=dp[i-1][j-1]*a[i];
        }
    }
    double res=0;
    for(int i=0;i<=n;i++)
    {
        if(i*2>n) res+=dp[n][i];
    }
    printf("%.10lf\n",res);
    return 0;
}


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

string s;
int pos[100004];

int main() {
	cin>>s;
	memset(pos, 0, sizeof(pos));
	int i = 0;
	while(i<s.length()){
		if(s[i] == 'L'){
			i += 1;
			continue;
		}
		int l = i;
		int r = i+1;
		while(s[r] == 'R' && r < s.length())	r++;
		if(r == s.length()){
			pos[r-1] += r - l;
		}
		else{
			pos[r-1] += (r-l+1)/2;
			pos[r] += (r-l)/2;
		}
		i = r;
	}
	i = s.length()-1;
	while(i >= 0){
		if(s[i] == 'R')	{
			i -= 1;
			continue;
		}
		int r = i;
		int l = i-1;
		while(s[l] == 'L' && r >= 0)	l--;
		if(l == -1){
			pos[0] += r - l;
		}
		else{
			pos[l+1] += (r-l+1)/2;
			pos[l] += (r-l)/2;
		}
		i = l;
	}
	for(int i = 0;i<s.length();i++)	cout<<pos[i]<<' ';
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N, M;
    cin >> N >> M;

    if(N >= M / 2) {
        cout << M / 2 << endl;
    } else {
        LL res = N;
        M -= N * 2;
        cout << res + M / 4 << endl;
    }
    return 0;
}



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

int a, b, c;

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

    int t = c + b;
    while (t % a != 0) {
        t += b;
        if (t > 10000) break;
    }

    if (t > 10000) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}

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

int main()
{

  string S;

  cin >> S;

  if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int ac, wa, tle, re;

int main() {
    int n = read();
    for(int i = 1; i <= n; ++i) {
        string S; cin >> S;
        if(S == "AC") ++ac;
        if(S == "WA") ++wa;
        if(S == "TLE") ++tle;
        if(S == "RE") ++re;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] sv = Console.ReadLine().Split();

            int[] v = new int[N]; 
            for(int i=0;i<N;i++)
            {
                v[i] = int.Parse(sv[i]);
            }

            Array.Sort(v);

            //int j = 0;

            double ave = (double)v[0];
            for(int j=1;j<N;j++)
            {
                ave = (double)(ave + v[j]) / 2;
            }
            Console.WriteLine(ave);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b; scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> dp(n);
    for (int i = 0; i < q; ++i) {
        int p, x; scanf("%d %d", &p, &x);
        dp[p-1] += x;
    }
    deque<int> Q;
    stack<int> s;
    int cnt = 0;
    vector<int> visited(n, 0), num(n);
    s.emplace(0);
    while(!s.empty()){
        int a = s.top(); s.pop();
        visited[a]++;
        num[a] = cnt++;
        Q.emplace_front(a);
        for (auto &&i : G[a]) {
            if(!visited[i]) {
                s.emplace(i);
                dp[i] += dp[a];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if(i) cout << " ";
        cout << dp[i];
    }
    puts("");
    return 0;
}

Measured memory_bytes: 17140
#include <iostream>
#include <string>
#define ll long
using namespace std;

int main()
{
  ll health, size, x;
  cin >> health;
  cin >> size;
  ll total = 0;
  for (int i = 0; i < size; i++)
  {
    cin >> x;
    total += x;
  }
  if (total >= health)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int H, W, N;
int main() {
  scanf("%d %d %d", &H, &W, &N);
  int ans[H*W], p;
  for(int i = 1, a; i <= N; ++i) {
    scanf("%d", &a);
    for(int j = 0; j < a; ++j, ++p) {
      if(p/W%2 == 0) ans[p] = i;
      else ans[(p/W*2+1)*W-p-1] = i;
    }
  }
  for(int i = 0; i < H*W; ++i) {
    printf("%d ", ans[i]);
    if((i+1)%W == 0) printf("\n");
  }
}

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

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcount((a))

typedef long long lint;
typedef pair<int, int> P;
typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};

struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, M, R;
int d[210][210] = {0};

signed main() {
  cin >> N >> M >> R;
  vec v;
  for (int i = 0; i < R; i++) {
    int r;
    cin >> r;
    r--;
    v.push_back(r);
  }

  for (int i = 0; i < 205; i++) {
    for (int j = 0; j < 205; j++) {
      if (i == j) {
        d[i][j] = 0LL;
      } else {
        d[i][j] = (1LL << 60);
      }
    }
  }

  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  sort(v.begin(), v.end());

  int ans = (1LL << 60);
  do {
    int sum = 0LL;
    for (int i = 0; i < R - 1; i++) {
      sum += d[v[i]][v[i + 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(v.begin(), v.end()));

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


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

ll mod = 1e9+7;

ll addmod(ll a, ll b){
    return (a+b)%mod; 
}

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

    int h,w;
    cin>>h>>w;
    vector<int> dp[h+1];
    for(int i=0;i<=h;++i)   dp[i].resize(w+1,0);

    vector<string> grid;

    string s;
    for(int i=0;i<h;++i){
        cin>>s;
        grid.push_back(s);
    }

    dp[0][0] = 1;

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(i+1 < h && grid[i+1][j]=='.'){
                dp[i+1][j] = addmod(dp[i+1][j], dp[i][j]);
            }
            if(j+1 < w && grid[i][j+1]=='.'){
                dp[i][j+1] = addmod(dp[i][j+1], dp[i][j]);
            }
        }
    }    

    cout<<dp[h-1][w-1]<<"\n";

    return 0;
}

Measured memory_bytes: 8228
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main()
{	
	int n;
	cin >> n;
	V<int> a(n);
	RBF(ai, a)cin >> ai;
	int ans = 0;
	REP(i, n) {
		int j = i + 1;
		if (j % 2 != 0 && a[i] % 2 != 0) {
			ans++;
		}
	}
	col(ans);
	return 0;
}


Measured memory_bytes: 3608
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var r = Number(inputs);

  console.log(
  	Math.PI* Math.pow(r,2),
  	2*Math.PI* r
  	);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

int main()
{
    int x, y;
    cin >> x >> y;
    set<int> a = {1,3,5,7,8,10,12};
    set<int> b = {4,6,9,12};
    
    if(a.count(x) == 1 && a.count(y) == 1 || b.count(x) == 1 && b.count(y) == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=20;
const int mod=1e9+7;
int n,m,q;
int limit[N+1][N+1],dp[2][1<<N];

template <class T> inline T add(const T x,const T y){
	return x+y<mod?x+y:x+y-mod;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifdef LOCAL
	//freopen("d.in","r",stdin);
#endif
	memset(limit,-1,sizeof(limit));
	n=nxi(),m=nxi(),q=nxi();
	--n;
	for(int i=1; i<=q; ++i){
		const int a=nxi(),b=nxi(),c=nxi();
		limit[a][b]=c;
	}
	dp[0][0]=1;
	for(int i=1; i<=m; ++i){
		for(int j=0; j<n; ++j){
			int p=j&1;
			memset(dp[p^1],0,sizeof(dp[p^1]));
			for(int k=0; k<1<<n; ++k){
				if(!dp[p][k]) continue;
				if((k>>j&1)==0&&limit[i][j+1]!=1){
					//apadd(dp[p^1][k],dp[p][k]);
					dp[p^1][k]=add(dp[p^1][k],dp[p][k]);
					//dp[p^1][k]=(dp[p^1][k]+dp[p][k])%mod;
				}
				if(limit[i][j+1]!=0){
					int lbit=((k>>j)&-(k>>j))<<j;
					int tgt=k^(1<<j)^lbit;
					//apadd(dp[p^1][tgt],dp[p][k]);
					dp[p^1][tgt]=add(dp[p^1][tgt],dp[p][k]);
					//dp[p^1][tgt]=(dp[p^1][tgt]+dp[p][k])%mod;
				}
			}
		}
		if(n&1){
			memcpy(dp[0],dp[1],sizeof(dp[1]));
		}
	}
	lint ans=0;
	for(int i=0; i<1<<n; ++i){
		ans+=dp[0][i];
	}
	printf("%lld\n",ans%mod);
	return 0;
}


Measured memory_bytes: 8576
//https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_b
//B - Exchange
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll A,B,K; cin>>A>>B>>K;    
    auto exec_func = [](ll& my,ll& op){
        if(my%2==1) {
            my=max(my-1,0LL);
        }
        ll d=my/2;
        my=max(my-d,0LL);
        op+=d;
    };
    REP(i,K){
        if(i%2==0) exec_func(A,B);
        else exec_func(B,A);
    }
    cout<<A<<" "<<B<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
commands = []
n.times {commands << gets.chomp.split}
list = []

commands.each do |co|
  case co[0]
  when "insert"
    list.unshift(co[1])
  when "delete"
    i = list.index(co[1])
    list.delete_at(i) if i
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
end
puts list.join(" ")



Measured memory_bytes: 311212