akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  string a;
  cin >> a;
  rep(i,8){
    int tmp = a[0]-'0';
    string s;
    rep(j,3){
      if(i & (1<<j)){
        tmp += a[j+1]-'0';
        s.pb('+');
      } else {
        tmp -= a[j+1]-'0';
        s.pb('-');
      }
    }
    if(tmp==7){
      cout << a[0];
      rep(j,3){
        cout << s[j] << a[j+1];
      }
      cout << "=7";
      return 0;
    }
  }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    if (s.length() + 1 != t.length()) {
        cout << "No" << endl;
        return 0;
    }
    t.pop_back();
    if (s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
    int h, w;
    char[][] field;
    int[][] visited;
    int ans = Integer.MAX_VALUE;
    int[] dx = {1, 0};
    int[] dy = {0, 1};


    void run() {
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        field = new char[h][w];
        visited = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                visited[i][j] = 1000000;
            }
        }

        for (int i = 0; i < h; i++) {
            field[i] = sc.next().toCharArray();
        }
        dfs(0, 0, field[0][0] == '.' ? 0 : 1, field[0][0]);
        System.out.println(ans);
    }

    void dfs(int x, int y, int count, char c) {
        if (x == h - 1 && y == w - 1) {
            ans = Math.min(count, ans);
            return;
        }
        visited[x][y] = count;
            for (int i = 0; i < 2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (0 <= nx && nx < h && 0 <= ny && ny < w) {
                    char nc = field[nx][ny];
                    int nCount = count + (nc == c || nc == '.' ? 0 : 1);
                    if (nCount < visited[nx][ny]) {
                        dfs(nx, ny, nCount, nc);
                    }
                }
            }
    }

    void search(int x, int y) {

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

void solve()
{
    int L; cin >> L;
    string S; cin >> S;

    int Max = 0;
    rep(i, L)
    {
        if(S[i]!='.')continue;
        int esti = 0;
        int left = 0;
        
        int cnt = 0;
        for(int j = i - 1; j >= 0; j--)
        {
                if(S[j] == '.')break;
                else if(S[j] == 'W')
                {
                    if(esti==0)esti = cnt;
                    
                }
                else{
                    cnt++;
                    left = 1;
                }
        }

        int es = 0;
        int right = 0;
        cnt=0;
        repi(j, i + 1, L)
        {
            if(S[j] == '.')break;
                else if(S[j] == 'W')
                {
                    if(es==0)es = cnt;
                    
                }
                else{
                    cnt++;
                    right = 1;
                }
        }

        if(left && right)continue;
        Max = max(Max, es + esti);
    }
    cout << Max << endl;
}

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


Measured memory_bytes: 3216
#include <stdio.h>

int main(void){
int a,b,i,j;
while(1){
scanf("%d",&a);
scanf("%d",&b);
if(a==0 && b==0){
break;
       } 
else{
for ( i=0; i < a; i++ ){
    for ( j=0; j < b; j++ ){
        printf("#");
    }
    printf("\n");
        }
}
 printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,K,Q;
 cin >>N>>K>>Q;
 vector<int>vec(N,-Q);
 for(int i=0;i<Q;i++){
   int A;
   cin >>A;
   vec.at(A-1)+=1;
 }
 for(int i=0;i<N;i++){
     
     if(K+vec.at(i)>0){
         cout <<"Yes"<<endl;
     }
     else{
         cout <<"No"<<endl;
      }
    }
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)
const int MOD = 998244353;

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	ll dp[c+1][d+1];
	dp[a][b] = 1;
	REP(j, b+1, d+1) dp[a][j] = dp[a][j-1] * a % MOD;
	REP(i, a+1, c+1) dp[i][b] = dp[i-1][b] * b % MOD;

	REP(i, a+1, c+1){
		REP(j, b+1, d+1){
			dp[i][j] = (dp[i-1][j]*j%MOD + dp[i][j-1]*i%MOD) % MOD;
			dp[i][j] -= dp[i-1][j-1]*(i-1)%MOD * (j-1)%MOD;
			if(dp[i][j]<0) dp[i][j] += MOD;
		}
	}

	printf("%ld\n", dp[c][d]);
	return 0;
}


Measured memory_bytes: 73844
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
int main()
{
    long A;
    long B;
    long N;
	
	long i;
	long ansx;
	long ans;

	i = 0;
	ans = 0;
    cin >> A >> B >> N;
 
	ansx = min((B-1), N);

	ans = (int)(A*ansx/B) - A*((int)(ansx/B));

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

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){

   int N, K;
   cin >> N >> K;
   int sum = 0;
   for(int i = 0; i < N; i++){
      if(i % 2 == 0){
         sum++;
      }
   }
   if(sum >= K){cout << "YES"<<endl;}
   else{cout << "NO" <<endl;}
   return 0;

}

Measured memory_bytes: 256
using System;

class Program
{
    //ITP1_6_A:   Reversing Numbers
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());

        string[] vals = Console.ReadLine().Split(' ');

        for (int i = vals.Length - 1; i >= 0; i--) {
            if (i < vals.Length - 1) { Console.Write(" "); }
            Console.Write(vals[i]);
        }
        Console.WriteLine(string.Empty);
    }
}



Measured memory_bytes: 15948
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

template <typename T>
struct SegmentTree{
    using F = function<T(T,T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;

    SegmentTree(){}
    SegmentTree(F f,T ti):f(f),ti(ti){}

    void init(int n_){
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }

    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }

    void set_val(int k,T x){
        dat[k+=n]=x;
        //dat[k+=n]+=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }

    T query(int a,int b){ //[a,b)
        if(a>=b) return ti;
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    string S; cin >> S;
    rep(i,N) S+='t';
    int Q; cin >> Q;
    auto f=[](char a,char b){return max(a,b);};
    vc<SegmentTree<int>> segs;
    rep(i,26){
        SegmentTree<int> seg(f,0);
        vi v(N,0);
        rep(j,N){
            if(S[j]==(char)(i+'a')){
                v[j]=1;
            }
        }
        seg.build(v);
        segs.eb(seg);
    }
    rep(q,Q){
        int s; cin >> s;
        if(s==1){
            int x; char c; cin >> x >> c;
            x--;
            segs[S[x]-'a'].set_val(x,0);
            segs[c-'a'].set_val(x,1);
            S[x]=c;
        } else {
            int a,b; cin >> a >> b;
            a--; b--;
            int cnt=0;
            rep(i,26){
                if(segs[i].query(a,b+1)>0) cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 146672
import math
 
k = int(input())
 
cache = {}
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans = ans + cache.get( (a,b,c), math.gcd(math.gcd(a, b), c))
print(ans)

Measured memory_bytes: 67728
#include<bits/stdc++.h>
#define MAX 100001
using namespace std;
struct Struct
{
	int Left;
	int Right;
	int Dist;
};
int Total,Have;
Struct Array[2*MAX];
int Fa[MAX];
int Dis[MAX];
inline int Find(int X)
{
	if(X!=Fa[X])
	{
		register int Fax;
		Fax=Fa[X];
		Fa[X]=Find(Fa[X]);
		Dis[X]+=Dis[Fax];
	}
	return Fa[X];
}
int main(void)
{
	register int i;
	cin>>Total>>Have;
	for(i=1;i<=Have;i++)
	{
		cin>>Array[i].Left>>Array[i].Right>>Array[i].Dist;
	}
	for(i=1;i<=Total;i++)
	{
		Fa[i]=i;
	}
	for(i=1;i<=Have;i++)
	{
		register int Fl,Fr;
		Fl=Find(Array[i].Left);
		Fr=Find(Array[i].Right);
		if(Fl==Fr&&Dis[Array[i].Left]-Dis[Array[i].Right]!=Array[i].Dist)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(Fl!=Fr)
		{
			Fa[Fl]=Fr;
			Dis[Fl]=Array[i].Dist+Dis[Array[i].Right]-Dis[Array[i].Left];
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 6636
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;



int main()
{
    ll M;
    cin >> M;
    ll ans=-1;
    ll sum=0;
    for(ll i=0; i<M; i++){
        ll d,c;
        cin >> d >> c;
        sum+=d*c;
        ans+=c;
    }
    
    if(sum>9){
        ans+=(sum-9)/9;
        if(sum%9!=0) ans++;
    }
    
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << (a + b + c - std::max(std::max(a, b), c)) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,m;
	char a[55][55];
	char b[55][55];
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
		for(int i=1;i<=m;i++)
		scanf("%s",b[i]+1);
		int flag=0;
		for(int e=1;e<=n-m+1;e++)
		for(int i=1;i<=n-m+1;i++)
		{
			int cnt=0;
			for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
			{
				if(b[j][k]==a[e+j-1][i+k-1])
				cnt++;
			}
			if(cnt==m*m)
			flag=1;
		}
		if(flag)
		printf("Yes\n");
		else
		printf("No\n");
	}
	return 0;
 } 

Measured memory_bytes: 256
a=[]
b={}
n,m = map(int,input().split())
for _ in range(m):
    i,j = map(int,input().split())
    if i==1:
        a.append(j)
    elif j==n:
        b[i]=1
for i in a:
    if i in b:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 18428
h, w = [int(i) for i in input().split()]
 
s = []
for i in range(h):
  s.append(input())

set_i = set()  
set_j = set()

for i in range(h):
    for j in range(w):
      if s[i][j] =="#":
        set_i.add(i)
        set_j.add(j)
        
for i in range(h):
  answer = ""
  if i in set_i:
    for j in range(w):
      if j in set_j:
        answer += s[i][j]
    print(answer)

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

int main(){
    int n,m,r;
    cin>>n>>m>>r;
    int mati[r];
    for(int i=0;i<r;i++){
        cin>>mati[i];
        mati[i]--;
    }
    int a,b,c[n][n]={};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if(i!=j) c[i][j]=1e9;
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        cin>>c[a][b];
        c[b][a]=c[a][b];
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    }
    int ans=1e9;
    sort(mati,mati+r);
    while(next_permutation(mati,mati+r)){
        int ret=0;
        for(int i=0;i<r-1;i++){
            ret+=c[mati[i]][mati[i+1]];
        }
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

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

  ll ans = 0;
  ll cnt = 0;
  rep(i, (ll)s.size()) {
    bool cond = s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C';
    if (!cond){
      if(cnt > 0){
        chmax(ans, cnt);
      }
      cnt = 0;
    }
    else cnt++;
  }
  if (cnt > 0) chmax(ans, cnt);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x, t int
	fmt.Scan(&n, &x, &t)
	fmt.Println((n + x - 1) / x * t)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
n,k=map(int,input().split())
red=n-k
blue=k
mod=10**9+7
fac=[1]*n
for i in range(n-1):
  fac[i+1]=((i+2)*fac[i])
def comb(a,b):
  if a==0:
    return 1
  if b==0 or b==a:
    return 1
  return (fac[a-1]//(fac[a-b-1]*fac[b-1]))%mod
for i in range(k):
  print((comb(n-k+1,i+1)*comb(k-1,i))%mod)

Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
/*int n,m;
int a[100][100]={0};
int f(int x,int y)
{
        if(x>=0&&x<n&&y>=0&&y<m){
                a[x][y]=a[x][y]^1;
        }
}
int main()
{
        while(cin>>n>>m){
                memset(a,0,sizeof(a));
                for(int i=0;i<n;i++){
                        for(int j=0;j<m;j++){
                                f(i,j);f(i-1,j);f(i-1,j-1);f(i,j-1);
                                f(i+1,j+1);f(i+1,j);f(i,j+1);f(i-1,j+1);
                                f(i+1,j-1);
                        }
                }
                int ans=0;
                for(int i=0;i<n;i++){
                        for(int j=0;j<m;j++){
                                if(a[i][j]==1) ans++;
                        }
                }
                cout<<ans<<endl;
        }
}*/
int main()
{
        LL n,m;
        cin>>n>>m;
        LL ans=0;
        ans=abs(n-2)*abs(m-2);
        cout<<ans<<endl;
}


Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)
S = gets.chomp
LR = Q.times.map { gets.split.map(&:to_i) }

L = 0
R = 1

ac_counts = Array.new(S.size, 0)
1.upto(S.size - 1) do |i|
  if S[i-1] == 'A' && S[i] == 'C'
    ac_counts[i] = ac_counts[i-1] + 1
  else
    ac_counts[i] = ac_counts[i-1]
  end
end

LR.each do |lr|
  puts ac_counts[lr[R]-1] - ac_counts[lr[L]-1]
end


Measured memory_bytes: 11004
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 1e5 + 5 ;
const int mod = 1e9 + 5 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif


void solve()
{
	int a,b ;
	cin >> a >> b ;
	int odd_b = b - (1 - b%2) ;
	int k = (odd_b - a + 1)/2 ;
	int ans = k % 2 ;
	if(a%2)
		ans ^= a ;
	if(b%2 == 0)
		ans ^= b ; 
	cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
   // cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
  //stream
  friend ostream& operator<<(ostream& os, const mint a);
};
ostream& operator<<(ostream& os, const mint a){
  os << a.x;
  return os;
}

int main(void) {
	int l,r; cin >> l >> r;
	r = min(r,l+2019);
	mint ans=2018;
	rep2(i,l,r)rep2(j,i+1,r+1){
//		cout << minti << " " << mintj << endl;
		ans = min(ans.x,(mint(i)*mint(j)).x);
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &x :a){
        cin >> x;
    }
    map<int, int > mp;
    for(auto &x :a){
        mp[x]++;
        mp[x+1]++;
        mp[x-1]++;
    }
    int res = 0;
    for (auto x:mp){
        res = max(res,x.second);
    }
    cout << res << endl;
}


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



int main(){
  int N,avg,ans=0;
  cin >> N;
  vector<int> x(N);
  double sum=0.0;
  for(int i=0;i<N;++i) cin >> x[i];
  for(int i=0;i<N;++i) sum += double(x[i]);
  avg = round(sum/N);
  for(int i=0;i<N;++i){
    ans += pow((x[i]-avg),2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define PB push_back
using namespace std;
const int INF = 3643648101919114514;
typedef vector<int> VI;

int n, k, a[2010], b[2010];
int ans = 0;
VI node[2010];

int solve(int now, int pre, int times)
{
  if(times == k / 2){
    return 1;
  }
  else{
    int ret = 0;
    for(auto pt:node[now])
      if(pt != pre)
	ret += solve(pt, now, times + 1);
    return ret + 1;
  }
}

signed main()
{
  cin >> n >> k;
  for(int i = 1; i <= n - 1; i++)
    cin >> a[i] >> b[i];

  for(int i = 1; i <= n - 1; i++){
    node[a[i]].PB(b[i]);
    node[b[i]].PB(a[i]);
  }
  
  if(k % 2)
    for(int i = 1; i <= n - 1; i++)
      ans = max(ans, solve(a[i], b[i], 0) + solve(b[i], a[i], 0));
  else
    for(int i = 1; i <= n; i++)
      ans = max(ans, solve(i, -1, 0));

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int count = 0;

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

        if (a >= b)
        {
            count += a;
            a--;
        }
        else
        {
            count += b;
            b--;
        }
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[3];
	for (int i = 0; i < 3; i++) cin >> a[i];

	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	
	int ans = 1145141919;
	for (int i = 0; i < (1 << (2 * n)); i++) {
		vector<int> st(n);
		int hoge = i;
		for (int j = 0; j < n; j++) {
			st[j] = hoge & 3;
			hoge /= 4;
		}

		vector<int> x(4, 0);
		vector<int> cnt(4, 0);
		for (int j = 0; j < n; j++) {
			x[st[j]] += l[j];
			cnt[st[j]]++;
		}

		int cost = 0;
		bool f = true;
		for (int j = 0; j < 3; j++) {
			if (cnt[j] == 0) f = false;
			cost += max((cnt[j] - 1) * 10, 0);
			cost += abs(x[j] - a[j]);
		}
		if (f) ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

#A.sort() #これを実装するぞ
def qsort(seq, left, right):
    #[再帰の終了条件は？]
    #print(left,right)
    if left == right: 
      return seq
    '''elif left+1 == right:
        if seq[left]>seq[right]:
            seq[left],seq[right] = seq[right], seq[left]
        return seq'''
    med = (left+right)//2
    pivot = seq[med] #[与えられた範囲の真ん中に位置する要素]
    #カーソルを⽤意
    cur_l = left
    cur_r = right
    #このwhile文で並べ替え終わらせる
    while True:
        #[左カーソル（cur_l）をpivotより⼤きい要素まで進める]
        while seq[cur_l] < pivot:
            if cur_l >= cur_r: break
            cur_l += 1
        #[右カーソル（cur_r）をpivotより⼩さい要素まで進める]
        while seq[cur_r] > pivot:
            if cur_r <= cur_l: break
            cur_r -= 1
        # カーソル交差でループ終了
        if cur_r <= cur_l: 
          break
        # cur_l < cur_rだが，左側にpivotより⼤きい要素，右側にpivotより⼩さい要素がそれぞれ⾒つかった．
        #[cur_rの要素とcur_lの要素を⼊れ替える]
        seq [cur_l], seq[cur_r] = seq[cur_r], seq[cur_l]
        cur_l += 1
        cur_r -= 1
    #print(seq)
    cut = -1
    if cur_l == cur_r:
        #print('pp')
        if seq[cur_l] <= pivot:
            #print('qq')
            cut = cur_l
        else:
            #print('rr')
            cut = cur_l-1
    elif cur_l == cur_r+1:
        #print('ss')
        cut = cur_r
    #print(left,cut,cut+1,right)
    # このwhileループを抜けるということは，左右の要素の⼊れ替えが完了したこと．
    # 分割したグループそれぞれに対して，qsortを実⾏したい！ -> 再帰
    #[左側だけでqsort]
    qsort(seq,left,cut)
    #[右側だけでqsort]
    qsort(seq,cut+1,right)
    # どんな引数を与えれば良い？

N = int(input())
vec = list(map(int,input().split()))
qsort(vec,0,N-1)
ans = vec[0]
for i in range(N-1):
  ans = (ans + vec[i+1])/2
print(ans)




Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll unsigned long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
ll max(ll x,ll y)
{
	if(x>y)
		return x;
	return y;
}
ll min(ll x,ll y)
{
	if(x<y)
		return x;
	return y;
}
int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0;
    int base = 1; 
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) 
	{ 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
    return dec_value; 
} 
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin.ignore(numeric_limits<streamsize>::max(),'\n');
    //const unsigned ll M=1000000007;
    int n;
    cin >> n;
    if(n>=400 && n<=599) cout << 8;
    else if(n>=600 && n<=799) cout << 7;
    else if(n>=800 && n<=999) cout << 6;
    else if(n>=1000 && n<=1199) cout << 5;
    else if(n>=1200 && n<=1399) cout << 4;
    else if(n>=1400 && n<=1599) cout << 3;
    else if(n>=1600 && n<=1799) cout << 2;
    else cout << 1;
    return 0;
}



Measured memory_bytes: 3652
A=[]
for _ in range(3):
    A.append(list(map(int,input().split())))
n=int(input())
B=[]
for _ in range(n):
    B.append(int(input()))

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

B=get_unique_list(B)
s=0
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    s+=1
elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
    s+=1
else:    
    for i in range(3):
        if A[0][i] in B and A[1][i] in B and A[2][i] in B:
            s+=1
        elif A[i][0] in B and A[i][1] in B and A[i][2] in B:
            s+=1

if s>=1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9144
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

#define long long long

const int N = 2e5 + 2;

int n, a[N];
queue<set<int>*> q;

set<int>* Merge(set<int> *a, set<int> *b)
{
    if (a->size() < b->size()) return Merge(b, a);
    for (int x: *b) a->insert(x);
    b->clear();
    return a;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        set<int> *s = new set<int>();
        s->insert(a[i]);
        q.push(s);
    }
    sort(a + 1, a + 1 + n);
    long res = 0;
    for (int i = 1; i <= n; ++i)
    {
        set<int> *s = new set<int>();
        do
        {
            s = Merge(s, q.front());
            q.pop();
        } while (s->find(a[i]) == s->end());
        s->erase(a[i]);
        res += s->size();
        q.push(s);
    }
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 39576
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5],b[5];
  int ans=0;
  cin>>a[0]>>a[1]>>b[0]>>b[1];
  sort(a,a+2);
  sort(b,b+2);
  ans=a[0]+b[0];
  cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 3636
n = input()
li = [input() for i in range(int(n))]

disp = {}

for i in range(int(n)):
    city, point = li[i].split()
    if not (city in disp.keys()):
        disp[city] = {}
    disp[city][point] = i + 1

for elm in sorted(disp.keys()):
    for item in sorted(map(int, disp[elm].keys()), reverse=True):
        print(disp[elm][str(item)])

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    map<int,int> a;
    REP(i,3){
        int c; cin >> c;
        a[c]++;
    }
    cout << ((a[5]==2 && a[7]==1)?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
class Main {
    public static void main(String args[]) {
      try(Scanner sc = new Scanner(System.in)){
          while(true){
              String str=sc.next();
              if(str.equals("-")){
                  break;
              }
              int m=sc.nextInt();
              for(int i=0;i<m;i++){
                  int length=sc.nextInt();
                  str=str.substring(length)+str.substring(0,length);
              }
              System.out.println(str);
          }
      }
    }
}


Measured memory_bytes: 26464
import sys
input = sys.stdin.readline
N = int(input().strip())
C = [0] * (N - 1)
ans = [0] * (N)
for n in range(N-1):
    C, S, F = [int(x) for x in input().strip().split()]
    ans[n] = S + C
    for i in range(n):
        if ans[i] <= S:
            ans[i] = S + C
        elif ans[i] % F == 0:
            ans[i] += C
        else:
            ans[i] = (ans[i] // F + 1) * F + C

for a in ans:
    print(a)

Measured memory_bytes: 41452
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	int N, L[100],Lmax=1,maxnumber,addnumber=0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
		if (Lmax < L[i])
		{
			Lmax = L[i];
			maxnumber = i;
		}
	}
	for (int i = 0; i < N; i++)
	{
		addnumber += L[i];
		if (i == maxnumber)addnumber -= L[i];
	}
	//cout << Lmax << endl << addnumber << endl;
	if (Lmax < addnumber) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int N;
	int ans = 0;
	cin >> N;

	int A[2][N];
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < N; j++)
			cin >> A[i][j];


	int count = N;
	while (count != 0) {
		int tmp = 0;
		for (int i = 0; i < count; i++) {
			tmp += A[0][i];
		}
		for (int j = count - 1; j < N; j++) {
			tmp += A[1][j];
		}
		if (tmp > ans) {
			ans = tmp;
		}
	count--;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

const int nax = 1e5+5;
int dp[nax];	

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n, k;
	cin >> n >> k;
	int a[n], v[n];
	for(int i=0; i<n; i++){		
		cin >> a[i] >> v[i];
	}
	for(int i=0; i<nax; i++)dp[i]=INT_MAX;
	dp[0]=0;
	for(int i=0; i<n; i++){		
		for(int j=nax-1; j>=v[i]; j--){
			dp[j] = min(dp[j], dp[j-v[i]]+a[i]);
		}
	}
	for(int i=nax-1; i>=0; i--){
		if(dp[i]<=k){
			cout << i << endl;
			return 0;
		}
	}
 
	return 0;
}  

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

int main(){
  int N,X;
  cin >> N >> X;
  
  vector<int> L(N);
  
  rep(i,N){
    cin >> L.at(i);
  }
  
  int D = 0;
  int cnt = 0;
  while(D <= X){
    if(cnt == N){
      cnt++;
      break;
    }
    D += L.at(cnt);
    cnt++;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,x;
ll dp[3005][6005][1];
ll C[3005][3005];
int main(){
	cin>>n>>x;
	dp[0][0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<6005;j++){
			rep(k,1){
				if(dp[i][j][k] == 0) continue;
				dp[i+1][j][k] += dp[i][j][k];
				dp[i+1][j+1][k] += dp[i][j][k];
				dp[i+1][j+2][k] += dp[i][j][k];
			}
		}
		for(int j=0;j<6005;j++){
			rep(k,1) dp[i+1][j][k] %= mod;
		}
	}
	rep(i,3003)rep(j,i+1){
		if(j==0||j==i)C[i][j]=1;
		else C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	ll ans = 0;
	for(int j=0;j<x;j++) ans += dp[n][j][0];

	if(x%2 == 1){
		for(int i=0;i<=n;i++){
			if(2*i <= x) continue;
			ans += C[n][i];
		}
	}
	for(int a=1;a<=n;a++){
		if(2*a >= x-1) break;
		int zan = x-1-2*a;
		for(int b=1;b<=n;b++){
			if(zan < b) break;
			if((zan-b)%2 != 0) continue;
			int all = 2*a+b+(zan-b)/2;
			if(n>=all){
			    ans += C[n][all]*C[(zan-b)/2+b][b]%mod;
			}
		}
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 209920
from collections import Counter

n = int(input())

A = [int(i) for i in input().split()]
counts = Counter(A)
tmp = 0


# case1: すべてが0の場合
if len(set(A)) == 1 and A[0] == 0:
    print("Yes")
    quit()

# case2: nが3の倍数で、x^y^z == 0 となり、counts ==  x:n//3,y:n//3,z:n//3を満たす

if len(counts.items()) == 3 and n % 3 == 0:
    tmp = 0
    for x, k in counts.items():
        if k == n // 3:
            tmp ^= x
        else:
            print("No")
            quit()
    if tmp == 0:
        print("Yes")
        quit()
    else:
        print("No")
        quit()

# case3: nが3の倍数で、counts == x: 2*n//3,0: n//3 を満たす

if len(counts.items()) == 2 and n % 3 == 0:
    if counts.most_common()[1][0] == 0 and counts.most_common()[1][1] == n // 3:
        print("Yes")
        quit()
    else:
        print("No")
        quit()

print("No")


Measured memory_bytes: 105668
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

int main(){
  ll N ,K ; cin >> N >> K;
  vector<ll> a(N + 1); rep(i,N) cin >> a[i];

  vector<P> b(N);
  rep(i,N){
    b[i].fi = max( (ll)0 , i - a[i] );
    b[i].sc = min( N , i + a[i] + 1 );
    // cout << b[i].fi << " " << b[i].sc << endl;
  }
  SORT(b);

  vector<ll> ans(N);
  vector<ll> s(N);
  vector<ll> g(N);
  rep(i,N) s[i] = b[i].fi;
  rep(i,N) g[i] = b[i].sc;
  rep(loop , K){
    // cout << loop << " " << ans[0] << endl;
    if(ans[0] > N - 1 and ans[N - 1] > N - 1){
      rep(i,N){
        ans[i] = N;
      }
      break;
    }
    else{
      rep(i,N) ans[i] = 0;
      ll tmp = 0;
      vector<ll> cnt(N + 4);
      // ansの更新
      rep(i,N){
        cnt[g[i]]++;
      }
      rep(i,N){
        tmp += POSU(s, i) - POSL(s , i);
        tmp -= cnt[i];
        ans[i] += tmp;
      }
      // sとgの更新
      rep(i,N){
        b[i].fi = max( (ll)0 , i - ans[i] );
        b[i].sc = min( N , i + ans[i] + 1 );
        // cout << b[i].fi << " " << b[i].sc << endl;
      }
      SORT(b);
      rep(i,N) s[i] = b[i].fi;
      rep(i,N) g[i] = b[i].sc;
    }
  }
  rep(i,N){
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 14056
#include<set>
#include<algorithm>
#define foreach(i, c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define DEBUG
using namespace std;

int main(){
	int m,n;
	while(cin>>m>>n, m||n){
		set<int> t;
		for(int i = 0; i < m+n; i++){
			int a;
			cin>>a;
			t.insert(a);
		}
		set<int> dt;
		int t0; t0 = 0;
		foreach(i, t){
			dt.insert(*i - t0);
			t0 = *i;
		}
		cout<<*(dt.rbegin())<<endl;
	}
	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    vector<ll> vec;
    cin >> n >>  k;
    for (int i = 0; i < n; i++) {
        ll in;
        cin >> in;
        vec.push_back(in);
    }
    sort(vec.begin(), vec.end());
    ll mx = 1e18;
    for (int i = 0; i < n; i++) {
        if (i + k - 1 >= n)
            continue;
        mx = min(mx, vec[i + k - 1]- vec[i]);
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int a[3];
	a[0] = a[1] = a[2] = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp <= A) a[0]++;
		else if (tmp <= B) a[1]++;
		else a[2]++;
	}

	int ans = min(a[0], a[1]);
	ans = min(ans, a[2]);
	cout << ans << endl;

	return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int s,w;
    cin >> s >> w;
    cout << (w>=s?"unsafe":"safe") << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;


/** DSL_2 - A : Range Query : Range Minimum Query **/
 
const int MAX_N = 1<<17;
class RMQ {
public:
	int n, dat[2*MAX_N-1];
	
	void init(int n_) {
		n=1;
		while (n<n_) n*=2;
		for (int i=0; i<2*n-1; i++) dat[i]=INT_MAX;
	}
	
	RMQ() {}
	
	void update(int k, int a) {
		k += n-1;
		dat[k] = a;
		while (k>0) {
			k = (k-1)/2;
			dat[k] = min(dat[k*2+1], dat[k*2+2]);
		}
	}
	
	int query(int a, int b, int k, int l, int r) {
		if (r<=a || b<=l) return INT_MAX;
		
		if (a<=l && r<=b) {
			return dat[k];
		} else {
			int vl = query(a, b, k*2+1, l, (l+r)/2);
			int vr = query(a, b, k*2+2, (l+r)/2, r);
			
			return min(vl, vr);
		}
	}
};

int main()
{
	int N, Q;
	cin>>N>>Q;
	RMQ ST;
	ST.init(N);
	
	rep(i, Q) {
		int c, x, y;
		cin>>c>>x>>y;
		if (c) {
			cout << ST.query(x, y+1, 0, 0, ST.n) << endl;
		} else {
			ST.update(x, y);
		}
	}
}

Measured memory_bytes: 2188
from itertools import permutations
from bisect import bisect_left

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

perm = list(permutations(p))
perm.sort()
a = bisect_left(perm, p)
b = bisect_left(perm, q)

print(abs(a- b))


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

const int M=100005;

int n;
vector <int> g[M];

int sg[M];
int dfs(int x,int fa) {
	sg[x]=0;
	// int s=0;
	for (int i=0;i<g[x].size();++i) {
		if (g[x][i]==fa) continue;
		dfs(g[x][i],x);
		sg[x]^=(sg[g[x][i]]+1);
	}
}

int main() {
	cin>>n;
	for (int i=1;i<n;++i) {
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,1);
	if (sg[1]==0) cout<<"Bob"<<endl;
	else cout<<"Alice"<<endl;
}

Measured memory_bytes: 12416