akhauriyash/Code-Regression huggingface dataset:
;;;; union find tree
(defun make-uft (n)
  (let ((parent (make-array (list (1+ n))))
        (rank (make-array (list (1+ n)))))
    (loop :for i :from 0 :to n
          :do (setf (aref parent i) i))
    (cons parent rank)))

(defun find-root (uft x)
  (let ((p nil)
        (stack nil))
    (loop :with stack := nil
          :while (/= (aref (car uft) x) x)
          :do (push x stack)
          :do (setf x (aref (car uft) x))
          :finally (setf p x))
    (loop :for y :in stack
          :do (setf (aref (car uft) y) p))
    p))

(defun union-nodes (uft x y)
  (let ((x-root (find-root uft x))
        (y-root (find-root uft y)))
    (cond ((> (aref (cdr uft) x-root) (aref (cdr uft) y-root))
           (setf (aref (car uft) y-root) x-root))
          ((< (aref (cdr uft) x-root) (aref (cdr uft) y-root))
           (setf (aref (car uft) x-root) y-root))
          ((/= x-root y-root)
           (setf (aref (car uft) y-root) x-root)
           (incf (aref (cdr uft) x-root))))))

(defun same-root (uft x y)
  (= (find-root uft x) (find-root uft y)))

;;;; main
(let* ((n (read))
       (m (read))
       (uft (make-uft n)))
  (loop :for _ :from 1 :to m
        :for a := (read)
        :for b := (read)
        :do (union-nodes uft a b))
  (loop :with cnt := 0
        :for i :from 1 :to n
        :if (= (find-root uft i) i)
        :do (incf cnt)
        :finally (format t "~A~%" (1- cnt))))



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

int main(void){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int res = INF;
    rep(ab,max(x,y)+1){
        int sum = 0;
        sum += c*ab*2;
        sum += max(x-ab,0)*a;
        sum += max(y-ab,0)*b;
        res = min(res,sum);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int z=0;
  if(k>=a)
  {
      z=a;
      k=k-a;
  }
  else
  {
      z=k;
      k=0;
  }
  if(k>=b)
  {
      z=z+0;;
      k=k-b;
  }
  else
  {
      k=0;
  }
  if(k>=c)
  {
      z=z-c;
      k=k-c;
  }
  else
  {
      z=z-k;
      k=0;
  }
  cout<<z;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int n;
vector<int> h;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    int res = 0;
    int ct = 0;
    while (true)
    {
        ct++;
        //水やり終わってるかチェック
        bool flag = true;
        for (int i = 0; i < n; i++)
        {
            if (h[i] != 0)
            {
                flag = false;
            }
        }
        if (flag)
        {
            cout << res;
            return 0;
        }

        //rとl決定
        int l = -1, r = -1;
        for (int i = 0; i < n; i++)
        {
            if (h[i] != 0 && l == -1)
            {
                //cout << "L!" << endl;
                l = i;
                continue;
            }

            if (l != -1 && h[i] == 0)
            {
                //cout << "R!" << endl;
                r = i - 1;
                break;
            }
        }

        if (r == -1)
        {
            r = n - 1;
        }

        //cout << l << " " << r << endl;

        //水やり実行
        res++;
        for (int i = l; i <= r; i++)
        {
            h[i]--;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())

drinks = []

for i in range(n):
	a,b= map(int,input().split())
	drinks.append((a,b))
drinks.sort()

ans = 0
for x,y in drinks:
	if y < m:
		ans += x*y
		m -= y
	else:
		ans += x*m
		break

print(ans)

Measured memory_bytes: 16908
#include <cstdio>

#define N 123

int a[11][11];
int d[N + 1][N + 1];

int main() {
	int i, j, k, l, m, n, t;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
	for (i = 0; i <= N; i++) for (j = 0; j <= N; j++) {
		t = 0;
		for (k = 1; k <= n; k++) for (l = 1; l <= m; l++) {
			if (a[k][l] - i * k - j * l >= t) {
				t = a[k][l] - i * k - j * l;
			}
		}
		d[i][j] = t;
	}
	for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) {
		t = 999;
		for (k = 0; k <= N; k++) for (l = 0; l <= N; l++) {
			if (d[k][l] + i * k + j * l <= t) {
				t = d[k][l] + i * k + j * l;
			}
		}
		if (t != a[i][j]) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	printf("%d %d\n", (N + 1) * 2, N * 2 + (N + 1) * (N + 1));
	for (i = 0; i < N; i++) {
		printf("%d %d X\n", i + 1, i + 2);
		printf("%d %d Y\n", N + N + 1 - i, N + N + 2 - i);
	}
	for (i = 0; i <= N; i++) for (j = 0; j <= N; j++) printf("%d %d %d\n", i + 1, N + N + 2 - j, d[i][j]);
	printf("1 %d\n", N + N + 2);
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   map<string, int> mp;
   mp["SUN"] = 7;
   mp["MON"] = 6;
   mp["TUE"] = 5;
   mp["WED"] = 4;
   mp["THU"] = 3;
   mp["FRI"] = 2;
   mp["SAT"] = 1;
   string s;
   cin >> s;
   cout << mp[s] << endl;
   return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    use std::cmp::Ordering::*;
    if n == 1 {
        return println!("{}", 1)
    }

    let mut mode = Equal;
    let mut ans = 0;
    for i in 1..n {
        if aa[i] == aa[i-1] {
            continue;
        }
        match mode {
            Equal => mode = aa[i].cmp(&aa[i-1]),
            cmp => {
                if cmp != aa[i].cmp(&aa[i-1]) {
                    ans += 1;
                    mode = Equal;
                }
            }
        }
    }
    println!("{}", ans+1);
}


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

bool check(ll cur,int n){//判定
	int cnt=0;
	ll tmp=cur;
	while(tmp){	tmp/=10;	cnt++;	}
	if(cnt!=2*n+1)	return false;
	if(cur%2==0)	return false;
	for(int i=3;i*i<=cur;i+=2){//curは２桁以上が保証されている
		if(cur%i==0)	return false;
	}
	return true;
}
	
ll dfs(int n,int c,ll cur,int keta){
	if(n==keta){
		ll rev=cur,tans=cur*10+c;
		while(rev){
			tans=tans*10+(rev%10);
			rev/=10;
		}
		if(check(tans,n))	return tans;
		else 	return -1;
	}
	else{
		for(int i=9;i>=0;i--){
			ll tans=dfs(n,c,cur*10+i,keta+1);
			if(tans>0)	return tans;
		}
		return -1;
	}
}

int main(){
	int n,c;	cin>>n>>c;
	if(c<0){//回分なので必ず１１で割れる。
		if(n==1){
			cout<<11<<endl;
			return 0;
		}
		for(int i=0;i<2*n;i++)	cout<<9;
		cout<<endl;
		return 0;
	}
	ll ans=dfs(n,c,0,0);//最後のケースはc<0、それ以外はn<5なのでOK
	if(ans<0){
		for(int i=0;i<n;i++)	cout<<9;
		cout<<c;
		for(int i=0;i<n;i++)	cout<<9;
	}
	else 	cout<<ans;
	cout<<endl;
	return 0;
}
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N; cin >> N;
    vector<int> b(N);
    REP(i,N) cin >> b[i];
    vector<int> ans;

    REP(i,N){
        int res = -1;
        int field = N-i;
        for(int j=N-1; j>=0; --j){
            if(b[j] == -1) continue;
            if(b[j] != field){
                --field;
                continue;
            }
            res = j;
            break;
        }
        if(res == -1){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(b[res]);
        b[res] = -1;
    }

    reverse(ans.begin(), ans.end());
    for(auto &x : ans) cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<string> vi;
int n;
void dfs(int pos, string str, char maxi)
{
    if(pos == n)
    {
        vi.push_back(str);
        return;
    }
    char akhir = str.back();
    akhir++;
    maxi = max(maxi, akhir);
    for(akhir=maxi; akhir >= 'a'; akhir--)
    {
        dfs(pos+1, str + akhir, maxi);
    }
}
int main()
{
    int i,j,k,x,y,ans,temp,curr,m;
    int tc;
    cin >> n;
    dfs(1, "a", 'a');
    sort(vi.begin(), vi.end());
    for(auto x : vi) cout << x << endl;
    return 0;
}


Measured memory_bytes: 9588
M, N = map(int, input().split())
div = 1000000007


def pos(x, n):
    if n == 0:
        return 1
    r = pos(x*x % div, n//2) % div
    if n % 2 == 1:
        r = (r*x) % div
    return r


print(pos(M, N))



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

int main(){
	int n;cin>>n;
	int a=(1<<30);
	int ans=0;
	rep(i,n){
		int b=0;
		cin>>b;
		if(b<a){
			ans++;
		}
		//cout<<a<<" ";
		a=min(a,b);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3560
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
ld = [0]*26
score = 0

def dec(day):
    ans = 0
    for i in range(26):
        ans += c[i]*(day-ld2[i])
    return ans

rss = [[0,0] for i in range(d+1)]

for i in range(1,d+1):
    st = rss[i-1][0]
    ma = st
    for t in range(26):
        ld2=ld.copy()
        ld2[t]=i
        score=st+s[i-1][t]-dec(i)
        ma = max(score,ma)
        if score==ma:
            t2=t+1
    ld[t2-1]=i
    rss[i][1]=t2
    rss[i][0]=ma
    print(t2)


Measured memory_bytes: 9424
#include <cstdio>
int n, a[100001];
int main() {
  scanf("%d", &n);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i]%2 == 1) {
      flag++;
    }
  }
  if (flag == n) {
    puts("0");
    return 0;
  }
  
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      while (a[i]%2==0 && a[i] != 0) {
        a[i] /= 2;
        ans++;
      }
    }
    
    printf("%d", ans);
    
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;
const ll INF = 1e12;
int n , s;
vector<pair<int,int>>arr;
ll dp[102][100005];

ll recur(int ind , int w){
    if(w < 0)return -INF;
    else if(ind==0 && w>=0)return 0;

    if(dp[ind][w]!=-1)return dp[ind][w];

    ll first = arr[ind].second + recur(ind-1 , w-arr[ind].first);
    ll second = recur(ind - 1, w);
    return dp[ind][w] = max(first , second);
}

void solve(){
   cin>>n>>s; 
   arr.resize(n+1);
   memset(dp,-1,sizeof(dp));
   for(int i=1;i<=n;i++)cin>>arr[i].first>>arr[i].second;

   cout<<recur(n , s)<<endl;

   return;
           
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
bool solve(const vector<vector<int>> &G) {
    bool six = false;
    vector<int> four;
    for (int i = 0; i < G.size(); i++) {
        int t = G[i].size();
        if (t % 2) return false;
        if (t >= 6) six = true;
        if (t == 4) four.push_back(i);
    }
    if (six || four.size() >= 3) {
        return true;
    } else if (four.size() <= 1) {
        return false;
    } else {
        queue<pair<int, int>> Q;
        bool ans = false;
        Q.emplace(four[0], -1);
        while (!Q.empty()) {
            int node, prev;
            tie(node, prev) = Q.front();
            Q.pop();
            if (node == four[0] && prev != -1) {
                ans = true;
                break;
            }
            if (node == four[1]) {
                continue;
            }
            for (int next : G[node]) if (next != prev) {
                Q.emplace(next, node);
            }
        }
        return ans;
    }
}
int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << (solve(G) ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d",&n);
	printf("%d",n*n*n);
}


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

int N;
int main () {
    cin >> N;
    int g;
    cin >> g;
    int ans = 0;
    for(int i=0; i<N-1; i++) {
        int x;
        cin>> x;
        g = __gcd(g,x);
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 256
N,D,A = map(int,input().split())
XH = [tuple(map(int,input().split())) for i in range(N)]
XH.sort()
from collections import deque
q = deque()

ans = dmg = 0
for x,h in XH:
    while q and q[0][0] < x:
        _,d = q.popleft()
        dmg -= d
    rem = h - dmg
    if rem <= 0: continue
    a = -(-rem // A)
    ans += a
    dmg += a*A
    q.append((x + 2*D, a*A))
print(ans)

Measured memory_bytes: 44588
#include <iostream>
#include <string>
using namespace std;
int main (){
    int N;
    int Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++){
        for(int j = 0; j <= N-i ;j++){
            int k=N-i-j;
            if(10000*i+5000*j+1000*k==Y){
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int mod = 1e9+7;

struct Matrix {
	vector<vector<ll> > m;
	int h, w;
	Matrix(int i, int j) {
		m.resize(i, vector<ll> (j, 0ll));
		h = i; w = j;
	}
	Matrix operator* (const Matrix& b) const {
		Matrix c = Matrix(h, b.w);
		if(b.h!=w) return Matrix(0, 0);
		for(int i=0; i<h; i++)
			for(int j=0; j<b.h; j++)
				for(int k=0; k<b.w; k++) {
					c.m[i][k]+=(m[i][j]*b.m[j][k]%mod);
					c.m[i][k]%=mod;
				}
		return c;
	}

};


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N; cin>>N;
	ll K; cin>>K;
	Matrix start = Matrix(N, N);
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) cin>>start.m[i][j];

	Matrix tmp = start;
	Matrix init = Matrix(N, 1);
	for(int i=0; i<N; i++) init.m[i][0] = 1ll;

	//Initialize the identity matrix
	Matrix ans = Matrix(N, N);
	for(int i=0; i<N; i++) ans.m[i][i] = 1ll;
	
	while(K)
	{
		if(K&1ll) ans = ans*tmp;
		tmp = tmp*tmp;
		K/=2ll;
	}

	Matrix ret = ans*init;

	ll sum = 0ll;
	for(int i=0; i<N; i++) {
		sum+=ret.m[i][0];
		sum%=mod;
	}

	cout << sum << '\n';



	return 0;
}

Measured memory_bytes: 384
h, w = gets.split.map(&:to_i)
grids = []
minus = 0
h.times do
  line = gets.chomp.chars
  grids << line
  minus += line.count('#')
end

steps = Array.new(h) {Array.new(w, -1)}
dy = [-1, 0, 1, 0]
dx = [0, -1, 0, 1]

q = [[0, 0]]
steps[0][0] = 0
while !q.empty? do
  cy, cx = q.shift
  (0..3).each do |i|
    ny = cy + dy[i]
    nx = cx + dx[i]
    next if ny < 0 || ny > h-1 || nx < 0 || nx > w-1
    next if grids[ny][nx] == '#'
    next if steps[ny][nx] != -1

    steps[ny][nx] = steps[cy][cx] + 1
    q << [ny, nx]
  end
end

if steps[h-1][w-1] == -1
  puts -1
else
  puts h * w - minus - steps[h-1][w-1] - 1
end


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

#define NMAX 305
using namespace std;

double dp[NMAX][NMAX][NMAX];
bool viz[NMAX][NMAX][NMAX];
int nr[4], n;

double solve(int a, int b, int c){
    if(a == 0 && b == 0 && c == 0)
        return 0.0;
    if(viz[a][b][c])
        return dp[a][b][c];
    double ex = n;
    if(a)
        ex += solve(a - 1, b, c) * a;
    if(b)
        ex += solve(a + 1, b - 1, c) * b;
    if(c)
        ex += solve(a, b + 1, c - 1) * c;
    viz[a][b][c] = 1;
    dp[a][b][c] = ex / (double)(a + b + c);
    return dp[a][b][c];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;

    for(int i = 1; i <= n; ++i){
        int x;
        cin >> x;

        nr[x]++;
    }

    cout << fixed << setprecision(10) << solve(nr[1], nr[2], nr[3]) << '\n';
    return 0;
}


Measured memory_bytes: 246016
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] R = new int[n];
		
		for(int i = 0; i < n; i++) {
			R[i] = sc.nextInt();
		}
		
		int max = Integer.MIN_VALUE;
		int min = R[0];
		
		for(int j = 1; j < n; j++) {
			max = Math.max(max, R[j] - min);
			min = Math.min(min, R[j]);
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 100480
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m, x;
    scan(n, m, x);
    long[] a = new long[114 /*514*/ ];
    auto admission = aryread();
    foreach (e; admission)
    {
        a[e] = 1;
    }

    auto cost_to_n = sum(a[x .. n]);
    auto cost_to_zero = sum(a[0 .. x]);
    min(cost_to_n, cost_to_zero).writeln();
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
#define MAX_V 10240
 
// 从顶点from指向顶点to的权值为cost的边
typedef struct edge
{
	int to, distance, cost;
	edge(){}
	edge(int to, int distance, int cost) : to(to), distance(distance), cost(cost){}
	bool operator > (const edge & b) const
	{
		return distance != b.distance ? distance > b.distance : cost > b.cost;
	}
} P;
 
// first 最短路径，second顶点编号
 
// 图
vector<edge> G[MAX_V];
 
// V是顶点数
int V;
bool visited[MAX_V];
 
// 求解从顶点s出发到所有点的最短花费
int dijkstra(int s)
{
	int result = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	memset(visited, 0, V * sizeof(bool));
	que.push(P(0, 0, 0));
 
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.to;
		if (visited[v]) continue;
		visited[v] = true;
		result += p.cost;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			que.push(P(G[v][i].to, p.distance + G[v][i].distance, G[v][i].cost));
		}
	}
 
	return result;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	int /*N = V,*/ M;
	while (cin >> V >> M && V)
	{
		for (int i = 0; i < V; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < M; ++i)
		{
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			--u, --v;
			G[u].push_back(edge(v, d, c));
			G[v].push_back(edge(u, d, c));
		}
 
		cout << dijkstra(0) << endl;
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////


Measured memory_bytes: 5408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    vector<int> dx = { 0,1,0,-1 };
    vector<int> dy = { 1,0,-1,0 };


    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    ll attack = std::accumulate(a.begin(), a.end(), 0);
    if (attack >= h) {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n";
    }


    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<set>
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;

lint N, M, A[100000];
lint sumA[100001];

bool check(lint line) {
	lint res = 0;
	REP(i, N) {
		lint border = line - A[i];
		res += (N - (lower_bound(A, A + N, border) - A));
	}
	return res > M;
}

int main() {
	cin >> N >> M;
	REP(i, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	lint lb = -1, ub = 2e5 + 1;
	while (ub - lb > 1) {
		lint mid = (lb + ub) / 2;
		if (check(mid)) lb = mid;
		else ub = mid;
	}
	sumA[N] = 0;
	IREP(i, N) {
		sumA[i] = sumA[i + 1] + A[i];
	}
	lint ans = 0;
	lint cnt = 0;
	REP(i, N) {
		lint idx = (N - (lower_bound(A, A + N, lb - A[i]) - A));
		cnt += idx;
		ans += (idx * A[i] + sumA[N - idx]);
	}
	cout << (ans - (cnt - M) * lb) << endl;
}


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

int main(){
    
    int x;
    cin>>x;
    
    int h = x/3600;
    int m = (x/60)%60;
    int s = x%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3116
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_|sc.cin()).collect();
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 100000+10]; 102];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..100002 {
            dp[i+1][j] += dp[i][j];
            if j+xs[i]+1 < dp[0].len(){
                dp[i+1][j+xs[i]+1] -= dp[i][j];
            }
        }
        let mut ac = 0;
        for j in 0..100002 {
            ac += dp[i+1][j];
            ac = (ac + M) % M;
            dp[i+1][j] = ac;
        }
    }
    put!(dp[n][k]);
}

use std::io;
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

int main(){
	int r, c;
	while(1){
		cin>>r>>c;
		if(r == 0 && c == 0) break;
	
		if(r%2 == 1 && c%2 == 1){
			cout<<"no"<<endl;
		} else{
			cout<<"yes"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 2988
x,y,a,b,c= map(int,input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = sorted(list(map(int, input().split())), reverse=True)
ans = p+q+r
ans.sort(reverse=True)
print(sum(ans[:x+y]))

Measured memory_bytes: 22504
n = int(input())
lst = [int(x) for x in input().split()]
if lst.count(0) > 0:
  print("0")
else:
  product = 1
  for i in range(n):
    product *= lst[i]
    if product > 1000000000000000000:
      product = -1
      break
  print(str(product))

Measured memory_bytes: 21420
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")

//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (int)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0
// a^b=(a+b)-2(a&b)

typedef double db;
typedef long long ll;

const int ary=1e5+5;
const int mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
int a,b;
string s,t;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>a>>b;
	for(int i=1;i<=b;i++){
		s+=char(a+48);
	}
	for(int i=1;i<=a;i++){
		t+=char(b+48);
	}
	if(a<b){
		cout<<s;
		return 0;
	}
	cout<<t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, t;
    cin >> n >> t;
    vint a(n);
    rep(i, n) cin >> a[i];

    int mx = 0;
    vint diff(n);
    rrep(i, n) {
        mx = max(mx, a[i]);
        diff[i] = mx - a[i];
    }
    int tmp = vmax(diff);

    int ans = 0;
    rep(i, n) if (tmp == diff[i]) ans++;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(sf("%d %d",&n,&m)==2)
    {
        string s[n+5],t[m+5];

        for(int i=0;i<n;i++)cin>>s[i];
        for(int i=0;i<m;i++)cin>>t[i];

        bool f=false;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                int cnt=0;
                for(int k=i;k<min(n,i+m);k++)
                {
                    for(int l=j;l<min(n,j+m);l++)
                    {
                        if(s[k][l]==t[k-i][l-j])cnt++;
                    }
                }
                if(cnt==m*m)
                {
                    f=true;
                    break;
                }
            }
            if(f)break;
        }
        if(f)puts("Yes");
        else puts("No");
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
r,s,p = gets.split.map(&:to_i)
score = Array.new(n){[0]*3}
R,S,P = 0,1,2

gets.chomp.split("").each_with_index do |t,i|
  sr, ss, sp = 0,0,0
  sr = r if t == "s"
  ss = s if t == "p"
  sp = p if t == "r"
  if i-k >= 0
    sr = 0 if score[i-k][R] != 0
    ss = 0 if score[i-k][S] != 0
    sp = 0 if score[i-k][P] != 0
  end
  score[i][R] += sr
  score[i][S] += ss
  score[i][P] += sp
end
ans = 0
score.each {|s| ans += s.max}
p ans


Measured memory_bytes: 30188
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;

priority_queue<ll> que;
int N;
int M;

int main() {
  cin >> N >> M;
  //まず値を入れる
  for(int i=0; i<N; i++) {
    ll A;
    cin >> A;
    que.push(A);
  }

  //最大値を割っていく
  for(int i=0; i<M; i++) {
    int n = que.top() / 2;
    que.pop();
    que.push(n);
  }

  //合計値を取得
  ll sum = 0;
  while(!que.empty()) {
    sum += que.top();
    que.pop();
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = 1e18L;
int main() {
  ll n,m,l;
  cin >> n >> m >> l;

  vector<vector<ll>> d(n,vector<ll>(n,INF));
  rep(i,n) d[i][i] = 0;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    d[a][b] = d[b][a] = c;
  }
  rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

  vector<vector<ll>> dl(n,vector<ll>(n,INF));
  rep(i,n)rep(j,n) if(d[i][j]<=l) dl[i][j] = 1;
  rep(k,n)rep(i,n)rep(j,n) dl[i][j] = min(dl[i][j], dl[i][k]+dl[k][j]);

  int q;
  cin >> q;
  rep(i,q){
    int s,t;
    cin >> s >> t;
    ll ans = dl[s-1][t-1];
    cout << (ans==INF ? -1 : ans-1) << endl;
  }
}


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


int main() {
  int n, k;
  cin >> n >> k;
  ll x = 0, y = 0;
  for(int i = 1; i <= n; i++) {
    if(i%k==0) x++;
    if(k%2==0&&i%k==k/2) y++;
  }
  cout << x*x*x+y*y*y << endl;
  return 0;
}

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

int main()
{
	int h, w;
	while (cin >> h >> w, !(h == 0 && w == 0)) {
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll a, b, k;
    cin >> a >> b >> k;

    cout << max(0LL, a - k) << " " << max(0LL, min(b, a + b - k)) << endl;
    
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,x,y;cin >>n >> x >> y;
    x--;y--;
    vector<int> ans(n);
    rep(j,n)rep(i,j){
        // trace(i,j);
        int ret1 = j-i;
        int ret2 = abs(i-x) + abs(j-y) + 1;
        int ret3 = abs(i-y) + abs(j-x)+1;
        int dist = min({ret1,ret2,ret3});
        ans[dist]++;
    }
    for(int i = 1;i < n;i++)cout << ans[i] << endl;
    // trace(ans);
    return 0;
    
}

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

int main() {
  string o, e; cin >> o >> e;
  for (int i = 0; i < o.size(); i++) {
    cout << o.at(i);
    if (i < e.size()) {
      cout << e.at(i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    int H, N;
    cin >> H >> N;
    int A[N];
    cins(A, A + N);
    Yes(accumulate(A, A + N, 0) >= H);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,k;cin >> a >> b >> c >> k;
	if(k%2==0) cout << a-b << endl;
	else cout << b-a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<int> L(N);
	for(int i=0;i<N;i++) cin >> L[i];
	
	sort(L.begin(), L.end());
	int tot = 0;
	for(int i=0;i<N-1;i++) tot += L[i];
	
	cout << (tot > L[L.size() - 1] ? "Yes" : "No") << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;

int dp[1010][1010];
int main(){
	ios::sync_with_stdio(false);
	int t;
	string a,b;
	cin>>t;
	while(t--){
		memset(dp,0,sizeof(dp));
		cin>>a>>b;
		int lena=a.length();
		int lenb=b.length();
		for(int i=1;i<=lena;i++){
			for(int j=1;j<=lenb;j++){
				if(a[i-1]==b[j-1]){
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		cout<<dp[lena][lenb]<<endl;
	}


	return 0;
}




Measured memory_bytes: 7172
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

int main()
{
	int N;
	int H[20];
	int max = 0;
	int count = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &H[i]);
		if (H[i] >= max)
		{
			max = H[i];
			count++;
		}
	}

	printf("%d\n", count);

}

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

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

//グローバル変数として、諸変数を宣言
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 10000000;
int H, W;
vector<string> grid;

ll solve(){
    //用いるdpのvector配列を生成。最初は非常に大きな値を入れておく
    vector<vector<ll>> dp(H, vector<ll>(W, INF));
    //左上のマスの初期状態によって、dp[0][0]の初期状態を変更
    if(grid[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;

    //dp開始
    rep(i, H){
        rep(j, W){
            //各マスから、右と下への移動を見る
            for(int dir = 0; dir < 2; dir++){
                int next_i = i + dx[dir], next_j = j + dy[dir];
                //next_i, next_jが、H*Wのグリッドの外に出てしまった場合は、飛ばす（次の経路を考える）
                if(next_i >= H || next_j >= W) continue;
                //(i, j)から、(next_i, next_j)に到達するまでに必要なコストをaddに入れる
                //今回の問題では、コストは、塗り替えの回数を表す
                int add = 0;
                //(i, j)が通路（白で塗られたマス）で、(next_i, next_j)が壁（黒で塗られたマス）の場合には、コストが1必要
                //コストが1必要というのは、塗り替えを1回行わなければならない
                if(grid[next_i][next_j] == '#' && grid[i][j] == '.') add = 1;
                //dp[next_i][next_j]の値を更新する。この更新は、dp[next_i][next_j] > (dp[i][j] + add)の時に行われる
                dp[next_i][next_j] = min(dp[i][j] + add, dp[next_i][next_j]);
            }
        }
    }
    return dp[H-1][W-1];
}

int main(){
    cin >> H >> W;
    //H*Wマスの状態を入力する2次元配列gridはグローバル領域で宣言しているので、
    //vector配列の要素数を指定
    grid.resize(H);
    rep(i, H) cin >> grid[i];
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3656
#include "stdio.h"

int main(void)
{
	int a,b,x;
 	while(1)
 	{
 		scanf("%d%d",&a,&b);
 		if(a==0 && b==0)
 			break;
 		if(a>b)
 		{
 			x=a;
 			a=b;
 			b=x;
 		}
 		printf("%d %d\n", a, b);	
 	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_beetween_a_and_b(void) {
	long int a, b, x;
	cin >> a >> b >> x;
	long int cnt = 0;
	long int div_a=0;
	long int div_b = b / x;
	if (a == 0) div_b += 1;
	else {
		div_a = (a - 1) / x;
	}
	cout << div_b-div_a << endl;
}

int main()
{
	b_beetween_a_and_b();
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(long i=0;i<(n);i++)
#define For1(i,n) for(long i=1;i<(n);i++)
long gcd(long a,long b){
    return b?gcd(b,a%b):a;
}
int main(){
    long n;cin>>n;
    vector<long> d(n);
    For(i,n){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    cout<<d.at(n/2)-d.at(n/2-1)<<endl;
}

Measured memory_bytes: 1024