akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

const long long INF = 1LL<<60;
int N;
long long K;
vector<int> P;
vector<long long> C;

long long solve() {
    vector<vector<int>> next(60, vector<int>(N));
    vector<vector<long long>> val(60, vector<long long>(N)),
                              all(60, vector<long long>(N));
    for (int v = 0; v < N; ++v) {
        next[0][v] = P[v];
        val[0][v] = all[0][v] = C[v];
    }
    for (int d = 0; d + 1 < 60; ++d) {
        for (int v = 0; v < N; ++v) {
            next[d+1][v] = next[d][next[d][v]];
            val[d+1][v] = val[d][v] + val[d][next[d][v]];
            all[d+1][v] = max(all[d][v], val[d][v] + all[d][next[d][v]]);
        }
    }
    long long res = -INF;
    for (int v = 0; v < N; ++v) {
        long long sum = 0;
        long long offset = v;
        for (int d = 59; d >= 0; --d) {
            if (K & (1LL<<d)) {
                chmax(res, sum + all[d][offset]);
                sum += val[d][offset];
                offset = next[d][offset];
            }
        }
    }
    return res;
}

int main() {
    cin >> N >> K;
    P.resize(N); C.resize(N);
    for (int i = 0; i < N; ++i) cin >> P[i], --P[i];
    for (int i = 0; i < N; ++i) cin >> C[i];
    cout << solve() << endl;
}

Measured memory_bytes: 9244
#include <stdio.h>
#include <math.h>

int main (void)
{
    int k,a,b;
    int ans;

    scanf("%d", &k);
    scanf("%d %d", &a, &b);

    ans = k * (b / k);

    if (ans >= a && ans <= b) {
        puts("OK");
    } else {
        puts("NG");
    }

    return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000

int n;
int main(){
  int i,j,u,v,k,Adj[MAX][MAX];


  scanf("%d",&n);

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      Adj[i][j]=0;
    }
  }

  for(i=0 ; i<n ; i++){
    scanf("%d %d",&u,&k);
    for(j=0 ; j<k ; j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      if(j<n)printf("%d ",Adj[i][j]);
      if(j==n)printf("%d",Adj[i][j]);
    }
    printf("\n");
  }
  return 0;
}
   


  

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
int main(){
    int len;
    cin>>len;
    string s;
    cin>>s;
    int ans = 1;
    for(int i = 0;i < len - 1;i++){
        if(s[i] != s[i + 1])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1e6+3;
long long fact[1000015];

long long modpow(int a, int b){
	if(b == 0){
		return 1;
	}else if(b == 1){
		return a%MOD;
	}else if((b%2) == 0){
		long long temp = modpow(a, b/2);
		return temp*temp%MOD;
	}else{
		long long temp = modpow(a, b/2);
		return ((temp*temp%MOD) * a)%MOD;
	}
}

int main(){
	int Q;
	scanf("%d", &Q);
	
	fact[0] = 1;
	for(int i = 1; i <= MOD; i ++){
		fact[i] = (fact[i-1] * i) % MOD; 
	}
	
	for(int i = 0; i < Q; i ++){
		int x, d, n;
		scanf("%d%d%d", &x, &d, &n);
		
		if(d == 0){
			printf("%lld\n", modpow(x, n));
		}else if(n >= MOD){
			printf("0\n");
		}else{
			long long x_div_d = x*modpow(d, MOD-2)%MOD;
			if(x_div_d + (n-1) >= MOD){
				printf("0\n");
			}else{
				printf("%lld\n", modpow(d, n) * fact[x_div_d + (n-1)] % MOD * modpow(fact[x_div_d-1], MOD-2) % MOD);
			}
		}
	}
	
	return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 069_arc_b / Link: https://abc055.contest.atcoder.jp/tasks/arc069_b?lang=en  ----- */
/* ------問題------

すぬけくんは動物が好きなので動物園を作りました。
この動物園では 1,2,3,…,N の番号を割り振られた N 匹の動物が円環状に並べられています。 i(2≦i≦N−1) 番の動物は i−1 番の動物と i+1 番の動物と隣り合っています。また、1 番の動物は N 番の動物と 2 番の動物と隣り合っており、N 番の動物は N−1 番の動物と 1 番の動物と隣り合っています。
動物園には本当のことしか言わない正直者の羊と、嘘しか言わない嘘つきの狼の 2 種類の動物がいます。
すぬけくんには羊と狼の区別がつかないので、それぞれの動物に両隣の動物が同じ種類かどうかを訪ねたところ、i 番目の動物は si と答えました。si が o ならば両隣の動物が同じ種類であると、x ならば異なる種類であると i 番の動物が言ったことを示します。
より形式的には、羊は両隣の動物がどちらも羊あるいはどちらも狼のとき o と答え、そうでないとき x と答えます。 狼は両隣の動物がどちらも羊あるいはどちらも狼のとき x と答え、そうでないとき o と答えます。
これらの回答結果と矛盾しないような各動物の種別の割り当てが存在するか、すぬけくんは気になっています。存在するならば一例を示し、存在しないならば -1 を出力しなさい。

-----問題ここまで----- */
/* -----解説等-----

4つ状態を決めるとあとは決定されていき、
全部の候補が上がったら確認を入れれば良い。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	string s;
	cin >> s;
	VVI a(4, VI(N, -1));
	a[0][0] = (0);	a[0][1] = (0);
	a[1][0] = (0);	a[1][1] = (1);
	a[2][0] = (1);	a[2][1] = (0);
	a[3][0] = (1);	a[3][1] = (1);
	// 動物の種類を決定 0 - S, 1 - W

	FOR(k, 0, 4) {
		VI &p = a[k];
		FOR(i, 1, N-1) {
			if (s[i] == 'o') {
				if(p[i] == 0)p[i + 1] = p[i - 1];
				else p[i + 1] = !p[i - 1];
			}
			else { // 'x'
				if (p[i] == 0)p[i + 1] = !p[i - 1];
				else p[i + 1] = p[i - 1];
			}
		}

	}

	string str= "SW";

	FOR(k, 0, 4) {
		VI &p = a[k];
		bool ok = 1;
		if (s[0] == 'o') {
			if (p[0] == 0) {
				if (p[N - 1] != p[1])ok = 0;
			}
			else {
				if (p[N - 1] == p[1]) ok = 0;
			}
		}
		else {
			if (p[0] == 0) {
				if (p[N - 1] == p[1])ok = 0;
			}
			else {
				if (p[N - 1] != p[1]) ok = 0;
			}
		}

		if (s[N-1] == 'o') {
			if (p[N-1] == 0) {
				if (p[N - 2] != p[0])ok = 0;
			}
			else {
				if (p[N - 2] == p[0]) ok = 0;
			}
		}
		else {
			if (p[N-1] == 0) {
				if (p[N - 2] == p[0])ok = 0;
			}
			else {
				if (p[N - 2] != p[0]) ok = 0;
			}
		}
		if (ok) {
			FOR(i, 0, N) {
				cout << str[p[i]];
			}cout << endl;
			return 0;
		}
	}

	cout << -1 << "\n";

	return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

class BinaryIndexTree
{
  public:
    BinaryIndexTree(int n)
        : mN(n)
    {
        node.resize(n + 1);
        REP(i, n + 1)
        {
            node[i] = 0;
        }
    }
    ~BinaryIndexTree()
    {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index)
    {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value)
    {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

  private:
    vector<ll> node;
    ll mN;
};

ll A[200005];

int main()
{
    ll N;
    cin >> N;
    vector<ll> x;
    REP(i, N)
    {
        cin >> A[i];
        x.push_back(A[i]);
    }
    sort(x.begin(), x.end());
    REP(i, N)
    {
        A[i] = lower_bound(x.begin(), x.end(), A[i]) - x.begin();
        A[i]++;
    }

    BinaryIndexTree bit(N);
    ll ans = 0;
    REP(i, N)
    {
        ans += i - bit.sum(A[i]);
        bit.add(A[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7804
import sys
input = sys.stdin.readline
mod = 2019
def main():
    s = input().rstrip()
    n = len(s)
    d = {}
    d[0] = 1
    ten = 1
    T = 0
    for x in reversed(s):
        T += ten*int(x)
        ten *= 10
        T %= mod
        ten %= mod
        if T in d:
            d[T] += 1
        else:
            d[T] = 1

    print(sum(i*(i-1)//2 for i in d.values()))
if __name__ == "__main__":
    main()

Measured memory_bytes: 9260
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    ll L, R; cin >> L >> R;
    const int a = 2019;

    ll div = (R - L + 1) / a;
    ll right = L + a - L % a;
    ll left = L - L % a;

    if (right <= R || left == L) {
        cout << 0 << endl;
        return 0;
    }
    else {
        ll min_ = 1000000000000;
        for (int i = 0; i < R - L + 1; i++) {
            for (int j = i + 1; j < R - L + 1; j++) {
                min_ = min(min_, ll(((L+i) % a) * ((L + j) % a) % a));
            }
        }
        cout << min_ << endl;
        return 0;
    }
}

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

int main()
{
  ll X;
  cin >> X;
  vector<ll> sum(50001, 0);
  rep(i, 50001) {
    if (i == 0) {
      sum.at(i) = 0;
    } else {
      sum.at(i) = sum.at(i-1) + i;
    }
  }
  ll ans;
  rep(i, 50001) {
    if (X <= sum.at(i)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    unsigned short num;                /* 情報量の格納用変数 */
    unsigned short house[4][3][10];    /* 部屋情報の格納用変数 */
    unsigned short bil;                /* 棟番号の格納用変数 */
    unsigned short flor;               /* 階数の格納用変数 */
    unsigned short room;               /* 部屋番号の格納用変数 */
    signed long  riside;              /* 入居者数の格納用変数 */
    unsigned short i, j, k;            /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                house[i][j][k] = 0;
            }
        }
    }

    /* 情報量の入力 */
    scanf("%d", &num);
    /* 入居者変更情報の入力 */
    for(i = 0;i < num;i++){
        /* 入居者変更情報の入力 */
        scanf("%d %d %d %d", &bil, &flor, &room, &riside);
        /* 入居者変更情報の加算 */
        house[bil - 1][flor - 1][room - 1] += riside;
    }

    /* 部屋情報の出力 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                /* 各部屋の入居者の出力 */
                printf(" %d", house[i][j][k]);
            }
            /* 階の区切り */
            printf("\n");
        }
        /* 第四棟でない場合棟を区切る */
        if(i != 3){
           /* 棟の区切り */
           printf("####################\n");
        }
    }
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

ll dp[100000+10];

void solve(){
    int N; cin>>N;
    vi h(N); rep(i,N) cin>>h[i];

    dp[0]=0; dp[1]=abs(h[0]-h[1]);
    rrep(i,2,N){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1]<<endl;

    return;
}

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

    solve();
    return 0;
}

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

long long n,a,m,k,q,b,c=1;
string ss,s1,s2;
int main(){
    cin>>a>>ss;
    if (a<3200){
        cout<<"red"<<endl;
    }
    else{
        cout<<ss<<endl;
    }
}


Measured memory_bytes: 256
class UnionFind_PathCompression
  attr_reader :rank, :parent, :value
  attr_writer :rank, :parent

  def initialize(x)
    @value = x
    @rank = 0
    @parent = self
  end

  def ==(obj)
    @value == obj.value
  end

  def find
    return self if self.parent == self
    root = self.parent.find
    self.parent = root
    root
  end

  def union(y)
    xr = find; yr = y.find
    return self if xr == yr
    if xr.rank >= yr.rank
      yr.parent = xr
      xr.rank += 1
      self
    else
      y.union(self)
    end
  end
end

N,M = gets.split.map(&:to_i)
langs = (0..M).map{ nil }
UF = (1..N).map{ |n| UnionFind_PathCompression.new(n) }

(1..N).each { |k|
  ls = gets.split.map(&:to_i)[1..-1]
  u1 = UF[k-1]
  ls.each{ |l|
    langs[l] = langs[l] ? langs[l].union(u1).find : u1
  }
}

puts UF.map{ |u| u.find.value }.uniq.size == 1 ? "YES" : "NO"


Measured memory_bytes: 10876
#include <stdio.h>

int friend[512][512];

int main(void)
{
    int n, m;
    int invite[512];
    int a, b;
    int cnt;
    int i, j;

    while (1){
        scanf("%d", &n);
        scanf("%d", &m);
        if (n == 0 && m == 0){
            break;
        }

        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                friend[i][j] = 0;
            }
        }
        for (i = 2; i <= n; i++){
            invite[i] = 0;
        }

        for (i = 0; i < m; i++){
            scanf("%d %d", &a, &b);
            friend[a][b] = friend[b][a] = 1;
        }

        for (i = 2; i <= n; i++){
            if (friend[1][i] != 1){
                continue;
            }
            invite[i] = 1;
            for (j = 2; j <= n; j++){
                if (friend[i][j] == 1){
                    invite[j] = 1;
                }
            }
        }

        cnt = 0;
        for (i = 2; i <= n; i++){
            if (invite[i] == 1){
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return (0);
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    Ans(!(abs(a-c)>d && (abs(a-b)>d || abs(b-c)>d)));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] sorted = new int[n];
		for(int i = 0; i < n; i++) {
			sorted[i] = in.nextInt();
		}
		for(int i = 0; i < n; i++) {
			int temp = sorted[i];
			int j = i-1;
			while(j >= 0 && temp < sorted[j]) {
				sorted[j+1] = sorted[j];
				j--;
			}
			sorted[j+1] = temp;
			for(int a = 0; a < sorted.length; a++) {
				if(a == sorted.length - 1) System.out.print(sorted[a]);
				else System.out.print(sorted[a] + " ");
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 31360
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return (a * b) / gcd(a,b); }
int main() {
    int n; cin >> n;
    vector<int> as(n), bs(n); repeat (i,n) cin >> as[i] >> bs[i];
    ll a = as[0];
    ll b = bs[0];
    repeat_from (i,1,n) {
        ll d = max(a / as[i], b / bs[i]);
        while (not (a <= as[i] * d and b <= bs[i] * d)) d += 1;
        a = as[i] * d;
        b = bs[i] * d;
    }
    cout << a + b << endl;
    return 0;
}


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

main() {
    int n; string s;
    cin >> n;
    cin >> s;
    int i = 0, j = n - 1, ans = 0;
    while (i < j) {
        if (s[i] == 'W' && s[j] == 'R') {
            i++, j--;
            ans++;
        } else if (s[i] == 'R') {
            i++;
        } else if (s[j] == 'W') {
            j--;
        } else {
            assert(0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3744
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int[] h=new int[n];
		for(int i=0;i<n;i++) {
			h[i]=scanner.nextInt();
		}
		long low=0;
		long high=1000000000;
		while(high-low>1) {
			long mid=(low+high)/2;
			long tmp=0;
			for(int i=0;i<n;i++) {
				if(h[i] > b*mid){
					tmp += Math.ceil( (double)(h[i] - b*mid) / (double)(a-b));
				}
			}
			if(tmp<=mid) {
				high=mid;
			}else {
				low=mid;
			}
		}
		System.out.println(high);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
vector<vector<int>> G;

ll ans;
ll N, K;
void dfs(int s, int b, ll num) {
    ans *= num;
    ans %= MOD;
    ll k = K - 1;
    if (b >= 0) k--;
    rep(i, G[s].size()) {
        if (G[s][i] == b) continue;
        dfs(G[s][i], s, k);
        k--;
    }
}
int main()
{
    cin >> N >> K;
    G = vector<vector<int>>(N);

    int s;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        s = a;
    }

    ans = 1;
    dfs(s, -1, K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9216
//Name: Maximum Sum Sequence II
//Level: 2
//Category: データ構造,累積和
//Note:

/**
 * 行列要素の累積和を求めておけば、任意の矩形に対して和をO(1)で計算できる。
 *
 * オーダーは O(N^4)。
 */
#include <iostream>
#include <vector>

using namespace std;

template<typename T>
struct Accumulate2D {
    vector<vector<T>> v;

    Accumulate2D(int R, int C) {
        v.resize(R, vector<T>(C));
    }

    void set(int r, int c, const T &val) {
        v[r][c] = val;
    }

    T& setter(int r, int c) {
        return v[r][c];
    }

    void freeze() {
        const int R = v.size();
        const int C = v[0].size();
        for(int r = 0; r < R; ++r) {
            for(int c = 0; c < C; ++c) {
                if(r > 0) v[r][c] += v[r-1][c];
                if(c > 0) v[r][c] += v[r][c-1];
                if(r > 0 && c > 0) v[r][c] -= v[r-1][c-1];
            }
        }
    }

    // Returns cumulative sum of ([r1, r2), [c1, c2))
    T operator ()(int r1, int c1, int r2, int c2) const {
        T res = v[r2-1][c2-1];
        if(r1 > 0) res -= v[r1-1][c2-1];
        if(c1 > 0) res -= v[r2-1][c1-1];
        if(r1 > 0 && c1 > 0) res += v[r1-1][c1-1];
        return res;
    }
};

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    Accumulate2D<long long> acc(N, N);
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> acc.setter(i, j);
        }
    }
    acc.freeze();

    long long ans = -100000;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = i+1; k <= N; ++k) {
                for(int l = j+1; l <= N; ++l) {
                    ans = max(ans, acc(i, j, k, l));
                }
            }
        }
    }
    cout << ans << endl;
    return true;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

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


void solve(){
    string s,t;cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i])ans+=1;
    }
    cout<<ans<<'\n';
}


int main(){
    //ll tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define ll 			long long
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    long long
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
ll n,i,j,k,l,sum=0,flag=0,t,h[200005],ans=0,dp[200005];
bool Q;
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : k < o.k;
    }
};
struct LineContainer : multiset<Line> {
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b){
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        Q = 1; auto l = *lower_bound({0,0,x}); Q = 0;
        return l.k * x + l.m;
    }
}Hull;
void solve(){
    cin>>n>>k;
    int ans;    
    for(int i=0;i<n;i++){
    	int h;
    	cin>>h;
    	if(i==0){
    		Hull.add(2LL*h, -h*h);
    		continue;
    	}
    	ans = -Hull.query(h) + k + h*h;
    	Hull.add(2LL*h , -ans-h*h);
    }
    cout<<ans<<endl;
    
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.ABC333
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split(null).Select(x => int.Parse(x)).ToArray();

            if (AB.Where(x => x % 2 == 0).Any())
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 11348
n = int(input())
ans = ''
alp = lambda x: chr(x + ord('a') - 1) if x != 0 else 'z'
x = 0
while n != 0:
    rem = (n % (26 ** (x + 1))) // (26 ** x)
    ans = alp(rem) + ans
    n -= rem * 26 ** x if rem != 0 else 26 ** (x + 1)
    x += 1
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  string s; cin>>s;
  deque<char> que(s.size());
  rep(i,0,s.size()) que[i] = s[i];
  int q;  cin>>q;
  int rev=1;
  rep(i,0,q){
    int type; cin>>type;
    if(type==1){
      rev = 1-rev;
    }else{
      int f;  cin>>f;
      char c; cin>>c;
      if((f==1&&rev==1)||(f==2&&rev==0)){
        que.push_front(c);
      }else{
        que.push_back(c);
      }
    }
  }
  if(!rev){
    reverse(all(que));
  }
  while(que.size()){
    cout<<que.front();
    que.pop_front();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if( ((0+r) <= x ) && ( x <= (W-r) ) && ((0+r) <= y ) && ( y <= (H-r) ) )
      printf("Yes\n");
    else
      printf("No\n");
}



Measured memory_bytes: 1992
nums = gets.split.map(&:to_i) 
array = []
n = nums[0]
b = nums[1]
r = nums[2]
length = b + r

sho = n / length
amari = n % length
if amari == 0
  puts (b * sho)
elsif amari >= b
  puts (b * sho) + b
else
  puts (b * sho) + amari
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>
#include <map>

int main() {
	long long int a, b;
	std::cin >> a >> b;
	long long int nSum = 0;
	if (a*2 <= b) {
		nSum = nSum + a;
		b = b - a * 2;
		nSum = nSum + b / 4;
		std::cout << nSum << std::endl;
	}
	else {
		nSum += b / 2;
		std::cout << nSum << std::endl;
	}
	return 0;
}
	


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

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

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

    unordered_map<int, int> umap;
    for (int i = 0; i < n; ++i) umap[a[i]]++;

    int picked = 0;
    for (auto item : umap) {
        int key = item.first;
        int val = item.second;
        if (key > val) picked += val;
        else picked += val - key;
    }

    cout << picked << endl;

    return 0;
}

Measured memory_bytes: 4644
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rrrep(i, n - 2, 0) {
    if (a[i] <= a[i + 1]) continue;
    a[i]--;
    if (a[i] > a[i + 1]) {
      Cout("No");
      return 0;
    }
  }
  Cout("Yes");
  return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    P = []
    distance_max = 0
    mode = 0

    for i in range(N):
        X, Y = map(int, input().split())
        distance = abs(X) + abs(Y)

        if i == 0:
            mode = distance % 2
        elif distance % 2 != mode:
            print(-1)
            return

        if mode == 0:
            X = X - 1
            distance = abs(X) + abs(Y)

        if distance > distance_max:
            distance_max = distance

        P.append((X, Y))

    d = []
    di = 1
    for i in range(40):
        if di > distance_max:
            break
        d.append(di)
        di = di * 2

    d.sort(reverse=True)

    if mode == 0:
        d.append(1)

    print(len(d))
    print(" ".join(map(str, d)))

    for p in P:
        path = ""
        x, y = p[0], p[1]
        previous = 0
        for di in d:
            if previous == di and di == 1:
                path = path + "R"
                break
            if x + y < 0:
                if x - y < 0:
                    path = path + "L"
                    x = x + di
                else:
                    path = path + "D"
                    y = y + di
            else:
                if x - y < 0:
                    path = path + "U"
                    y = y - di
                else:
                    path = path + "R"
                    x = x - di
            previous = di
        print(path)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();
    println!("{}", c / a * b);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll LL_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N;
    cin >> N;
    map<ll,int> cnt;
    for(int i = 0; i < N; i++){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    ll sum = 0;
    for(auto p : cnt) if(p.se % 2) sum++;
    cout << sum << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
int N, M;
Graph G;

void solve() {
  vector<int> dist(N, -1);
  vector<int> prev(N, -1);
  queue<int> que;
  que.push(0);
  dist[0] = 0;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (auto nv : G[v]) {
      if (dist[nv] == -1) {
        dist[nv] = dist[v] + 1;
        prev[nv] = v;
        que.push(nv);
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; ++i) cout << prev[i] + 1 << endl;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  solve();
}


Measured memory_bytes: 10644
N, M = map(int, input().split())
shopList = [];

for i in range(N):
    Aap, Bap = map(int, input().split())
    listap = [Aap, Bap]
    shopList.append(listap);

cost = 0;
shopList.sort();

while(M>0):
    lowestPrice = shopList[0][0];
    if (shopList[0][1] >= M):
        cost += M*lowestPrice;
        M = 0;
    else:
        cost += shopList[0][1]*lowestPrice;
        M -= shopList[0][1];
        del shopList[0];

print(cost);


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

using namespace std;

int main(void){
    string s;
    cin>>s;
    int ans=s.size();
    for(int pat=0;pat<=1;pat++){
        int count=0;
        for(int i=0;i<s.size();i++){
            if(i%2==0&&s[i]!=pat+'0') count++;
            else if(i%2!=0&&s[i]==pat+'0') count++;
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll powll(ll x, ll n) {
	if (n == 0)
		return 1;
	ll xx = powll(x, n / 2);
	if (n % 2 == 0)
		return xx * xx;
	else
		return xx * xx * x;
}

int main() {
	ll N;
	cin >> N;
	bool ans = false;
	for (int i = 0;i < N;i++) {
		ll a;
		cin >> a;
		if (a % 2 == 1)
			ans = true;
	}
	if (ans)
		cout << "first" << endl;
	else
		cout << "second" << endl;
	return 0;
}


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

typedef long long int ll;

using namespace std;

void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

void find(vector <int> &a,ll n,int size,int i,int cur,int d,bool *flag)
{
    double y=(d/cur);
        ll temp=cur-1+ceil(y);
        if(temp<=n)
            *flag=1;
    while(i<size)
    {
        
        //cur*=a[i];
        find(a,n,size,i+1,cur*a[i],d,flag);
        //cur/=a[i];
        i++;
    }
}

int main()
{
    
   
    int n;
    cin>>n;
    vector <int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    int test=1;
    int min=v[0];
    for(int i=1;i<n;i++)
    {
        if(v[i]<min)
            min=v[i];
        if(v[i]<=min)
            test++;
    }
    cout<<test<<endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
    "fmt"
    "sort"
)

var a []int

func main() {
  var N int
  var In int
  var Alice int = 0
  var Bob int   = 0

  
  fmt.Scan(&N)

  a = make([]int,N)

  for i := 0; i < N; i++ {
    fmt.Scan(&In)
    a[i] = In
  }

//  fmt.Println(a)
  sort.Sort(sort.Reverse(sort.IntSlice(a)))
//  fmt.Println(a)

  for i := 0; i < N; i++ {
    if i%2 == 0 {
      Alice += a[i]
    } else {
      Bob += a[i]
    }
  }

  //fmt.Printf("Alice:%d\n",Alice)
  //fmt.Printf("Bob  :%d\",Bob)
  //fmt.Printf("Alice - Bob  :%d\n",Alice-Bob)
  fmt.Println(Alice-Bob)

}


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

int main() {
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int count=1;
    if (x1 == 0) cout << count << endl;
    count++;
    if (x2 == 0) cout << count << endl;
    count++;
    if (x3 == 0) cout << count << endl;
    count++;
    if (x4 == 0) cout << count << endl;
    count++;
    if (x5 == 0) cout << count << endl;
    return 0; 
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;
	

int main() {
	fastio;
	ll k,a,b;
	cin>>k>>a>>b;
	f(i,a,b+1){
		if(i%k==0){
			cout<<"OK\n";
			return 0;
		}
	}
	cout<<"NG\n";
	return 0;
	}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
 
int main(){
	fast;
	int n, r;
	cin>>n>>r;
	if(n<10) cout<<(r+100*(10-n))<<"\n";
	else cout<<r<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N, M;
string s;

int main() {

	while (cin >> N, N)
	{
		cin >> M >> s;

		int ren = 0;
		bool frag = false;
		int ans = 0;
		vector<int> a;
		int k = 0;
		a.push_back(0);

		for (int i = 0; i < M; i++) {

			if (frag) {
				if (s[i] == 'O' && s[i + 1] == 'I') {
					ren++;

					a[k] = max(a[k], ren - N + 1);

					i++;
				}
				else {

					k++;
					a.push_back(0);
					ren = 0;
					frag = false;
				}
			}

			if (s[i] == 'I') {
				frag = true;
			}

			
		}

		for (int i = 0; i < k; i++) {
			ans += a[i];
		}


		cout << ans << endl;

	}


	return 0;
}



Measured memory_bytes: 3856
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    V = read_ints()
    print(solve(N, V))


def solve(N, V):
    V.sort()
    pos = {}
    for i, a in enumerate(V):
        pos[a] = i
    best = 2
    done = [[False] * N for _ in range(N)]
    for i in range(N):
        a = V[i]
        for j in range(i + 1, N):
            if done[i][j]:
                continue
            b = V[j]
            d = b - a
            c = 2
            done[i][j] = True
            k = j
            v = b + d
            while v in pos:
                done[k][pos[v]] = True
                k = pos[v]
                c += 1
                v += d
            best = max(best, c)
    return best


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 202060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"a", "b", "c"},
	{"d", "e", "f"},
	{"g", "h", "i"},
	{"j", "k", "l"},
	{"m", "n", "o"},
	{"p", "q", "r", "s"},
	{"t", "u", "v"},
	{"w", "x", "y", "z"}
};
int loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

int main(){
	int N;
	cin >> N;
	vector<string> ansvec;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		ansvec.push_back(ans);
	}

	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    H=list(mi())

    for h in H:
        if h != 0:break
    else:
        print(0)
        exit()
    
    ans = 0
    while True:
        i = 0
        while i < N and H[i] == 0:
            i += 1
            
        while i < N:
            # print(i)
            for j in range(i,N):
                if H[j] == 0: break
                H[j] -= 1
            while j < N and H[j] == 0:
                j += 1
            # print(H)
            if j == N-1 and H[j] != 0:
                i = N
            else:
                i = j
            ans += 1
        
        count = 0
        for j in range(N):
            count += H[j] == 0
        
        if count == N:
            break
        


    print(ans)
    



        





if __name__ == "__main__":
    main()

Measured memory_bytes: 69848
#include<iostream>
#include<stdio.h>
int main(){
    double a,b,c,d,e,f;
    double x,y;
    while(std::cin>>a>>b>>c>>d>>e>>f){
    y=(a*f-d*c)/(a*e-b*d);
    x=(c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a),greater<int>());
	
	vi v(2,0);
	int j=0;
	for(int i=1;i<n;++i){
		if(a[i-1]==a[i]){
			v[j]=a[i];
			j++;
			i++;
		}
		if(j==2) break;
	}
	
	//cout<<v.size()<<endl;//!!!
	//printf("%d %d\n",v[0],v[1]);//!!!
	
	cout<<(llong)v[0]*v[1]<<endl;
	return 0;
}

Measured memory_bytes: 640