akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



int main() {

  int n;
  cin >> n;

  bool ans = true;
  map<string, int> flags;
  rep(i, n) {
    string a;
    cin >> a;

    if (flags.find(a) != end(flags)) {
      ans = false;
    } else {
      flags[a] = 1;
    }
  }

  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }



  return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >=0; --i)
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 (a>b) { a=b; return 1; } return 0; }

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

// 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 = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);



int main() {
  ll a,b;
  cin >> a>>b;

  
  cout << max(0LL, a-2*b)  << endl;
  return 0;
}


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

using namespace std;
#define int64 long long

const int N_MAX = 200010;

int A[N_MAX], B[N_MAX];
int nNum;

inline int nextIndex(int i) {
	return i < nNum ? i + 1 : 1;
}

inline int prevIndex(int i) {
	return i > 1 ? i - 1 : nNum;
}

bool reducible(int i) {
	return B[i] - A[i] >= B[nextIndex(i)] + B[prevIndex(i)];
}

void outerInit() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto fi = new ifstream("test.inp");
	if (*fi) {
		cin.rdbuf(fi->rdbuf());
	}
}

void readData() {
	cin >> nNum;
	for (int i = 1; i <= nNum; ++i) cin >> A[i];
	for (int i = 1; i <= nNum; ++i) cin >> B[i];
}

void solveData() {
	queue<int> reducibleIndices;
	for (int i = 1; i <= nNum; ++i) {
		if (reducible(i)) {
			reducibleIndices.push(i);
		}
	}

	int64 result = 0;
	while (!reducibleIndices.empty()) {
		int i = reducibleIndices.front();
		reducibleIndices.pop();
		if (!reducible(i)) continue;

		int in = nextIndex(i);
		int ip = prevIndex(i);
		int ac = B[in] + B[ip];
		int nStep = (B[i] - A[i]) / ac;
		result += nStep;
		B[i] -= nStep * ac;

		if (reducible(in)) {
			reducibleIndices.push(in);
		}
		if (reducible(ip)) {
			reducibleIndices.push(ip);
		}
	}

	for (int i = 1; i <= nNum; ++i) {
		if (A[i] != B[i]) {
			cout << "-1\n";
			return;
		}
	}

	cout << result << "\n";
}

int main() {
	outerInit();

	readData();
	solveData();
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int R[4010];
int B[4010];
int G[4010];

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

	int n;cin>>n;

	string s;cin>>s;
	int r=0,g=0,b=0;
	for(int i=0; i<s.length(); i++){
		if(s[i] =='R'){
			R[i]++;
		}else if (s[i] =='B') {
			B[i]++;
		}else {
			G[i]++;
		}
	}

	for(int i=0; i<s.length(); i++){
		 R[i+1] += R[i];
		 B[i+1] += B[i];
		 G[i+1] += G[i];
	}


	ll sum =0;
	int last =s.length()-1;
	for(int i=0; i<s.length(); i++){
		for(int j=i+1; j<s.length(); j++){
			bool judge =false;
			char left = s[i]; char center = s[j];

			if(left =='R' && center =='B'){
				sum += (G[last]-G[j]);
				judge = true;
			}else if (left =='R' && center =='G') {
				sum += B[last]-B[j];
				 judge =true;
			}else if (left =='B' && center =='R') {
				sum += G[last]-G[j];
				judge =true;
			}else if (left =='B' && center =='G') {
				sum += R[last]-R[j];
				 judge =true;
			}else if (left =='G' && center =='B') {
				sum += R[last]-R[j];
				 judge =true;
			}else if (left =='G' && center =='R') {
				sum += B[last]-B[j];
				 judge =true;
			}

			if(j*2-i<s.length()){
			if( judge && s[i] != s[j*2-i] && s[j] !=s[j*2-i]){
						sum--;
			}
			}
		/*	writeln(sum);*/
	}
	}

		writeln(sum);
}




Measured memory_bytes: 3680
N = int(input())
A = list(map(int, input().split()))
up_down = [0]
for i in range(1, N):
    if A[i - 1] < A[i]:
        up_down.append(1)
    elif A[i - 1] > A[i]:
        up_down.append(-1)
    elif A[i - 1] == A[i]:
        up_down.append(0)

# print(up_down)

money = 1000
kabu = 0

for i in range(0, N - 1):
    if up_down[i + 1] == 1:
        can_buy = money // A[i]
        money -= A[i] * (can_buy)
        kabu += can_buy
    elif up_down[i + 1] == -1:
        money += A[i] * kabu
        kabu = 0
    # print(money, kabu)

if kabu > 0:
    money += kabu * A[N - 1]

print(money)


Measured memory_bytes: 9092
#include <stdio.h>

//メイン関数
int main(void){
  int n;
  scanf("%d", &n);

  int a[n];
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(int i=n-1; i>=0 ; i--){
    if(i != 0){
      printf("%d ", a[i]);
    }else{
      printf("%d\n", a[i]);
    }
  }

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll x; cin >> x;
  ll ans = (x / 11) * 2;
  if (x % 11 != 0 && x % 11 <= 6) ans += 1;
  else if (x % 11 > 6)ans += 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
long long n;
int main(){
	cin>>n;n++;
	int m=100,p1=0,p2=0;
	while(n>1){
		if(n&1) a[++p1]=m--,n--;
		else b[++p2]=m--,n>>=1;
	}
	printf("%d\n",p1+p2<<1);
	for(int i=1;i<=p1;i++){
		printf("%d ",a[i]);
	}
	for(int i=p2;i>=1;i--){
		printf("%d ",b[i]);
	}
	for(int i=100-p1-p2+1;i<=100;i++){
		cout<<i<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const int s_MAX = 200000;
char s[s_MAX];

int main(){
  string str;
  cin >> str;
  for(int i=0;i<str.length();i++)
    s[i] = str[i];

  int counter = 0,position_of_a,position_of_z = 0;
  while(s[counter] != 'A'){ counter++;}
  position_of_a = counter;
  while(s[counter] != '\0'){
    if(s[counter] == 'Z'){
      position_of_z = counter;
    }
    counter++;
  }
  cout << position_of_z - position_of_a + 1 << endl;
  return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    char c;
    cin >> c;
    cout << (c >= 'A' && c <= 'Z' ? 'A' : 'a') << endl;

    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n, m;
  cin >> n >> m;

  vector<int64_t> x(n), y(m);
  for (auto&& xx : x) {
    cin >> xx;
  }
  for (auto&& yy : y) {
    cin >> yy;
  }

  constexpr auto M = 1000000007L;
  int64_t sx = 0, sy = 0;
  for (auto i : irange(0L, n - 1)) {
    sx += (i + 1) * (n - i - 1) % M * (x[i + 1] - x[i]) % M;
    sx %= M;
  }
  for (auto i : irange(0L, m - 1)) {
    sy += (i + 1) * (m - i - 1) % M * (y[i + 1] - y[i]) % M;
    sy %= M;
  }

  cout << sx * sy % M << endl;
}

Measured memory_bytes: 1792
# coding: utf-8
# Here your code !

def func():
        try:
            nums = input()
            line = input().rstrip()
            numbers = line.split(" ")
            for i,item in enumerate(numbers):
                numbers[i]=int(item)
        except:
            print("input error")
            return -1
        
        print(str(min(numbers))+" "+str(max(numbers))+" "+str(sum(numbers)))
        

func()

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,a,b,c,d; cin>>n>>a>>b>>c>>d;
  a--,b--,c--,d--;
  string s; cin>>s;
  
  bool ok=true;
  irep(i,a,c){
    if(s[i]=='#'&&s[i+1]=='#') ok=false;
  }
  irep(i,b,d){
    if(s[i]=='#'&&s[i+1]=='#') ok=false;
  }
  
  if(c>d){
    bool flg=false;
    irep(i,b-1,d){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') flg=true;
    }
    if(!flg) ok=false;
  }
  
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

const int INF = 10001000;

int main(){

    //d := 日数 n := 服の種類
    int d, n; cin >> d >> n;
    vector<int> t(d);
    for(int i = 0; i < d; i++) cin >> t[i];
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int> > dp(d + 1, vector<int> (110, -INF));

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

        //着れるなら
        if(a[i] <= t[0] && t[0] <= b[i]) dp[0][c[i]] = 0;
    }

    for(int i = 0; i < d - 1; i++){
        for(int j = 0; j <= 100; j++){

            if(dp[i][j] == -INF) continue;

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

                //k番目の服を i 日目にきる
                if(a[k] <= t[i + 1] && t[i + 1] <= b[k]) dp[i + 1][c[k]] = max(dp[i + 1][c[k]], dp[i][j] + (int)abs(j - c[k]));
            
            }
        }
    }

    //cout << 30 << " " << 40 << " " << 60 << " " << 90 << endl;
    /*for(int i = 0; i < d - 1; i++){
        cout << dp[i][30] << " " << dp[i][40] << " " << dp[i][60] << " " << dp[i][90] << endl;
    }*/

    int ans = -INF;
    for(int i = 0; i <= 100; i++) ans = max(ans, dp[d - 1][i]);

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


Measured memory_bytes: 3184
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.append(X)
y.append(Y)

x.sort()
y.sort()

if x[-1] < y[0]:
    print('No War')
else:
    print('War')


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[100005];

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	LL s=0;
	cin>>ca;
	n=strlen(ca);
	a=1;
	for(i=0;i<n;i++){
		if(ca[i]=='1'){
			s+=a*pow_mod(3,n-i-1);
			if(s>=MAX)s%=MAX;
			a*=2;
			if(a>=MAX)a%=MAX;
		}
	}
	s+=a;
	cout<<s%MAX<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
		int d = a/b;
		int r = a%b;
		double x = a;
		double y = b;
		double f = x/y;
		
		BigDecimal z = new BigDecimal(f);
		BigDecimal z1 = z.setScale(5, BigDecimal.ROUND_HALF_UP);

		System.out.print(d + " " + r + " ");
		System.out.printf("%.5f",z1);
	}

}

Measured memory_bytes: 26708
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int x;
  scanf("%d", &x);
  int times = x / 100;
  int rem  = x - 100 * times;
  int count = 0;
  while (rem >= 5) {
    rem -= 5;
    count++;
  }
  if (rem != 0) count++;
  if (count <= times) 
    printf("1\n");
  else
    printf("0\n");
  return 0;
}


Measured memory_bytes: 128
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;
const int MOD = 1e9 + 7;

ll add(ll a,ll b) {
	a += b;
	a %= MOD;
	if (a < 0) a += MOD;
	return a;
}

ll mul(ll a, ll b) {
	return (ll)a * b % MOD;
}

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	ll k = pow(a, b / 2);
	if (b % 2) return mul(mul(a, k), k);
	return mul(k, k);
}

int n, p[MAXN];
ll k, fak[MAXN];
int bio[MAXN];
ll pref[MAXN];

ll ans[MAXN];

ll choose(int a, int b) {
	if (b > a || b < 0) return 0;
	return mul(fak[a], pow(mul(fak[b], fak[a - b]), MOD - 2));
}

ll get(int a, int b) {
	ll ret = pref[b];
	if (a) return add(ret, -pref[a - 1]);
	return ret;
}

int main() {
	scanf("%d",&n);
	REP(i, n + 1) scanf("%d",&p[i]);
	ll a;
	ll b;
	REP(i, n + 1) {
		if (bio[p[i]]) {a = bio[p[i]] - 1; b = i - bio[p[i]];k = n + 1 - i - 1;}
		bio[p[i]] = i + 1;
	}

	fak[0] = 1;
	FOR(i, 1, MAXN) fak[i] = mul(fak[i - 1], i);

	//ans[2] = add(ans[2], -a);

	TRACE(a _ b _ k);
	ans[1] = n;
	FOR(i, 2, n + 2) {
		ans[i] = choose(n + 1, i);
		/*
		ans[i] = add(ans[i], choose(n + 1 - 2, i - 2));
		ans[i] = add(ans[i], choose(n + 1 - 2, i));
		ans[i] = add(ans[i], mul(2, choose(b + k, i - 1)));
		ans[i] = add(ans[i], mul(2, choose(a + b, i - 1)));
		*/
		ans[i] = add(ans[i], -choose(a + k, i - 1));
	}

	FOR(i, 1, n + 2) printf("%lld\n",ans[i]);

	return 0;
}

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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  ll k = -1;
  rep(i, 0, 2 * n + 1) {
    if (i * i - i == 2 * n) {
      k = i;
      break;
    }
  }
  if (k == -1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << k << endl;

  ll num = 1;
  vector<vector<ll>> s(k, vector<ll>(k - 1));
  rep(i, 0, k) {
    for (int j = i; j < k - 1; j++) {
      s[i][j] = num;
      s[j + 1][i] = num;
      num++;
    }
  }

  rep(i, 0, k) {
    cout << sz(s[i]) << " ";
    rep(j, 0, k - 1) cout << s[i][j] << " ";
    cout << endl;
  }
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>

int main(void) {
	// in
	int n;
	std::cin >> n;
	std::vector<int> p(n);
	for(int i = 0; i < n; ++i) std::cin >> p[i];

	int n_p = 0;
	for(int i = 1; i < n-1; ++i) {
		int p_min = std::min(p[i-1], p[i+1]);
		int p_max = std::max(p[i-1], p[i+1]);
		if(p[i] > p_min && p[i] < p_max) n_p += 1;
	}

	std::cout << n_p << std::endl;

	return 0;
}


Measured memory_bytes: 256
l=input().split()
r=int(l[0])
c=int(l[1])

# for yoko
i=0
b=[]
while i<r:
    a=input().split()
    q=0
    su=0
    while q<c:
        b.append(int(a[q]))
        su+=int(a[q])
        q=q+1
    b.append(su)
    i=i+1

# for tate
#x=0
#d=b[0]+b[c+1]+b[2*(c+1)]+b[3*(c+1)]
#x<c+1
x=0
while x<c+1:
    d=0
    z=0
    while z<r:
        d+=b[x+z*(c+1)]
        z+=1
    b.append(d)
    x=x+1
# for output
# C=[]
# y=0 (for gyou)
# z=0 (for yoko)
C=[]
y=0
while y<r+1:
    z=0
    Ans=str(b[y*(c+1)+z])
    while z<c:
        z+=1
        Ans=Ans+" "+str(b[y*(c+1)+z])
    C.append(Ans)
    y+=1

for k in C:
    print(k)



Measured memory_bytes: 5768
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % findSum(n) == 0)
      System.out.println("Yes");
    else
      System.out.println("No");
  }

  public static int findSum(int n) {
    int sum = 0;
    while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  int A[N+1];
  for (int i = 0; i < N; i++) cin >> A[i];
  A[N] = 0;
  sort(A, A+N);
  

  
  vector<bool> P(1000001, true);
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int j = 1;
    if (P[A[i]]) {
      if (A[i] != A[i+1]) {
        ans++;
      }
      while (A[i] * j <= 1000000) {
        P[A[i] * j] = false;
        j++;
      }
    }
  }
  
  cout << ans << endl;
  
  
}

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

int main() {
	int N, i, judg = 0;
	string A;
	cin >> A;
	N = A.length();

	for (i = 0; i < N; i++) {
		if (A[i] == 'o')
			judg += 1;
	}
	int Ans;
	Ans = judg + (15 - N);
	if (Ans >= 8)
		cout << "YES";
	else
		cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

string J(string s) {
	return  s.back() + s.substr(0, s.size() - 1);
}

string C(string s) {
	return  s.substr(1, s.size() - 1) + s.front();
}

string E(string s) {
	string ret;
	if(s.size() % 2) {
		for(int i = s.size() / 2 + 1; i < s.size(); i++) {
			ret += s[i];
		}
		ret += s[s.size() / 2];
		for(int i = 0; i < s.size() / 2; i++) {
			ret += s[i];
		}
	}
	else {
		for(int i = s.size() / 2; i < s.size(); i++) {
			ret += s[i];
		}
		for(int i = 0; i < s.size() / 2; i++) {
			ret += s[i];
		}
	}
	return ret;
}

string A(string s) {
	reverse(s.begin(), s.end());
	return s;
}

string P(string s) {
	for(int i = 0; i < s.size(); i++) {
		if(!isalpha(s[i])) {
			s[i] = '0' + (s[i] - '0' + 9) % 10;
		}
	}
	return s;
}

string M(string s) {
	for(int i = 0; i < s.size(); i++) {
		if(!isalpha(s[i])) {
			s[i] = '0' + (s[i] - '0' + 1) % 10;
		}
	}
	return s;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int loop = 0; loop < n; loop++) {
		string s, t;
		cin >> s >> t;
		for(int i = s.size() - 1; i >= 0; i--) {
			char c = s[i];
			if(c == 'J') t = J(t);
			if(c == 'C') t = C(t);
			if(c == 'E') t = E(t);
			if(c == 'A') t = A(t);
			if(c == 'P') t = P(t);
			if(c == 'M') t = M(t);
		}

		cout << t << endl;
	}
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

int32_t main()
{
	FAST_IO;
	
	int n;
	cin >> n;
	
	int ans = n-1;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			ans = min(ans, i + n/i -2);
		}
	}
	cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(N)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, left, right):
        """
        [left, right)のsegfuncしたものを得る
        left: index(0-index)
        right: index(0-index)
        """
        res = self.ide_ele
        left += self.num
        right += self.num
        while left < right:
            if left & 1:
                res = self.segfunc(res, self.tree[left])
                left += 1
            if right & 1:
                res = self.segfunc(res, self.tree[right - 1])
            left >>= 1
            right >>= 1
        return res


def segfunc(x, y):
    """
    区間(x,y)に対して行いたい操作の入力
    最小値：min(x,y)
    最大値：max(x,y)
    和：x + y
    積：x * y
    最大公約数：math.gcd(x, y)
    """
    return math.gcd(x, y)


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    res = 0

    ide_ele = 0
    seg = SegTree(A, segfunc, ide_ele)

    for i in range(n):
        tmp = A[i]
        seg.update(i, 0)
        g = seg.query(0, n)
        res = max(res, g)
        seg.update(i, tmp)
    print(res)


if __name__ == '__main__':
    resolve()


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

#define INFTY 1000000001

long int inversion = 0;

void merge(vector<int> &A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1);
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	vector<int> R(n2 + 1);
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = INFTY;
	R[n2] = INFTY;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++){
		if (L[i] <= R[j]){
			A[k] = L[i];
			if (i > k - left){
				inversion += i - (k - left);
			}
			i = i + 1;
		}
		else{
			A[k] = R[j];
			if (j + n1 > k - left){
				inversion += j + n1 - (k - left);
			}
			j = j + 1;
		}
	}

}

void mergeSort(vector<int> &A, int left, int right){
	if (left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){

	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];

	mergeSort(A, 0, n);

	cout << inversion << endl;

	return 0;
}


Measured memory_bytes: 4336
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
for i,d in enumerate(a):    
    if i >= 1:
        if a[i-1] + 1 == a[i]:
            s += c[d-2]
        s += b[d-1]
    else:
        s += b[d-1]

print(s)

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

int main(){
  string s;
  cin >> s;
  string ans="None";
  char answer='0';
  for(char i='z';i>='a';i--){
    bool check=true;
    for(int j=0;j<s.size();j++){
      if(i==s.at(j)){
        check=false;
      }
    }
    if(check){
      answer=i;
    }
  }
  if(answer=='0'){
    cout << ans << endl;
  }
  else{
    cout << answer << endl;
  }
}

Measured memory_bytes: 512
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int n,m,a[55][55];
int main(){
	splay(n),splay(m);
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			splay(a[i][j]);
			if(i==j)a[i][j]=0;
		}
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
			}
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x;splay(x);
			if(x==-1)continue;
			ans+=a[x][1];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec

#ifdef DEBUGGING
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using namespace std;

using namespace std;
const ll inf = 5e15;

int main() {
    ll N;
    cin >> N;
    V<ll> X(N);
    for (auto &&e : X) cin >> e;
    ll ans = inf;
    for (ll i = -100; i <= 100; i++) {
        ll tmp = 0;
        for (ll e : X) tmp += (e - i) * (e - i);
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int A, B;

string S, c, d;

int main() {

	cin >> A >> B >> S;

	string ans = "No";
	int last = 0;
	int pos = S.find("-");
	if (pos >= 1) {
		c = S.substr(last, pos - last);
		if (A == c.length() && all_of(c.cbegin(), c.cend(), [](char c) {return isdigit(c); }))
		{
			last = pos + 1;
			d = S.substr(last, S.length());
		}
		if (B == d.length() && all_of(d.cbegin(), d.cend(), [](char d) {return isdigit(d); }))
		{
			
			ans = "Yes";
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=140,h=170,now=1;
  cin >>a>>b>>c;
  if(a*c<=b) cout <<c<<'\n';
  else{
    cout <<b/a<<'\n';
  }
  return (0);
}


Measured memory_bytes: 256
var cnt = 0;
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let arr = lines.shift().split(' ').map(Number);
  mergeSort(arr, 0, n);
  console.log(arr.join(' '));
  console.log(cnt);
})();

function merge(arr, left, mid, right) {
  let L = arr.slice(left, mid);
  let R = arr.slice(mid, right);
  L.push(Infinity);
  R.push(Infinity);
  let i = 0;
  let j = 0;
  for (let k = left; k < right; k++) {
    if (L[i] <= R[j]) arr[k] = L[i++];
    else arr[k] = R[j++];
    cnt++;
  }
}

function mergeSort(arr, left, right) {
  if (left + 1 < right) {
    let mid = Math.floor((left + right) / 2);
    mergeSort(arr, left, mid);
    mergeSort(arr, mid, right);
    merge(arr, left, mid, right);
  }
}



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

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int r, l;
		r = l = 0;
		string s;
		int bb = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s == "lu") {
				l++;
			}
			else if (s == "ru") {
				r++;
			}
			else if (s == "ld") {
				l--;
			}
			else {
				r--;
			}
			if (bb == 0 && l == 1 && r == 1) {
				ans++;
				bb = 1;
			} else if (bb == 1 && l == 0 && r == 0) {
				ans++;
				bb = 0;
			}

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

Measured memory_bytes: 3112
count=[[[0 for k in range(10)] for j in range(3)] for i in range(4)]
n=int(input())
for elem in range(n):
    b,f,r,v=map(int,input().split())
    count[b-1][f-1][r-1]+=v
    
for i in range(4):
    if i>0:
        print("#"*20)
    for j in range(3):
        for k in range(10):
            print(" %d"%(count[i][j][k]),end="")
        print()


Measured memory_bytes: 5624
# coding: utf-8
N, T = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = sorted([[c, t] for c, t in A if t <= T], key=lambda x: x[0])
if len(B) == 0:
    print('TLE')
else:
    print(B[0][0])

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

#define lol long long

int main() {

	string s;
	cin >> s;
	lol k;
	cin >> k;

	char first;
	bool frag = false;
	if (s.size() < k) {
		frag = true;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != '1') {
				first = s[i];
				break;
			}
		}
	}
	else {
		for (int i = 0; i < k; i++)
		{
			if (s[i] != '1') {
				first = s[i];
				frag = true;
				break;
			}
		}
	}

	if (frag == true) {
		cout << first;
	}
	else {
		cout << "1";
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >>c >> k;
    int mx = max(a,b);
    int mn = min(a,b);
    int mn2 = min(mx,c);
    mx = max(mx,c);
    for(int i=0;i<k;i++){
        mx = mx*2;
    }
    int ans = mx+mn+mn2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



ll calc_zero_to_A_xor_old(const ll A, const ll maxbit)
{
	ll retval = 0;
	//	ll A = 1;

	for (ll bit = maxbit; bit > 0; --bit)
	{
		bool flag = false;
		ll a = A;
		while (true)
		{
			if (((a >> bit) & 1) == 0)
			{
				break;
			}
			else
			{
				flag = !flag;
			}
			a--;
		}

		if (flag) retval += (1LL << bit);
		//cout << flag;// << endl;
	}

	bool lastbit = 0;
	if (A % 4 == 1 || A % 4 == 2) lastbit = 1;

	retval += lastbit;
	//cout << lastbit;

	//cout << retval;
	//cout << endl;

	return retval;
}

ll calc_zero_to_A_xor(const ll A, const ll maxbit)
{
	ll retval = 0;
	//	ll A = 1;

	for (ll bit = maxbit; bit > 0; --bit)
	{
		if (((A >> bit) & 1) == 0)
		{
			continue;
		}

		ll cnt = 1;
		for (ll tbit = bit - 1; tbit >= 0; --tbit)
		{
			if (((A >> tbit) & 1) == 1)
			{
				cnt += (1LL << tbit);
			}
		}
		if (cnt % 2 == 1) retval += (1LL << bit);
		//cout << flag;// << endl;
	}

	bool lastbit = 0;
	if (A % 4 == 1 || A % 4 == 2) lastbit = 1;

	retval += lastbit;
	//cout << lastbit;

	//cout << retval;
	//cout << endl;

	return retval;
}

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

	ll A, B;
	cin >> A >> B;
	
	ll maxbit = (ll)ceil(log2(max((double)A, (double)B)));

	ll AA = min(A, B) - 1;
	ll BB = max(A, B);

	if (AA == -1)
	{
		ll ans = calc_zero_to_A_xor(BB, maxbit);
		cout << ans << endl;
	}
	else
	{
		ll AAA = calc_zero_to_A_xor(AA, maxbit);
		ll BBB = calc_zero_to_A_xor(BB, maxbit);

		ll ans = AAA ^ BBB;

		//cout << AAA << endl;
		//cout << BBB << endl;
		cout << ans << endl;
	}

	/*	//for (ll A = 0; A < 16; ++A)
	for (ll A = 0; A < 16; ++A)
	{
		//cout << calc_zero_to_A_xor(A, maxbit) << endl;
	}
	*/



	//system("pause");
}

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

int main() {
	int N;
	cin >> N;
	int ans = N;
	for (int i = 0; i <= N; i++) {
		int cnt = 0;
		int t = i;
		while (t > 0) 
			cnt += t % 6, t /= 6;
			t = N - i;
			while (t > 0) 
				cnt += t % 9, t /= 9;
				if (ans > cnt) 
					ans = cnt;
	}

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

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //青カード
            long N = long.Parse(Console.ReadLine());
            List<string> itemsName = new List<string>();
            List<int> itemsCnt = new List<int>();
            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                int index = itemsName.IndexOf(s);
                if (index == -1)
                {
                    itemsName.Add(s);
                    itemsCnt.Add(1);
                }
                else
                {
                    itemsCnt[index]++;
                }
            }
            //赤カード
            long M = long.Parse(Console.ReadLine());
            for (int j = 0; j < M; j++)
            {
                string s = Console.ReadLine();
                int index = itemsName.IndexOf(s);
                if (index != -1)
                {
                    itemsCnt[index]--;
                }
            }
            if (itemsCnt.Max() < 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(itemsCnt.Max());
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28224
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int sum = 0;
        for(int i=0; i<m; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }

        if(sum <= n) {
            System.out.println(n - sum);
        } else {
            System.out.println(-1);
        }

        
    }
}


Measured memory_bytes: 39144
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
 
int i,set,n,x;
double h;
 
int main(){
    scanf("%d",&n);
    for(set=1;set<=n;set++){
        printf("Case %d:\n",set);
        scanf("%d",&x);
        for(i=0;i<10;i++){
            x=(x*x/100)%10000;
            printf("%d\n",x);
        }
    }
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;

  mint(ll x=0):x((x%mod+mod)%mod){}

  mint operator-() const { return mint(-x);}
  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;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

  combination com(100001);

  sort(A.begin(), A.end());
  mint mxsum = 0;
  rep(i,N) {
    if(i < K-1) continue;
    mint a = A[i];
    mxsum += com(i,K-1) * a;
  }

  sort(A.begin(), A.end(), greater<>());
  mint mnsum = 0;
  rep(i,N) {
    if(i < K-1) continue;
    mint a = A[i];
    mnsum += com(i,K-1) * a;
  }

  mint ans = mxsum - mnsum;
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int sum=-1;
    for(int i=1; i<=n/2; i++)
    {
        int a=i;
        int b=n-i;
        int d=0;
        while(a>0)
        {
            int r=a%10;
            d+=r;
            a=a/10;
        }
        while(b>0)
        {
            int r=b%10;
            d+=r;
            b=b/10;
        }
        if(sum==-1)
        {
            sum=d;
        }
        else{
            if(d<sum)
                sum=d;
        }
    }

    cout<<sum;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

s=input()
i=s.find('A')
s=s[::-1]
j=s.find('Z')
print(len(s)-i-j)



Measured memory_bytes: 42864
N,a,b=map(int,input().split())
ans=0
for i in range(N):
  #print(i+1)
  #print(str(i+1))
  #print(sum(list(map(int,list(str(i+1))))))
  if (a<=sum(list(map(int,list(str(i+1)))))<=b):
    ans+=i+1
print(ans)

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

int main(){
  ll n;
  cin>> n;
  ll a[2][n];
  rep(i,2){
    rep(j,n){
      cin>>a[i][j];
    }
}
 ll sum[n+1];
 ll plus[n+1];
 sum[0]=0;
 plus[0]=0;
 rep(i,n){
    sum[i+1]=sum[i]+a[0][i];
    plus[i+1]=plus[i]+a[1][i];
}
 ll kotae=0;
 ll ans[n];
 rep(i,n){
    ans[i]=sum[i+1]+plus[n]-plus[i];
}
 rep(i,n){
    kotae=max(kotae,ans[i]);
}
cout<<kotae<<endl;
}



Measured memory_bytes: 256