akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
vector<vector<int>> graph;
bool used[10005];
vector<int> cost;

int dfs(int from = 0, int p = -1){
    int res = 0;
    for(int to : graph[from]){
        if(to == p) continue;
        res += dfs(to, from);
    }
    if(p != -1)  res += min(cost[from], cost[p]);
    return res;
}

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

    cin >> n;
    graph.resize(n);
    cost.resize(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    priority_queue<int> que;
    for(int i = 0; i < n; ++i){
        int c;
        cin >> c;
        que.push(c);
    }

    int maxdeg = 0, v = 0;
    for(int i = 0; i < n; ++i){
        if(graph[i].size() > maxdeg){
            maxdeg = graph[i].size();
            v = i;
        }
    }
    
    queue<int> vertex;
    vertex.push(v);
    while(!vertex.empty()){
        int from = vertex.front();
        vertex.pop();
        cost[from] = que.top();
        que.pop();
        used[from] = true;
        for(int to : graph[from]){
            if(used[to])    continue;
            vertex.push(to);
        }
    }
    

    int ans = dfs();
    cout << ans << endl;
    for(int i = 0; i < n; ++i){
        cout << cost[i];
        cout << ((i == n - 1) ? "\n" : " ");
    }
}

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

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  sort(a, a+n);
  ll ans = 0;
  if(!(n % 2)){
    rep(i, n/2){
      ans -= 2*a[i];
      ans += 2*a[n-1-i];
    }
    ans += a[n/2-1];
    ans -= a[n/2];
  } else {
    ll ans1 = 0, ans2 = 0;
    rep(i, n/2){
      ans1 -= 2*a[i];
      ans1 += 2*a[n-1-i];
      ans2 -= 2*a[i];
      ans2 += 2*a[n-1-i];
    }
    ans1 -= a[n/2];
    ans1 += a[n/2-1];
    ans2 -= a[n/2+1];
    ans2 += a[n/2];
    ans = max(ans1,ans2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
const double eps = 1e-8;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}int n, m, s, t, r, Q, b, c; 
vector<int> w;
const int MOD = 1e9 + 7;
int dp[1<<21];
bool a[21][21];
int main(void) {
    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    dp[0] = 1;
    req(S, (1 << n) - 1) {
        int sum = 0;
        rep(i, n) {
            if (S & (1 << i)) sum++;
        }rep(i, n) {
            if (S & (1 << i) && a[sum - 1][i]) {
                dp[S] += dp[S ^ (1 << i)];
                dp[S] %= MOD;
            }
        }
    }cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 8448
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0031
{
    class Program
    {
        readonly static int[] weights = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };

        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                var usedWeights = new List<int>();

                if (string.IsNullOrEmpty(input))
                {
                    break;
                }

                var inputWeight = int.Parse(input);
                foreach (var weight in weights)
                {
                    if ((inputWeight / weight) == 1)
                    {
                        usedWeights.Add(weight);
                    }
                    inputWeight %= weight;
                }
                usedWeights.Reverse();

                foreach (var usedWeight in usedWeights)
                {
                    if (usedWeight == usedWeights.First())
                    {
                        Console.Write(usedWeight);
                    }
                    else
                    {
                        Console.Write(" " + usedWeight);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5864
a,b,c,d=map(int,input().split())
lcm=0
cc=min(c,d)
dd=max(c,d)

while cc>0:
  amari=dd%cc
  dd=cc
  cc=amari

lcm=c*d//dd
  
bika=b-b//c-b//d+b//lcm
amiman=a-1-(a-1)//c-(a-1)//d+(a-1)//lcm
print(bika-amiman)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Stack;
class Main {
   public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = str.length();
		
		Stack<Integer> stack1 = new Stack<Integer>();
		Stack<Integer> stack2 = new Stack<Integer>();
		Stack<Integer> stack3 = new Stack<Integer>();
		
		int j;
		int temp;
		int delete;
		int total = 0;
		for(int i = 0; i < n; i++){
			
			if(str.charAt(i) == '\\'){
				stack1.add(i);
			}else if((str.charAt(i) == '/') && !stack1.isEmpty()){
				j = stack1.pop();
				temp = i - j;
				total += temp;
				while(!stack2.isEmpty() && stack2.get(stack2.size() - 1) > j){
					temp += stack3.pop();
					delete =  stack2.pop();
				}
				stack2.add(j);
				stack3.add(temp);
			}
		}
		System.out.println(total);
		if(stack3.size() != 0){
			System.out.print(stack3.size() + " ");
		}else{
			System.out.println(stack3.size());
		}
		
		for(int x = 0; x < stack3.size(); x++){
			if(x != stack3.size() - 1){
				System.out.print(stack3.get(x) + " ");
			}else{
				System.out.println(stack3.get(x));
			}
		}
	}
}

Measured memory_bytes: 29788
#include <iostream>
#include <sstream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-9;
const double inf = (double)(1<<24);
const int size = 1001;
int n;
int b[size], x[size], y[size];
bool p[size][size];
double c[size][size];

int CN[size][size];
int CNcnt[size];

double mc[size];
int prev[size];
typedef pair <double, int> Node;
typedef priority_queue <Node, vector<Node>, greater<Node> > QUEUE;

bool big_equal( double a, double b )
{
    return fabs( a - b ) < eps ? true : a < b;
}

double getdist( int x1, int y1, int x2, int y2 )
{
    double X = x2 - x1, Y = y2 - y1;
    return sqrt( X * X + Y * Y );
}

string solve( int s, int g )
{
    QUEUE Q;
    Node start( 0.0, s );
    Q.push( start );
    mc[s] = 0.0;

    while ( !Q.empty() ) {
        Node node = Q.top();
        Q.pop();

        double cost = node.first;
        int ind = node.second;

        if ( ind == g ) {
            vector <int> list;
            list.push_back( g+1 );
            int t = prev[g];
            while ( t != -1 ) {
                list.push_back( t+1 );
                t = prev[t];
            }
            reverse( list.begin(), list.end() );
            ostringstream os;
            for ( vector <int> ::iterator it = list.begin(); it != list.end(); it++ ) {
                os << *it;
                if ( it + 1 != list.end() ) os << " ";
            }
            return os.str();
        }

        for ( int i = 0; i < CNcnt[ind]; i++ ) {
            int next_ind = CN[ind][i];
            double next_cost = node.first + c[ind][next_ind];
            if ( big_equal( mc[next_ind], next_cost ) ) {
                continue;
            }
            mc[next_ind] = next_cost;
            prev[next_ind] = ind;
            Node next_node( next_cost, next_ind );
            Q.push( next_node );
        }
    }

    return "NA";
}

int main()
{
    while ( cin >> n && n ) {
        // init
        for ( int i = 0; i < n; i++ ) {
            CNcnt[i] = 0;
            for ( int j = 0; j < n; j++ ) {
                p[i][j] = false;
                c[i][j] = inf;
            }
        }

        // input
        for ( int i = 0; i < n; i++ ) {
            cin >> b[i];
            int ind = b[i] - 1;
            cin >> x[ind] >> y[ind];
        }

        // proc
        for ( int i = 0; i < n; i++ ) {
            for ( int j = 0; j < n; j++ ) {
                if ( i == j ) continue;
                c[i][j] = getdist( x[i], y[i], x[j], y[j] );
                if ( big_equal( c[i][j], 50.0 ) ) {
                    p[i][j] = true;
                    CN[i][CNcnt[i]++] = j;
                }
            }
        }

        int m;
        cin >> m;
        for ( int i = 0; i < m; i++ ) {
            for ( int j = 0; j < n; j++ ) {
                mc[j] = inf;
                prev[j] = -1;
            }

            int s, g;
            cin >> s >> g;
            cout << solve( s-1, g-1 ) << endl;
        }
    }
    return 0;
}

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

int main(){
    int n;
    int sum = 0;

    cin >> n;

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

    cout << sum << endl;

    return 0;
}


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

int main(){
    ll x,k,d; cin >> x >> k >> d;
    x = abs(x);
    ll res = x%d,div = x/d,ans;
    if(div >= k){
        ans = x - d*k;
    }
    else{
        k -= div;
        ll res2 = abs(res-d);
        if(res2 < res && k%2 == 1) ans = res2;
        else if(res < res2 && k%2 == 0) ans = res;
        else if(k%2 == 0) ans = res;
        else if(k%2 == 1) ans = res2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}


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

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


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

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

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

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

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


fn main () {
    input!{
        a: i32,
        b: i32
    };

    if a > 8 || b > 8 {
        println!(":(");
    }
    else {
        println!("Yay!");
    }
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		cout << (n / 500) * 1000 + ((n % 500) / 5) * 5 << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	cin >> a >> b;
	switch(a)
	{
	case 0:n = 1; break;
	case 1:n = 100; break;
	case 2:n = 10000; break;
	}
  if(b==100)
    cout<<101*n<<endl;
  else
	cout << n * b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long lint;

lint solve(lint a, lint b, lint c, lint x, lint y){
    lint price = 1LL<<32;
    // case 1
    price = min(price, a * x + b * y);
    // case 2
    if(y >= x){
        price = min(price, c * (2 * x) + b * (y - x));
    }
    // case 3
    if(x >= y){
        price = min(price, a * (x - y) + c * (2 * y));
    }
    // case 4
    price = min(price, c * max(2 * x, 2 * y));
    return price;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    cout << solve(a, b, c, x, y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1001001001;
const ll LINF = 1e18;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

int dp[105][100100];

signed main()
{
  int n,W; cin>>n>>W;
  vi w(n+1); vi v(n+1);
  reps(i,n) {
    cin>>w[i];
    cin>>v[i];
  }
  
  FILL(dp[0],100100,INF);
  dp[0][0]=0;
  
  reps(i,n){
    reps(j,100005){
      if(v[i]==j) dp[i][j]=min(dp[i-1][j], w[i]);
      else if(j>v[i]) dp[i][j]=min(dp[i-1][j-v[i]]+w[i], dp[i-1][j]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  
  int ans=0;
  for(int i=100005; i>=0; i--){
    if(dp[n][i]<=W) {
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int a[200000];

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    int u = -INF, cnt = 1;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'o' && i > u + c && cnt <= k) {
            a[i] = cnt;
            u = i;
            cnt++;
        }
    }
    u = INF;
    cnt = k;
    vector<int> ans;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'o' && i < u - c && cnt > 0) {
            if (a[i] == cnt)
                ans.push_back(i + 1);
            u = i;
            cnt--;
        }
    }
    sort(ans.begin(), ans.end());
    for (int t : ans) {
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 3448
import itertools
N = input()
S = [raw_input() for _ in range(N)]
nums = {}
for s in S:
    initial = s[0]
    if not initial in nums:
        nums[initial] = 1
    else:
        nums[initial] += 1

res = 0
for a, b, c in itertools.combinations('MARCH', 3):
    if a not in nums or b not in nums or c not in nums:
        continue
    res += nums[a] * nums[b] * nums[c]
print res



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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    bool cond1,cond2,cond3;
    cond1 = true;
    for (int i=0;i<S.size();i++){
        if (S[i] != S[S.size()-1-i]) cond1 = false;
    }
    cond2 = true;
    for (int i=0;i<S.size()/2;i++){
        if (S[i] != S[S.size()/2-1-i]) cond2 = false;
    }
    cond3 = true;
    for (int i=0;i<S.size()/2;i++){
        if (S[S.size()/2 + 1 + i] != S[S.size()-1-i]) cond3 = false;
    }
    if (cond1 && cond2 && cond3){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
def resolve():
	# N: 足場の個数
	N = int(input())
	# h: 各足場の高さ
	h = list(map(int, input().split()))
	# テーブル宣言:カエルは足場１にいる⇒dp[0]のコストは0
    # また、dp,hとも添え字の数は足場の数より１少ないので注意
	dp = [0] * N
	# 漸化式の都合、カエルが足場2にいるとこのコストも定義
	dp[1] = abs(h[0] - h[1])
	# dp計算
	for i in range(2, N):
		dp[i] = min(
			# 1個左の足場からカエルが来た時の最小コスト
			abs(h[i] - h[i-1]) + dp[i-1],
			# 2個左の足場からカエルが来た時の最小コスト
			abs(h[i] - h[i-2]) + dp[i-2]
		)
	# 求める足場Nの時の最小コストはdp[N-1]
	print(dp[N-1])
    
resolve()

Measured memory_bytes: 13928
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
int H,W;
string S[50];
int search_range[8][2]={{-1,-1},{-1,0},{-1,+1},
                        {0,-1},{0,+1},
                        {+1,-1},{+1,0},{+1,+1}};
cin>>H>>W;
for(int i=0;i<H;i++){
    cin>>S[i];
}

for(int i=0;i<H;i++){
    
    for(int j=0;j<W;j++){
    if(S[i][j]=='.'){
        int cnt=0;
        int tmp_i,tmp_j;
        for(int k=0;k<8;k++){
            tmp_i=i+search_range[k][0];
            tmp_j=j+search_range[k][1];
            if(tmp_i>=0&&tmp_i<H&&tmp_j>=0&&tmp_j<W){
                if(S[tmp_i][tmp_j]=='#'){
                    cnt++;
                }
            }
        }
        S[i][j]=cnt+'0';
    }
    }
}

for(int i=0;i<H;i++){
    cout<<S[i]<<endl;
}
//system("pause");
return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N, K;
  cin >> N >> K;
  ll v[N];
  for (int i = 0; i < N; i++) cin >> v[i];

  // 左右独立で考えて良い？
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    int lmax = i; // 左側で操作できる最大回数
    int rmax = K - i; // 右側で操作できる最大回数

    for (int j = 0; j <= lmax; j++) { // 左側から行く最奥
      int maxi = 0;
      vector<int> lv;
      if (j > 0) {
        for (int t = 0; t < j; t++) lv.push_back(v[t]);
        sort(lv.begin(), lv.end());
        
        int tmp = lmax - j; // 再び戻せる宝石の数
        int cnt = 0;
        while (tmp--) {
          if (cnt == lv.size() || lv[cnt] > 0) break;
          lv[cnt] = 0;
          cnt++;
        }
        maxi += accumulate(lv.begin(), lv.end(), 0);
      }

      for (int m = N + 1; m > (N - rmax); m--) { // 右側から行く最奥
        if (m <= j) break;

        vector<int> rv;

        int maxi2 = maxi;
        if (m <= N) {
          for (int t = N - 1; t >= m - 1; t--) rv.push_back(v[t]);
          sort(rv.begin(), rv.end());
          int tmp = rmax - (N - m + 1);
          int cnt = 0;
          while (tmp--) {
            if (cnt == rv.size() || rv[cnt] > 0) break;
            rv[cnt] = 0;
            cnt++;
          }
          maxi2 += accumulate(rv.begin(), rv.end(), 0);
        }

        ans = max(ans, maxi2);
      }
    }
  }

  cout << max(ans, 0) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	signed n;
	string s;
	cin >> n >> s;
	int r = 0, g = 0, b = 0;
	for (signed i = 0; i < n; i++){
		if (s[i] == 'R')
			r++;
		if (s[i] == 'G')
			g++;
		if (s[i] == 'B')
			b++;
	}
	int x = r * g * b;
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			string t = "";
			t += s[i];
			t += s[j];
			t += s[j + (j - i)];
			sort(t.begin(), t.end());
			if (t == "BGR")
				x --;
		}
	}
	cout << x;
}


Measured memory_bytes: 3644
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
const lines = input.split('\n');

for (let i = 0; i < lines.length; i++) {
	e = Number(lines[i]);
	if (e !== 0) {
		let min = e;
		let maxZ = Math.floor(Math.cbrt(e));
		for (let z = 0; z <= maxZ; z++) {
			let maxY = Math.floor(Math.sqrt(e - z * z * z));
			for (let y = 0; y <= maxY; y++) {
				x = e - z * z * z - y * y;
				if (x + y + z < min) min = x + y + z;
			}
		}
		console.log(min);
    }	
}


Measured memory_bytes: 21452
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  bool able = false;
  int increment = 1;
  int ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(a == increment){
      increment++;
      able = true;
    }else{
      ans++;
    }
  }

  if(able) cout << ans << endl;
  if(!able) cout << -1 << endl;
  return 0;
}


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

using namespace std;

const int MAX_N = 100;

int main(void) {
  int n, x;
  int a[MAX_N];

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

  sort(a, a+n);
  int remain = x;
  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (remain >= a[i]) {
      ans++;
      remain -= a[i];
    }
    else {
      remain = 0;
      break;
    }
  }

  if (remain > 0) {
    ans--;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

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

void pattern(ll& answer, ll A, ll B, ll C)
{
    // A * B * C * 3!
    answer += A * B * C;
}

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++)
    {
        cin >> S[i];
    }

    vector<ll> counter(5,0); // M,A,R,C,H
    for(auto x : S)
    {
        if(x[0]=='M') counter[0]++;
        if(x[0]=='A') counter[1]++;
        if(x[0]=='R') counter[2]++;
        if(x[0]=='C') counter[3]++;
        if(x[0]=='H') counter[4]++;
    }

    vector<pair<ll,pair<ll,ll>>> tup(10);
    tup[0] = make_pair(0,make_pair(1,2));
    tup[1] = make_pair(0,make_pair(1,3));
    tup[2] = make_pair(0,make_pair(1,4));
    tup[3] = make_pair(0,make_pair(2,3));
    tup[4] = make_pair(0,make_pair(2,4));
    tup[5] = make_pair(0,make_pair(3,4));
    tup[6] = make_pair(1,make_pair(2,3));
    tup[7] = make_pair(1,make_pair(2,4));
    tup[8] = make_pair(1,make_pair(3,4));
    tup[9] = make_pair(2,make_pair(3,4));

    ll answer = 0;

    for(auto x : tup)
    {
        pattern(answer,counter[x.first],counter[x.second.first],counter[x.second.second]);
    }

    cout << answer << endl;

    return 0;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  FOR(i, 50001) {
    if (i * 108 / 100 == N) {
      print(i);
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    char S[10],T[10],U[9];
    int A,B;
    scanf("%s%s",S,T);
    scanf("%d%d",&A,&B);
    scanf("%s",U);
   
   if(*S==*U){
       A = A-1;
   }
   else{
       B=B-1;
   }
   printf("%d %d\n",A,B);
    return 0;
}

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

bool n, w, s, e;

int main()
{
    string t;
    cin >> t;
    int k = t.size();
    for(int i = 0; i < k; i++){
        if(t[i] == 'N') n = true;
        if(t[i] == 'W') w = true;
        if(t[i] == 'S') s = true;
        if(t[i] == 'E') e = true;
    }
    if((n ^ s) || (w ^ e)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int solve(int src,vector<vector<int> >&arr){
int ans=0;
for(int i=0;i<arr[src].size();i++){
    if(dp[src]!=-1){
        ans=max(ans,dp[src]);
    }else{
    ans=max(ans,1+solve(arr[src][i],arr));
    }
}
    return dp[src]= ans;

}

int main()
{
    ios_base::sync_with_stdio(false);
    int n,m,x,y;
    cin>>n>>m;
    vector<vector<int> >arr(n+1);
    memset(dp,-1,sizeof dp);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        arr[x].push_back(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,solve(i,arr));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
// program.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
long long GCD(long long a, long long b) {
	if (a == 0)
		return b;
	return GCD(b % a, a);
}

int main()
{
	int n;
	string str;
	cin >> n >> str;
	int l = str.length();
	char a[(int)1e4];
	strcpy(a,str.c_str() );
	for (int i = 0; i < l; i++) {
		int temp;
		 temp = int(a[i]) + n;
		if (temp > 90) {
			a[i] = (char)(64 + (temp - 90));
		}
		else {
			a[i] = (char) temp;
		}
	}
	for (int i = 0; i < l; i++) {
		cout << a[i];
		if (i == l - 1) {
			cout << endl;
		}
	}
	return 0;



}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file





Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	static char prime[1000001];
    static char ok[1000001];
	int i, j;
	int n, t;
    int a[30];
    int max;
	
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = 1;
	}
	prime[2] = 1;
	
	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = i * i; j <= 1000000; j += 2 * i){
				prime[j] = 0;
			}
		}
	}
	
	while (1){
        scanf("%d%d", &t, &n);
		
        if (t + n == 0){
            break;
        }
        
        for (i = 0; i < t; i++){
            scanf("%d", &a[i]);
        }
        
        memset(ok, 0, sizeof(ok));
        ok[0] = 1;
        max = -100;
        for (i = 0; i < t; i++){
            for (j = 0; j + a[i] <= n; j++){
                if (ok[j] != 0){
                    ok[j + a[i]] = ok[j];
                    if (j + a[i] > max && prime[j + a[i]]){
                        max = j + a[i];
                    }
                }
            }
        }
        
        if (max != -100){
		    printf("%d\n", max);
        }
        else {
            printf("NA\n");
        }
	}
	
	return (0);
}

Measured memory_bytes: 2368
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;

int main(){   
    int n,m;
    cin >> n >> m;
    P b[n];
    for(int i=0;i<n;i++){
        int x;
        cin >> b[i].first >> b[i].second;
    }
    sort(b, b+n);

    int ans=0;
    priority_queue<int> que;
    int cur=0;
    for(int i=1;i<=m;i++){
        while(cur<n && b[cur].first<=i) que.push(b[cur].second), cur++;
        if(!que.empty()) ans+=que.top(), que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1660
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Set<Character> set = new HashSet<>();
    for (char c : S.toCharArray()) {    
      if(set.contains(c)){
        System.out.println("no");
        return;
      }
      set.add(c);
    }
    System.out.println("yes");
  }
}    

Measured memory_bytes: 35840
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;

const int N = 1e6 + 6;

int main(){

        int x,y;
        cin >> x >> y;
        for(int i = 0; i <= x; i++){
                if(i*2 + (x-i)*4 == y){
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;
}


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

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

const int MOD = 1000000007; 

using namespace std;
typedef long long lint;

template< class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< class T = lint>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {
	const T INF = numeric_limits<T>::max();
	vector<T> dist(V, INF);
	dist[st] = 0;
	for (int i = 0; i < V; i++) {
		for (const auto &ele : edges) {
			if (dist[ele.from] != INF && dist[ele.to] > dist[ele.from] + ele.cost) {
				dist[ele.to] = dist[ele.from] + ele.cost;
				if (i == V - 1 && ele.to == V - 1) return vector<T>(); // negative loop
			}
		}
	}
	return dist;
}

int main() {

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

	int N, M;
	cin >> N >> M;

	vector<Edge<lint>> edge(M);
	for (int i = 0; i < M; i++) cin >> edge[i].from >> edge[i].to >> edge[i].cost;
	for (auto &&elem : edge) {
		elem.from--;
		elem.to--;
		elem.cost *= -1;
	}

	vector<lint> ans = Bellman_Ford<lint>(edge, N, 0);
	
	if(ans.empty())	cout << "inf";
	else cout << -ans[N - 1];

	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  std::string S, T;
  std::cin >> S >> T;

  int res = 0;

  for(int i=0;i<3;++i){
      if(S[i] == T[i]){
          res += 1;
      }
  }

  std::cout << res << std::endl;
}


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

namespace ConsoleApp1
{
    static class CCountOrder
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Replace(" ", "");
            var q = Console.ReadLine().Replace(" ", "");

            string s = "";
            for (int i = 1; i <= n; i++)
            {
                s += i.ToString();
            }

            var enumerateList = Enumerate(s);
            enumerateList.Sort();
            var indexList = enumerateList.Select((x, i) => new { s = x, index = i });

            int a = indexList.Where(x => x.s == p).Select(x => x.index + 1).First();
            int b = indexList.Where(x => x.s == q).Select(x => x.index + 1).First();

            Console.WriteLine(Math.Abs(a - b));
            Console.ReadLine();
        }

        static List<string> Enumerate(string input)
        {
            if (input.Length == 1)
            {
                return new List<string> { input };
            }

            var list = new List<string>();
            for (int i = 0; i < input.Length; i++)
            {                
                foreach (var item in Enumerate(input.Remove(i, 1)))
                {
                    list.Add(input[i] + item);
                }                
            }

            return list;
        }
    }
}

Measured memory_bytes: 25408
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<ctime>
#include<map>
#include<set>
using namespace std;
#define MP(x,y) make_pair((x),(y))
#define PB(x) push_back(x)
typedef long long LL;
//typedef unsigned __int64 ULL;
/* ****************** */
const int INF=100011122;
const double INFF=1e100;
const double eps=1e-8;
const LL mod=1000000007;
const int NN=300010;
const int MM=1000010;
/* ****************** */

const int limit=1000000;

int aa,bb;
int C = ~(1<<31);
int M = (1<<16)-1;
int rr() {
    aa = 36969 * (aa & M) + (aa >> 16);
    bb = 18000 * (bb & M) + (bb >> 16);
    return (C & ((aa << 16) + bb)) % 1000000;
}

struct node
{
    int x,y,z;
    bool operator<(const node &tt)const
    {
        return x<tt.x;
    }
}a[NN];
struct node1
{
    int x,y,z,id;
    bool operator<(const node1 &tt)const
    {
        if(y!=tt.y)return y<tt.y;
        return z>tt.z;
    }
}b[NN];
int dp[NN];
int c[2][limit+1];

int lowbit(int x)
{
    return x&(-x);
}
void update(int fg,int x,int val)
{
    for(;x<=limit;x+=lowbit(x))
        c[fg][x]=max(c[fg][x],val);
}
int get_max(int fg,int x)
{
    int ans=0;
    for(;x>0;x-=lowbit(x))
        ans=max(ans,c[fg][x]);
    return ans;
}
void clr_update(int fg,int x)
{
    for(;x<=limit;x+=lowbit(x))
        c[fg][x]=0;
}

void cdq(int l,int r)
{
    if(l==r)
    {
        dp[l]=max(dp[l],1);
        return;
    }
    int mid=(l+r)>>1;
    int t,i,cnt=0,tx=a[mid+1].x;

    cdq(l,mid);

    for(i=l;i<=r;i++)
    {
        b[cnt].x=a[i].x;
        b[cnt].y=a[i].y;
        b[cnt].z=a[i].z;
        b[cnt].id=i;
        cnt++;
    }
    sort(b,b+cnt);
    for(i=0;i<cnt;i++)
    {
        if(b[i].id<=mid)
        {
            update(1,b[i].z, dp[ b[i].id ] );
            if(b[i].x!=tx)
                update(0,b[i].z, dp[ b[i].id ] );
        }
        else
        {
            if(b[i].x==tx)
                t=get_max(0,b[i].z-1);
            else
                t=get_max(1,b[i].z-1);

            dp[ b[i].id ] = max( dp[ b[i].id ] , t+1 );
        }
    }
    for(i=0;i<cnt;i++)
        if(b[i].id<=mid)
        {
            clr_update(1,b[i].z);
            if(b[i].x!=tx)
                clr_update(0,b[i].z);
        }

    cdq(mid+1,r);
}

void solve(int n)
{
    int i,ans=0;
    sort(a+1,a+1+n);

    memset(c,0,sizeof(c));
    memset(dp,0,sizeof(dp));

    cdq(1,n);

    for(i=1;i<=n;i++)
        ans=max(ans,dp[i]);

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

int main()
{
    int m,n,i;
    while(scanf("%d%d%d%d",&m,&n,&aa,&bb)!=EOF)
    {
        if(m==0 && n==0)break;

        for(i=1;i<=m;i++)
        {
            scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
            a[i].x++;
            a[i].y++;
            a[i].z++;
        }
        for(i=1;i<=n;i++)
        {
            a[i+m].x=rr();
            a[i+m].y=rr();
            a[i+m].z=rr();

            a[i+m].x++;
            a[i+m].y++;
            a[i+m].z++;
        }

        solve(n+m);
    }
    return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    ll x;
    cin >> x;
    ll n = 100;
    int cnt = 0;
    while (n < x) {
        cnt++;
        n *= 1.01;
    }

    out(cnt);

    return 0;
}


Measured memory_bytes: 3652
a, b, c, d = map(int,input().split())
count = 1
hp = 1
result = ""
while hp > 0:
    if count % 2 == 1:
        c -= b
        hp = c
        count += 1
        if hp <= 0:
            result = 'Yes'
    else:
        a -= d
        hp = a
        count += 1
        if hp <= 0:
            result = 'No'

print(result)

Measured memory_bytes: 9132
package main

import "fmt"

func main() {
	//変数の定義
	var H, N, p int
	//変数の読み込み %dは整数を表す。
	fmt.Scanf("%d %d", &H, &N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		// N個のスペースで区切られた変数を読み取る。
		fmt.Scan(&a[i])
	}

	// 総和を計算
	for i := 0; i < N; i++ {
		p += a[i]
	}

	// check :fmt.Printf("%d %d\n", a[4], p)

	// 総和がH以上ならOK。
	// 違うならNO。

	if p >= H {
		fmt.Printf("%s\n", "Yes")
	} else {
		fmt.Printf("%s\n", "No")
	}

}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX_SUM 100000
vector<vector<int>> dp(3001, vector<int>(3001, 0)), input;

string s,t;
int n,l,f;
int main()
{
    cin>>s>>t;
    n = s.length();
    l = t.length();
    dp[0][0] = 0;
    for(int i=0;i<s.length();i++){
        f=0;
        for(int j=0;j<t.length();j++){
            if(s[i]==t[j]){dp[i+1][j+1] = dp[i][j]+1;}
            else{
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);}
        }
    }
    
    string ans;
    int i = n, j = l;
   while (i > 0 && j > 0)
   {
      //if current character in s1 and s2 are same, then include this character in LCS[]
      if (s[i-1] == t[j-1])
      {
          ans+= s[i-1]; // Put current character in result
          i--; j--;     // reduce values of i, j and index
      }
      // compare values of L[i-1][j] and L[i][j-1] and go in direction of greater value.
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }
    reverse(ans.begin(),ans.end());
    cout<<ans;

    return(0);
}

Measured memory_bytes: 35584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

ll f(ll n) {
  if (n <= 0) return 0ll;
  ++n;
  ll res = 0;
  for (int i = 0; i < 50; i++) {
    ll loop = (1ll << (i + 1));
    ll tot = n / loop * (loop / 2);
    tot += max(0ll, (n % loop) - loop / 2);
    if (tot & 1) {
      res |= 1ll << i;
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  ll A, B;
  while (cin >> A >> B) {
    ll res = f(B) ^ f(A - 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

typedef long long ll;
ll a[3];
ll n, m, i, j;

int main()
{
	while(cin >> a[0] >> a[1] >> a[2])
	{
		sort(a, a + 3);
		if(a[2] % 2 == 0)
			cout << 0 << endl;
		else
			printf("%lld\n",a[0] * a[1]);
	}
	return 0;
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
import numpy as np
import math


n = int(input())
aList = list(map(int, input().split()))
gcdListLeft = [0 for i in range(n)]
gcdListRight = [0 for i in range(n)]

tmp = aList[0]
for i in range(n):
	tmp = gcdListLeft[i] = math.gcd(tmp, aList[i])

tmp = aList[n-1]
for i in range(n-1, -1, -1):
	tmp = gcdListRight[i] = math.gcd(tmp,aList[i])

ans = gcdListRight[1]
for i in range(1,n-1):
	ans = max(ans, math.gcd(gcdListLeft[i-1], gcdListRight[i+1]))
ans = max(ans, gcdListLeft[n-2])
print(ans)

Measured memory_bytes: 38720
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>v(N);
  for(int i=0;i<N;i++) cin>>v.at(i);
  sort(v.begin(),v.end());
  cout<<v.at(N-1)-v.at(0)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
 long int N=0,k=0,a;
  scanf ("%ld",&N);
  for( a=1 ;a<=N ; a++ ){
    if(a%3!=0 && a%5!=0) k+=a;
  };
  printf("%ld",k);
  return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

ll day[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

// <------------- Implement Functions Here ----------> //

  


// <------------- Start of main() -------------------> //

void MAIN() {
	ll m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	cout<<(d1 == day[m1]);
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 12984
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  



void solve(){
	int n = 5; 
	int ans = 0 ; 
	int i = 0 ;
	while(i<n){
		int a; re(a);
		if(a==0) {
			cout << i+1 << endl; 
			return ;
		}
		i++;
	}
}



signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3596
n = int(input())

lst = [0]*n
a = int(n ** 0.5)

for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            b = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if b > n:
                continue
            else:
                lst[b - 1] += 1

for i in lst:
    print(i) 


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    h[0]--;
    for (int i = 1; i < n; i++){
        if (h[i] > h[i-1]) h[i]--;
        else if (h[i] < h[i-1]){
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640