akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

bool isAllVisit(const vector<bool>& visit) {
    for (auto&& v : visit) {
        if (!v)return false;
    }
    return true;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}


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

    string S;
    cin >> S;

    int len = S.length();
    int size = (1 << (S.length() - 1));
    ll ans = 0;

    auto add = [](ll n, string s) {
        stringstream ss(s);
        ll a;
        ss >> a;
        return n + a;
    };
    REP(i, size) {
        ll sum = 0;
        string s = "";
        REP(j, len) {
            s += S[j];
            if (i &(1 << j)) {
                sum = add(sum, s);
                s = "";
            }
        }
        sum = add(sum, s);
        ans += sum;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C;

  cin >> A >> B >> C;

  int a=A%2,b=B%2,c=C%2;

  int ans=0;

  if(a==b){
    if(b!=c) {A++; B++; ans++;}//Cだけパリティ違い
  }

  else if(a==c){//Bだけパリティ違い
    A++; C++; ans++;
  }

  else{//Aだけパリティ違い
    B++; C++; ans++;
  }

  //パリティ違いは解決済み、全部同じパリティならなにもしない

  vector<int> n(3);
  n.at(0)=A; n.at(1)=B; n.at(2)=C;

  sort(n.begin(),n.end());

  ans+=(2*n.at(2)-n.at(1)-n.at(0))/2;

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

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 080
  D - Recording

  方針
    同時に最大いくつのチャンネルを録画しなければならないかを数えればよい。

    あるチャンネルで区間[s,t)を録画したいとき、
    録画機が使用される時間は区間[s-0.5,t)である。
    これを離散化させるために区間を2倍して考えると、
    録画機が使用される時間は区間[2s-1,2t)となる。

  実装
    いもす法を使用すると高速化が可能である。
    ただし、あるチャンネルで連続する2つのチャンネルを録画する場合に注意する。
*/

#include<iostream>
using namespace std;

int N, C;
int s, t, c;
int schedule[31][200002];

int main() {
  scanf("%d%d", &N, &C);
  for (int n = 0; n < N; ++n) {
    scanf("%d%d%d", &s, &t, &c);
    for (int i = 2 * s - 1; i < 2 * t; ++i) {
      schedule[c][i] = 1;
    }
  }

  int maxval = 0;
  for (int i = 0; i < 200002; ++i) {
    int val = 0;
    for (int c = 1; c <= C; ++c) val += schedule[c][i];
    maxval = max(maxval, val);
  }

  printf("%d\n", maxval);
  return 0;
}

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

int main(){
 int m,d,count=0;
  cin>>m>>d;
  for(int i=22;i<=d;i++){
    if((i/10)<2||(i%10)<2)
      continue;
    for(int j=1;j<=m;j++)
    if((i/10)*(i%10)==j)
    count++;
  }
  cout<<count;
  
  
  
}

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

int main(){
    int A,B,ans=0;
    cin >> A >> B;

    bool kaiA = false;
    bool kaiB = false;

    int i = 0;

    while(i <= 1000){
        ans =(int)(i * 0.08);
        if(ans == A){
            kaiA = true;
        }else{
            kaiA = false;
        }
        ans =(int)(i * 0.1);

        if(ans == B){
            kaiB = true;
        }else{
            kaiB = false;
        }
        if(kaiA == true && kaiB == true){
            break;
        }
        i++;
    }

    if(kaiA&&kaiB)
        cout << i << endl;
    else
    {
        cout << -1 << endl;
    }
    

}

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

ans=0
for i in range(n):
    if a[i]>=b[i]:
        ans+=b[i]
    elif a[i]+a[i+1]>=b[i]:
        ans+=b[i]
        a[i+1]=a[i+1]+a[i]-b[i]
    elif a[i]+a[i+1]<b[i]:
        ans+=a[i]+a[i+1]
        a[i+1]=0

print(ans)


Measured memory_bytes: 18476
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
  int  a[3];

  cin >> a[0] >> a[1] >> a[2];  
  sort(a, a+3);

  cout << a[1]-a[0]+a[2]-a[1] << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

H, W = map(int, input().split())
lis = []
for i in range(H):
    a = list(input())
    lis += a

lis = list(Counter(lis).values())
length = len(lis)

check_4 = 0
check_2 = 0
check_kisu = 0
for i in lis:
    if i % 4 == 0:
        check_4 += 1
    elif i % 2 == 0:
        check_2 += 1
    else:
        if check_kisu:
            print('No')
            exit()
        else:
            check_kisu = i % 4

if (H % 2 == 0) & (W % 2 == 0):
    if (check_kisu != 0) | (check_2 != 0):
        print('No')
        exit()

elif (H % 2 == 1) & (W % 2 == 1):
    if (H + W - 1 < check_kisu + 2 * check_2) | ((H + W - 1 - check_kisu - 2 * check_2) % 4 != 0):
        print('No')
        exit()

elif H % 2 == 1:
    if (W < 2 * check_2) | ((W - 2 * check_2) % 4 != 0):
        print('No')
        exit()


elif W % 2 == 1:
    if (H < 2 * check_2) | ((H - 2 * check_2) % 4 != 0):
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 9508
#include <stdio.h>

//数式の最大の長さ
#define MAXLENGTH 400
//オペランドの最大個数
#define MAXOP 100

void push(int stack[MAXOP], int *sp, int op);
int pop(int stack[MAXOP], int *sp);

int main(void)
{
	//spはスタックのポインタ、opは数式に含まれるオペランドを格納
	int i, sp, op;
	//calc_value1とcalc_value2は計算用のオペランドを格納
	int calc_value1, calc_value2;
	int stack[MAXOP];
	char formual[MAXLENGTH];

	//数式を入力
	scanf("%[^\n]", formual);

	//初期値は0
	sp = 0;
	i = 0;

	//数式の最後まで繰り返す
	while(formual[i] != '\0'){
		//数字ならば数値に変換し、プッシュする
		if(formual[i] >= '0' && formual[i] <= '9'){
			//数値に変換
			op = formual[i] - 48;
			i++;
			//数字が2桁以上の場合の動作
			while(formual[i] != ' '){
				op *= 10;
				op += formual[i] - 48; 
				i++;
			}

			push(stack, &sp, op);
		}
		//演算子ならばポップし、計算する
		else if(formual[i] == '+'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value1 + calc_value2;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}
		else if(formual[i] == '-'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value2 - calc_value1;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}
		else if(formual[i] == '*'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value1 * calc_value2;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}

		//インデックスを増加
		i++;
	}

	//結果をポップし出力
	op = pop(stack, &sp);
	printf("%d\n", op);

	return 0;
}

void push(int stack[100], int *sp, int op)
{
	stack[*sp] = op;
	*sp += 1;
}

int pop(int stack[100], int *sp)
{
	int op;

	*sp -= 1;
	op = stack[*sp];

	return op;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define int long long
int sum=0;
int a[510],ans,n,k;

int sum1[510],sum2[510],p[510];
bool check(int x){
	int cnt=0;
	for(int i=1;i<=n;i++)p[i]=a[i]%x;
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++)sum1[i]=sum1[i-1]+p[i];
	for(int i=n;i>=1;i--)sum2[i]=sum2[i+1]+x-p[i];
	int mi=k;
	for(int i=1;i<=n;i++){
		if(sum1[i]==sum2[i+1]){
			if(sum1[i]<=k)return 1;
			else return 0;
		}
	}
	return 0;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			if(check(i))ans=max(ans,i);
			if(i!=(sum/i)){
				if(check(sum/i))ans=max(ans,sum/i);
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;

int main(){
    int N, M;
    cin >> N >> M;
    VVI s(M);
    REP(i,M){
        int ktemp;
        cin >> ktemp;
        VI stemp(ktemp);
        REP(j,ktemp){
            cin >> stemp[j];
            stemp[j]--;
        }
        s[i] = stemp;
    }
    VI p(M);
    REP(i,M){
        cin >> p[i];
    }
    int cnt = 0;
    bool chk;
    REP(bit, (1<<N)){
        chk = true;
        REP(i, M){
            int temp = 0;
            int sz = s[i].size();
            REP(j, sz){
                if ((bit>>s[i][j]) & 1) temp++;
            }
            if (temp % 2 != p[i]){
                chk = false;
                break;
            }
        }
        if (chk) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#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
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> L(N);
    REP(i,N) cin >> L[i];
    sort(ALL(L));
    int sum = 0;
    REP(i,N-1) sum += L[i];
    if(sum <= L[N-1]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main() {
  long long N;
  cin >> N;

  long long max = floor(sqrt(N*1.0));
  long long count = 0;

  for(int i=1;i<max+1;++i){
    long long a = N/i -1;
    if(a && (N-i)%i==0 && N/a == N%a) count += (N-i)/i;
  }



  cout << count << endl;

}

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

int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    
    int arr[n];
    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    int dp[n];
    for(int i = 0; i < n; i++){
        dp[i] = 0;
    }
    
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    
    for(int i = 2; i < n; i++){
        int minimum = dp[i - 1] + abs(arr[i] - arr[i - 1]);
        for(int j = 2; j <= k ; j++){
            if(i - j >= 0)
            minimum = min(minimum, dp[i - j] + abs(arr[i] -  arr[i - j]));  
        }
        dp[i] += minimum;
    }
    cout<<dp[n - 1];
    return 0;
}


Measured memory_bytes: 4304
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int t;
	long long n, a, b, c, d, x, y, z, s, ans;
	priority_queue<pair<long long, long long> >q;
	set<long long>st;
	scanf("%d", &t);
	f(tt, t) {
		scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
		ans = 0;
		st.clear();
		while (!q.empty())q.pop();
		q.push(make_pair(0, n));
		while(true) {
			x = q.top().second;
			while (st.count(x) == 1) {
				q.pop();
				x = q.top().second;
			}
			if (x == 0) {
				ans = -(q.top().first);
				break;
			}
			s = q.top().first;
			st.insert(x);
			q.pop();
			if (x % 2 == 0) {
				y = x / 2;
				if (st.count(y) == 0) {
					q.push(make_pair(s - a, y));
				}
			}
			else {
				y = (x + 1) / 2;
				if (st.count(y) == 0) {
					q.push(make_pair(s - a - d, y));
				}
				y = (x - 1) / 2;
				if (st.count(y) == 0) {
					q.push(make_pair(s - a - d, y));
				}
			}
			if (x % 3 == 0) {
				y = x / 3;
				if (st.count(y) == 0) {
					q.push(make_pair(s - b, y));
				}
			}
			else {
				z = x % 3;
				y = (x - z) / 3;
				if (st.count(y) == 0) {
					q.push(make_pair(s - b - (z*d), y));
				}
				y++;
				if (st.count(y) == 0) {
					q.push(make_pair(s - b - ((3 - z)*d), y));
				}
			}
			if (x % 5 == 0) {
				y = x / 5;
				if (st.count(y) == 0) {
					q.push(make_pair(s - c, y));
				}
			}
			else {
				z = x % 5;
				y = (x - z) / 5;
				if (st.count(y) == 0) {
					q.push(make_pair(s - c - (z*d), y));
				}
				y++;
				if (st.count(y) == 0) {
					q.push(make_pair(s - c - ((5 - z)*d), y));
				}
			}
			z = abs(x);
			if ((10000000000000000 / z) > d) {
				q.push(make_pair(s - (z*d), 0));
			}
		}


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

	return 0;
}

Measured memory_bytes: 3712
#include<cstdio>
using namespace std;
int n,b[105];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <n; ++i) scanf("%d", &b[i]);
	int ans = b[n-1]+b[1];
	for (int i = n-2; i; --i) {
		if (b[i] >= b[i + 1])ans += b[i + 1];
		else ans += b[i];
	}
	printf("%d", ans);
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	*/
	long long int n,w;
	cin>>n>>w;

	long long int max_val=0;
	long long int max_wt=0;

	long long int wt[n],v[n];
	for(long long int i=0;i<n;i++) {
		cin>>wt[i]>>v[i];
		max_val+=v[i];
		max_wt+=wt[i];
	}

	long long int dp[n+1][max_val+1];
	
	for(long long int i=0;i<n;i++) {
		for(long long int j=0;j<=max_val;j++) {
			dp[i][j]=max_wt+1;
		}
	}
	long long int ans=0;

	dp[0][0]=0;
    for(long long int i=0;i<n;i++) {
	    for(long long int j=0;j<=max_val;j++) {
          	if(j>=v[i]) {
		        dp[i+1][j] = min(dp[i][j-v[i]] + wt[i], 
		        	dp[i][j]);
            } else {
		        dp[i+1][j] = dp[i][j];
            }
        }
    }

    for(long long int j=0;j<=max_val;j++)
    {
    	if(dp[n][j]<=w)
    		ans=max(ans,j);
    }

    cout<<ans<<"\n";
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
    int n=0,cnt=0;
    if(scanf("%d",&n)==EOF)break;
    for(int i=0;i<10;i++){
        for(int r=0;r<10;r++){
            for(int l=0;l<10;l++){
                for(int k=0;k<10;k++){
                    if(n==i+r+l+k)cnt++;
                }
            }
        }
    }
    cout << cnt <<endl;
    }

    return 0;
}

Measured memory_bytes: 1208
n=int(input())
s=input()
cnt=0
r_num=0
g_num=0
b_num=0
for i in s:
  if i=="R":
    r_num+=1
  if i=="G":
    g_num+=1
  if i=="B":
    b_num+=1
cnt=r_num*g_num*b_num

for i in range(1,n):
  l=i-1
  r=i+1
  while l>=0 and r<=n-1:
    if s[l]!=s[i] and s[i]!=s[r] and s[l]!=s[r]:
      cnt-=1
    l-=1
    r+=1
print(cnt)

Measured memory_bytes: 9208
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    string a, b ;
    cin >> a >> b;

    cout << b << a << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^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()
{
    ll n, d;
    cin >> n >> d;

    cout << ceil((ld)n/(2*d+1)) << "\n";
}




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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

const int mod = 998244353;

void Main() {
  int n; cin >> n;
  vector<int> m(n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    if (i == 0 && t) {
      cout << 0 << '\n';
      return;
    }
    m[t]++;
    mx = max(mx, t);
  }
  if (m[0] != 1) {
    cout << 0 << '\n';
    return;
  }
  int ans = 1;
  for (int i = 1; i <= mx; i++) {
    if (m[i] == 0) {
      cout << 0 << '\n';
      return;
    }
    for (int j = 1; j <= m[i]; j++) {
      ans *= m[i - 1];
      ans %= mod;
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


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

int used[100010];

int main(){
	int N; cin >> N;
	if(N == 1){ cout << "No" << "\n"; return 0; }
	if(N == 6){
		cout << "Yes" << "\n";
		cout << 3 << " " << 5 << "\n";
		cout << 4 << " " << 5 << "\n";
		cout << 4 << " " << 2 << "\n";
		cout << 9 << " " << 2 << "\n";
		cout << 9 << " " << 11 << "\n";
		cout << 10 << " " << 11 << "\n";
		cout << 10 << " " << 8 << "\n";
		cout << 1 << " " << 5 << "\n";
		cout << 7 << " " << 4 << "\n";
		cout << 4 << " " << 6 << "\n";
		cout << 2 << " " << 12 << "\n";
		return 0;
	}
	if(N % 4 == 1){
		cout << "Yes" << "\n";
		cout << 1 << " " << 2 << "\n";
		cout << N+1 << " " << 3 << "\n";
		cout << N+2 << " " << N << "\n";
		rep(i, N-2){
			cout << 2+i << " " << 3+i << "\n";
			cout << 2+i+N << " " << 3+i+N << "\n";
		}
	}else if(N % 4 == 3){
		cout << "Yes" << "\n";
		rep(i, 2*N-1){
			cout << i+1 << " " << i+2 << "\n";
		}
	}else{
		int n = N, f = 0;
		int ch;
		for(int i=0; f == 0; i++){
			if(N & (1<<i)){ ch = (1<<i); f = 1; n -= (1<<i); }
		}
		if(n == 0){
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << "\n";
		cout << N << " " << ch << "\n";
		cout << n << " " << ch << "\n";
		cout << 2*N << " " << n << "\n";
		int pr = -1;
		if((N-1) % 4 == 1){
			int p = (ch+2)/4, q = (n+2)/4;
			for(int i=1; i<=(N-2)/4; i++){
				if(i == p || i == q){
					rep(j, 3){
						cout << 4*i-2+j << " " << 4*i-1+j << "\n";
						cout << 4*i-2+j+N << " " << 4*i-1+j+N << "\n";
					}
					cout << 4*i+1 << " " << 4*i-2+N << "\n";
				}else{
					rep(j, 3){
						cout << 4*i-2+j << " " << 4*i-1+j << "\n";
						cout << 4*i-2+j+N << " " << 4*i-1+j+N << "\n";
					}
					cout << 4*i+1 << " " << 4*i-2+N << "\n";
					if(pr == -1){
						pr = i;
					}else{
						cout << 4*pr+1+N << " " << 4*i-2 << "\n";
						pr = i;
					}
				}
			}
			if(pr != -1){
				cout << N << " " << 4*pr+1+N << "\n";
			}
			cout << 1 << " " << 2 << "\n";
			cout << N+1 << " " << 3 << "\n";
		}else{
			int p = ch/4, q = n/4;
			for(int i=0; i<(N/4); i++){
				if(i == p || i == q){
					rep(j, 3){
						if(i != 0 || j != 0){
							cout << 4*i+j << " " << 4*i+1+j << "\n";
							cout << 4*i+j+N << " " << 4*i+1+j+N << "\n";
						}
					}
					if(i != 0){
						cout << 4*i+3 << " " << 4*i+N << "\n";
					}else{
						cout << 3 << " " << N+1 << "\n";
					}
				}else{
					rep(j, 3){
						if(i != 0 || j != 0){
							cout << 4*i+j << " " << 4*i+1+j << "\n";
							cout << 4*i+j+N << " " << 4*i+1+j+N << "\n";
						}
					}
					if(i != 0){
						cout << 4*i+3 << " " << 4*i+N << "\n";
					}else{
						cout << 3 << " " << N+1 << "\n";
					}
					if(pr == -1){
						pr = i;
					}else{
						cout << 4*pr+3+N << " " << 4*i << "\n";
						pr = i;
					}
				}
			}
			if(pr != -1){
				cout << N << " " << 4*pr+3+N << "\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main(void){
    int n, max = 1, cmax = 0;
    cin >> n;
    for(int i = 2; i <= n; i++){
        int tmp = i, count = 0;
        while(tmp%2==0){
            ++count;
            tmp /= 2;
        }
        if(count > cmax){
            max = i;
            cmax = count;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public  static  void main(String args[]){
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        int h []=new int[n];
        for(int j=0;j<n;j++)
            h[j]=sc.nextInt();
        int cost[]= new int [n];
        cost[0]=0;
        cost[1]=Math.abs(h[1]-h[0]);
        for (int i=2;i<n;i++){
            cost[i]=Math.min(cost[i-1]+Math.abs(h[i]-h[i-1]),cost[i-2]+Math.abs(h[i]-h[i-2]));
        }
        System.out.println(cost[n-1]);
    }
}


Measured memory_bytes: 50988
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n;
  cin >> n;
  vector<int> p(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int c;
    cin >> c;
    c--;
    p[c]++;
  }
  for (int i = 0; i < n; i++) {
    cout << p[i] <<endl;
  }
} 


Measured memory_bytes: 4052
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, [ $struct:ident; $( $field:ident ),* ]) => {
        $struct {
            $(
                $field : read_value!($iter),
            )*
        }
    };

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

    ($iter:expr) => {
        $iter.next().unwrap().parse().expect("Parse error")
    };
}

#[derive(Debug)]
struct Load {
    weight: i64,
    value: i64,
}

fn main() {
    input! {
        n: i64,
        w: i64,
        loads: [[Load; weight, value]; n as usize]
    }
    let vs: i64 = loads.iter().map(|l| l.value).sum();
    // [min_v][k] -> weight
    let mut cache = vec![vec![None; n as usize]; (vs + 1) as usize];
    for min_v in 0..=vs {
        for k in 0..=(n - 1) {
            let using = access(&cache, min_v - loads[k as usize].value, k - 1)
                .map(|s| s + loads[k as usize].weight);
            let not_using = access(&cache, min_v, k - 1);
            cache[min_v as usize][k as usize] =
                vec![using, not_using].into_iter().flat_map(|s| s).min();
        }
    }
    for min_v in (0..=vs).rev() {
        for k in 0..=(n - 1) {
            if let Some(min_w) = cache[min_v as usize][k as usize] {
                if min_w <= w {
                    println!("{}", min_v);
                    return;
                }
            }
        }
    }
    println!("{}", 0);
}

fn access(cache: &Vec<Vec<Option<i64>>>, v: i64, k: i64) -> Option<i64> {
    if v <= 0 {
        Some(0)
    } else if k < 0 {
        None
    } else {
        cache[v as usize][k as usize]
    }
}


Measured memory_bytes: 162220
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


int main()
{
    long long int n;
    cin >> n;
    vector<long long int> h;
    for (int i = 0; i < n; i++) {
        long long int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    vector<long long int> h2;
    long long int before = 0;
    for (int i = 0; i < n; i++) {
        h2.push_back(h[i] - before);
        before = h[i];
    }

    int res = 0;
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (h2[i] > 0) {
            res = max(res, count);
            count = 0;
        } else {
            count++;
        }
    }
    res = max(res, count);

    cout << res << endl;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int vis[N];

vector<int> pri;

void sieve()
{
    rep(i , 2 , 2300)
    {
        if(!vis[i])
            pri.push_back(i);
        for(int x : pri)
        {
            if(i * x > 2300) break ;
            vis[i * x] = 1;
            if(i % x == 0) break ;
        }
    }
}

int n ; LL A[N] , Ans;

LL L[N] , R[N];

map<LL , int> G;

int check(LL x)
{
    LL v = sqrt(x);
    return v * v == x;
}

int main()
{
    read(n) , sieve();
    rep(i , 1 , n) read(A[i]);
    rep(i , 1 , n)
    {
        LL x = A[i];
        for(int d : pri)
        {
            LL v = 1ll * d * d * d;
            if(v > x) break ;
            while(x % v == 0) x /= v;
        }
        G[x]++ , L[i] = x;
        LL y = 1;
        for(int d : pri)
        {
            if(1ll * d * d * d > x) break ;
            if(x % d == 0)
            {
                y *= (x % (1ll * d * d) == 0 ? d : 1ll * d * d);
                while(x % d == 0) x /= d;
            }
        }
        y *= check(x) ? sqrt(x) : x * x;
        R[i] = y;
    }
    if(G[1])
        Ans += 1 , G[1] = 0;
    rep(i , 1 , n)
        Ans += max(G[L[i]] , G[R[i]]) , G[L[i]] = G[R[i]] = 0;
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 12928
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
int main() {
	int n;
	std::cin >> n;
	int sum = 0;
	for (int i = 0; i < n;++i) {
		int st, ed;
		std::cin >> st >> ed;
		sum += ed - st + 1;
	}
	std::cout << sum << std::endl;
	return 0;
}

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

int main() {
	int A, B, C, K;
	bool flag = false;
	
	cin >> K >> A >> B;
	
	if(A%K == 0)
		flag = true;
	
	C = A/K;
	C++;
	C = C*K;
	if(C<=B)
		flag = true;
	
	if(flag)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
}


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

ll tetra(ll num){
    return ((num) * (num + 1) * (num + 2) / 6);
}
//100
int main() {
    ll N = 1e6;

    vector<ll> dp(1000001, 1e9);
    vector<ll> dp_o(1000001, 1e9);

    dp[0] = 0;
    dp_o[0]= 0;

    for(int i = 1; tetra(i) < 1e6 + 2; i++){
        for(int j = 0; j <= N; j++){
            if(j + tetra(i) >= 1e6) break;
            dp[j + tetra(i)] = min(dp[j + tetra(i)], dp[j] + 1);
        }
    }



    for(int i = 1; tetra(i) < 1e6 + 2; i++){
        for(int j = 0; j <= N; j++){
            if(j + tetra(i) >= 1e6) break;
            if(tetra(i) % 2 ==1) dp_o[j + tetra(i)] = min(dp_o[j +tetra(i)], dp_o[j] + 1);
        }
    }


    vector<ll> v_ans;
    vector<ll> v_ans_o;

    while(1){
        ll num;
        cin >> num;
        if(num == 0) break;
        v_ans.push_back(dp[num]);
        v_ans_o.push_back(dp_o[num]);
    }

    for(int i = 0; i < v_ans.size(); i++){
        cout << v_ans[i] <<" "<< v_ans_o[i] << endl;
    }
}





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

int main()
{
    int N; cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }
    int sum = 0;
    for(int i = 0; i < N; i++)
    {
        sum += L.at(i); 
    }
    int Max_L = 0;
    for(int i = 0; i < N; i++)
    {
        if(Max_L < L.at(i))
        {
            Max_L = L.at(i);
        }
    }
    if(2*Max_L < sum)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ans = 0;
	rep(i, A+1) {
		rep(j, B+1) {
			rep(k, C+1) {
				int sum = 500*i + 100*j + 50*k;
				if (sum == X) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
Blue = [str(input()) for i in range(N)]
M = int(input())
Red = [str(input()) for i in range(M)]
Blue_Set = list(set(Blue))
X = 0
for i in range(len(Blue_Set)):
  if (Blue.count(Blue_Set[i]) - Red.count(Blue_Set[i])) > X:
    X = Blue.count(Blue_Set[i])-Red.count(Blue_Set[i])
print(X)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6 + 50;
int node[N][28], num[N], u, v, type, ql, qr, p, n, q;
int alpha[30];
char s[N], ch;

void update(int o, int L, int R) {
    int M = L + (R - L) / 2;
    if(L == R) {
        node[o][u] --;
        node[o][v] ++;
    }else {
        //int cnt = 0;
        if(p <= M)update(o*2, L, M);
        else update(o*2+1, M+1, R);
        for(int i=0;i<26;i++) {
            node[o][i] = node[o*2][i] + node[o*2+1][i];
        }
    }
}

void query(int o, int L, int R) {
    int M = L + (R - L) / 2;
    if(ql <= L && R <= qr) {
        for(int i=0;i<26;i++)
            alpha[i] += node[o][i];
        return;
    }
    if(ql <= M)query(o*2, L, M);
    if(M < qr)query(o*2+1, M+1, R);
}

int main() {
    cin>>n;
    scanf("%s", s);
    for(int i=1;i<=n;i++) {
        num[i] = s[i-1] - 'a';
        u = 27;
        v = num[i];
        p = i;
        update(1, 1, n);
    }
    cin>>q;
    while(q --) {
        cin>>type;
        if(type == 2) {
            scanf("%d%d", &ql, &qr);
            memset(alpha, 0, sizeof(alpha));
            query(1, 1, n);
            int ret = 0;
            for(int i=0;i<26;i++) {
                if(alpha[i] > 0)ret ++;
            }
            cout<<ret<<endl;
        }else {
            cin>>ql>>ch;
            u = num[ql];
            v = ch - 'a';
            num[ql] = v;
            p = ql;
            update(1, 1, n);
        }
    }
    return 0;
}


Measured memory_bytes: 119680
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<vector<int> > a(2, vector<int>(n));
    rep(i, 2)rep(j, n) cin >> a[i][j];

    for (int i = 0; i < n; i++) {
        int num = 0;
        for (int j = 0; j < n; j++) {
            if (j == i) {
                num += a[0][j] + a[1][j];
            }
            else if (j > i) {
                num += a[1][j];
            }
            else {
                num += a[0][j];
            }
        }
        ans = max(ans, num);
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

int main(){

    long A,V; // oni
    long B,W; // nigeteru
    long T;

    cin >> A >> V >> B >> W >> T;

    if(V <= W ){
        printf("NO");
        return 0;
    }

    if(A == B){
        printf("YES");
        return 0;
    }

    long double catch_time = double (abs(A - B)) / double(V - W);

    if(catch_time > T){
        printf("NO");
        return 0;
    }

    printf("YES");

  return 0;
}


Measured memory_bytes: 3764
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = list(map(int, input().split()))
u = 10**9+7
M = 61
ANS = 0

for i in range(M):
    d = 1 << i
    zero = 0
    for j in range(N):
        k = l[j]
        if (k & d)==0:
            zero += 1
    ANS += zero*(N-zero)*(2**i)
    ANS %= u
print(ANS)

Measured memory_bytes: 124728
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define sum(n)((n)*((n)+1)/2)


ll a[100010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);
	
	ll l=2,r=2;
	for(int i=n-1;i>=0;i--){
		//lを[l,r]にある最小のa[i]の倍数
		//rを[l,r]にある最大のa[i]の倍数+a[i]-1
		//にそれぞれ更新
		ll tl=(l-1+a[i])/a[i]*a[i];
		ll tr=r/a[i]*a[i]+a[i]-1;
		if(tl>r){
			puts("-1");
			return 0;
		}
		l=tl;
		r=tr;
	}
	
	printf("%lld %lld\n",l,r);
	return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

int main()
{
	
string s;
cin>>s;
cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;

}



Measured memory_bytes: 3520
H[1<<18],h;
p(a){
	for(*H=a,a=++h;a>1&*H>H[a/2];a/=2)H[a]=H[a/2];
	H[a]=*H;
}
q(a,b){
	for(a=b=1;a<h&H[a]>H[h];H[a]=H[b=(H[b=a*2]<H[b+1]&b<h)+b])a=b;
	H[a]=H[h];H[h--]=0;
}
long s;N;M;
main(a){
	for(scanf("%d%d",&N,&M);~scanf("%d",&a);)p(a);
	for(;M--;p(a/2))q(a=H[1]);
	for(;N--;s+=a)q(a=H[1]);
	printf("%ld",s);
}


Measured memory_bytes: 2036
import sys
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
s=[]
linecnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	linecnt+=1
	if linecnt<8:
		s.append(line.rstrip("\n"))
	else:
		s.append(line.rstrip("\n"))
		while s[0]=="00000000":
			del(s[0])
		while s[len(s)-1]=="00000000":
			del(s[len(s)-1])
		i=len(s[0])-1
		while i>=0:
			for l in xrange(len(s)):
				if s[l][i]=="1":
					break
			else:
				for l in xrange(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
			i-=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])
		linecnt=0

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    char x, y;
    cin >> x >> y;
    if(x < y) cout << '<' << endl;
    else if(x > y) cout << '>' << endl;
    else cout << "=" << endl;

    return 0;
}

Measured memory_bytes: 3508
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n, ma;
vector<int> acc, cnt;
set<vector<int>> res;
void dfs(int cur) {
    if (acc.size() == n) {
        auto tmp(acc);
        sort(tmp.begin(), tmp.end());
        for (int i = 0; i + 1 < n; i++) tmp[i] = tmp[i + 1] - tmp[i];
        tmp.pop_back();
        res.emplace(tmp);
        return ;
    }
    while (cur > 0 && cnt[cur] == 0) cur--;
    if (cur == 0) return;
    for (int k: {cur, ma - cur}) {
        bool neg = false;
        for (int x: acc) if (--cnt[abs(x - k)] < 0) neg = true;
        if (!neg) {
            acc.emplace_back(k);
            dfs(cur);
            acc.pop_back();
        }
        for (int x: acc) ++cnt[abs(x - k)];
    }
}

int main() {
    while (cin >> n, n) {
        int nC2 = n * (n - 1) / 2;
        cin >> ma;
        cnt.assign(401, 0);
        while (--nC2) {
            int d; cin >> d; cnt[d]++;
        }
        acc.clear();
        acc.emplace_back(0);
        acc.emplace_back(ma);
        res.clear();
        dfs(ma);
        for (auto &v: res) {
            for (int i = 0; i < n - 1; i++) cout << v[i] << " \n"[i == n - 2];
        }
        cout << "-----" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    while (n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<tgmath.h>
int main()
{
  long double a, b, c;
  scanf("%Lf%Lf%Lf", &a, &b, &c);
  long double e = 1.0e-14;
  if(sqrtl(a)+sqrtl(b)+e < sqrtl(c))
    printf("Yes");
  else 
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

bool ok(string s) {
    int N = s.size();
    for(int i = 0; i < N - i - 1; i++) {
        if(s[i] != s[N - 1 - i])
            return false;
    }
    return true;
}

int main() {
    string S;
    cin >> S;
    if(ok(S) && ok(S.substr(0, S.size() / 2)) &&
       ok(S.substr(S.size() / 2 + 1, S.size() / 2))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

n, x = map(int, input().split())
xx = list(map(int, input().split()))

ls = []
xx.sort()


for s in xx:
    diff = abs(x-s)
    ls.append(diff)


def gcd_ls(num):
    return reduce(gcd, num)


print(gcd_ls(ls))


Measured memory_bytes: 16308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=420;
const int mod=998244353;
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int jc[maxn],jcn[maxn],inv[maxn];
inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,400)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

int n,a[maxn],b[maxn],sa,sainv,p[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)a[i]=read(),b[i]=read(),sa+=a[i];
	sainv=power(sa,mod-2);
	REP(i,1,n)p[i]=(ll)a[i]*sainv%mod;
}

int dp[maxn][maxn];

inline void doing()
{
	dp[0][0]=1;
	REP(i,1,n)
	{
		DREP(j,400,0)DREP(k,400,0)if(dp[j][k])
		{
			int t=dp[j][k]; dp[j][k]=0;
			int xs=1;
			dp[j][k+a[i]]=(dp[j][k+a[i]]+t)%mod;
			REP(x,0,b[i]-1)
			{
				dp[j+x][k]=(dp[j+x][k]-(ll)t*xs%mod+mod)%mod;
				xs=(ll)xs*p[i]%mod*inv[x+1]%mod;
			}
		}
	}
	int ans=0;
	REP(j,0,400)REP(k,0,sa-1)if(dp[j][k])
	{
		int v=(ll)k*sainv%mod;
		int c=(mod-dp[j][k])%mod;
		ans=(ans+(ll)c*power(1-v+mod,mod-j-2)%mod*jc[j])%mod;
	}
	printf("%d\n",ans);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const long long MOD = 1e9 + 7;
const int MAXN = 2001;
long long dp[MAXN][MAXN];
int s[MAXN], t[MAXN];

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

	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
	for (int i = 1; i <= m; i++) scanf("%d", &t[i]);

	for (int i = 0; i <= n; i++) dp[i][0] = 1;
	for (int i = 0; i <= m; i++) dp[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + MOD) % MOD;
			if (s[i] == t[j]) dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
		}
	}

	/*
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) printf("%lld ", dp[i][j]);
		puts("");
	}
	*/

	printf("%lld\n", dp[n][m]);
}


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

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;

    while(a >= b) {
        b *= 2;
        k--;
    }

    if(k < 0) {
        cout << "No" << endl;
        return 0;
    }

    while(b >= c) {
        c *= 2;
        k--;
    }

    if(k < 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n),dist(n,LINF),ord;
	rep(i,n)cin>>a[i],a[i]--;
	ll next=0,cur=-1;
	while(dist[next]==LINF){
		cur++;
		dist[next]=cur;
		ord.push_back(next);
		next=a[next];
	}
	ll loop=cur-dist[next]+1;
	ll tab=0;
	if(k>=dist[next]){
		k-=dist[next];
		k%=loop;
		k+=dist[next];
	}
	ll ans=ord[k]+1;
	puta(ans);
}


Measured memory_bytes: 8380
asdf = int(input())
if asdf % 2 == 0:
  k1 = asdf / 2
  Ans = k1 * k1
else:
  k2 = (asdf + 1) / 2
  k3 = k2 - 1
  Ans = k2 * k3
print(int(Ans))

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char c1,c2;
	cin>>c1;
	int c=0;
	while(~scanf("%c",&c2)&&c2!='\n')
	{
		if(c1!=c2)c++;
		c1=c2;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()

a,b = na()
if  a == 1: a += 13
if b == 1: b += 13
if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")


Measured memory_bytes: 3316