akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int N;
vector <int> E[100010];
pii P[100010];
int head[100010], down[100010], son[100010], par[100010], dep[100010];
int SN[100010], cc;

void pre(int x, int fa) {
	down[x] = 1;
	for(int e : E[x]) if(e != fa) {
		par[e] = x;
		dep[e] = dep[x] + 1;
		pre(e, x);
		down[x] += down[e];
	}
}

void dfs(int x, int fa, int h) {
	SN[x] = ++cc;
	head[x] = h;
	son[x] = -1;
	for(int e : E[x]) if(e != fa) {
		if(son[x] == -1 || down[son[x]] < down[e]) son[x] = e;
	}
	if(son[x] != -1) dfs(son[x], x, h);
	for(int e : E[x]) if(e != fa && e != son[x]) {
		dfs(e, x, e);
	}
}

struct node{
	node(){}
	node(int v):v(v){}
	int v;
	set <int> sc;
};

node T[1<<18];

void update(int s, int d, int c, int ww = -1, int rt = 1, int l = 2, int r = N) {
	//if(l == 2 && r == N) printf("%d, %d, %d, %d\n", s, d, c, ww);
	if(s <= l && r <= d) {
		if(c == 1) T[rt].sc.insert(ww), T[rt].v++;
		else T[rt].sc.erase(ww), T[rt].v--;
		return;
	}
	int m = (l + r) >> 1;
	if(s <= m) {
		update(s, d, c, ww, rt<<1, l, m);
	}
	if(m < d) {
		update(s, d, c, ww, rt<<1|1, m+1, r);
	}
	T[rt].v = sz(T[rt].sc) + min(T[rt<<1].v, T[rt<<1|1].v);
}

void update_node(int x, int y, int c, int ww = -1) {
	if(x == y) return;
	if(head[x] == head[y]) {
		if(dep[x] > dep[y]) swap(x, y);
		update(SN[x] + 1, SN[y], c, ww);
		return;
	}
	if(dep[head[x]] < dep[head[y]]) swap(x, y);
	update(SN[head[x]], SN[x], c, ww);
	update_node(par[head[x]], y, c, ww);
}

int Find(int rt, int l, int r) {
	if(sz(T[rt].sc) == 1) {
		return *T[rt].sc.begin();
	}
	int m = (l + r) >> 1, res = -1;
	if(T[rt<<1].v < T[rt<<1|1].v) res = Find(rt<<1, l, m);
	else res = Find(rt<<1|1, m+1, r);
	return res;
}

void Fix(int rt, int l, int r) {
	if(sz(T[rt].sc)) return;
	if(l == r) {
		T[rt].v = 1e9;
		return;
	}
	int m = (l + r) >> 1;
	if(T[rt<<1].v < T[rt<<1|1].v) Fix(rt<<1, l, m);
	else Fix(rt<<1|1, m+1, r);
	T[rt].v = sz(T[rt].sc) + min(T[rt<<1].v, T[rt<<1|1].v);
}

void solve(){
	scanf("%d", &N);
	rep(i, N-1){
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	pre(1, -1);
	dfs(1, -1, 1);
	rep(i, N-1) {
		int x, y; scanf("%d%d", &x, &y);
		P[i] = pii(x, y);
		update_node(x, y, 1, i);
	}
	rep(i, N-1) {
		if(T[1].v != 1) {
			puts("NO");
			return;
		}
		int f = Find(1, 2, N);
		int x = P[f].Fi, y = P[f].Se;
		update_node(x, y, -1, f);
		Fix(1, 2, N);
	}
	puts("YES");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d\n", tc);
		solve();
	}
	return 0;
};

Measured memory_bytes: 104064
#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++)
#define _GLIBCXX_DEBUG
//static const int MAX = 100000;

int main(){
  int K, X;
  cin >> K >> X;

  for(int i = X-K+1; i <= X+K-1; i++)
  cout << i << " ";
}

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

int main(){

string a,b;
cin>>a>>b;


int check = 1 ;

for(int i = 0 ; i < a.length() ; i++){
    if(a[i] == b[i]) check = 1;
    else{
        check = 0 ;
        break ;
    }
}

if(check == 1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, x, t;
    cin >> n >> x >> t;

    int tp = n/x + (n % x > 0);
    cout << tp * t << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'
 
const ll MOD = 1000000007;

bool cmp (tuple<int, int, int> a, tuple<int, int, int> b) {
   return get<2>(a) < get<2>(b);
}

int sum(vector<int> &bit, int idx) {
   int temp = 0;
   while (idx > 0) {
      temp += bit[idx];
      idx -= idx & -idx;
   }
   return temp;
}

void add(vector<int> &bit, int idx, int val) {
   while (idx < bit.size()) {
      bit[idx] += val;
      idx += idx & -idx;
   }
}

int main() {
   int n, q; scanf("%d%d", &n, &q);
   vector<int> c(n + 1);
   for (int i = 1; i <= n; i++)
      scanf("%d", &c[i]);
   vector<tuple<int, int, int>> queries(q);
   for (int i = 0; i < q; i++) {
      int l, r; scanf("%d%d", &l, &r);
      queries[i] = {i, l, r};
   }
   sort(all(queries), cmp);
   vector<int> ans(q);
   vector<int> bit(n + 1);
   vector<int> lv(n + 1, -1);
   int cnt = 0;
   for (int i = 1; i <= n; i++) {
      if (lv[c[i]] != -1)
         add(bit, lv[c[i]], -1);
      lv[c[i]] = i;
      add(bit, i, 1);
      while (get<2>(queries[cnt]) == i) {
         ans[get<0>(queries[cnt])] =
            sum(bit, get<2>(queries[cnt])) -
            sum(bit, get<1>(queries[cnt]) - 1);
         cnt++;
      }
   }
   for (int i : ans)
      printf("%d\n", i);
   return 0;
}

Measured memory_bytes: 17380
n,m,r=map(int,input().split())
a,b=sorted([n-1,r-m*n])
if a<1:print(0)
else:
 d=1
 for i in range(a):d*=i+1
 u=1
 for i in range(b,a+b):u*=i+1
 print(u//d)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o,e;cin>>o>>e;
    int n = o.size() + e.size();
    vector<char> ans(n);
    for(int i=0; i<o.size(); i++){
        ans[i*2]=o[i];
    }
    for(int i=0;i<e.size(); i++){
        ans[i*2+1]=e[i];
    }
    for(char c : ans){
        cout<<c;
    }
    cout<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
  int N; cin >> N;
  vector<int> b(N);
  rep(i,N){
     cin >> b[i];
     if(b[i] > i+1){
        cout << -1 << endl;
        return 0;
     }
  }
  vector<int> ans;
  rep(i,N){
     for(int j = b.size()-1; j >= 0; j--){
        if(b[j] == j+1){
           ans.push_back(b[j]);
           b.erase(b.begin() + j);
           break;
        }
     }
  }
  for(int i = N-1; i >= 0; i--){
    cout << ans[i] << endl;
  }

}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int X;
  cin >> X;
  int ans = 1;
  rep(i, 2, X) {
    int a = i * i;
    while (a <= X) {
      chmax(ans, a);
      a *= i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

class UnionFind{
public:

    vector<int> parent;
    vector<int> rank;

    UnionFind();

    UnionFind(int n){

        rep(i,n + 1){
            parent.pback(i);
            rank.pback(1);
        }
    }

    int find(int n){

        int tmp_parent = parent[n];
        vector<int> update;

        while(tmp_parent != n){
            update.pback(n);
            n = tmp_parent;
            tmp_parent = parent[n];
        }

        rep(i, update.size()){
            parent[update[i]] = tmp_parent;
        }

        return tmp_parent;

    }

    void merge(int a, int b){
        int parent_a = find(a);
        int parent_b = find(b);

        if(rank[parent_a] < rank[parent_b]){
            parent[parent_a] = parent_b;
        }else{

            parent[parent_b] = parent_a;

            if(rank[parent_a] == rank[parent_b]){
                rank[parent_a]++;
            }
        }
    }

};

int main(){

    int n,k,l;
    cin >> n >> k >> l;

    UnionFind load(n);
    UnionFind rail(n);

    rep(i,k){
        int a,b;
        cin >> a >> b;

        load.merge(a, b);
    }

    rep(i,l){
        int a,b;
        cin >> a >> b;

        rail.merge(a, b);
    }

    map<pair<int,int>,int> m;

    rep(i,n){
        int idx = i + 1;

        m[mpair(load.find(idx), rail.find(idx))]++;

        CERR << load.find(idx) << " " << rail.find(idx) << endl;
    }

    rep(i,n){
        int idx = i + 1;

        cout << m[mpair(load.find(idx), rail.find(idx))] << " ";
        
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 15124
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  COMinit();
  int n,k;
  cin >> n >> k;
  ll M = 0,m = 0;
  vector<ll>v(n);
  rep(i,n)cin >> v[i];
  sort(all(v));
  REP(i,k - 1,n)M += (v[i] * (COM(i,k - 1) % INF)) % INF;
  reverse(all(v));
  REP(i,k - 1,n)m += (v[i] * (COM(i,k - 1) % INF)) % INF;
  if(M - m < 0)cout <<  (M - m + INF) % INF << endl;
  else cout << (M - m) % INF << endl;
  return 0;
}


Measured memory_bytes: 12928
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int x;
	cin >> x;
	string s;
	switch (x % 7) {
	case 0:s = "thu"; break;
	case 1:s = "fri"; break;
	case 2:s = "sat"; break;
	case 3:s = "sun"; break;
	case 4:s = "mon"; break;
	case 5:s = "tue"; break;
	case 6:s = "wed"; break;
	}
	cout << s << endl;
}



Measured memory_bytes: 3184
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
inline int readint() {
	int res = 0;
	char c = getchar();
	if ('0' <= c && c <= '9') {
		while ('0' <= c && c <= '9') {
			res = res * 10 + c - '0';
			c = getchar();
		}
	}
	else {
		c = getchar();
		while ('0' <= c && c <= '9') {
			res = res * 10 + c - '0';
			c = getchar();
		}
		res *= -1;
	}
	return res;
}
signed main() {
	long long inf = 2e17;
	int n = readint();
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; a = readint(); b = readint();
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf;
}

Measured memory_bytes: 11632
#include <iostream>
 
using namespace std;
 
int main() {
  int N, M, C;
  cin >> N;
  cin >> M;
  cin >> C;
  
  int A[N][M], B[M];
  int count = 0;
  int judge;
  
  for(int i = 0; i < M; i++) {
    cin >> B[i];
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  
  for(int i = 0; i < N; i++) {
    judge = 0;
    for(int j = 0; j < M; j++) {
      judge += A[i][j] * B[j];
    }
    judge += C;
    if(judge > 0) count += 1;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int H = Integer.parseInt(tokens[2]);
		int M = Integer.parseInt(tokens[3]);

		int totalMin = 60 * H + M;
		double hourRatio = (double) totalMin / (double) (12 * 60);
		double hourX = (double) A * Math.sin(2. * Math.PI * hourRatio);
		double hourY = (double) A * Math.cos(2. * Math.PI * hourRatio);

		double minuteRatio = (double) M / (double) 60;
		double minuteX = (double) B * Math.sin(2. * Math.PI * minuteRatio);
		double minuteY = (double) B * Math.cos(2. * Math.PI * minuteRatio);
		double distance = Math.sqrt(Math.pow(hourX - minuteX, 2.0) + Math.pow(hourY - minuteY, 2.0));
		System.out.println(distance);
	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 33300
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod

int num(int n, int d){
    if(n < 0) return 0;
    int a = n % bit(d), b = n / bit(d + 1);
    if((n >> d) & 1) return b * bit(d) + a + 1;
    else return b * bit(d);
}

signed main(){

    int A, B; cin >> A >> B;
    int ans = 0;
    REP(i, 60){
        if((num(B, i) - num(A - 1, i)) % 2) ans += bit(i);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	ll n, m, x;
	cin >> n >> m >> x;
	vector<ll> a(n + 1, 0);

	ll ans = 0;
	for (ll i = 0; i < m; i++)
	{
		ll temp;
		cin >> temp;
		a[temp]++;
	}
	
	for (ll i = x - 1; i >= 0; i--)
	{
		ans += a[i];
	}
	ll temp = 0;

	for (ll i = x + 1; i <= n; i++)
	{
		temp += a[i];
	}

	cout << min(ans, temp) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 各種変数の読み込み
            var n = int.Parse(Console.ReadLine());

            var s = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            int maxcount = 0;
            int tempcount = 0;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
            }
            for (int i = 1; i < n; i++)
            {
                if (a[i] > a[i - 1])
                {
                    tempcount = 0;
                }
                else
                {
                    tempcount++;
                }
                maxcount = Math.Max(maxcount, tempcount);
            }

            Console.WriteLine(maxcount);
            

#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 27100
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct segtree{
  in MX;
  const in inf=10000000000LL;
  vector<pair<in,in> > mxp;
  VI lft,rgt;
  pair<in,in> comb(pair<in,in> a, pair<in,in> b){
    if(a.first<b.first)
      return a;
    return b;
  }
  pair<in,in> mnin(in l, in r, in id=1){
    if(r<lft[id] || l>rgt[id])return MP(inf,0);
    if(l<=lft[id] && r>=rgt[id])return mxp[id];
    return comb(mnin(l,r,2*id),mnin(l,r,2*id+1));
  }
  void ini(in n,VI hv){
    MX=1;
    while(MX<n)
      MX*=2;
    mxp.resize(2*MX);
    forv(i,mxp)
      mxp[i]=MP(inf,i-MX);
    forn(i,n)
      mxp[i+MX].first=hv[i];
    lft=rgt=VI(2*MX);
    forn(i,MX)
      lft[i+MX]=rgt[i+MX]=i;
    for(in i=MX-1;i>=1;--i){
      lft[i]=lft[2*i];
      rgt[i]=rgt[2*i+1];
      mxp[i]=comb(mxp[2*i],mxp[2*i+1]);
    }
  }
};
vector<pair<in,in> > res;
segtree par[2];
map<pair<in,in>,vector<pair<in,in> > > unlck;
priority_queue<pair<in,in> > q;
void genpairs(in l, in r, pair<in,in> pp){
  assert((r-l+1)%2==0);
  if(l>=r)
    return;
  pair<in,in> c=par[l%2].mnin(l,r);
  pair<in,in> d=par[(l+1)%2].mnin(c.second+1,r);
  unlck[pp].PB(MP(c.first,d.first));
  genpairs(l,c.second-1,MP(c.first,d.first));
  genpairs(c.second+1,d.second-1,MP(c.first,d.first));
  genpairs(d.second+1,r,MP(c.first,d.first));
}
void mkn(pair<in,in> u){
  vector<pair<in,in> >& v=unlck[u];
  forv(i,v)
    q.push(MP(-v[i].first,v[i].second));
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  VI p[2];
  in a;
  forn(z,n){
    cin>>a;
    p[z%2].PB(a);
    p[(z+1)%2].PB(1e9);
  }
  par[0].ini(n,p[0]);
  par[1].ini(n,p[1]);
  genpairs(0,n-1,MP(0,0));
  mkn(MP(0,0));
  forn(zz,n/2){
    pair<in,in> u=q.top();
    u.first=-u.first;
    q.pop();
    res.PB(u);
    mkn(u);
  }
  forv(i,res)
    cout<<res[i].first<<" "<<res[i].second<<" ";
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 71240
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
 
int main(void){
    int cards[4][13]={},n;
    char mark;
    int number;
    cin>> n;
    for (int i= 0;i<n;i++){
        cin>> mark>> number;
        switch(mark){
                case 'S':
                    cards[0][number-1] = 1;
                    break;
                 
                case 'H':
                    cards[1][number-1] = 1;
                	break;
                case 'C':
                	cards[2][number-1] = 1;
                	break;
                case 'D':
                	cards[3][number-1] = 1;
              	  break;
        }
    }
    for (int k = 0; k < 4;k++){
        for (int j = 0; j < 13;j++){
            if (cards[k][j] == 0) {
                switch (k) {
                    case 0:
                        cout<< "S ";
                        break;
                    case 1:
                        cout<< "H ";
                        break;
                    case 2:
                        cout<< "C ";
                        break;
                    case 3:
                        cout<< "D ";
                        break;
                         
                }
                cout<< j +1<< endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  int r;
  cin >> r;
  if(r<1200){cout<<"ABC"<<endl;exit(0);}
  else if(r<2800){cout<<"ARC"<<endl;exit(0);}
  else{cout<<"AGC"<<endl;exit(0);}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x <= 1) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl; 
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
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;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll oo = numeric_limits<ll>::max();
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll a,b,c,d; cin >> a >> b >> c >> d;
	ll res = -oo;
	for(auto &x : {a,b}){
		for(auto &y : {c,d}){
			res = max(res,x*y);
		}
	}
	cout << res << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3644
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
string str[1009];
ll ans[1009][1009];
ll N = 1e9+7;
ll dp(ll i,ll j)
{
    if(ans[i][j]!=-1)
    {
        return ans[i][j];
    }
    if(i==0 && j==0)
    {
        return ans[i][j] = 1;
    }
    ll res = 0;
    if(i-1>=0 && str[i-1][j]!='#')
    {
        res = dp(i-1,j);
    }
    if(j-1>=0 && str[i][j-1]!='#')
    {
        res = (res+dp(i,j-1))%N;
    }
    return ans[i][j]  =res;


}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>str[i];
    }
    memset(ans,-1,sizeof ans);
    cout<<dp(n-1,m-1)<<endl;
    return 0;
}



Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int R = scan.nextInt();

		if(N >= 10) {
			System.out.println(R);
		}else {
			System.out.println(R + 100 * (10-N));
		}
	}
}


Measured memory_bytes: 21844
k = int(input())
l = [[0,1]] + [[i,i+1,i+2] for i in range(8)]+[[8,9]]
ln = [i+1 for i in range(9)]
aln = [i+1 for i in range(9)]
for i in range(10):
    tln = []
    for j in ln:
        for m in l[int(str(j)[-1])]:
            tln.append(j*10+m)
    aln += tln
    ln =tln
    if len(aln) >= k:
      break
print(aln[k-1])

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll n, y;
  cin >> n >> y;
  REP(a, n+1) {
    REP(b, n+1-a) {
      ll c = n - a - b;
      if(a*10000+b*5000+c*1000==y) {
	printf("%lld %lld %lld\n", a, b, c);
	return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector <int> cnt(26, 0);
  for (int i = 0; i < n; i++) {
    cnt[s[i] - 'a']++;
  }
  long long ans = 1 + (long long) n * (n - 1) / 2;
  for (int x : cnt) {
    ans -= (long long) x * (x - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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 int long long

vector<vector<int>> f;

int sum(int la, int ra, int lb, int rb) {
    return f[lb][rb] - f[lb][ra - 1] - f[la - 1][rb] + f[la - 1][ra - 1];
}

void solve() {
	int n, k; cin >> n >> k;
    vector<P> p(n);
    rep(i, n) {
        int x, y; cin >> x >> y;
        x %= (2 * k); y %= (2 * k);
        ++x; ++y;
        char c; cin >> c;
        if(c == 'B') {
            p[i] = make_pair(x, y);
        } else {
            x = (x + k) % (2 * k);
            p[i] = make_pair(x, y);
        }
    }
    f.assign(7 * k, vector<int>(7 * k, 0));
    rep(i, n) {
        int x = p[i].fr, y = p[i].sc;
        f[x][y] ++;
        f[x + 2 * k][y] ++;
        f[x][y + 2 * k] ++;
        f[x + 2 * k][y + 2 * k] ++;
    }
    for(int i = 0; i < 7 * k; ++i) {
        for(int j = 1; j < 7 * k; ++j) {
            f[i][j] += f[i][j - 1];
        }
    }
    for(int j = 0; j < 7 * k; ++j) {
        for(int i = 1; i < 7 * k; ++i) {
            f[i][j] += f[i - 1][j];
        }
    }
    int ans = 0;
    rep1(i, 2 * k) {
        rep1(j, 2 * k) {
            chmax(ans, sum(i, j, i + k - 1, j + k - 1) + sum(i + k, j + k, i + 2 * k - 1, j + 2 * k - 1));
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 192768
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

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

		int N = sc.nextInt();
		Integer num[] = new Integer[105];
		for (int i = 0; i < N; i++) {
			num[i] =sc.nextInt();
		}
		int alice = 0;
		int bob = 0;

		List<Integer> li = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			li.add(num[i]);
		}

		Collections.sort(li);

		for (int i = N - 1; i >= 0; i--) {
			alice += li.get(i);
			if (--i < 0) {
				break;
			}
			bob += li.get(i);
		}

		System.out.println(alice - bob);
	}
}

Measured memory_bytes: 22484
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <complex>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
 
#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back
#define ll long long
 
const long long MAXN = 1e7 + 1;
const long long MOD = 1e9 + 7;
using namespace std;
 
typedef pair<int, int> pii;
 
 
long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const long long  MAX_N = 1e6 + 1;
const long long P = 127;
unsigned long long p1[MAX_N + 1];
unsigned long long h1[MAX_N + 1];

char a[MAXN];

bool f(int i, int j, int len){
    ll H1 = (h1[i + len] - h1[i - 1]);
    ll H2 = (h1[j + len] - h1[j - 1]);
    H1 *= p1[j - i];
    return H1 == H2;
}

int main(){
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    string a;
    cin >> a;
    a = '$' + a;
    p1[0] = 1;
    for(int i = 1; i <= n; i++){
        p1[i] = (p1[i - 1] * P);
        h1[i] = (h1[i - 1] + (a[i] - 'a' + 1) * p1[i]) ;
    }    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int l = 0, r = min(n - j, j - i - 1);
            while(r - l > 1) {
                int m = (l + r) / 2;
                if (f(i, j, m)) {
                    l = m;
                } else {
                    r = m;
                }
            }
            if (f(i, j, r)) {
                ans = max(r + 1, ans);
            } else if (f(i, j, l)) 
                ans = max(ans, l + 1);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4352
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::cmp;

#[allow(unused_mut)]
fn main() {

    // input
    input!(
        n: usize,
        a: isize,
        b: isize,
        c: isize,
        l: [isize; n],
    );

    let mut ans: isize = std::isize::MAX;

    // 4-based search
    for num in 0..4_usize.pow(n as u32) {
        let mut cur = num;
        let mut cnt: Vec<usize> = vec![0; 4];
        let mut bmb: Vec<isize> = vec![0; 4];
        for digit in 0..n {
            cnt[cur%4] += 1;
            bmb[cur%4] += l[digit];
            cur /= 4;
        }

        if cnt[1] * cnt[2] * cnt[3] == 0 {
            continue;
        }

        ans = cmp::min(ans, (a-bmb[1]).abs() + (b-bmb[2]).abs() + (c-bmb[3]).abs() + (10*(n-cnt[0]-3) as isize));
    }

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


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String s;
        Scanner reader = new Scanner(System.in);
        s = reader.nextLine();

        String[] str;
        str = s.split(" ");
        BigInteger a = new BigInteger(str[0]);
        BigInteger b = new BigInteger(str[1]);

        BigInteger c = a.mod(b);

        System.out.println(c);
    }
}



Measured memory_bytes: 26956
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=2e5;
ll N;
vector<ll> G[MAX_N];
ll dst[MAX_N];
void caldst(ll s,ll d,ll p){
	dst[s]=d;
	for(auto e:G[s]){
		if(e!=p){
			caldst(e,d+1,s);
		}
	}
}
ll dia(){
	caldst(0,0,-1);
	ll v=0;
	REP(i,N){
		if(dst[i]>dst[v]){
			v=i;
		}
	}
	caldst(v,0,-1);
	ll ans=0;
	REP(i,N){
		ans=max(ans,dst[i]);
	}
	return ans;
}
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N-1){
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cout<<(dia()%3==1?"Second":"First")<<endl;
}

Measured memory_bytes: 162816
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final String s = scanner.nextLine();
    final String t = scanner.nextLine();

    if (s.length() + 1 == t.length() && t.startsWith(s)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;
ll dp[100005];

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,m) {
        int s;
        cin >> s;
        a[s-1] = -1;
    }
    rep(i,n){
        if(a[i] == -1){
            dp[i] = 0;
            continue;
        }
        if(i == 0){
            dp[i] = 1;
            continue;
        }
        if(i == 1){
            dp[i] = dp[0]+1;
            continue;
        }
        dp[i] = (dp[i-1] + dp[i-2])%MOD;
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans += s[i] != t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3452
raw_input()
A=map(int,raw_input().split(" "))
dictA={}
for a in A:
    if a not in dictA:
        dictA[a]=1
    else:
        dictA[a]+=1

n_o=0
n_e=0

for n in dictA.values():
    if n%2==0:
        n_e+=1
    else:
        n_o+=1

if n_e%2==0:
    print n_o+n_e
else:
    print (n_e-1)+n_o
    

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	//$ string even = "RUD", odd = "LUD";
	string s;
	cin >> s;
	int n = s.length();
	bool ok = true;
	
	for(int i = 0; i < n; i++) {
		if(i % 2 && s[i] == 'R') {
			ok = false;
		}
		
		if(i % 2 == 0 && s[i] == 'L') {
			ok = false;
		}
	}
	
	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*
Aizu 1369
2017年8月11日23:00:33 
*/ 

#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn=2e5+10;
struct node{
	int x,y;
}arm[maxn];
int a[maxn][2];
int n,m;
bool cmp(node a,node b){
	return a.x==b.x?a.y>b.y:a.x<b.x;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&arm[i].x,&arm[i].y);
	}
	sort(arm+1,arm+1+m,cmp);
	memset(a,0,sizeof(a));
	for(int i=1;i<=m;i++){
		int y=arm[i].y;
		a[y][1]=a[y+1][1]+1;
		a[y+1][0]=a[y][0]+1;
	}
	for(int i=1;i<=n;i++){
		if(i!=n) printf("%d ",a[i][0]+a[i][1]+1);
		else printf("%d\n",a[i][0]+a[i][1]+1);
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] array = new long[N];
		long[] sort_array = new long[N];
		long cnt = 0;
		for (int i=0; i<N; i++) {
			long A = sc.nextLong();
			array[i] = A;
			sort_array[i] = A;
		}
		Arrays.sort(sort_array);
		for (int i=0; i<N; i++) {
			int j = indexOf(sort_array, array[i], 0, N);
			if ((i+j)%2==1) cnt++;
		}
		System.out.println((long)((cnt+1)/2));
		sc.close();
	}
	
	private static int indexOf(long[] array, long v, int h, int t) {
		long l = array[(h+t)/2];
		if (v==l) return (h+t)/2;
		else if (v<l) return indexOf(array, v, h, (h+t)/2);
		else return indexOf(array, v, (h+t)/2, t);
	}

}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	string a[3] = {"Sunny", "Cloudy", "Rainy"};
	string s;
	cin >> s;
	for(int i = 0; i < 3; ++i) {
		if(a[i] == s) {
			cout << a[(i + 1) % 3];
			break;
		}
	}

	return 0;
}


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

int main(){
  int N;cin>>N;
  vector<long> A(3*N);
  for(int i=0;i<3*N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  long ans=0;
  for(int i=1;i<=N;i++) ans+=A.at(3*N-2*i);
  cout<<ans<<endl;
}
    


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    int cnt = 0;
    for(int i=0; i<N; i++)
        if(A[i] < 0)
            cnt++;
    vector<long long> B(N);
    for(int i=0; i<N; i++)
        B[i] = abs(A[i]);

    sort(B.begin(), B.end());
    long long ans = 0;
    for(int i=0; i<N; i++)
        ans += B[i];
    if(cnt%2==1)
        ans -= 2*B[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
string op;
int bfs()
{
    int st = 0;
    queue<int> q;
    q.push(st);
    while(!q.empty())
    {
        int now = q.front();
        if(now == op.size())
        {
            return 1;
        }
        if(op.substr(now, 5) == "dream") q.push(now + 5);
        if(op.substr(now, 7) == "dreamer") q.push(now + 7);
        if(op.substr(now, 5) == "erase") q.push(now + 5);
        if(op.substr(now, 6) == "eraser") q.push(now + 6);
        q.pop();
    }
    return 0;
    
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> op;
    if(bfs())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" <<endl;
    }
    
}

Measured memory_bytes: 512