akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  if(A >= K) {
    cout << A-K << ' ' << B << endl;
  } else {
    cout << 0 << ' ' << max(0LL, B-(K-A)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    if (n == m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int i;
    vector<ll> number(s.size());
    for(i = 0;i < s.size();++i){
        number.at(i) = s.at(i)-'0';
    }
    int bit;
    ll ans = 0,tmp;
    for(bit = 0;bit < (1 << s.size()-1);++bit){
        tmp = s.at(0)-'0';
        for(i = 0;i < s.size()-1;++i){
            if(bit & (1 << i)){
                ans += tmp;
                tmp = number.at(i+1);
            }else{
                tmp *= 10;
                tmp += number.at(i+1);
            }
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
r,c=map(int,input().split())
sheet=[list(map(int,input().split())) for i in range(r)]
for i in range(r):
    sheet[i].append(sum(sheet[i]))
Column_sum=[0]*(c+1)
for j in range(c+1):
    for i in range(r):
        Column_sum[j]+=sheet[i][j]

for i in range(r):
    print(*sheet[i])
print(*Column_sum)


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

#define REP(i,n) for(int i=0; i< int(n); (i)++)
int all(int *,int );
int odd(int *);
int main()
{
    int n, sum_all=1, sum_odd=1, a[101]={0};
    cin >> n;
    REP(i,n)
    {
        cin >> a[i];
        sum_odd *= odd(&a[i]);
        sum_all *= 3;
    }
    cout << sum_all - sum_odd << endl;
    return 0;
}
int odd(int *a)
{
    if(*a%2==0)
    {
        return 2;
    }
    else
    {
        return 1;
    }
}

Measured memory_bytes: 256
N=int(input())
count=0
LastA=0
FirstB=0
LA=0
for i in range(0,N):
    f=input()
    count=count+f.count('AB')
    if f[0]=='B' and f[-1]=='A':
        LA=LA+1
    elif f[0]=='B':
        FirstB=FirstB+1
    elif f[-1]=='A':
        LastA=LastA+1
count=count+LA
if LastA==0 and FirstB==0 and LA!=0:
    count=count-1
elif FirstB>=LastA:
    count=count+LastA
else:
    count=count+FirstB
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
//#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    while(true){
        ll n;
        cin>>n;
        if(n==0)break;
        ll l[n+1];
        l[0]=0;
        for(int i=1;i<n+1;i++){
            int x;
            cin>>x;
            l[i]=l[i-1]+x;
        }
        ll ans=-1000000;
        for(int i=0;i<n+1;i++){
            for(int j=i+1;j<n+1;j++){
                ans=max(ans,l[j]-l[i]);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	int n, k;	cin >> n >> k;
	vint a(n);
	rep(i, n)	cin >> a[i];
	map<int, int> mp;
	rep(i, n)	mp[a[i]]++;
	vint cnt;
	for (auto it : mp)	cnt.push_back(it.scn);
	sort(all(cnt));
	int m = cnt.size();
	int ret = 0;
	rep(i, m - k)	ret += cnt[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 11516
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( +^ ) (n - k + 1)
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)
let repcomb n k = comb (n + k - 1) k

let () = Scanf.scanf "%d %d" @@ fun n k ->
  for i = 1 to k do
    Printf.printf "%d\n" @@
      if n - k - i + 1 < 0
      then 0
      else repcomb i (k - i) *^ repcomb (i + 1) (n - k - i + 1)
  done


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
using namespace std;
class SegTree {
public:
    explicit SegTree(int n) {
        while (_n < n) _n *= 2;
        _dat.resize(2 * _n - 1, 0);
    }
    explicit SegTree(const string& s) : SegTree(s.size()) {
        for (size_t i = 0; i < s.size(); i++) update(i, s[i]);
    }
    ~SegTree() = default;
    void update(int k, char c) {
        k += _n - 1;
        _dat[k] = 1 << (c - 'a');
        while (k > 0) {
            k = (k - 1) / 2;
            _dat[k] = _dat[2 * k + 1] | _dat[2 * k + 2];
        }
    }
    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = _n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return _dat[k];
        return query(a, b, 2 * k + 1, l, (l + r) / 2) | query(a, b, 2 * k + 2, (l + r) / 2, r);
    }
private:
    int _n = 1;
    vector<int> _dat;
};

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    SegTree st(S);
    for (int i = 0; i < Q; i++) {
        int type, a, b;
        char c;
        cin >> type >> a;
        if (type == 1) {
            cin >> c;
            st.update(a - 1, c);
        }
        else if (type == 2) {
            cin >> b;
            cout << bitset<26>(st.query(a - 1, b)).count() << endl;
        }
    }
}

Measured memory_bytes: 4996
def main():
    n = int(input())
    h = [int(i) for i in input().split()]
    ans = 1
    for i in range(1, n):
        for j in range(i):
            if h[i] < h[j]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
s = input()
while True:
    temp = s
    s5 = temp[-5:]
    s6 = temp[-6:]
    s7 = temp[-7:]

    if (s5 == 'erase') | (s5 == 'dream'): 
        s = temp[:-5]
    elif s6 == 'eraser':
        s = temp[:-6]
    elif s7 == 'dreamer':
        s = temp[:-7]
    else:
        print('NO')
        exit()

    if s == '':
        print('YES')
        exit()



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;

int t[3];
int k;

int main() {
	loop(i, 0, 2)
		scanf("%d",&t[i]);
	scanf("%d",&k);
	sort(t,t+3);
	int p = pow(2,k);
	t[2] *= p;
	int ans = 0;
	loop(i, 0, 2)
		ans += t[i];
	printf("%d",ans);
}

Measured memory_bytes: 256
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

# 最強の魔法の特定
a_max = max(a for a, b in ab)
# 動的計画法用の配列の定義及び初期化
dp = [0]*(h + a_max)

for i in range(h + a_max):
	if i > 0:
		dp[i] = min(dp[i - a] + b for a, b in ab)

print(min(dp[h:]))

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 1000000000; i++)
    {
        if(abs(a-i) == abs(b-i))
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H')
    {
        cout<<b<<endl;
    }
    else
    {
        if(b=='H')
        {
            cout<<"D"<<endl;
        }
        else
        {
            cout<<"H"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int g[100001];
int di[100001];

int dfs(int i){
    if(g[i]!=i){
        int r = dfs(g[i]);
        di[i]+=di[g[i]];
        //printf("di[%d]=%d\n",i,di[i]);
        return g[i]=r;
    }else{
        return i;
    }
}
int main(){
    int i,j;
    int N,M;
    scanf("%d %d",&N,&M);
    for(i=1;i<=N;i++)g[i]=i;
    for(i=0;i<M;i++){
        int l,r,d;
        scanf("%d %d %d",&l,&r,&d);
        int g1=dfs(l);
        int g2=dfs(r);
        if(g1!=g2){
            g[g2]=l;
            di[g2]=d-di[r];
        }  else{
            //printf("di[%d](%d)-di[%d](%d)!=%d\n",r,di[r],l,di[l],d);
            if(di[r]-di[l]!=d){
                printf("No\n");
                return 0;
            }
        }
    }
    //printf("%d %d %d\n",di[1],di[2],di[3]);
    printf("Yes\n");
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::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; }
using namespace std;

ll x;

int main() {
    cin >> x;

    ll n = 1;
    while (true) {
        ll xmin = n * (n - 1) / 2;
        ll xmax = n * (n + 1) / 2;
        if (xmin < x && x <= xmax) {
            cout << n << endl;
            return 0;
        } else {
            n++;
        }
    }
}


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

int main() {
	int N;
	cin >> N;
	int s = 1;
	int sum = 0;
	while (N > 100*s-1) {
		sum = sum + 9*s;
		s*= 100;
	}
	if (N > s*10-1) {
		cout << sum+9*s;
		return 0;
	}
	else {
		cout << sum+N-s+1;
	}
	}

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

//<num>
//終了後イテレータは数字の次をさしていることに注意
int num(itr &begin){
	int res = 0;

	while(isdigit(*begin)){
		res *= 10;
		res += *begin - '0';
		begin++;
	}

	return res;
}

//再帰を書くということはグラフを表現することと同義

//BNFで記述すると再帰になるので再帰で実装する
//<expr> ::= [<left> <expr> <right>]*
int expr(itr &begin){
	begin++; //skip "["
	int ans;
	if(isdigit(*begin)){ //<expr> == <expr> つまり <expr> := <num>
		int res = num(begin);
		ans = res / 2 + 1;
	}
	else{ //otherwise
		vector<int> v; //階層ごとにベクターを生成
		while(*begin == '[') v.push_back(expr(begin)); //<right>は下の階層へ潜る演算子, <left>は上の階層に浮上する演算子、潜ったタイミングで要素を追加、浮上したタイミングで計算
		sort(v.begin(), v.end());
		int res = 0;
		for(int i = 0; i < (int)v.size() / 2 + 1; i++) res += v[i];
		ans = res;
	}


	begin++; //skip "]"
	return ans;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		itr begin = s.begin();
		cout << expr(begin) << endl;
	}

	return 0;
}



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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

int main(){
    fcin;
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> w(n, 0), er(n, 0);
    w[0] = (s[0] == 'W');
    for(int i = 1; i < n; i++) w[i] = w[i-1] + (s[i] == 'W');

    er[n-1] = s[n-1] == 'E';

    for(int i = n-2; i >= 0; i--) er[i] = er[i+1] + (s[i] == 'E');

    int ans = INF;
    // W: L
    // E: R
    for(int i = 0; i < n; i++){
        if(i == 0) ans = min(ans, er[i+1]);
        else if(i == n - 1) ans = min(ans, w[i-1]);
        else ans = min(ans, w[i-1] + er[i+1]);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

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

    JUDGE((n+1)/2 >= k);




    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		LinkedList list = new LinkedList();
		int n = Integer.parseInt(br.readLine());

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

			String[] input = br.readLine().split(" ");

			if(input[0].equals("insert")){
				list.insert(Integer.parseInt(input[1]));
			}else if(input[0].equals("delete")){
				list.delete(Integer.parseInt(input[1]));
			}else if(input[0].equals("deleteFirst")){
				list.deleteFirst();
			}else if(input[0].equals("deleteLast")){
				list.deleteLast();
			}


		}

		list.output();

	}

}

class Cell{

	int data;
	Cell next;
	Cell back;

	public Cell(int x){

		data = x;

	}

}

class LinkedList{

	Cell head;

	public LinkedList(){

		head = new Cell(-1);
		head.next = head;
		head.back = head;

	}

	public void insert(int x){

		Cell first = head.next;
		Cell c = new Cell(x);
		c.next = first;
		c.back = head;
		first.back = c;
		head.next = c;


	}

	public void delete(int x){

		Cell refe = head.next;

		while(refe.data != -1){

			if(refe.data == x){

				refe.next.back = refe.back;
				refe.back.next = refe.next;
				break;

			}else{

				refe = refe.next;

			}

		}

	}

	public void deleteFirst(){

		head.next = head.next.next;
		head.next.back = head;

	}

	public void deleteLast(){

		head.back = head.back.back;
		head.back.next = head;

	}

	public void output(){

		Cell refe = head.next;
		StringBuilder sb = new StringBuilder();

		while(refe.data != -1){

			sb.append(refe.data);
			refe = refe.next;

			if(refe.data != -1){
				sb.append(" ");
			}

		}

		sb.append("\n");

		System.out.print(sb);

	}

}

Measured memory_bytes: 189200
#include <cstdio>
  #include <iostream>
  #include <string.h>
  #include <cstring>
  #include <cmath>
  #include <math.h>
  #include <algorithm>
  #include <iomanip>
  #include <map>
  #include <set>
  #include <vector>
  #include <sstream>
  #include <queue>  
  #include <bitset>
#define MAX 100005
#define INF 9999999999999
#define pb push_back
using namespace std;
typedef long long int ll;
 typedef pair<ll,ll> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;
 
vector <vii> adj(MAX); 
ll arr[100005];
int main()
{
//  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  set<char> s;
  cin>>str;
  ll len=int(str.size());
  for(ll i=0;i<len;i++)
  {
s.insert(str[i]);
   
}
if(int(s.size())==len)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
   return 0;
  
}  

Measured memory_bytes: 2560
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main(){
   string s;
   while( getline(cin,s) ){ // 文字列に半角スペースを含むので1行読み込みします
       if( s == "." ) break;
       stack<char> st;
       bool flag = true;

       for(int i=0 ; i < s.size() ; i++ ){
           char c = s[i];
           if( c == '(' || c == '[' ){ // 括弧の初めが来たら
               st.push( c );
           }else if( c == ')' ){ // 括弧の終わり')'が来たら
               if( st.empty() || st.top() == '[' ){
                   flag = false;
                   break;
               }else if( st.top() == '(' ){
                   st.pop();
               }
           }else if( c == ']' ){ // 括弧の終わり']'が来たら
               if( st.empty() || st.top() == '(' ){
                   flag = false;
                   break;
               }else if( st.top() == '[' ){
                   st.pop();
               }
           }
       }
       if( flag && st.empty() )
           cout << "yes" << endl;
       else
           cout << "no" << endl;
   }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string s; cin >> s;
  vector<int> whiteIndex{};
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'W') {
      whiteIndex.push_back(i);
    }
  }
  ll res{};
  for (int i = 0; i < whiteIndex.size(); ++i) {
    auto d = whiteIndex[i] - i;
    res += d;
  }
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main(){
    ll n,k=0,ans;
    cin>>n;
    rep(i,sqrt(n-1.0)){
        if(n%(i+1)==0){
            k=i+1;
        }
    }
    ans=n/k+k-2;
    cout<<ans;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  const Int M = 30;
  Int ans=0;
  for(Int k=0;k<M;k++){
    Int mod=1<<k;
    vector<Int> c(n);
    for(Int i=0;i<n;i++) c[i]=b[i]%mod;
    sort(c.begin(),c.end());
    Int cnt=0,p=0,q=0;
    for(Int i=0;i<n;i++){
      p+=(a[i]>>k)&1;
      q+=(b[i]>>k)&1;
      Int x=upper_bound(c.begin(),c.end(),mod-(a[i]%mod)-1)-c.begin();
      cnt+=n-x;
    }
    cnt+=(n-p)*q;
    cnt+=p*(n-q);
    if(cnt&1) ans+=mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

x `mydiv` y = if y /= 0 then x `div` y else 0
x `mymod` y = if y /= 0 then x `mod` y else 1

main = do
  n <- getInt

  let solve i res | i*i >     n    = res
                  | n `mod` i == 0 = let m1 = i - 1
                                         q1 = n `mydiv` m1
                                         r1 = n `mymod` m1

                                         m2 = n `div` i - 1
                                         q2 = n `mydiv` m2
                                         r2 = n `mymod` m2

                                         res' = res
                                           + (if q1 == r1 then m1 else 0)
                                           + (if q2 == r2 then m2 else 0)
                                     in solve (i+1) res'
                  | otherwise      = solve (i+1) res

  print $ solve 1 0

Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N;

	cin >> N;
	int h[22];

	int nowmax = 0;

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		cin >> h[i];
		if (nowmax <= h[i]) {
			nowmax = h[i]; 
			ans++;
		}
	}

	cout << ans;
}

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

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

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

  string s;
  cin >> s;

  int sum = 0;
  rep(i, 4) {
    if (s.at(i) == '+') {
      sum++;
    } else {
      sum--;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
var  n:longint;
    f,a:array[0..10,0..1000]of longint;
    i,j:longint;
function max(a,b:longint):longint;
begin
  if a>b then exit(a) else exit(b);
end;
begin
  read(n);
  for i:=1 to 2 do
  begin
    for j:=1 to n do
    read(a[i,j]);
    readln;
  end;
  for i:=1 to 2 do
  for j:=1 to n do
  f[i,j]:=max(f[i-1,j],f[i,j-1])+a[i,j];
  writeln(f[2,n]);
end.


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=4005,MOD=998244353;
int K,n,fac[MAXN],invf[MAXN];
inline int mod(int x){return x<MOD?x:x-MOD;}
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
inline int comb(int n,int k){if(k<0)return 0;if(n<k)return 0;return (ll)fac[n]*invf[k]%MOD*invf[n-k]%MOD;}
int main() {
	fac[0]=1;for(int i=1;i<=4000;++i)fac[i]=(ll)fac[i-1]*i%MOD;
	invf[4000]=pow_mod(fac[4000],MOD-2);
	for(int i=3999;i>=0;--i)invf[i]=(ll)invf[i+1]*(i+1)%MOD;
	K=read();n=read();
	for(int i=2;i<=K*2;++i){
		int s=0,ans=0,t=0;
		//cout<<"------------- "<<i<<": "<<endl;
		for(int j=1;j<=K;++j)if(j<=i-j&&i-j>=1&&i-j<=K){if(j!=i-j)s++;else t=1;}
		int c=K-2*s-t;
		//cout<<s<<" "<<c<<endl;
		assert(c>=0);
		if(c>0)ans=comb(n+c-1,c-1);
		for(int j=1;j<=s&&j<=n;++j){
			ans=mod(ans+(ll)comb(s,j)*comb(n+c-1,j+c-1)%MOD*pow_mod(2,j)%MOD);
		}
		if(t){
			if(c>0)ans=mod(ans+comb(n-1+c-1,c-1));
			for(int j=1;j<=s&&j<=n-1;++j){
				ans=mod(ans+(ll)comb(s,j)*comb(n-1+c-1,j+c-1)%MOD*pow_mod(2,j)%MOD);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vpll path; vl D;
//***********//
int main() {
	string S; cin >> S;
	if ((S.size() % 2 == 0) ^ (S[0] == S[S.size() - 1])) cout << "Second";
	else cout << "First";
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2; cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;) {
		if((xa2 < xb1 || xb2 < xa1) || (ya2 < yb1 || yb2 < ya1)) cout << "NO" << endl;
		else cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void) {
    char buf1[200001];
    char buf2[200001];
    int i = 0, a = 0;
	scanf("%s%s",buf1,buf2);
    for(i=0;buf1[i]!='\0';i++){
        if (buf1[i] != buf2[i])
            a++;
    }
    printf("%d", a);
    return 0;
}

Measured memory_bytes: 2096
x, a, b = map(int, (input().split()))

if a < x:
    a_abs = x-a
else:
    a_abs = a-x

if b < x:
    b_abs = x-b
else:
    b_abs = b-x
if a_abs > b_abs:
    print("B")
else:
    print("A")

Measured memory_bytes: 3064
lst = []
while True:
    a = list(map(int, input().split()))
    if a[0] == 0 and a[1] == 0:
        break
    else:
        lst.append(a)
for i in range(len(lst)):
    for y in range(lst[i][0]):
        for x in range(lst[i][1]):
            print("#", end="")
        print()
    print()


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

int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i = 0; i < N; i++) 
    cin >> x.at(i);
  x.push_back(X); 
  sort(x.begin(), x.end());
  for (int i = 0; i < M; i++) 
    cin >> y.at(i);
  y.push_back(Y);
  sort(y.begin(),y.end());
  
  if (x.at(N) < y.at(0))
    cout << "No War" <<endl;
  else
    cout << "War" << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

#define D  double
typedef pair<D,int>T;
int N;
int X[1111],Y[1111],R[1111];
D dist[1111];
D INF=1e12;
D EPS=1e-9;

int table2[1111][1111];
D table[1111][1111];

signed main(){

    cin>>X[0]>>Y[0]>>X[1]>>Y[1];
    cin>>N;
    rep(i,N)cin>>X[i+2]>>Y[i+2]>>R[i+2];
    N+=2;

    rep(i,N)rep(j,N){
        table2[i][j]=(X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);
        table[i][j]=sqrt(1.0*table2[i][j]);
    }

    fill_n(dist,1111,INF);
    dist[0]=0;
    priority_queue<T,vector<T>,greater<T>>que;
    que.push(make_pair(0,0));
    while(que.size()){
        D d;
        int idx;
        tie(d,idx)=que.top();
        que.pop();
        if(dist[idx]!=d) continue;
 
        rep(i,N){
            int foo=table2[i][idx];
            int bar=R[i]+R[idx];
            D cost=d;
            if(foo>bar*bar) cost+=sqrt(1.0*foo)-bar;
            if(dist[i]>EPS+cost){
                dist[i]=cost;
                que.push(T(dist[i],i));
            }
        }
    }
    printf("%.20f\n",dist[1]);
    return 0;
}


Measured memory_bytes: 21872
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let lrd: Vec<(usize, usize, i64)> = (0..m)
        .map(|_| {
            let l = input();
            let r = input();
            let d = input();
            (l, r, d)
        })
        .collect();

    let mut g = vec![vec![]; n + 1];
    for &(l, r, d) in &lrd {
        g[l].push((r, d));
        g[r].push((l, -d));
    }

    let mut v = vec![false; n + 1];
    let mut x = vec![0; n + 1];
    for i in 1..n + 1 {
        if !v[i] {
            v[i] = true;
            dfs(i, &mut x, &mut v, &g);
        }
    }

    let mut ok = true;
    for (l, r, d) in lrd {
        if x[r] - x[l] != d {
            ok = false;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}

fn dfs(i: usize, x: &mut Vec<i64>, v: &mut Vec<bool>, g: &Vec<Vec<(usize, i64)>>) {
    for &(j, d) in &g[i] {
        if !v[j] {
            v[j] = true;
            x[j] = x[i] + d;
            dfs(j, x, v, g);
        }
    }
}


Measured memory_bytes: 28540
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 10000
#define MAX_E 100000
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {}
};

int V, E;
vector<edge> G[MAX_V];

int Prim() {
	int res = 0;
	bool used[MAX_V];
	priority_queue<P, vector<P>, greater<P>> que;
	for (int i = 0; i < V; i++) {
		used[i] = false;
	}
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (used[v]) continue;
		used[v] = true;
		res += p.first;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			que.push(P(e.cost, e.to));
		}
	}
	return res;
}

int main()
{
	cin >> V >> E;
	for (int i = 0, s, t, c; i < E; i++) {
		cin >> s >> t >> c;
		G[s].push_back(edge(t, c));
		G[t].push_back(edge(s, c));
	}
	cout << Prim() << endl;
	return 0;
}

Measured memory_bytes: 7856
#include<bits/stdc++.h>
#include <iostream>
#define ll long long

using namespace std;

int main() {
    string s,t; cin>>s>>t;
    int ans=INT_MAX;
    for(int i=0;i<s.size();i++){
        int c_ans=INT_MAX;
        if(i+t.size()<=s.size()){
            c_ans=0;
            for(int j=i;j<i+t.size();j++){
                if(s[j]!=t[j-i]) c_ans++;
            }
            //cout<<i<<" "<<c_ans<<"\n";
        ans =min(ans,c_ans);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int num1 = num;
		List<Integer> numList = new ArrayList<>();
		while(num>0) {
			int nextNum = sc.nextInt();
			numList.add(nextNum);
			num--;
		}
		List<Integer> resultNumList = numList.
				stream()
				.filter(n -> isResult(n))
				.collect(Collectors.toList());
		
		if(resultNumList.size() != num1) {
			System.out.println("DENIED");
		} else {
			System.out.println("APPROVED");
		}
		
	}
	
	private static boolean isResult(int num) {
		return (isNotOdd(num) && isSplitByThreeOrFive(num)) || !isNotOdd(num);
	}
	
	
	private static boolean isNotOdd(int num) {
		return Integer.valueOf(num)%2 == 0;
	}

	private static boolean isSplitByThreeOrFive(int num) {
		return num%3 == 0 || num%5 == 0;
	}
}


Measured memory_bytes: 28876
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

ll memo[2500][2500];
ll comb( int x, int y ){
	if( x < y || memo[x][y] ) return memo[x][y];
    if( y == 0 || y == x ) return memo[x][y] = 1;
	return memo[x][y] = (comb(x-1, y)+comb(x-1, y-1))%mod;
} 

int main(){
	int n, k; cin >> n >> k;
	for( int i = 1; i <= k; ++i ){
		cout << comb(k-1, i-1) * comb(n-k+1, i) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 39680
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("Ofast", "unroll-loops")
#pragma GCC target ("arch=ivybridge")

const int nmax = 204800, block = 8192, unrl = 8;
int a[nmax], b[nmax];

int main() {

	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (int i = 0; i + unrl <= N; i += unrl) {
		for (int j = 0; j + block <= N; j += block) {
			for (int k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);

			}
		}
	}

	for (int i = 0; i < N / unrl * unrl; i++) {
		for (int j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (int i = N / unrl * unrl; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

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

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,n;
    cin>>k>>n;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    vector<int>dis(n);
    for(int i=0; i<n-1; i++){
        dis.at(i)=a.at(i+1)-a.at(i);
    }
    dis.at(n-1)=a.at(0)+k-a.at(n-1);
    sort(dis.begin(),dis.end());
    //int max=max_element(dis.begin(),dis.end());

    cout<<k-dis.at(n-1)<<endl;

    


}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

vector<int> g[101010];

int dfs(int s) {
        int res = 0;
        vector<int> v;
        for (auto ns : g[s]) v.push_back(dfs(ns));
        //sort(rall(v));
        //rep(i, v.size()) amax(res, v[i] + i);
        sort(all(v));
        rep(i, v.size()) {
                res = max(res + 1, v[i]); 
        }
        return res + 1;
}

signed main() { 
        int n;
        cin >> n;
        rep(i, n - 1) {
                int a;
                cin >> a;
                a --;
                g[a].push_back(i + 1);
        }
        cout << dfs(0) - 1 << endl;
        return 0;
}               


Measured memory_bytes: 13568
package main

import "fmt"

func main() {
	var A, B, C, X int
	a, b, c := 500, 100, 50
	count := 0
	fmt.Scan(&A, &B, &C, &X)

	for _c:= 0; _c <= C; _c ++ {
		for _b:= 0; _b <= B; _b++ {
			for _a:=0; _a <= A; _a++ {
				if X == a*_a + b*_b + c*_c {
					count ++
				}
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  for (ll i = 0; i < 26; ++i) {
    ll temp = 4 * i;
    for (ll j = 0; j < 20; ++j) {
      ll temp2 = temp + 7 * j;
      if (temp2 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <map>
#include <stack>
using namespace std;

int calc(int x,int y){
	if( x < 0 ){
		x *= -1;
		y *= -1;
	}
	
	if( x > 0 && y > 0 ){
		int r = min(x,y);
		x -= r;
		y -= r;
		return r + x + y;
	}
	
	return abs(x) + abs(y);
}

int main(){
	int W,H,N;
	cin >> W >> H >> N;
	int px=-1,py=-1;
	int s = 0;
	for(int i = 0 ; i < N ; i++){
		int x,y;
		cin >> x >> y;
		if( px != -1 ){
			s += calc(x-px,y-py);
		}
		px = x;
		py = y;
	}
	cout << s << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int d[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> d[i];
    
    sort(d, d + n);
    int a = n / 2 - 1;
    int b = n / 2;
    cout << d[b] - d[a];
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    rep(i, s.size()) {
        if (s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+1, mod=1e9+7;
int len1[N],len2[N], res=0;
vector<int> g1[N],g2[N];
vector<int> vis(N);

void dfs(int u,int p){
	vis[u]=1;  len1[u]=0;  
	for(auto v:g1[u]){
		if(v==p) continue;
		if(!vis[v])dfs(v,u);
		len1[u]=max( len1[u],len1[v] +1 );
	}
}

void dfs1(int u,int p){
	vis[u]=1; len2[u]=0;
	for(auto v:g2[u]){
		if(v==p ) continue;	
		if(!vis[v])dfs1(v,u);
		len2[u]=max( len2[u],len2[v] +1 );
	}
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		g1[a].pb(b);
		g2[b].pb(a);
	}
	
	for(int i=1;i<=n;i++){
		if(!vis[i])
			dfs(i,0);
	}
	
	
	vis.clear();
	vis.resize(N);
	for(int i=1;i<=n;i++){
		if(!vis[i])
			dfs1(i,0);
		res=max(res,len1[i]+len2[i]);
	}
	
	cout<<res;
	
}
// check for any potential overflow before submitting



Measured memory_bytes: 18432
n = int(input())
li = list(map(int, input().split()))
yon = 0
ni  = 0
ki = 0
for a in li:
    if a % 4 == 0:
        yon += 1
        continue
    if a % 2 == 0:
        ni += 1
    else:
        ki += 1

if ni > 0:
    if yon >= ki:
        print('Yes')
    else:
        print('No')
elif ni == 0:
    if yon >= ki-1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15020
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
A, B = 0, 0


def set_inputs():
    global A, B
    A, B = get_list_of_int()
    return


def f(n):
    mod = n % 4
    ret = n
    for i in range(mod):
        ret ^= (n-1-i)
    return ret


def main():
    setrecursionlimit(100000)
    set_inputs()
    print(f(A-1) ^ f(B))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 39696