akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, q;
ll a[100005], ps[100005];

ll query(ll x) {
  ll ans = 0, sum = 0;
  ll l = 1, r = 0;
  while (l <= n) {
    while (r < n && ps[r + 1] - ps[l - 1] <= x)
      r++;
    ans += max(0ll, r - l + 1);
    l++;
  }
  return ans;
}

int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  partial_sum(a, a + n + 1, ps);
  for (int i = 1; i <= q; i++) {
    ll x; cin >> x;
    cout << query(x) << endl;
  }
}



Measured memory_bytes: 4636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

#define vin(v, N) for (long long i = 0; i < N; i++) cin >> v.at(i)
#define lin(n) long long n; cin >> n
#define chin(x) char x; cin >> x;
#define sin(s) string s; cin >> s;
#define vlin(v, N) vector<long long> v(N); for (long long i = 0; i < N; i++) cin >> v.at(i)

int main(){
    int N, K;
    cin >> N >> K;
    ll int A[N], B[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll int ans = INF;
    for (int bit = 0; bit < (1<<N); ++bit){ // 0 1 2 3 4 
        if(__builtin_popcount(bit) < K) continue;
        for(int i = 0; i < N; i++) B[i] = A[i];
        ll int cost = 0;
        vector<int> ind;
        ll int max_num = A[0];
        for(int i = 1; i < N; i++){ // bit 0 bit 1 => 0 bit 2 => 1
            if(bit & (1 << i)){
                B[i] = max(max_num + 1, B[i]);
                cost += B[i] - A[i];
                max_num = max(max_num, B[i]);
            }
            else max_num = max(max_num, A[i]);
        }

        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL); 
   int n;cin>>n;
   if(n>=400 && n<600){
      cout<<"8"<<endl;
   }if(n>=600 && n<800){
      cout<<"7"<<endl;
   }if(n>=800 && n<1000){
      cout<<"6"<<endl;
   }if(n>=1000 && n<1200){
      cout<<"5"<<endl;
   }if(n>=1200 && n<1400){
      cout<<"4"<<endl;
   }if(n>=1400 && n<1600){
      cout<<"3"<<endl;
   }if(n>=1600 && n<1800){
      cout<<"2"<<endl;
   }if(n>=1800 && n<2000){
      cout<<"1"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        long L = scanner.nextInt();
        long R = scanner.nextInt();
        scanner.close();

        R = Math.min(R, L + 4038);

        long ans = 2018;
        for(long i = L; i < R; i++) {
            for(long j = i + 1; j <= R; j++) {
                ans = Math.min(ans, i * j % 2019);
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    int n = 0;
    long int maxnum = -1000001, minnum = 1000001, sum = 0, tmp = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        if (maxnum < tmp) {
            maxnum = tmp;
        }
        if (minnum > tmp) {
            minnum = tmp;
        }
        sum += tmp;
    }

    cout << minnum << " " << maxnum << " " << sum << endl;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cmath>

int main()
{
    int a, b;

    std::cin >> a >> b;

    std::printf("%d\n", a / b);
    std::printf("%d\n", a % b);

    double aa = static_cast<double>(a);
    double bb = static_cast<double>(b);

    std::printf("%lf\n", aa / bb);
    return 0;


}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int h[n-1];
    for(int i=0;i<n;++i) cin >> h[i];
    int ans=1;
    for(int i=1;i<n;++i) {
         bool ok=true;
        for(int j=0;j<i;++j) {
            if(h[i]<h[j]) {
                ok=false;
                break;
            }
        }
        if(ok) ++ans;
    }
    cout << ans << endl;
}


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

typedef long long li;

template<class ValueType, ValueType offset, size_t AlphabetSize>
struct Trie {
    typedef Trie<ValueType, offset, AlphabetSize> Node;
    vector<Node*> children;
    bool have;

    Trie(): children(AlphabetSize, nullptr), have(false) {}
    ~Trie() {
        for (auto &&child : children) {
            if (child != nullptr) {
                delete child;
            }
        }
    }

    void insert_internal(const vector<ValueType>& seq, int index) {
        if (index == seq.size()) {
            have = true;
        } else {
            Node*& next = children[seq[index] - offset];
            if (next == nullptr) {
                next = new Trie();
            }
            next->insert_internal(seq, index + 1);
        }
    }

    void insert(const vector<ValueType>& seq) {
        insert_internal(seq, 0);
    }

    void insert(const string& s) {
        insert(vector<char>(s.begin(), s.end()));
    }

    bool contains_internal(const vector<ValueType>& seq, int index) {
        if (have) {
            return true;
        }
        for (int i = 0; i < AlphabetSize; ++i) {
            if (children[i] != nullptr && children[i]->contains_internal(seq, index + 1)) {
                return true;
            }
        }
        return false;
    }

    bool contains(const vector<ValueType>& seq) {
        return contains_internal(seq, 0);
    }
};

typedef Trie<char, '0', 2> BinaryTrie;

li traverse(BinaryTrie* node, li depth) {
    if (node == nullptr) {
        return 0;
    }
    int null_count = 0;
    for (auto &&child : node->children) {
        null_count += child == nullptr;
    }
    li nim = 0;
    if (null_count == 1) {
        nim ^= depth & -depth;
    }
    for (auto &&child : node->children) {
        nim ^= traverse(child, depth - 1);
    }
    return nim;
}

int main() {
    li n, l;
    cin >> n >> l;

    BinaryTrie* root = new BinaryTrie();
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        root->insert(s);
    }

    li nim = traverse(root, l);
    cout << (nim ? "Alice" : "Bob") << endl;
    return 0;
}

Measured memory_bytes: 12928
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)*}
    };
}

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)*}
    };
}

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(dead_code)]
fn in_digit(mut x: u32, a: u32, b: u32) -> bool {
    let mut sum = 0;
    while x > 0 {
        sum += x % 10;
        x /= 10;
    }
    a <= sum && sum <= b
}

fn main() {
    input! {
        n: u32,
        m: [u32; n]
    }
    let mut v: Vec<u32> = m;
    v.sort();
    v.dedup();
    println!(
        "{}",
        v.len()
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
main(){
    int sec;
    cin >> sec;
    int h,m,s;
    h = sec /3600;
    m = (sec - 3600*h) / 60;
    s = (sec - 3600*h - 60*m);
    
    cout << h << ":" << m << ":" << s <<  endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define mid (l+r+1)/2
#define f first
#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 1e18
#define EPS 1e-11
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;
int main(){
    Hossam_Yehia;
    cin >> n >> m;
    cout<<(n-1)*(m-1)<<endl;
    re 0;
}

Measured memory_bytes: 256
/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 8/23/2020
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
const double PI = acos(-1);
const int MOD = 1000000007;

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

	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x)*t;

	return 0;
}
/*

	Ceiling of ( X / Y ) is :-
	(x + y - 1) / y

*/

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

using namespace std;

typedef long long ll;

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

    ll n;
    ll count = 0;
    cin >> n;

    count = 0;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ll m = 0;
            m = i - 1;
            if (m > 0)
                if (n / m == n % m)
                    count += m;

            m = n / i - 1;
            if (m > 0)
                if (n / m == n % m)
                    count += m;
        }
    }
    cout << count << endl;

    return 0;
}


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

#define pii pair<int,int>

int main() {
  int n;
  int dx[]={0,1,0,-1};
  int dy[]={-1,0,1,0};
  
  while(cin >> n, n) {
    char cs, ct, cb;
    cin >> cs >> ct >> cb;
    int s=cs-'A', t=ct-'A', b=cb-'A';
    int sx = s%3, sy = s/3;
    int tx = t%3, ty = t/3;
    int bx = b%3, by = b/3;

    double dp[3][3][n+1];

    for (int i=0; i<3;i++)
      for(int j=0; j<3; j++)
        for(int k=0; k<=n; k++)
          dp[i][j][k] = 0;
    
    dp[sx][sy][0] = 1;
    double p = 1;
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    
    for (int i=1; i<=n; i++) {
      for (int x=0; x<3; x++) {
        for (int y=0; y<3; y++) {
          if (x==bx&&y==by) continue;
          for(int j=0; j<4; j++) {
            int xx = x+dx[j];
            int yy = y+dy[j];
            if (xx<0||3<=xx || yy<0||3<=yy || (xx==bx&&yy==by)) {
              xx = x;
              yy = y;
            }
            dp[x][y][i] += dp[xx][yy][i-1] * 0.25;
          }
        }
      }
    }

    printf("%.8f\n", dp[tx][ty][n]);
  }
}

Measured memory_bytes: 0
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

A.reverse()
ans = [A[0]]

for i in range(1, N):
    n = bisect.bisect_right(ans, A[i])
    if A[i] >= ans[-1]:
        ans.append(A[i])
    else:
        ans[n] = A[i]

print(len(ans))


Measured memory_bytes: 7840
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
int a, b, k;

bool ok() {
    for (int i = 0; i <= b; ++i) {
        for (int j = 0; j <= a; ++j) {
            if (a * i - 2 * i * j + b * j == k)
                return true;
        }
    }
    return false;
}

int main() {
    int i, j;
    cin >> a >> b >> k;
    cout << (ok() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n,m,c;
    cin >> n >> m >> c;
    ll b[m];
    ll a[n][m];
    ll ans = 0;
    F0R(i,m) cin >> b[i];
    F0R(i,n)  {
      ll sum = c;
      F0R(j,m){
        cin >> a[i][j];
        sum += a[i][j]*b[j];
      }
      if(sum > 0) ++ans;
    }

    cout << ans<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
int n;
bool e[5000000];
vector<int>s;
unsigned long long xor128() {
    static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123;
    unsigned long long rt = (rx ^ (rx << 11));
    rx = ry;
    ry = rz;
    rz = rw;
    return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}
void make(){
	for(int i=11;i<=55555;i++){
		int f=0;
		for(int j=2;j*j<=i;j++){
			if(i%j==0)f++;
		}
		if(!f&&(i%10==1))s.push_back(i);
	}
	n=s.size();
}
void era(){
	for(int i=2;i<5000000;i++){
		if(!e[i]){
			for(int j=i+i;j<5000000;j+=i){
				e[j]=1;
			}
		}
	}
}
main(){
	set<vector<int> >st;
	make();
	int n;
	cin>>n;
	r(i,n){
		if(i)cout<<' ';
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=5010,Mo=1000000007;
char s[N];
int f[N][N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m;
    scanf("%d%s",&n,s+1);
    m=strlen(s+1);
    f[0][0]=1;
    for(int i=1;i<=n;i++) {
	f[i][0]=f[i][1]=f[i-1][0];
	for(int j=1;j<=i;j++) {
	    f[i][j-1]=(f[i][j-1]+2LL*f[i-1][j])%Mo;
	    f[i][j+1]=(f[i][j+1]+f[i-1][j])%Mo;
	}
    }
    cout<<f[n][m];
    return 0;
}

Measured memory_bytes: 96512
/*zhen hao*/
#include <bits/stdc++.h>
using namespace std;

#define lson l, m, rt*2
#define rson m + 1, r, rt*2+1
#define xx first
#define yy second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
LL a[N], b[N];

int main() {
#ifdef JUDGE
  freopen("case.in", "r", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%lld%lld", a + i, b + i);
  LL res = 0, cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    LL t;
    a[i] += cur;
    if (a[i] % b[i] == 0) t = a[i] / b[i]; else t = a[i] / b[i] + 1;
    res += b[i] * t - a[i];
    cur += b[i] * t - a[i];
  }
  cout << res << endl;
  return 0;
}


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

int main(void){
  int d, t, s;
  cin >> d >> t >> s;
  if((double)d/s <= t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){

    int N;
    cin >> N;

    vector<int> X(N), A(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
        A[i] = X[i];
    }

    sort(X.begin(), X.end());
    int left = X[(N / 2) - 1];
    int right = X[N / 2];
    
    for(int i = 0; i < N; i++){
        if(A[i] < right) cout << right << endl;
        else cout << left << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,k,ans,cnt,a[N],dep[N],head[N],to[N*2],nxt[N*2];
void adde(int u,int v){
	to[++cnt]=v;
	nxt[cnt]=head[u];
	head[u]=cnt;
}
void dfs(int pre,int u){
	int v;
	for(int i=head[u];i;i=nxt[i]){
		v=to[i];
		if(v!=pre){
			dfs(u,v);
			dep[u]=max(dep[u],dep[v]+1);
		}
	}
	if(dep[u]==k-1&&a[u]!=1){
		ans++;
		dep[u]=-1;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(a[1]!=1){
		ans++;
		a[1]=1;
	}
	for(int i=2;i<=n;i++){
		adde(i,a[i]);
		adde(a[i],i);
	}
	dfs(0,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length(),ans = 0;
    rep(i,n/2){
        if (s[i] != s[n-i-1]) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n);
  V a(n);VECCIN(a);
  sort(ALL(a),greater<int>());
  int b=0;int c=0;
  bool flag=true;
  while(a.size()){
    (flag?b:c)+=a[0];
    a.erase(a.begin());
    flag = !flag;
  }
 
  COUT(b-c);

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NM[0];
            var M = NM[1];

            var shop = new Dictionary<long, long>();

            for (int i = 0; i < N; i++)
            {
                var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var A = AB[0];
                var B = AB[1];

                if (shop.ContainsKey(A))
                {
                    shop[A] += B;
                }
                else
                {
                    shop.Add(A, B);
                }
            }

            var sot = shop.OrderBy(pair => pair.Key);

            var res = M;
            var ans = 0L;

            foreach (var item in sot)
            {
                if (res == 0) break;

                ans += Min(res, item.Value) * item.Key;

                res = Max(res - item.Value, 0);
            }


            Console.WriteLine(ans);

            
        }

        


    }

}


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


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c,x,y,z;

		while(true){
			if(a==0 && b==0)
				break;
		
			c=b-a;
			
			for(x=0;c>=1000;x++){
				c=c-1000;
			}
			
			for(y=0;c>=500;y++){
				c=c-500;
			}
			
			for(z=0;c>=100;z++){
				c=c-100;
			}
			
			System.out.println(z+" "+y+" "+x);
			
			a = sc.nextInt();
			b = sc.nextInt();
		}

	}

}

Measured memory_bytes: 12000
from itertools import count, takewhile, dropwhile
 
def dfs(n, max9, max6, d={0:0}):
    if n in d: 
      return d[n]
  
    max9 = next(dropwhile(lambda x: x>n, (max9 / 9**i for i in count())))
    max6 = next(dropwhile(lambda x: x>n, (max6 / 6**i for i in count())))
    d[n] = min(dfs(n-max9, max9, max6), dfs(n-max6, max9, max6)) + 1
    return d[n]
 
n = int(input())
 
max9 = max(takewhile(lambda x: x<=n, (9**i for i in count())))
max6 = max(takewhile(lambda x: x<=n, (6**i for i in count())))
 
print(dfs(n, max9, max6))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		bool check = true;
		int A;
		cin >> A;
		for (int i = 2; i <= sqrt(A); i++) {
			if (A % i == 0) check = false;
		}
		ans += check;
	}
	cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  int a, b, c, d;
  d = n % 10;
  c = ((n-d)/10) % 10;
  b = ((n-d-10*c)/100) % 10;
  a = ((n-d-10*c-100*b)/1000) % 10;
  
  if (a == b && b == c) {
  	cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

/*
func readLine(r *bufio.Reader) []byte {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := r.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return buf
}
	r := bufio.NewReaderSize(os.Stdin, 4096)
*/

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	ans := "APPROVED"
	for i := 0; i < N; i++ {
		if a[i]%2 == 0 {
			if a[i]%3 != 0 && a[i]%5 != 0 {
				ans = "DENIED"
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 640
n = int(input())
a = [0]
for x in input().split():
	a.append(int(x))
x = [0] * (n + 1)

i = n
while i > 0:
	x[i] = a[i]
	j = 2 * i
	while j <= n:
		x[i] += x[j]
		x[i] %= 2
		j += i
	i -= 1

m = 0
for i in range(1, n + 1):
	if x[i] == 1:
		m += 1
print(m)
for i in range(1, n + 1):
	if x[i] == 1:
		print(i, end=" ")

Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())


int main(){
    int N;
    string s;
    bool ok = true;
    cin>>N;
    cin>>s;
    set<string> st;
    st.insert(s);
    char last = s.back();
    rep(i,N-1){
        cin>>s;
        if(last!=s.front()) ok = false;
        st.insert(s);
        last = s.back();
    }
    if(N!=st.size()) ok = false;
    
    puts(ok?"Yes":"No");

}

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

using namespace std;


int main(){
	int size, A[100], k;
	
	while( cin >> size ) {
		
	if( size == 0)
	break;
	
	k = 0;
	
	for(int i=0;i<size;i++)
	cin >> A[i];

	for(int j = size-1; j > 0; j--) 
		for(int i = 0; i < j; i++)
			if(A[i] > A[i + 1]) {
				
				swap(A[i], A[i + 1]);
				k++;
				
		}
			 
	cout << k << "\n";
	
}
	return 0;
	
}



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

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int r_,g_,b_,n;

    cin >> r_ >> g_ >> b_ >> n;


    int a = 0;
    int b = 0;
    int c = 1;

    int ans = 0;

    for(;g_*b<=n;b++){
        for(;r_*a<=n;a++){
            
            c=((n-(r_*a)-(g_*b))/b_);
            
            //cout <<a<<b<<c<<endl;
            
            if(((n-(r_*a)-(g_*b))%b_)==0&&r_*a + g_*b + b_*c==n&&c>=0){
                ans++;
            }
        }
        a=0;
    }

    cout << ans;

    //n = r_*a + g_*b + b_*c 
    //c = ((n-(r_*a)-(g_*b))/b_)


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<stack>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int mod = 998244353;

struct Edge
{
	int next,to;
}e[MAXN];
int head[MAXN],etot=0;
inline void add(int u,int v)
{
	e[++etot]=(Edge){ head[u],v};
	head[u]=etot;
}

struct Node
{
	int x,d;
}a[MAXN];
inline bool cmp(const Node &p,const Node &q){ return p.x<q.x;}

stack<int> sta;
int fa[MAXN];

int f[MAXN];
void dfs(int u)
{
	f[u]=1;
	for(int i=head[u]; i; i=e[i].next)
	{
		int v=e[i].to;
		dfs(v);
		f[u] = (ll)f[u] * (f[v]+1) %mod;
	}
}

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		scanf("%d%d",&a[i].x,&a[i].d);
	
	sort(a+1,a+n+1,cmp);
	for(int i=n; i>=1; --i)
	{
		while(!sta.empty() && a[sta.top()].x < a[i].x+a[i].d)
			fa[sta.top()] = i,
			sta.pop();
		sta.push(i);
	}
	
	for(int i=1; i<=n; ++i)
		add(fa[i],i);
	dfs(0);
	printf("%d",f[0]);
	return 0;
}

Measured memory_bytes: 15104
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
int main(void) {
	ll N, M; scanf("%lld %lld", &N, &M);
	vector<pii> inp(N);
	for (ll i = 0, a, b; i < N; i++) {
		scanf("%lld %lld", &a, &b);
		inp[i] = { a, b };
	}
	sort(inp.begin(), inp.end());
	ll ans = 0, cur = 0;
	while (M) {
		if (inp[cur].second <= M) {
			ans += inp[cur].second * inp[cur].first;
			M -= inp[cur].second;
		}
		else {
			ans += inp[cur].first * M;
			M = 0;
		}
		cur++;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 1792
N = int(input())
Alist = list(map(int, input().split()))
counter = 0

while True:
    Ajudge = []
    for i in range(N):
        Alista = Alist[i]
        Ajudge.append(Alista % 2)
    if Ajudge.count(0) != N:
        break
    else:
        Alist = list(map(lambda x:x / 2, Alist))
        counter += 1

print(counter)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.1415926535897932
using namespace std;
int a,b,h,m;
long double angle1,angle2;

int main()
{
    cin>>a>>b>>h>>m;
    angle1=6*m;
    angle2=h*30+m*0.5;
    angle1=abs(angle1-angle2);
    if(angle1>180)
    angle1=360-angle1;
    angle1*=(long double)(PI/180);
    cout.setf(ios::fixed);
    cout<<setprecision(12)<<(long double)sqrt(a*a+b*b-2*a*b*cos(angle1));
    
}

Measured memory_bytes: 4152
#include <cstdio>
#include <algorithm>
#define IL inline
#define N 1000007
#define REP(a,b,c) for(a=b;a<=c;a++)
using namespace std;
const int mod=1e9+7;
int n,f[N],ans;
IL int rd(){
	int res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
int main(){
	n=rd();int i,d=0,t,bs;
	if(n==1){puts("1");return 0;}
	f[0]=1;bs=1LL*(n-1)*(n-1)%mod;
	REP(i,0,n-2){
		t=f[i]=(f[i]+d)%mod;
		f[i+2]=(f[i+2]-t+mod)%mod;
		d=(t+d)%mod;
		ans=(ans+1LL*f[i]*(bs+i+1))%mod;
	}
	t=f[i]=(f[i]+d)%mod,d=(t+d)%mod;
	ans=(ans+1LL*f[i]*(n-1))%mod;i++;
	t=f[i]=(f[i]+d)%mod,ans=(ans+t)%mod;
	printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#if 0
void print_array(vector<int> n) {
    for (int i = 0; i < n.size(); i++)
        cout << n.at(i) << " ";
    cout << endl;
}
#endif
int main() {
    string s; cin >> s;
    int n = s.size()+1;
    vector<int> a(n);

    char before = '-';
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '<' && before == '-') {
            before = s[i];
            a[i] = 0;
            a[i+1] = 1;
        }
        else if (s[i] == '<') {
            a[i+1] = a[i]+1;
        }
        else if (s[i] == '>') {
            before = '-';
        }
    }
    before = '-';
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == '>' && before == '-') {
            before = s[i];
            a[i+1] = 0;
            a[i] = max(a[i], a[i+1]+1);
        }
        else if (s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
        else if (s[i] == '<') {
            before = '-';
        }
    }
    //print_array(a);
    Int sum = 0;
    for (auto e : a) {
        sum += (Int)e;
    }
    cout << sum << endl;
}


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


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

	ll n, k;	cin >> n >> k;

	vector <ll> v(n);

	for (auto &i: v)	cin >> i;

	ll hcf = v[0];

	rep (i, n) {
		hcf = __gcd(hcf, v[i]);
	}

	if (k % hcf == 0 && k <= *max_element(v.begin(), v.end()))
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int n;
    int s[100];
    int ans = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    for(int j = 1;j < n;j++){
        if(s[j] == s[j - 1]){
            s[j] = 0;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" ( fun n -> n )
let lst = List.init n ( fun _ -> Scanf.sscanf (read_line ()) "%d" ( fun a -> a ))

let rec f lst mmax max =
        match lst with
                  [] -> []
                | first :: rest -> 
                        let rlst = f rest mmax max in
                                if first = max then
                                        mmax :: rlst
                                else
                                        max :: rlst

let ans =
        let max = List.max lst in
        let mmax = List.max (List.remove lst max) in
                List.iter (fun elmnt ->
                        Printf.printf "%d\n" elmnt
                ) (f lst mmax max)


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int K, T; cin >> K >> T;
  vector<pair<int, int>> vs;
  rep(i, T) {
    int x; cin >> x;
    vs.push_back({x, i});
  }
  int last = -1;

  int N = vs.size();

  while(vs.size() > 1) {
    sort(all(vs));

//    for(auto e: vs) {     cout << e.first << ", ";   }cout << endl;

    for(int i=N-1; i>=0; i--) {
      if(last != vs[i].second) {
        if(vs[i].first > 0) {
          last = vs[i].second;
          vs[i].first --;
          if(vs[i].first == 0) {
            vs.erase(vs.begin() + i);
            N = vs.size();
          }
          break;
        }
      }
    }
  }

  cout << vs[0].first - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, x, pre = 0, ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++, pre = x)
        scanf("%d", &x), ans += max(0, x - pre);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
// 今日はお盆前の最終出社日です
// いい加減寝ろ

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,d,n,maxi=0,f=0,mini=INF,sum=0;
    ll h,w;
    ll m;
    cin>>n>>m;
    vector<pair<ll,ll>> p(m);
    rep(i,m){
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(all(p),comp);
    ll r=0;
    rep(i,m){
        if(p[i].second>=r) {
            sum++;
            r=p[i].first;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4756
#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>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    ll n,k;
    cin >> n >> k;
    if(n < k){
        cout << min(n, k - n) << endl;
        return 0;
    }
    n %= k;
    cout << min(n, k - n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1);
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

struct EmployeeSale {
	long employee_number;
	long long sales;
};

int main()
{
	int data_count = 0;
	while (std::cin >> data_count) {
		if (data_count == 0) {
			break;
		}
		std::vector<EmployeeSale> sales_per_employee;
		for (int i = 0; i < data_count; ++i) {
			long employee_number = 0;
			long unit_price = 0;
			long quantity = 0;
			if (std::cin >> employee_number >> unit_price >> quantity) {
				long long each_sales = static_cast<long long>(unit_price) * quantity;
				auto it = std::find_if(
					sales_per_employee.begin(),
					sales_per_employee.end(),
					[=](EmployeeSale const& sale){ return sale.employee_number == employee_number; });
				if (it != sales_per_employee.end()) {
					it->sales += each_sales;
				} else {
					EmployeeSale sales = { employee_number, each_sales };
					sales_per_employee.push_back(sales);
				}
			}
		}

		std::vector<EmployeeSale> sales_achieved;
		std::copy_if(
			sales_per_employee.begin(),
			sales_per_employee.end(),
			std::back_inserter(sales_achieved),
			[](EmployeeSale const& sale){ return sale.sales >= 1000000; });
		if (!sales_achieved.empty()) {
			std::for_each(
				sales_achieved.begin(),
				sales_achieved.end(),
				[](EmployeeSale const& sale){ std::cout << sale.employee_number << std::endl; });
		} else {
			std::cout << "NA\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <numeric>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, const std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, const std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  rep(i, N) {
    cin >> V[i];
  }
  rep(i, N) {
    cin >> C[i];
  }
  int ans = 0;
  rep(i,N) {
    if (V[i] - C[i] > 0) {
      ans += V[i] - C[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int L, R;
    cin >> L >> R;
    
    int a = (L-1) / 2019;
    int b = (R) / 2019;
    
    if (a != b) {
        cout << 0 << endl;
        return 0;
    }
    
    LL ans = INT_MAX;
    for (LL i = L; i < R; i++) {
        for (LL j = i + 1; j <= R; j++) {
            LL X = (i % 2019) * (j % 2019);
            X %= 2019;
            
            ans = min(ans, X);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H, W; cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  
  vector<vector<int>> ans(H, vector<int>(W,0));
  
  rep(i, H) rep(j, W) {
    if(S[i][j] == '#') {
      ans[i][j] = -100;
      if(i > 0) ans[i-1][j]++;
      if(i < H-1) ans[i+1][j]++;
      if(j > 0) ans[i][j-1]++;
      if(j < W-1) ans[i][j+1]++;
      if(i > 0 && j > 0) ans[i-1][j-1]++;
      if(i > 0 && j < W-1) ans[i-1][j+1]++;
      if(i < H-1 && j > 0) ans[i+1][j-1]++;
      if(i < H-1 && j < W-1) ans[i+1][j+1]++;
    }
  }
  
  rep(i, H) {
    rep(j, W) {
      if(ans[i][j] >= 0) cout << ans[i][j];
      else cout << "#";
    }
    cout << endl;
  }
  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector <ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <vector<ll>> vv;
typedef vector <string> vs;
typedef vector <char> vc;


ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/

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

    while (1) {
        if (cnt*m + (cnt + 1) * k == n) {
            cout << cnt << endl;
            return 0;
        } else if (cnt*m + (cnt + 1) * k > n) {
            break;
        } else {
            cnt++;
        }
    }
    while (1) {
        if (cnt*m + (cnt + 1) * k == n) {
            cout << cnt << endl;
            return 0;
        } else if (cnt*m + (cnt + 1) * k < n) {
            cout << cnt << endl;
            return 0;
        } else {
            cnt--;
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans = 0;
	for (int i = 0; i <= a; ++i)
	{
		for (int j = 0; j <= b; ++j)
		{
			for (int k = 0; k <= c; ++k)
			{
				if ( x == i*500 + j * 100 + k * 50)
				{
					ans++;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,plan,cheeper;
    while(scanf("%d%d%d",&n,&a,&b)!=EOF)
    {
        plan=n*a;
        if (plan<b)
        cheeper=plan;
        else 
        cheeper=b;
        printf("%d\n",cheeper);
    }
    return 0;
}

Measured memory_bytes: 128
A, B, M = [int(num) for num in input().split()]
a = [int(num) for num in input().split()]
b =  [int(num) for num in input().split()]
minimum = -1
for i in range(M):
    xi, yi, ci =  [int(num) for num in input().split()]
    ai = a[xi-1]
    bi = b[yi-1]
    sum = ai + bi - ci
    if minimum == -1 or sum < minimum:
        minimum = sum
a.sort()
b.sort()
sum = a[0]+b[0]
if minimum < sum:
    print(minimum)
else:
    print(sum)

Measured memory_bytes: 18500
o=input()
e=input()
if len(o)==len(e):
    for i in range(int(len(o))):
        print(o[i],end="")
        print(e[i],end="")
else:
    for i in range(int(len(e))):
        print(o[i],end="")
        print(e[i],end="")
    print(o[-1:])

Measured memory_bytes: 9084
program main
      implicit none
      integer :: h, n, i, j, k, l
      integer, allocatable :: a(:), b(:)
      integer(8), allocatable :: dp(:)

      read *, h, n
      allocate( a(n) )
      allocate( b(n) )
      do i = 1, n
        read *, a(i), b(i)
      end do

      allocate( dp(0:h) )
      dp(:) = 10**9
      dp(0) = 0
      do i = 1, h
        do j = 1, n
          k = i - a(j)
          if ( k < 0 ) k = 0
          dp(i) = min( dp(i), b(j) + dp(k)  )
        end do
      end do

      print *, dp(h)

end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  char op;
  cin>>A>>op>>B;
  if(op=='+') {
cout<<A+B<<endl;
  }
  else {
cout<<A-B<<endl;
  }
}

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

int main(){
    string s;
    cin >> s;
    string t;
    vector<int> num;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i]!='x') {
            t.push_back(s[i]);
            num.push_back(cnt);
            cnt = 0;
        }else cnt++;
    }
    num.push_back(cnt);

    rep(i,t.size()/2){
        if(t[i] != t[t.size()-i-1]){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = 0;
    rep(i,(t.size()+1)/2) ans += abs(num[i] - num[t.size()-i]);
    cout << ans << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll n;
    cin >> n;
    vector<ll> v(n+1);
    for (int i = 0; i <= n; i++)
      cin >> v[i];
    ll cur = v[n];
    dbg << var(cur) << var(v) << '\n';
    vector<ll> p(n+1);
    p[n] = v[n];
    for (ll k = n - 1; k >= 0; k--)
      p[k] = p[k + 1] + v[k];
    ll ans = 0;
    ll max_on_this_level = 1;
    for (ll i = 0; i <= n; i++) {
      ans += max_on_this_level;
      dbg << var(i) << var(max_on_this_level) << '\n';
      max_on_this_level -= v[i];
      if (max_on_this_level < 0) {
        cout << "-1\n";
        return;
      }
      max_on_this_level *= 2;
      max_on_this_level = min(max_on_this_level, i < n ? p[i + 1] : 0);
    }

    cout << ans << '\n';

  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


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

int main()
{
    int k;
    cin >> k;
    if (k % 2 == 0 ) {
        cout << (k / 2) * (k / 2) << endl;
    } else {
        cout << ((k - 1) / 2) * ((k + 1) / 2) << endl;
    }
    return 0;
}


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

int main(){
 int N, countR, countA;
  countR = 0;
  countA = 0;
  cin >> N;
 string str;
  cin >> str;
  vector<char> a(str.begin(), str.end());
  for(int i = 0; i < N; i++){
    if(a.at(i) == 'R' )
      countR++;
  }
  for(int i = 0; i < countR; i++){
  if(a.at(i) == 'W' )
    countA++;
  }
cout << countA << endl;
}
  

Measured memory_bytes: 3920