akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int A,B,C,D,ans;
    cin >> A >> B >> C >> D;
    int T = A / D;
    if(A%D == 0)T--;
    int Ao = C / B;
    if(C%B == 0)Ao--;
    
    if(T >= Ao){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int p[300005];
bool vis[300005];

void check(int l,int r) {
  int max1=0,max2=0;
  for(int i=l;i<=r;i+=2)
    if (p[i]>i) {
    	if (p[i]<max1) {
    		puts("No");
    		exit(0);
		}
		max1=p[i];
	} 
	else {
		if (p[i]<max2) {
			puts("No");
			exit(0);
		}
		max2=p[i];
	}
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&p[i]);
  int l=1;
  while (l<=n) {
  	if (p[l]==l) l++;
	else {
		int r=l,s=1;
		vis[p[l]]=1;
		while (s) {
			if (r+2>n||p[r+1]!=r+1||p[r+2]==r+2) {
				puts("No");
				return 0;
			}
			r+=2;
			vis[p[r]]=1;
			if (p[r]>r) s++;
			if (vis[r]) s--;
		}
		check(l,r);
		l=r+1;
	}
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
  int N;
  cin >> N;
  unordered_map<ll, ll> freq;
  ll n_pairs = 0;
  for (int i = 1; i <= N; i++) {
    ll A;
    cin >> A;
    ll diff = i - A;
    n_pairs += freq[diff];
    freq[A + i]++;
  }
  cout << n_pairs << endl;
  return 0;
}

Measured memory_bytes: 18464
from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(1, 2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row))+row
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

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

void solve() {
  string a, b;
  cin >> a >> b;
  int la = (int) a.size();
  int lb = (int) b.size();
  if(la > lb) {
    cout << "GREATER";
  }
  else if(la < lb) {
    cout << "LESS";
  }
  else {
    for (int i = 0; i < la; i++) {
      if(a[i] > b[i]) {
        cout << "GREATER";
        return;
      }
      if(a[i] < b[i]) {
        cout << "LESS";
        return;
      }
    }
    cout << "EQUAL";
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long K, long long S)
{
    ll ans = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            ll k = S - i - j;
            if (0 <= k && k <= K)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    long long K;
    scanf("%lld", &K);
    long long S;
    scanf("%lld", &S);
    solve(K, S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,W;


int32_t main()
{
    cin>>n>>W;
    int w[n+2];
    int v[n+2];
    int dp[n+1][W+1];
    for(int i=1;i<=n;i++){cin>>w[i]>>v[i];}
    for(int wi=0;wi<=W;wi++){
        dp[1][wi] = 0;
    }
    for(int wi = w[1];wi<=W;wi++){
        dp[1][wi] = v[1];
    }
    for(int i=2;i<=n;i++){
        for(int wi = 0; wi<=W;wi++){
            dp[i][wi] = dp[i-1][wi];
            if(wi>=w[i])
            {
                dp[i][wi] = max(dp[i][wi], v[i]+dp[i-1][wi-w[i]]);
            }
        }
    }
    cout<<dp[n][W];



}

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

int main() {
  int n, a, min = 1000000, max = -1000000;
  long sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    if (a < min) min = a;
    if (a > max) max = a;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int A, B;

int main() {
	scanf("%d%d", &A, &B);
	puts(A <= 0 && B >= 0 ? "Zero" : (A > 0) ? "Positive" : (B - A & 1) ? "Positive" : "Negative");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>

#define f(i,x) for(int i=0;i<x;i++)


using namespace std;

int main()
{
	int a; cin >> a;
	if (a < 1200)cout << "ABC";
	else cout << "ARC";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,s[10000],j,t[500],n=0,q=0,count=0,count2=0;

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


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


  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	count2++;
	if(count2>=2){
	  count--;
	}
	count++;
      }
    }
    count2=0;
  }
  
  printf("%d\n",count);
  
  return 0;
}



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//ori
#define MOD 1000000007
 
int main() {
  int N, x=0, ans=0;
  string S;
  cin >> N >> S;
  REP(i,N) {
    if(S.at(i) == 'I') x++;
    else x--;
    ans = max(ans,x);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
dp=[[0 for _ in range(3)] for _ in range(n)]
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
dp[0]=a[0]
for i in range(1,n):
  for j in range(3):
    dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j-2])
print(max(dp[-1]))

Measured memory_bytes: 102680
use std::io::*;
use std::str::FromStr;

fn main() {
    let a:u64 = read();
    let b:u64 = read();
    let x:u64 = read();

    let cnt = b / x - a / x + (if a % x == 0 { 1 } else { 0 });

    println!("{}", cnt);
}

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


Measured memory_bytes: 4352
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Flow = int;
struct FlowEdge {
  int src, dst;
  Flow cap;
  int rev;
  FlowEdge(const int s = 0, const int d = 0, const Flow c = 0, const int r = 0) : src(s), dst(d), cap(c), rev(r) {}
};

using FlowEdges = std::vector<FlowEdge>;

class FlowGraph {
  std::vector<FlowEdges> g;

public:
  FlowGraph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  FlowEdges &operator[](const int i) & { return g[i]; }

  void addEdge(const int src, const int dst, const Flow c = 1) {
    g[src].emplace_back(src, dst, c, g[dst].size());
    g[dst].emplace_back(dst, src, 0, g[src].size() - 1);
  }
};

template<int inf = std::numeric_limits<Flow>::max() / 8> Flow fordFulkerson(FlowGraph g, const int source, const int sink) {
  std::vector<int> used(g.size());
  std::function<Flow(int, int)> dfs = [&](int s, int f) -> Flow {
    if (s == sink) return f;
    used[s] = true;
    for (auto &e : g[s]) {
      if (used[e.dst] || e.cap <= 0) continue;
      int d = dfs(e.dst, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.dst][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  };
  Flow s = 0;
  for (;;) {
    std::fill(used.begin(), used.end(), false);
    Flow f = dfs(source, inf);
    if (f == 0) return s;
    s += f;
  }
}

main {
  int n, m;
  cin >> n >> m;
  FlowGraph g(n);
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    g.addEdge(a, b, c);
  }
  cout << fordFulkerson(g, 0, n - 1) << endl;
}

Measured memory_bytes: 3176
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    }
}

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

using namespace std;

long long h;

int main() {
    cin >> h;
    int d = (int) log2(h);
    long long ans = 0, pwr = 1;
    for (int i = 0; i <= d; i++) {
        ans += pwr;
        pwr *= 2;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>

using namespace std;

const int N_MAX = 1000000;

int main(){
  int x, y;
  cin >> x;
  cin >> y;

  int residue = -1;
  int ans;
  while(residue != 0){
    residue = max(x, y)%min(x, y);
    ans = min(x, y);
    if(x>y) x = residue;
    else y = residue;
  }

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



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#ifdef CHECK_

int main() {
  int n, k;
  int xs[10] = {};
  n = get<int>();
  k = get<int>();
  for(int i = 0; i < k; ++i) {
    xs[get<int>()] = true;
  }

  for(;;++n) {
    bool check = true;
    int t = n;
    while( t != 0 ) {
      if( xs[t % 10] ) check = false;
      t /= 10;
    }
    if( check ) {
      printf("%d\n", n);
      break;
    }
  }  
  
  return 0;
}

#else

template<typename T>
T get() { return 0; }
template<>
int get() { int x; scanf("%d", &x); return x; }
template<>
long get() { long x; scanf("%ld", &x); return x; }

template<typename T>
void put(T x) {}
template<>
void put(int x) { printf("%d\n", x); }
template<>
void put(long x) { printf("%ld\n", x); }
template<>
void put(std::string str) { printf("%s\n", str.c_str()); }
template<>
void put(const char* str) { printf("%s\n", str); }

#define CHECK_
#include __FILE__
#endif



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    rep(i,N){
        cin >> A[i];
        B[i] = A[i] - i - 1;
    }
    sort(B.begin(),B.end());
    ll b = B[N/2];
    ll ans = 0;
    rep(i,N){
        ans += abs(B[i] - b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x,y;
    cin >> x >> y;
    ll now=x,ans=0;;
    while(now>0&&now<=y){
        now*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def f(n):
    return 3 * n + 1 if n % 2 else n // 2


def main():
    s = int(stdin.readline().rstrip())
    am = s
    tmp = {am}
    for m in range(2, 1000001):
        am = f(am)
        if am in tmp:
            print(m)
            return
        tmp.add(am)


if __name__ == "__main__":
    main()


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

int main() {
  int N,L; cin >>N >>L;
  vector<string> s(N);
  rep(i,0,N) cin >>s[i];
  sort(s.begin(),s.end());
  rep(i,0,N) cout <<s[i];
  cout <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int x,y,z;
int c=0;
bool f[12];
while(scanf("%d %d %d",&x,&y,&z)!=EOF){
for(int i=0;i<11;i++)
f[i]=true;

f[x]=false;f[y]=false;f[z]=false;


for(int i=1;i<11;i++)
{if(f[i]==true){if(x+y+i<=20)c++;}}

if(c>=4)printf("YES\n");

else printf("NO\n");
c=0;
}
return 0;
}

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

template<class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

int main() {
  int N, M; cin >> N >> M;
  vector<int> D(N); rep(i, N) cin >> D[i];
  vector<int> U(M), V(M);
  vector<vector<int>> G(N);
  rep(i, M) {
    cin >> U[i] >> V[i]; U[i]--; V[i]--;
    G[U[i]].push_back(i);
    G[V[i]].push_back(i);
  }
  vector<set<int>> T(N);
  vector<bool> vis(N);
  vector<int> color(N, -1);
  constexpr int INF = 1e9;
  vector<int> ans(M, INF + 1);
  rep(i, N) {
    pair<int, int> mn(INF, INF);
    for (int k : G[i]) {
      int j = U[k] ^ V[k] ^ i;
      mn = min(mn, make_pair(D[j], k));
    }
    ans[mn.second] = D[i];
  }
  rep(i, N) if (color[i] == -1) {
    color[i] = 0;
    queue<int> q;
    q.push(i);
    while (not q.empty()) {
      int v = q.front(); q.pop();
      for (int j : G[v]) if (ans[j] <= INF) {
        int u = U[j] ^ V[j] ^ v;
        if (color[u] == -1) {
          color[u] = color[v] ^ 1;
          q.push(u); 
        }
      }
    }
  }
  rep(i, M) ans[i] = min(ans[i], INF);
  for (int ii = 0; ii < 2; ii++) {
    constexpr ll INFL = 1e18;
    vector<ll> dist(N, INFL);
    minheap<pair<ll, int>> heap;
    rep(i, N) if (color[i] == ii) {
      dist[i] = 0;
      heap.emplace(0, i);
    }
    while (not heap.empty()) {
      ll d;
      int u;
      tie(d, u) = heap.top(); heap.pop();
      if (d > dist[u]) continue;
      for (int i : G[u]) {
        int v = U[i] ^ V[i] ^ u;
        if (dist[v] > dist[u] + ans[i]) {
          dist[v] = dist[u] + ans[i];
          heap.emplace(dist[v], v);
        }
      }
    }
    rep(i, N) if (color[i] == 1 - ii and dist[i] != D[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep(i, N) cout << (color[i] ? 'B' : 'W');
  cout << endl;
  rep(i, M) {
    cout << ans[i] << '\n';
  }
}

Measured memory_bytes: 18500
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define LL long long 
using namespace std;
const int M = 200001;
int a[M],m,n,p,v;

bool check(int x)
{
	int k=x+p-1;
	k=min(k,v);
	int t=a[x]+m;
	LL s=(LL)m*(v-k);
	for(int i=x+1;i<=n-p+1;i++)
	{
		if(a[i]>t) return 0;
		s-=t-a[i];
	}
	if(s>0) return 0;
	return 1;
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int l=1,r=n-p,mid,tmp=n-p+1;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid)) tmp=mid, r=mid-1;
		else l=mid+1;
	}
	printf("%d",n-tmp+1);
} 

Measured memory_bytes: 640
package main

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

type task struct {
	a int
	b int
}

type byB []task

func (a byB) Len() int           { return len(a) }
func (a byB) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byB) Less(i, j int) bool { return a[i].b < a[j].b }

func main() {
	n := getInt()

	tasks := make([]task, n)
	for i := range tasks {
		tasks[i].a = getInt()
		tasks[i].b = getInt()
	}

	sort.Sort(byB(tasks))

	sum := 0
	ans := "Yes"
	for _, task := range tasks {
		sum += task.a
		if sum > task.b {
			ans = "No"
			break
		}
	}

	fmt.Println(ans)
}


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

signed main(){
	int Q, q;
	scanf("%lld", &Q);
	priority_queue<int> pq1;
	priority_queue<int, vector<int>, greater<int>> pq2;
	int asum1 = 0, asum2 = 0, bsum = 0;
	for(q = 0; q < Q; q++){
		int c, a, b;
		scanf("%lld", &c);
		if(c == 1){
			scanf("%lld%lld", &a, &b);
			if(pq1.size() == pq2.size()){
				if(pq2.size() == 0 || a <= pq2.top()){
					pq1.push(a);
					asum1 += a;
				}
				else{
					pq2.push(a);
					asum2 += a;
					a = pq2.top();
					pq2.pop();
					asum2 -= a;
					pq1.push(a);
					asum1 += a;
				}
			}
			else{
				if(a >= pq1.top()){
					pq2.push(a);
					asum2 += a;
				}
				else{
					pq1.push(a);
					asum1 += a;
					a = pq1.top();
					pq1.pop();
					asum1 -= a;
					pq2.push(a);
					asum2 += a;
				}
			}
			bsum += b;
		}
		else{
			printf("%lld ", pq1.top());
			printf("%lld\n", (pq1.size() * pq1.top() - asum1) + (asum2 - pq2.size() * pq1.top()) + bsum);
		}
	}
	return 0;
}

Measured memory_bytes: 3828
import java.util.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] num = new int[n];
    int sum = 0;
    for(int i = 0; i < n; ++i) {
      num[i] = sc.nextInt();
      sum += num[i];
    }
    int res1 = 0;
    int res2 = 0;
    int mid1 = sum / n;
    int mid2 = sum / n + 1;
    for(int i = 0; i < n; ++i) {
      int cur1 = Math.abs(mid1 - num[i]);
      int cur2 = Math.abs(mid2 - num[i]);
      res1 += cur1 * cur1;
      res2 += cur2 * cur2;
    }
    System.out.println(Math.min(res1, res2));
  }
}

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

template <class T> class Queue_Ring {
    
public:
    
    Queue_Ring(vector<T> list, int max_count):
    max_count(max_count+1){
        for(int i=0; i<max_count+1; i++){
            if(i<list.size()){
                s.push_back(list[i]);
            }else{
                s.push_back(list[0]);
            }
        }
        head = 0;
        tail = list.size();
    }
    
    void enqueue(T x){
        if( getDataNum() == max_count-1 ) return;
        s[tail] = x;
        tail = (tail+1)%max_count;
    }
    
    T dequeue(){
        T a = s[head];
        head = (head+1)%max_count;
        return a;
    }
    
    bool isEmpty(){
        return getDataNum() == 0;
    }
    
    int getDataNum(){
        if( tail - head > 0 ){
            return tail - head;
        }else if( tail - head < 0 ){
            return tail - head + max_count;
        }else{
            return 0;
        }
    }
    
private:
    vector<T> s;
    int head;
    int tail;
    const int max_count;
    
    static const int MAX = 10000;
    
    void reset(){
        vector<T> _s;
        for(int i=head; i<s.size(); i++){
            _s.push_back(s[i]);
        }
        s = _s;
        head = 0;
    }
    
};

class RoundRobinScheduling {
    
public:
    
    RoundRobinScheduling(int n, int q, vector<string> name, vector<int> time):
    n(n),
    q(q),
    name(new Queue_Ring<string>(name, n)),
    time(new Queue_Ring<int>(time, n)),
    sum_time(0){}
    
    ~RoundRobinScheduling(){
        delete name;
        delete time;
    }
    
    void update(){
        
        if(name->isEmpty()) return;
        
        string nm = name->dequeue();
        int t = time->dequeue();
        if(t>q){
            t -= q;
            name->enqueue(nm);
            time->enqueue(t);
            sum_time += q;
        }else{
            sum_time += t;
            cout << nm << " " << sum_time << endl;
        }
        
    }
    
    bool isFinished(){
        return name->isEmpty();
    }
    
private:
    int n;
    int q;
    Queue_Ring<string>* name;
    Queue_Ring<int>* time;
    
    int sum_time;
    
};

int main() {
    
    int n;
    cin >> n;
    
    int q;
    cin >> q;
    
    vector<string> name;
    vector<int> time;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        name.push_back(s);
        int t;
        cin >> t;
        time.push_back(t);
    }
    
    RoundRobinScheduling* rrs = new RoundRobinScheduling(n, q, name, time);
    
    while (!rrs->isFinished()) {
        rrs->update();
    }
    
    delete rrs;
    
    return 0;
}



Measured memory_bytes: 7604
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/15/20 19:44:33
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string b; cin>>b;
  string ans;
  for (auto c:b) {
    if (c == 'A')
      ans.push_back('T');
    if (c == 'T')
      ans.push_back('A');
    if (c == 'C')
      ans.push_back('G');
    if (c == 'G')
      ans.push_back('C');
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	int N;
	double money = 100000;

	cin >> N;
	rep(i,N) {
		money = money * 1.05;
		money = ceil(money/1000) * 1000;
	}
	cout << (int)money << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int X,A;
  cin>>X>>A;
  if(X<A){
  cout<<0<<endl;
  }else{
  cout<<10<<endl;
  }
}

Measured memory_bytes: 256
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1)*100 + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            now_cnt = cnt
            now_tot = tot - C[i]
            for k in range(P[i]-1):
                now_cnt -= 1
                now_tot -= (i+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)


Measured memory_bytes: 3064
n = input().split()

s = []
for i in n:
    if i == '+':
        s.append(s.pop(-1) + s.pop(-1))
    elif i == '-':
        s.append(s.pop(-2) - s.pop(-1))
    elif i == '*':
        s.append(s.pop(-1) * s.pop(-1))
    else:
        s.append(int(i))

print(s[0])


Measured memory_bytes: 5596
using System;
 
public class Program
{
 
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        if (n % 2 == 0)
        {
            Console.WriteLine("0.5");
        }
        else
        {
            double even = (double) (n / 2) / n;
            Console.WriteLine((double)1-even);
        }
    }
 
    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}
 
class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }
 
    const char Separator = ' ';
    private int _pos;
    private string[] _line;
 
    #region スペース区切りで取得
 
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }
 
        return _line[_pos++];
    }
 
    public int NextInt()
    {
        return int.Parse(Next());
    }
 
    public long NextLong()
    {
        return long.Parse(Next());
    }
 
    public double NextDouble()
    {
        return double.Parse(Next());
    }
 
    #endregion
 
    #region 型変換
 
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }
 
        return result;
    }
 
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }
 
        return result;
    }
 
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }
 
        return result;
    }
 
    #endregion
 
    #region 配列取得
 
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);
 
        _pos = _line.Length;
        return _line;
    }
 
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
 
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
 
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
 
    #endregion
}

Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		int X=scanner.nextInt();
		int Y=scanner.nextInt();
		int x[]=new int[n];
		int y[]=new int[m];
		for(int i=0;i<n;i++) {
			x[i]=scanner.nextInt();
		}
		Arrays.sort(x);
		for(int i=0;i<m;i++) {
			y[i]=scanner.nextInt();
		}
		Arrays.sort(y);
		for(int i=X+1;i<=Y;i++) {
			if(x[n-1]<i&&i<=y[0]) {
				System.out.println("No War");
				return;
			}
		}
		System.out.println("War");
	}
}


Measured memory_bytes: 23508
def rec(L):
    return sum([d for a, b, c, d in X if L[b] - L[a] == c]) if len(L) > N else max([rec(L + [i]) for i in range(L[-1], M)])

N, M, Q = map(int, input().split())
X = []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    X.append((a, b, c, d))
print(rec([0]))

Measured memory_bytes: 80920
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin >> x;
	ll ans = 0;
	while(x >= 500){
		x -= 500;
		ans += 1000;
	}
	while(x >= 5){
		x -= 5;
		ans += 5;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,k,num,A,B;
    cin >> a >> b >> k;
    for(int i=100;i>0;i--){
        A=a%i;
        B=b%i;
        if(A==0 && B==0){ //公約数かどうか
            num = i;
            k-=1;
            if(k==0){
                break;
            }
        }
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
mod = 10**9+7

def minus(n,k):
    x,y =1,1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(k-i)%mod
    return x*pow(y, mod-2, mod)%mod

ans = pow(2,n,mod)-1-minus(n,a)-minus(n,b)
while ans<0:
    ans+=mod
print(ans)


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

int main()
{
  int w,h,n;
  cin>>w>>h>>n;
  int left=0, right=w, upper=h, lower=0;
  for(int i=0;i<n;i++){
    int x,y,a;
    cin>>x>>y>>a;
    if (a==1) left=max(left,x);
    if (a==2) right=min(right,x);
    if (a==3) lower=max(lower,y);
    if (a==4) upper=min(upper,y);
  }
  int ans=0;
  if (right>left && lower<upper) ans= (right-left)*(upper-lower);
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
 
int main()
{
    string a, b;
    long long cnt = 0;
    cin >> a >> b;
    for(long long i=0; i < a.length(); i++)
    {
        if (a[i] != b[i]) cnt += 1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2019/03/24/091900
int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    REP(i, N) {
        cin >> b[i];
        b[i]--;
    }
    // print(b);
    vector<int> res;
    for(int i = 0; i < N; i++) {
        //文字数分
        int pivot = -1;
        for(int j = (int)b.size() - 1; j >= 0; j--) {
            // stringを逆順に走査する
            if(b[j] == j) {
                pivot = j;
                break;
            }
        }
        if(pivot == -1) {
            cout << -1 << endl;
            return 0;
        }
        res.push_back(pivot + 1);
        b.erase(b.begin() + pivot);
    }
    reverse(res.begin(), res.end());
    for(auto v : res) {
        cout << v << endl;
    }
    return 0;
}

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

int main(){
  int num,a[4]={};
  char c;
  string s,b[4]={"A","B","AB","O"};

  while(cin>>num>>c>>s){
      if(s==b[0]) 
	a[0]++;
      else if(s==b[1]) 
	a[1]++;
      else if(s==b[2]) 
	a[2]++;
      else a[3]++;
  }
  for(int i=0;i<4;i++)
    cout<<a[i]<<endl;
 return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;


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

    int D, T, S; cin >> D >> T >> S;

    if ( D <= T * S ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int day = cin.ReadInt;

            if (day == 25)
            {
                Console.WriteLine("Christmas");
            }
            else if (day == 24)
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (day == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else if (day == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 15:26:28 2019

@author: maezawa
"""

n, q = list(map(int, input().split()))
s = input()
qs = []
for i in range(q):
    ti, di = input().split()
    qs.append([ti, di])
    
def isaliveleft(p):
    current = p
    for query in qs:
        if query[0] == s[current]:
            if query[1] == 'L':
                current -= 1
                if current < 0:
                    return False
            else:
                current += 1
                if current >= n:
                    return True
    return True

def isaliveright(p):
    current = p
    for query in qs:
        if query[0] == s[current]:
            if query[1] == 'R':
                current += 1
                if current >= n:
                    return False
            else:
                current -= 1
                if current < 0:
                    return True
    return True

# find left limit
left = 0
right = n-1
if isaliveleft(left):
    ansleft = -1
elif isaliveleft(right) == False:
    ansleft = n
else:
    while True:
        mid = (right + left)//2
        if isaliveleft(mid):
            right = mid
        else:
            left = mid
        if right - left <= 1:
            ansleft = left
            break

# find right limit
left = 0
right = n-1
if isaliveright(right):
    ansright = n
elif isaliveright(left) == False:
    ansright = -1
else:
    while True:
        mid = (right + left)//2
        if isaliveright(mid):
            left = mid
        else:
            right = mid
        if right - left <= 1:
            ansright = right
            break
if ansleft == n:
    print(0)
elif ansright == -1:
    print(0)
else:
    print(ansright - ansleft - 1)

Measured memory_bytes: 25776
# frozen_string_literal: true

s = gets.chomp

so = (0..(s.size-1)).step(2).map { |i| s[i] }
se = (1..(s.size-1)).step(2).map { |i| s[i] }

if so.all? { |e| %w[D R U].include?(e) } && se.all? { |e| %w[D L U].include?(e) }
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
 
int main(){
  ll N, i, ans = 0;
  cin >> N;
  
  rep(i, N + 1){
    if(i % 3 == 0 || i%5 == 0){
      continue;
    }
    ans += i;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
n = list(input())

op_count= len(n)-1
for i in range(2**op_count):
    op = ["-"]*op_count
    for j in range(op_count):
        if ((i>>j)&1):
            op[j]="+"
    formula = n[0]+op[0]+n[1]+op[1]+n[2]+op[2]+n[3]
    if eval(formula)==7:
        print(formula+"=7")
        break

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int a[m];
    rep(i, m) {
        cin >> a[i];
        sum += a[i];
    }
    cout << (n - sum >= 0 ? n - sum : -1) << endl;
    return 0;
}

Measured memory_bytes: 3632
a = int(input())
b = [a]
c = 1
while True:
    c += 1
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1
    if a in b:
        print(c)
        exit()
    else:
        b.append(a)


Measured memory_bytes: 2940
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll A,B;cin>>A>>B;
  ll m;cin>>m;
  vector<ll>a(A);
  vector<ll>b(B);
  ll ans=0;
  ll n1=INF;
  rep(i,A){
    cin>>a[i];
    n1=min(n1,a[i]);
  }
  ans+=n1;
  n1=INF;
  rep(i,B){
    cin>>b[i];
    n1=min(n1,b[i]);
  }
  ans+=n1;

  rep(i,m){
    ll x,y,c;cin>>x>>y>>c;x--;y--;
    ans=min(ans,a[x]+b[y]-c);
  }
  cout<<ans<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_3_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n  = ReadInt();
            LinkedList<int> res = new LinkedList<int>();

            for (int i = 0 ; i < n ; i++)
            {
                string[] line = ReadStAr();

                switch (line[0])
                {
                    case "insert":
                        res.AddFirst(int.Parse(line[1]));
                        break;
                    case "delete":
                        res.Remove(int.Parse(line[1]));
                        break;
                    case "deleteFirst":
                        res.RemoveFirst();
                        break;
                    case "deleteLast":
                        res.RemoveLast();
                        break;
                }
            }

            Console.WriteLine(String.Join(" ",res.Select(x => x.ToString()).ToArray()));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int n;

    cin >> n;
    vector<int> R(n);
 
    REP(i, n) cin >> R[i];

    int minimum = R[0];
    int diff = -1000000000;

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

        diff = max(diff, R[i] - minimum);
        minimum = min(R[i], minimum);
        
    }
    cout << diff << endl;
}


Measured memory_bytes: 3608
INF  = float("inf") # 正の無限大

N = int(input())						# 5
H = list( map(int, input().split()) )	# 1 2 3 4 5 ...

C = [INF]*(N)
C[0] = 0

for i in range(N):
	if (i+1) < N: C[i+1] = min(C[i+1], C[i] + abs(H[i] - H[i+1]))
	if (i+2) < N: C[i+2] = min(C[i+2], C[i] + abs(H[i] - H[i+2]))

print(C[-1])

#print(C)


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

int N;
int a[100050];

int main(){

    cin>>N;
    a[0]=0; a[N+1]=0;
    for(int i=1;i<=N;i++)scanf("%d",&a[i]);
    
    int sum=0;   
    for(int i=1;i<=N+1;i++)
        sum+=abs(a[i]-a[i-1]);
    for(int i=1;i<=N;i++)
        printf("%d\n",sum+abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i]-a[i+1]));
}

Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) {
        int b;
        cin >> b;
        a[i] = b;
    }

    sort(ALL(a), greater<int>());
    int al = 0, bo = 0;
    REP(i, n) {
        if(i%2 == 0) al += a[i];
        else bo += a[i];
    }

    cout << al-bo << endl;
}


Measured memory_bytes: 256