akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define swap(a,b) ((a!=b)&&(a+=b,b=a-b,a-=b))
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int c[26],s[365][26]={{0}},type[365],candidate[365][4]={{0}};
void greedy(int d)
{
  int now,since[26]={0},keep[26],rank[26];
  for(int i=0;i<d;i++)
  {
    now=0,since[type[i]]=i;
    for(int j=0;j<26;j++){keep[j]=s[i][j]+c[j]*(i-since[j]);rank[j]=j;}
    for(int j=0;j<26;j++)
    {
      for(int k=j+1;k<26;k++)
      {
        if(keep[j]<keep[k]){swap(keep[j],keep[k]);swap(rank[j],rank[k]);}
      }
    }
    now=rank[0],type[i]=now,since[now]=i;
    for(int j=0;j<4;j++){candidate[i][j]=rank[j+1];}
  }
}
int main()
{
  int D=IN(),i=0,j=0,sum=0,temp=0,update[26]={0};
  while(i<26){c[i++]=IN();}i=0;
  while(i<D){while(j<26){s[i][j++]=IN();}i++,j=0;}i=0;
  greedy(D);
  while(i<1)
  {
    j=0;temp=type[i],sum+=s[i][temp];update[temp]=++i;
    while(j<26){sum-=c[j]*(i-update[j]);j++;}
  }
  temp=sum;
  int remain=0,flag=0;j=0;srand((unsigned int)time(NULL));
  while(remain<10*D)
  {
    int d=rand()%D,q=rand()%26,l0=-1,l1=-1,r0=D,r1=D,esc0=0,esc1=0,old=type[d];
    sum+=s[d][q]-s[d][type[d]];i=d-1;
    while(i>=0)
    {
      if(type[i]==type[d]&&!esc0){l0=i;esc0=1;}
      if(type[i]==q&&!esc1){l1=i;esc1=1;}
      if(esc0&esc1){break;}i--;
    }
    esc0=esc1=0;i=d+1;
    while(i<D)
    {
      if(type[i]==type[d]&&!esc0){r0=i;esc0=1;}
      if(type[i]==q&&!esc1){r1=i;esc1=1;}
      if(esc0&esc1){break;}i++;
    }
    sum-=c[type[d]]*(d-l0)*(r0-d);sum+=c[q]*(d-l1)*(r1-d);type[d]=q;
    if(temp<sum&&sum>0){temp=sum;}else{type[d]=old;}
    j++;if(j==3){j=0;}remain++;
  }i=0,sum=0;
  while(i<D){printf("%d\n",type[i++]+1);}
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main()
{
ll n;
cin>>n;
ll k;
cin>>k;
ll a[n+1];
for(ll i=1;i<=n;i++){
    cin>>a[i];
}
ll dp[n+1];
for(ll i=0;i<=n;i++){
    dp[i]=0;
}
 
dp[1]=0;
for(ll i=2;i<=n;i++){
    dp[i]=LLONG_MAX;
    for(int j = i - 1 ; j >= max(1ll, i - k) ; j--){
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
}
cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

vector<ll> fac(2000001);
vector<ll> ifac(2000001);

ll pow (ll x, ll n) {
	if (n==0)
		return 1;
	if (n==1)
		return x%MOD;
	ll tmp = pow (x, n/2) % MOD;
	ll tmp2 = (tmp*tmp) % MOD;
	if (n%2)
		return tmp2*x % MOD;
	return tmp2;
}

ll comb (ll a, ll b) {
	if (a==0 && b==0)
		return 1;
	if (a<b || a<0)
		return 0;
	ll tmp = ifac[a-b] * ifac[b] % MOD;
	return tmp * fac[a] % MOD;
}

int main () {
	fac[0] = 1;
	ifac[0] = 1;
	for (int i=0; i<2000000; i++) {
		fac[i+1] = fac[i]*(i+1) % MOD;
		ifac[i+1] = ifac[i]*pow(i+1,MOD-2) % MOD;
	}

	int K, l;
	string S;

	cin >> K;
	cin >> S;
	l = S.length();
	ll ans = 0;

	for (int i=l; i<=K+l; i++) {
		ll tmp = pow (25,i-l) % MOD;
		tmp *= comb (i-1, l-1) % MOD;
		tmp %= MOD;
		tmp *= pow (26, K+l-i) % MOD;
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 36504
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int m, long[][] xxs) {

    long ans = 0;
    for (int i = 0; i < 8; i++) {
        long[] xs;
        for (int j = 0; j < xxs.length; j++) {
            long sum = 0;
            for (int k = 0; k < 3; k++) {
                sum += ((i >> k) & 1) == 0 ? xxs[j][k] : -xxs[j][k];
            }
            xs ~= sum;
        }

        xs.sort!"a > b";
        ans = max(ans, xs.take(m).sum);
    }
    return ans;
}

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    long[][] xxs;
    for (int i = 0; i < n; i++) {
        xxs ~= reads!long;
    }

    auto ans = calc(m, xxs);
    writeln(ans);
}

Measured memory_bytes: 2556
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 100000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 61
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define mat vector<vector<T>>
#define T long long
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;
const int N = 200000;
long long t[N + 5];

void inc(int x, long long val){
	for(++x;x <= N;x += x&-x){
		t[x] += val;
	}
}

long long query(int x){
	ll res = 0;
	for(++x;x > 0; x&=x-1){
		res += t[x];
	}
	return res;
}

bool b[N + 5];

int main(){
	fast_io();
	string s;cin >> s;
	int n = s.length();
	vector<int> p[26];
	cu(i,0,n){
		p[s[i] - 'a'].pb(i);
	}
	int odd = 0;
	cu(i,0,26)odd+=p[i].size()&1;
	if(odd > 1){
		cout << -1 << '\n';
		return 0;
	}
	int st[26] = {};

	ll ans = 0;

	int cur_start = 0;
	bool after = false;
	cd(i,n,0){
		if(!b[i]){
			int cur = s[i] - 'a';
			int l_ind = p[cur][st[cur]];
			if(st[cur] >= p[cur].size()/2){after = true;continue;}
			int greater = cur_start - query(l_ind);
			ans += l_ind - (cur_start - greater);
			if(after)++ans;
			b[l_ind] = true;
			inc(l_ind, 1);
			++cur_start;
			++st[cur];
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 2448
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
int n;
vector<vector<int>>edge(1e5+7,vector<int>());
vector<int>pr(1e5+7);
void dfs(int pre,int now)
{
  pr[now]=pre;
  //cout<<now<<" "<<pre<<endl;
  if(now==n-1)return;
  for(auto nn:edge[now])
  {
    if(pre==nn)continue;
    dfs(now,nn);
  }
  return;
}



class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  rep(i,n-1)
  {
    int a,b;cin>>a>>b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(-1,0);
  vector<int>node;
  int id=n-1;
  while(1)
  {
    node.push_back(id);
    if(id==0)break;
    id=pr[id];
    //cout<<id<<endl;

  }
  int cuts,cutt,ns=node.size();
  if(ns%2)
  {
    cuts=node[ns/2];
    cutt=node[ns/2-1];
  }
  else
  {
    cuts=node[ns/2];
    cutt=node[ns/2-1];
  }
  UnionFind uf(n);
  rep(i,n)
  {
    for(auto j:edge[i])
    {
      if(i==cuts&&j==cutt)continue;
      if(j==cuts&&i==cutt)continue;
      uf.connect(i,j);
    }
  }
  //cout<<cuts<<" "<<cutt<<endl;
  if(uf.size(uf.root(0))>uf.size(uf.root(n-1)))cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;




  return 0;

}


Measured memory_bytes: 11768
from collections import Counter
# これは, u749194f さんの改造です。
# オリジナルではございません。
# https://atcoder.jp/contests/abc162/submissions/11825963
n = int(input())
s = input()
flag = True
if len(set(s))<=2:
    print(0)
    flag = False
if flag:
    r = [i+1 for i in range(n) if s[i]=='R']
    b = [i+1 for i in range(n) if s[i]=='B']
    g = [i+1 for i in range(n) if s[i]=='G']
    minus = 0
    def cnt_cmb(a, b, c):
        cnt = 0
        set_c = set(c)
        for i in a:
            for j in b:
                if (i+j)/2 in set_c:
                    cnt += 1
        return cnt
    minus += cnt_cmb(r, b, g)
    minus += cnt_cmb(b, g, r)
    minus += cnt_cmb(g, r, b)
    a = Counter(s)
    rslt = 1
    for value in a.values():
        rslt *= value
    print(len(r)*len(b)*len(g)-minus)

Measured memory_bytes: 68752
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, q := nextInt(), nextInt()
	s := next()

	cnt := make([]int, n)
	for i := 1; i < n; i++ {
		cnt[i] = cnt[i-1]
		if s[i-1:i+1] == "AC" {
			cnt[i]++
		}
	}

	for i := 0; i < q; i++ {
		l, r := nextInt()-1, nextInt()-1
		puts(cnt[r] - cnt[l])
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

int main() {
  string a,b;
  int c;
  cin>>c;
  cin>>a>>b;
  rep(i,c){
      cout<<a.at(i)<<b.at(i);
  }
  cout<<endl;
}


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


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int f = 0;
            int ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (f == 0 && s[i] == '0')
                {
                    ans++;
                }
                else if (f == 1 && s[i] == '1')
                {
                    ans++;
                }

                f ^= 1;
            }

            Console.WriteLine(Math.Min(ans, s.Length - ans));
        }
    }
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  int n ;
  cin >> n ;
  ll a[n];
  rep(i,n) cin>>a[i];
  
  ll ans=0;
  ll sum=1;
  rep(i,n){
    if(a[i]==a[i+1]) sum++;
    else{
      ans+=sum/2;
      sum=1;
    }
    if(i==n-1) ans+=sum/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, M, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))


    nowtime = 0

    Asum = [0]
    Bsum = [0]
    tmp = 0
    for a in A:
        tmp += a
        Asum.append(tmp)
    tmp = 0
    for b in B:
        tmp += b
        Bsum.append(tmp)

    maxbooks = 0
    before = M
    bcount = M
    for acount in range(N+1):
        if Asum[acount] > K:
            continue
        while K < Asum[acount] + Bsum[bcount]:
            bcount -= 1
        maxbooks = max(maxbooks, acount+bcount)

    print(maxbooks)



if __name__ == '__main__':
    solve()

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

int main(){
  int n;
  cin >> n;
  int d;
  vector<int> vec;
  
  for(int i=0;i<n;++i){ 
    cin >> d;
    vec.push_back(d);
  }
  
  sort(vec.begin(),vec.end(), greater<int>());
  int sum, op=1;
  for(int i=0;i<n;i++){
    sum+=op*vec.at(i);
    op*=-1;
  }
  cout << sum << endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n, rt, siz[nsz + 5];
num w[nsz + 5];
map<num, int> id, to;
vector<int> g[nsz + 5];
vector<pair<int, int>> ans;

num inline cmp(num a, num b) {
    return a > b;
}

num calc(int u = rt, int dep = 0) {
    num res = dep;
    for (int v : g[u]) {
        res += calc(v, dep + 1);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    rt = n;
    cont (i, n) {
        cin >> w[i];
        to[w[i]] = i;
    }
    fill(siz, siz + sizeof(siz) / sizeof(int), 1);
    sort(w + 1, w + n + 1, cmp);
    cont (i, n) {
        id[w[i]] = i;
    }
    cout << ln;
    cont (u, n) {
        if (u == rt)  continue;
        int v = id[w[u] - n + 2 * siz[u]];
        if (!v) {
            cout << -1 << ln;
            return 0;
        }
        siz[v] += siz[u];
        g[v].push_back(u);
        ans.push_back({to[w[u]], to[w[v]]});
    }
    if (calc() != w[n]) {
        cout << -1 << ln;
        return 0;
    }
    for (pair<int, int> p : ans) {
        cout << p.first << ' ' << p.second << ln;
    }
}


Measured memory_bytes: 23668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<ll> a(m),b(m),c(m);
	FOR(i,0,m)cin>>a[i]>>b[i]>>c[i];
	ll d[n][n];
	FOR(i,0,n)FOR(j,0,n)d[i][j]=INF;
	FOR(i,0,n)d[i][i]=0;
	FOR(i,0,m){
		a[i]--;
		b[i]--;
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	}
	FOR(k,0,n)
		FOR(i,0,n)
			FOR(j,0,n)
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
	ll ans = 0;
	FOR(i,0,m){
		bool ok = false;
		FOR(k,0,n)FOR(j,0,n){
			if((d[k][a[i]]+c[i]+d[b[i]][j])==d[j][k])ok=true;
		}
		if(not ok)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
d={}
for i in range(int(input())):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
        
for j in range(int(input())):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d[t] = -1

print(max(0,max(d.values())))

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	string s, t;
	getline(cin, s);
	getline(cin, t);

	for (auto i = 0; i < s.size(); ++i)
	{
		if (s[i] != t[i])
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
}


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

using namespace std;

signed main(){
	int n; cin>>n;
	vector<int> a(n);
	bool zero = true;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		if(a[i] != 0) zero = false;
	}
	if(zero){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(n%3 != 0){
		cout<<"No"<<endl;
		return 0;
	}
	map<int, int> f;
	vector<int> c;
	for(int i: a){
		f[i]++;
		if(f[i] == (n/3)){
			c.push_back(i);
			f[i] = 0;
		}
	}	

	bool good = true;
	if(c.size() != 3) good = false;
	if(good){
		good = c[0]^c[1]^c[2];
		good = !good;
	}

	if(!good){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;	
	}
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int D; cin >> D;
    vector<int> c(26+1, 0);
    for(int i = 1; i <= 26; i++) cin >> c[i];
    vector<vector<int>> s(D+1, vector<int>(26+1, 0));
    for(int i = 1; i <= D; i++)for(int j = 1; j <= 26; j++) cin >> s[i][j];
    vector<int> t(D+1, 0);
    for(int i = 1; i <= D; i++) {
        t[i] = rand() % 25 + 1;
    }
    int ans = 0;
    for(int i = 1; i <= 100000; i++){
        vector<int> last(26+1, 0);
        auto f = [&](int d){
            int res = 0;
            for(int i = 1; i <= 26; i++){
                res += c[i] * (d - last[i]);
            }
            return res;
        };
        vector<int> old = t;
        t[rand() % (D-1) + 1] = rand() % 25 + 1;
        int tmp = 0;
        for(int day = 1; day <= D; day++){
            int con = t[day];
            tmp += s[day][con];
            last[con] = day;
            tmp -= f(day); 
        }
        if(ans > tmp) {
            t = old;
            continue;
        }
        ans = max(ans, tmp);
        //cout << ans << endl;
    }
    for(int i = 1; i <= D; i++) cout << t[i] << endl;
}

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

int main() {
  long n,nn,m;
  cin >> n >> m;
  vector<vector<long>> ans;
  nn=(n+1)/2*2-1;
  for(long i=1;i<=nn/4;i++) {
    ans.push_back({i,nn/4*2+1-i});
  }
  for(long i=0;i<(nn+1)/4;i++) {
    ans.push_back({nn/4*2+i+1,nn-i});
  }
  for(long i=0;i<m;i++) {
    if(ans[i][1]==nn&&n%4==0) ans[i][1]++;
    cout << ans[i][0] << " " << ans[i][1] << endl;
  }
}

Measured memory_bytes: 8180
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


// #define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

main(){
    ll int h=in(),w=in();
    int n=in();
    vecll ans(10);
    map<pii,int> mp;
    set<pii> v;
    rep(i,n){
        int a=in(),b=in();
        rep2(j,-2,0)rep2(k,-2,0){
            if(a+j>0 && a+j+2<=h && b+k>0 && b+k+2<=w)
            mp[{a+j,b+k}]++;
        }
    }
    for(auto e:mp){
        ans[e.second]++;
    }
    ll sum=(h-2)*(w-2);
    rep2(i,1,9)sum-=ans[i];
    ans[0]=sum;
    for(auto e:ans)cout<<e<<endl;
}

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

int main(){
    ll R,G,B,n,ans=0;
    cin >> R >> G >> B >> n;
    for(int r = 0;r <= n/R;r ++){
        int rem = n-R*r;
        for(int g = 0;g <= rem/G;g ++){
            int rem1;
            rem1 = rem-G*g;
            if(rem1%B==0) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    c = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    c += 1

    print(c)



Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		String S=sc.next();
		Deque<Integer> tmp=new ArrayDeque<Integer>();
		for(int i=0; i<N; i++) {
			if(S.charAt(i)=='(') {
				tmp.push(0);
			}
			else if(S.charAt(i)==')') {
				if(tmp.size()==0) {
					tmp.push(1);
				}
				else {
					if(tmp.size()==0) {
						tmp.push(1);
					}
					else {
						if(tmp.peek()==0) {
							tmp.remove();
							//pl("!");
						}
						else {
							tmp.push(1);
							//pl("?");
						}
					}
				}
			}
		}
		int mae=0;
		int ato=0;
		int size=tmp.size();
		//pl(size);
		for(int i=0; i<size; i++) {
			int get=tmp.poll();
			if(get==0) {
				ato++;
			}
			else if(get==1) {
				mae++;
			}
		}
		StringBuilder sb=new StringBuilder();
		for(int i=0; i<mae; i++) {
			sb.append("(");
		}
		sb.append(S);
		for(int i=0; i<ato; i++) {
			sb.append(")");
		}
		pl(sb.toString());

	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;
ll C[32];
ll S[366][32];
ll T[366];
ll P[32];
ll L[32];
set<int> H[32];

uint32_t xor128(void) {
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123;
  uint32_t t;

  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

ll calcPenalty(int con, int D) {
  ll ret = 0;
  ll prev = 0;
  for (auto& it: H[con]) {
    ll dif = it - prev;
    ret += (dif - 1) * dif / 2;
    prev = it;
  }
  ll dif = D + 1 - prev;
  ret += (dif - 1) * dif / 2;
  ret *= C[con];
  return ret;
}

ll update(int day, int pcon, int ncon, int D) {
  ll pen = -P[pcon] - P[ncon];
  H[pcon].erase(day);
  H[ncon].insert(day);
  T[day] = ncon;
  ll vP = calcPenalty(pcon, D);
  ll vN = calcPenalty(ncon, D);
  pen += vP + vN;
  ll ret = -pen;
  ret -= S[day][pcon];
  ret += S[day][ncon];
  if (ret > 0) {
    P[pcon] = vP;
    P[ncon] = vN;
    T[day] = ncon;
  } else {
    H[pcon].insert(day);
    H[ncon].erase(day);
  }
  return ret;
}

int main() {
  clock_t time_start = clock();
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  for (int i=1; i<=26; i++) {
    cin >> C[i];
  }
  for (int i=1; i<=D; i++) {
    for (int j=1; j<=26; j++) {
      cin >> S[i][j];
    }
  }
  for (int day=1; day<=D; day++) {
    ll ocon = 1;
    ll oval = S[day][ocon] + (day - L[ocon]) * C[ocon];
    for (int con=2; con<=26; con++) {
      ll val = S[day][con] + (day - L[con]) * C[con];
      if (val > oval) {
        ocon = con;
        oval = val;
      }
    }
    T[day] = ocon;
    L[ocon] = day;
    H[ocon].insert(day);
  }
  for (int con=1; con<=26; con++) {
    P[con] = calcPenalty(con, D);
  }
  while (1) {
    clock_t time_now = clock();
    if ((double)(time_now - time_start) > (double)CLOCKS_PER_SEC * 1.9) {
      break;
    }
    int day = xor128() % D + 1;
    int ncon = xor128() % 26 + 1;
    int pcon = T[day];
    update(day, pcon, ncon, D);
  }
  for (int day=1; day<=D; day++) {
    cout << T[day] << '\n';
  }
  cout << flush;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> X(N);
	for(int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	int res = 0;
	for(int i = 0; i < N - 1; ++i) {
		res += min(B, A * (X[i+1] - X[i]));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define all(a) a.begin(),a.end()
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){x=x>y?y:x;}
template<class T> inline void gmax(T &x,const T &y){x=x<y?y:x;}
template<class T> inline bool Gmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T> inline bool Gmax(T &x,const T &y){return x<y?x=y,1:0;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=2005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,x,sum;
bitset<N*N> dp;

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d",&n);
	dp[0]=1;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		dp|=dp<<x;
		sum+=x;
	}
	sum=(sum+1)>>1;
	for(int i=sum;;i++)
		if(dp[i]){printf("%d\n",i);return 0;}
	return 0;
}

Measured memory_bytes: 1664
fun main(args: Array<String>) {
    // Your code here!
    var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
    var n = readLine()!!.toInt()
    var s = readLine()!!.toMutableList()
    
    if(n != 0){
        for(i in 0..s.size-1){
            var index = alpha.indexOf(s[i]) + n
            if(index > 25){
                index %= 26
            }
            s[i] = alpha[index]
        }
    }
    print(s.fold(""){i,v -> i+v})
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int[] count = new int[26];
		while(true){
//			//int x = Integer.parseInt(br.readLine());
//			String input = br.readLine();
//
//			if(input.equals("0")){
//				break;
//			}
//
//			int sum = 0;
//			for(int i = input.length() - 1; i >= 0 ; i--){
//				sum += input.charAt(i) - '0';
//			}
//
//			System.out.println(sum);
//		}
			String input = br.readLine();
			if(input == null){
				break;
			}

			
			for(int i = 0; i < input.length() ; i++){
				char c = input.charAt(i);
				if(Character.isUpperCase(c)){
					c = Character.toLowerCase(c);
				}

				if(Character.isAlphabetic(c)){
					//System.out.println(c);
					count[c - 'a']++;
				}
			}
		}
		
		for(int i = 0; i < 26; i++){
			System.out.println((char)('a'+i) + " : " + count[i]);
		}
//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24284
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
int main()
{
    char c,h;
    cin>>c;
    c++;
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
int n,i,j,temp,count=0;
int A[N];

scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);

for(i=0;i<n-1;i++){
for(j=n-1;j>i;j--){
if(A[j]<A[j-1]){
temp=A[j];
A[j]=A[j-1];
A[j-1]=temp;
count++;
}
}
}

for(i=0;i<n;i++){
printf("%d",A[i]);
if(i!=n-1) printf(" ");
}
printf("\n");
printf("%d\n",count);

return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int		main()
{
	char		N, M ,O;

	scanf("%c%c%c\n", &N, &M, &O);
	if (N == '7' || M == '7' || O == '7')
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}


Measured memory_bytes: 1644
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
        


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(){

    while(1){
    int n; cin >> n;
    if(!n) break;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i > 0) a[i] += a[i - 1];
    }
    a[0] = 0;
    int ans = a[1];
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            ans = max(ans, a[j] - a[i]);
        }
    }

    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 2000 + 5;
int n, m;
struct Tree {
	vector<int> G[maxN];
	int lca[maxN][maxN];
	int dep[maxN];
	vector<int> build(int u, int fa) {
		vector<int> x(1, u);
		lca[u][u] = u;
		for(int v : G[u]) if(v != fa) {
			dep[v] = dep[u] + 1;
			auto y = build(v, u);
			for(int p : x) for(int q : y) lca[p][q] = lca[q][p] = u;
			x.insert(x.end(), y.begin(), y.end());
		}
		return x;
	}
	void init(int n) {
		for(int u = 0; u <= n; ++u) G[u].clear();
		for(int i = 0; i < n - 1; ++i) {
			int x, y; cin >> x >> y;
			G[x].push_back(y);
			G[y].push_back(x);
		}
		dep[1] = 0;
		auto lst = build(1, -1);
		assert((int)lst.size() == n);
	}
	bool align(int x, int y, int z) {
//		printf("%d %d %d\n", x, y, z);
		auto judge = [&](int top, int low, int aside) {
			return lca[aside][low] == low || lca[aside][top] == lca[aside][low];
		};
		if(lca[x][y] == x) return judge(x, y, z);
		else if(lca[x][y] == y) return judge(y, x, z);
		else if(lca[x][z] == x) return judge(x, z, y);
		else if(lca[x][z] == z) return judge(z, x, y);
		else if(lca[y][z] == y) return judge(y, z, x);
		else if(lca[y][z] == z) return judge(z, y, x);
		else return false;
	}
} T;
ULL adj[maxN][maxN / 64 + 5];

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	T.init(n);
	queue<pii> Q;
	memset(adj, 0, sizeof(adj));
	for(int i = 1; i <= m; ++i) {
		int x, y;
		cin >> x >> y;
		Q.emplace(x, y); Q.emplace(y, x);
		adj[x][y / 64] |= 1ull << (y % 64);
		adj[y][x / 64] |= 1ull << (x % 64);
	}
	for(int u = 1; u <= n; ++u) adj[u][u / 64] |= 1ull << (u % 64);
	int cnt = 0;
	while(Q.size()) {
		int x = Q.front().first, y = Q.front().second;
//		printf("%d %d\n", y, x);
		Q.pop(); cnt++;
		for(int i = 0, b = 0; b <= n; ++i, b += 64) {
			ULL mask = adj[x][i] & ~adj[y][i];
//			cout << bitset<10>(adj[x][i]) << endl;
//			cout << bitset<10>(adj[y][i]) << endl;
//			cout << bitset<10>(mask) << endl;
			while(mask) {
				int p = __builtin_ctzll(mask);
				mask ^= (1ull << p);
				int v = b + p;
				if(T.align(y, x, v)) {
//					printf("got\n");
					adj[y][v / 64] |= 1ull << (v % 64);
					adj[v][y / 64] |= 1ull << (y % 64);
					Q.emplace(y, v); Q.emplace(v, y);
				}
			}
		}
	}
	printf("%d\n", cnt / 2);
	return 0;
}


Measured memory_bytes: 49412
# -*- coding: utf-8 -*-

N = int(input())
array = [int(input()) for i in range(N)]

array_sorted = sorted(array, reverse=True)
max_index = array.index(array_sorted[0])
max_value = array_sorted[0]
second_value = array_sorted[1]

for i in range(N):
  if array[i] == max_value:
    print(second_value)
  else:
    print(max_value)

Measured memory_bytes: 70488
#include<iostream>
#include<string.h>
int main()
{
	char str[21];
	std::cin >> str;
	const int length = strlen(str);
	for(int i = length - 1; i >= 0; i--)
	{
		std::cout << str[i];
	}
	std::cout << std::endl;
	return 0;
}


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

#define llint long long int

using namespace std;

int main(){
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;

    cin >> K;

    cout << a[K - 1] << endl;
}

Measured memory_bytes: 256
import math
A,B=map(int,input().split())
x=0
if A%2==0:#偶数スタート
    if(B%2==0):#偶数エンド
        if((B-A)/2 %2 == 0 ):#1が偶数個ならば？
            print(B)
        else:
            print(1^B)
    else:#奇数エンド
        if(((B+1) - A)/2 %2 == 0):#1が偶数個ならば？
            print(0)
        else:
            print(1)
else:#奇数スタート
    if(B%2==0):#偶数エンド
        if((B-(A+1))/2 %2 ==0):
            print(A^B)
        else:
            print(A^B^1)
    else:#奇数エンド
        if((B-A)/2 %2 == 0):
            print(A)
        else:
            print(A^1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct comparator{
	bool operator()(ll const&a,ll const&b){
		return a<b;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	priority_queue<ll,vector<ll>,comparator>pq;
	for(int i=0;i<n;i++){
		ll temp;
		cin>>temp;
		pq.push(temp);
	}
	while(!pq.empty() && m--){
		ll temp=pq.top();
		pq.pop();
		pq.push(temp/2);
	}
	ll sum=0;
	while(!pq.empty()){
		sum+=pq.top();
		pq.pop();
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1400
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin >> a >> b;
    if(a+b>=10) cout << "error";
    else cout << a+b;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
// ConsoleApplication85.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int a[105];
int main()
{
	int n;
	double aa = 0;
	double as=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		aa += a[i];
	}
	sort(a, a + n);
	aa /= n;
	if (aa - floor(aa) >= 0.5)
	{
		aa = floor(aa) + 1;
	}
	else
	{
		aa = floor(aa);
	}
	for (int i = 0; i < n; i++)
	{
		as += (a[i] - aa) * (a[i] - aa);
	}
	cout << setprecision(0)<<fixed<<as << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a[110],b[110];
int main()
{
    int n,m,x,y,i,j;
    cin >> n >> m >> x >> y;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i=0;i<m;i++)
        cin >> b[i];
    sort(a,a+n);
    sort(b,b+m);

	if(x<=a[n-1] && a[n-1]<b[0] && b[0]<=y)
    	cout << "No War" << endl;
    else
    	cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
C = []
for _ in range(3):
    C.append(list(map(int,input().split())))

for a1 in range(max(C[0])+1):
    b1 = C[0][0] - a1
    for a2 in range(max(C[1])+1):
        b2 = C[1][1] - a2
        if a1 + b2 != C[0][1] or a2 + b1 != C[1][0]:
            continue
        for a3 in range(max(C[2])+1):
            b3 = C[2][2] - a3
            if a1 + b3 == C[0][2] and a2 + b3 == C[1][2] and a3 + b1 == C[2][0] and a3 + b2 == C[2][1]:
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

long double pi=3.1415926535897933238463643383279;

int main(){cout<<fixed<<setprecision(20);
		   long double a,b,x;
           cin>>a>>b>>x;
           x/=a;
           if(2*x<a*b){
             long double l=x*2/b;
             cout<<atan(b/l)*180/pi<<endl;
           }
           else{
            x=a*b-x;
             long double l=x*2/a;
             cout<<atan(l/a)/pi*180<<endl;
           }
}

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

using namespace std;

long long myatoll(char c) {
    return (long long)atoi(&c);
}

long long P_is_not_2_5(long long N, long long P, const string& S) {
    map<long long, long long> residual;
    residual.insert(make_pair(0LL, 1LL));
    long long pow10 = 1;
    long long curr = 0LL;
    for (long long i = N - 1; i >= 0; --i) {
        int s = atoi(S.substr(i, 1).c_str());
        int m = (s * pow10 + curr) % P;
        if (residual.count(m) == 0) {
            residual.insert(make_pair(m, 0LL));
        }
        residual[m] += 1;
        curr = m;
        //long long x = (curr + pow10 * myatoll(S[i])) % P;
        //if (residual.count(x) == 0) {
        //    residual.insert(make_pair(x, 1LL));
        //}
        //else {
        //    residual[x] += 1;
        //}
        //residual[x] += 1;
        //curr = x;
        pow10 *= 10;
        pow10 %= P;
    }
    long long ans = 0;
    for (auto it : residual) {
        long long n = it.second;
        if (n >= 2) {
            ans += n * (n - 1) / 2;
        }
    }
    return ans;
}

long long P_is_2_or_5(long long N, long long P, const string& S) {
    long long ans = 0LL;
    for (long long i = 0; i < N; ++i) {
        long long c = myatoll(S[i]);
        if (c % P == 0) {
            ans += i + 1;
        }
    }
    return ans;
}

void Main() {
    long long N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    long long ans = 0LL;
    if (P == 2LL || P == 5LL) {
        ans = P_is_2_or_5(N, P, S);
    }
    else {
        ans = P_is_not_2_5(N, P, S);
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(void){
    vector<int> A(10010);
    for(int i=0;i<10010;i++){
        cin>>A.at(i);
        if(A.at(i)==0){
            break;
        }
        cout<<"Case"<<" "<<i+1<<":"<<" "<<A.at(i)<<endl;
    }
}



Measured memory_bytes: 3084
n = int(input())
s = input()

count = 0

for i in range(1000):
  a = "{0:03d}".format(i)
  if a[0] in s:
    idx1 = s.index(a[0])
    s1 = s[idx1+1:]
    if a[1] in s1:
      idx2 = s1.index(a[1])
      s2 = s1[idx2+1:]
      if a[2] in s2:
        count += 1
print(count)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

int main()
{
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	int count = 0;
	for(int i = 0; i <= (N/R) + 1; i++){
		for(int j = 0; j <= (N/G) + 1; j++){
			if( (N - i * R - j * G) >= 0 && (N - i * R - j * G) % B == 0){
				count++;
				//cout<<i<<" "<<j<<" "<< (N - i * R - j * G)<<endl;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

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

int main(void)
{
    string s;
    cin >> s;
    bool flag = true;
    for (int i = 1; i < 4; i++)
    {
        if(s[i-1]==s[i])
        {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Good":"Bad") << endl;
}

Measured memory_bytes: 256