akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

int A[MAX];
LL P[MAX];
LL N[MAX];
int n, k;

LL getN(int l, int r)
{
	if (r < 0) return 0;
	if (l >= n) return 0;
	LL res = N[r];
	if (l) res -= N[l - 1];
	return res;
}

LL getP(int l, int r)
{
	if (r < 0) return 0;
	if (l >= n) return 0;
	LL res = P[r];
	if (l) res -= P[l - 1];
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	FOR(i, 0, n)
	{
		cin >> A[i];
	}

	FOR(i, 0, n)
	{
		if (i)
		{
			P[i] = P[i - 1];
			N[i] = N[i - 1];
		}

		if (A[i] > 0) P[i] += A[i];
		N[i] += A[i];
	}

	LL ans = -LINF;
	FOR(l, 0, n)
	{
		int r = l + k - 1;
		if (r >= n) break;
		LL tmp = getP(0, l - 1) + getP(r + 1, n - 1) + getN(l, r);
		ans = max(tmp, ans);
		tmp = getP(0, l - 1) + getP(r + 1, n - 1);
		ans = max(tmp, ans);
	}

	cout << ans << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

std::string S;
int cnt[2];

int main()
{
  std::cin >> S;

  rep( i, 3 )
    ++cnt[S[i]-'A'];

  std::cout << (cnt[0]&&cnt[1] ? "Yes" : "No" ) << std::endl;

  return 0;
}

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

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

    sort(s.begin(), s.end());
    
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
s=list(input())[::-1] # 10進数で位を上げていくために反転させる
n=len(s)
amari_lis=[0]*2019 # 
amari_lis[0]=1 # 2019で割り切れる場合、組合せ総数は (n+1)C2 となるため（その他はnC2でOK）

num=0
kurai=1
for keta in s:
    num+=int(keta)*kurai
    num%=2019
    amari_lis[num]+=1
    kurai*=10
    kurai%=2019 # amari_lisが 0~2019 のため、位の数も 2019 で割った余りで考える

ans=0
for i in amari_lis:
    ans+=i*(i-1)/2 # nC2の計算, 余りが同じものを引けば 0⇒2019で割れると言える（組合せ数を逐次追加することで総数算出）

print(int(ans))

Measured memory_bytes: 11892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    ll ans;
    REP(i,1,6){
        int x; cin >> x;
        if(x == 0)ans = i;
    }
    cout << ans << endl;
    return 0;
}  

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

int main() {
	int n,pt=0,px=0,py=0,f=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t,x,y;
		cin>>t>>x>>y;
		int a=abs(x-px);
		int b=abs(y-py);
		int c=abs(t-pt);
		if(abs(x-px)+abs(y-py)>(t-pt))  f=0;
		else
		{
			if((a+b)%2!=c%2) f=0;
		}
		pt=t; px=x; py=y;
	}
	if(f)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ATCoder
{
    class Program
    {
        static void Main( string[] args )
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine();

            string[] token1 = input1.Split(' ');
            string[] token2 = input2.Split(' ');
            int H = int.Parse(token1[0]);
            int N = int.Parse(token1[1]);
            int A = 0;

            for(int i = 0; i < N; i++)
            {
                A += int.Parse(token2[i]);
            }
            
            if(A >= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 18528
# ABC094D - Binomial Coefficients (ARC095D)
def main():
    # pascal's triangle := mid area (nCn/2) is the biggest
    N, *A = map(int, open(0).read().split())
    n = max(A)
    mid, r, cur = n / 2, -1, float("inf")
    for i in A:
        if i != n:
            x = abs(mid - i)
            if x < cur:
                r, cur = i, x
    print(n, r)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14028
#include<stdio.h>
#include<math.h>
#include<string.h>
int n,w[10];
double a[10],b[10],c[10],sum,ans;
void dfs(const int x,int y)
{
	if(x==n-1) {
		for(int i=0;i<x;i++)
		{
			sum+=c[i];
	//		printf("c[%d]=%.10lf\n",i,c[i]);
		}
	return ;
	}
	for(int i=0;i<n;i++)
	{
		if(w[i]==0)
		{
			c[x]=sqrt((a[i]-a[y])*(a[i]-a[y])+(b[i]-b[y])*(b[i]-b[y]));
		//	printf("%lf\n",c[x]);
			w[i]=1;
			dfs(x+1,i);
			w[i]=0;
		}
	}
	return ;
}
int main()
{
	while(~scanf("%d",&n))
	{
		memset(w,0,sizeof(w));
		for(int i=0;i<n;i++)
		scanf("%lf%lf",&a[i],&b[i]);
		sum=0;
		for(int i=0;i<n;i++){
			w[i]=1;
		    dfs(0,i);
			w[i]=0;
		}
		int f(int n);
		int d=f(n);
		ans=sum/d;
		printf("%.10lf\n",ans);
	}
} 
int f(int n)
{
	if(n==0||n==1)return 1;
	else return f(n-1)*n;
}

Measured memory_bytes: 128
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	string s;
	cin>>s;
	LL sum = 0;
	for(int i=0;i<s.length();i++) {
		sum  = sum + (s[i]-'0');
	}
	if(sum % 9 == 0) cout<<"Yes"<<en;
	else cout<<"No"<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3748
use proconio::input;

fn main() {
    input!(n: usize, a: [i32; n]);
    let a: Vec<_> = std::iter::once(0)
        .chain(a.into_iter())
        .chain(std::iter::once(0))
        .collect();
    let dist = |i: usize, j: usize| (a[i] - a[j]).abs();
    let full = (0..=n).map(|i| dist(i, i + 1)).sum::<i32>();
    for i in 1..=n {
        println!(
            "{}",
            full - dist(i - 1, i) - dist(i, i + 1) + dist(i - 1, i + 1)
        );
    }
}


Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  ll a,b;
  cin>>a>>b;
  ll res=0;
  ll tmp=a;
  while(tmp<=b){
    tmp*=2;
    res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(n);
	int ans[n+1];
	mem(ans);
	int res = 0;
	rep(i, 1, n+1)
	{
		for(int j=i;j<=n; j+=i) ans[j] += 1;
		res += ans[i]*i;
	}
	cout<<res<<endl;	
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


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

using Lint=long long;
const int INF=1e9;

int main()
{
   int N; cin>>N;
   vector<int> row(N),col(N);
   for(int i=0;i<N;i++) cin>>row[i]>>col[i];

   vector<vector<int>> dp(N+1,vector<int>(N+1,INF));
   for(int i=0;i<N;i++) dp[i][i+1]=0;
   for(int len=2;len<=N;len++){
      for(int l=0;l+len<=N;l++){
         int r=l+len;
         for(int m=l+1;m<r;m++) dp[l][r]=min(dp[l][r],dp[l][m]+dp[m][r]+row[l]*row[m]*col[r-1]);
      }
   }
   cout<<dp[0][N]<<endl;
   return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int X,A;
	cin>>X>>A;
	if(X<A)
		cout<<0;
	else
		cout<<10;
		
	return 0;
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

ll ffind(vl &v,ll x)
{
    for(auto i:v) if(i==x) return 2;
    return -1;
}

void _case()
{
    ll x,y;
    cin>>x>>y;
    if((x==2 or y==2) and x!=y) cout<<"No" el;
    else{
        vector<ll> v={1,3,5,7,8,10,12},z={4,6,9,11};
        if(ffind(v,x)!=-1 and ffind(v,y)!=-1){cout<<"Yes" el;}
        else if(ffind(z,x)!=-1 and ffind(z,y)!=-1){cout<<"Yes" el;}
        else cout<<"No" el;
    }

}

main()
{
//      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cout << #x << " = " << x << endl;
#define pb push_back
#define MP make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vii vector<pi>
#define all(x) x.begin(), x.end()

int n,m,t,k;
int d[MAXN];
int dp[MAXN];

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

	cin >> n >> k;
	for (int i = 0; i < n;++i)
		cin >> d[i];
	
	for (int i = 0; i <= k;++i)
		dp[i] = -1; 

	dp[0] = 1;
	for (int i = 1; i <= k; ++i)
	{
		bool flag = false;
		for (int j = 0; j < n; ++j)
			if(i >= d[j] && dp[i-d[j]] == 1)
			{
				flag=1;
				break;
			}	
		if(flag)
			dp[i] = 0;
		else
			dp[i] = 1; 	
	}

	if(dp[k] == 0)
		cout << "First\n";
	else
		cout << "Second\n";

	// for (int i = 0; i <= k; ++i)
	// {
	// 	cout << i _ dp[i] << endl; 
	// }

	return 0;
}


Measured memory_bytes: 640
integer :: n,d
      integer,allocatable :: x(:,:)
      integer :: i,j,k, dist2,ans
      
      read*,n,d
      allocate( x(n,d) )
      do i = 1,n
        read*,x(i,:)
      end do
      
      ans = 0
      do i = 1,n-1
        do j = i+1,n
          
          dist2 = 0
          do k = 1,d
            dist2 = dist2 + ( x(i,k)-x(j,k) )**2
          end do
          
          if( dist2==int(sqrt(real(dist2)))**2 )then
            ans = ans + 1
          end if
        end do
      end do
      
      print*,ans
      end

Measured memory_bytes: 2844
#include<cstdio>
#include<cstring>
char a[105],b[]="keyence";
int main()
{
    scanf("%s",a);
    int lena=strlen(a);
    int i=0,j=lena-1,tot=0;
    while(a[i]==b[i] && i<7)
    {
        i++;tot++;
    }
    j=lena-1;
    while(a[j]==b[j-lena+7] && j>=lena-7)
    {
        j--;tot++;
    }
    if(tot>=7)
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int H,W;
	int h,w;
	int K,k;
	
	cin >> H >> W;
	seiyaku_check(H,1,20);
	seiyaku_check(W,1,20);
	
	cin >> h >> w;
	seiyaku_check(h,1,H);
	seiyaku_check(w,1,W);

	k=H*W-(H*w+W*h)+h*w;
	
	cout << k << endl;
	
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INFTY 1000000001

int A[500000];
int n;

typedef long long llong;

llong merge(int A[],int left,int mid,int right) {

	llong sum = 0;
	int i,k,j,n1,n2;

	n1 = mid - left;
	n2 = right - mid;

	//L[0...n1], R[0...n2] を生成

	int L[n1+1], R[n2+1];

	for(i=0; i<n1; i++) {
		L[i]=A[left+i];
	}

	for(i=0; i<n2; i++) {
		R[i]=A[mid+i];
	}

	L[n1] = INFTY;
	R[n2] = INFTY;
	
	i = 0;
	j = 0;

	for (k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i = i + 1;
		}
		else {
			A[k] = R[j];
			j = j + 1;
			sum+=n1-i;
		}

	}
	return sum;
}

llong mergeSort(int A[], int left, int right) {
	
	int mid;
	llong v1,v2,v3;
	
	if(left+1 < right) {
		mid = (left + right)/2;
		v1=mergeSort(A, left, mid);
		v2=mergeSort(A, mid, right);
		v3=merge(A, left, mid, right);
		return v1+v2+v3;
	}
	else return 0;
}

int main(void) {

	int i;
	scanf("%d",&n);

	for(i=0; i<n; i++) scanf("%d",&A[i]);
	
	llong ans = mergeSort(A,0,n);
	printf("%lld\n", ans);
	
	return 0;
}




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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef array<int, 3> iii;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int X, Y, Z, N;
ii P[MX_N];
ll ans, mx;
ll L[MX_N], R[MX_N];

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> X >> Y >> Z;
    N = X+Y+Z;
    ans = 0;
    FOR(i,1,N){
        int A, B, C; cin >> A >> B >> C;
        ans += C;
        P[i] = ii(A-C,B-C);
    }
    sort(P+1,P+1+N,[](ii a, ii b) {
                if (a.fi-a.sc == b.fi-b.sc) {
                    if (a.fi == b.fi) return a.sc < b.sc;
                    else return a.fi > b.fi;
                }
                return a.fi-a.sc > b.fi-b.sc;
            });

    multiset<ll> ms;
    L[0] = 0;
    FOR(i,1,N){
        ms.insert(P[i].fi);
        L[i] = L[i-1] + P[i].fi;
        if (SZ(ms) > X) { L[i] -= *ms.begin(); ms.erase(ms.begin()); }
    }
    ms.clear();
    R[N+1] = 0;
    RFOR(i,N,1){
        ms.insert(P[i].sc);
        R[i] = R[i+1] + P[i].sc;
        if (SZ(ms) > Y) { R[i] -= *ms.begin(); ms.erase(ms.begin()); }
    }
    mx = -1e18;
    FOR(i,X,N-Y){
        mx = max(mx,L[i]+R[i+1]);
    }
    cout << ans+mx << '\n';
}



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

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

    rep(i, n) cout << s[i] << t[i];
    cout << endl;
}

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

int main(){
  vector<int> array;
  int tmp;
  for(int i=0;i<5;i++){
    cin >> tmp;
    array.push_back(tmp);
  }

  sort(array.begin(), array.end(), std::greater<int>());

  for(int i=0;i<array.size();i++){
    cout << array[i] << ((i!=4)?' ':'\n');
  } 
}


  

Measured memory_bytes: 1220
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll x,n;
	cin>>x>>n;
	
	vll a(n),cnt(200,0);
	
	for(ll i=0;i<n;i++)
		cin>>a[i],cnt[a[i]]++;
	if(n==0){
		cout<<x;
		return;
	}
	ll l,r;
	for(ll i=x;i<=101;i++)
		if(cnt[i]==0)
		{	l=i;
			break;
			
		}
	for(ll i=x-1;i>=0;i--)
		if(cnt[i]==0)
		{	r=i;
			break;
			
		}
	if(l-x<x-r)
		cout<<l;
	else
		cout<<r;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

struct UnionFind
{
    vector<int> par;
    vector<int> rank;
    vector<int> num;

    UnionFind(int N) : par(N), rank(N), num(N)
    {
        for (int i = 0; i < N; i++)
        {
            par[i] = i;
            rank[i] = 0;
            num[i] = 1;
        }
    }

    void init(int N)
    {
        for (int i = 0; i < N; i++)
        {
            par[i] = i;
            rank[i] = 0;
            num[i] = 1;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    int ranker(int x)
    {
        x = root(x);
        return rank[x];
    }

    int number(int x)
    {
        x = root(x);
        return num[x];
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (rank[rx] < rank[ry])
        {
            par[rx] = ry;
            num[ry] += num[rx];
            num[rx] = 0;
        }
        else
        {
            par[ry] = rx;
            num[rx] += num[ry];
            num[ry] = 0;
            if (rank[rx] == rank[ry])
                rank[rx]++;
        }
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
};

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

    ll N;
    cin >> N;

    map<ll, ll> X, Y;
    UnionFind Group(N);

    ll now = 0;
    rep(i,N){
        ll x, y;
        cin >> x >> y;

        if(X.count(x) == 0 and Y.count(y) == 0){
            X[x] = now, Y[y] = now;
            ++now;
        }else if(X.count(x) == 0){
            X[x] = Y[y];
        }else if(Y.count(y) == 0){
            Y[y] = X[x];
        }else{
            if(X[x] != Y[y]){
                Group.unite(X[x], Y[y]);
            }
        }
    }

    vector<ll> xv(N, 0), yv(N, 0);

    for(auto x : X) ++xv[Group.root(x.second)];
    for(auto y : Y) ++yv[Group.root(y.second)];

    ll ans = 0;
    rep(i, N) ans += xv[i] * yv[i];

    print(ans - N);

    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> a(n);
    vector<int> b;
    int sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        if(a.at(i) % 10 != 0) {
            b.push_back(a.at(i));
        }
        sum += a.at(i);
    }
    sort(b.begin(), b.end());

    if(sum % 10 == 0) {
        if(b.size() == 0) {
            sum = 0;
        }else {
            sum -= b.at(0);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	int a;
  	cin >> a;
  	while(a>0){
    	if(a%10==7){
        	cout << "Yes"<< endl;
          	return 0;
        }
      	a/=10;
    }
  	cout << "No"<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int p(vector<int>x,int y,int z){
  int l=0;
  for(int i=0;i<x.size();i++){
    if(y<x.at(i) && x.at(i)<=z){
    l++;
    } 
  }
  return l;
}
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  vector<int>c(n);
  for(int i=0;i<n;i++){
  cin >> c.at(i);
  }
  cout << min(min(p(c,0,a),p(c,a,b)),p(c,b,21)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;


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

  string s,t;
  cin>>s>>t;
  RH rh(s),rh2(t);
  int n=s.size(),m=t.size();
  rep(i,n-m+1){
    if(rh.get(i,i+t.size())==rh2.get(0,t.size())) cout<<i<<endl;
  }



}


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

int main(){
	int n, m, k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    vector<ll> sa(n+1, 0), sb(m+1, 0);
    rep(i, n) cin >> a[i], sa[i+1] = sa[i] + a[i];
    rep(i, m) cin >> b[i], sb[i+1] = sb[i] + b[i];
    
    ll ans = 0, j = m;
    rep(i, n+1){
        if(sa[i] > k) break;
        while(sb[j] > k - sa[i]){
            j--;
        }
        ans = max(ans, i+j);
    }

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

Measured memory_bytes: 7924
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var S string
  var i int

  //S = "2019/10/20"
  //fmt.Println(S[5:7])
  fmt.Scan(&S)

  i, _ = strconv.Atoi(S[5:7])
  //fmt.Println(i)

  if i <=4 {
    fmt.Println("Heisei")
  } else {
    fmt.Println("TBD")
  }

}


Measured memory_bytes: 512
#include <stdio.h>
int main (int argc, char * argv[])
{
    int n;//サイコロの個数
    int dice[100][7];
    int i,j,k,l;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=1;j<7;j++){
            scanf("%d",&dice[i][j]);
        }
    }
    //処理
    for(l=1;l<n;l++){
        for(i=0;i<6;i++){
            if(dice[0][1]==dice[l][1])
                for(j=0;j<4;j++){
                    
                    
                    for(k=1;k<7;k++)
                        if(dice[0][k]!=dice[l][k])break;
                    if(k==7){
                        printf("No\n");
                        return 0;
                    }
                    
                   dice[l][0] = dice[l][2];
                   dice[l][2] = dice[l][3];
                   dice[l][3] = dice[l][5];
                   dice[l][5] = dice[l][4];
                   dice[l][4] = dice[l][0];
                }
            dice[l][0] = dice[l][1];
                    
            switch(i){
                        
                case 2:
                    dice[l][1] = dice[l][3];
                    dice[l][3] = dice[l][6];
                    dice[l][6] = dice[l][4];
                    dice[l][4] = dice[l][0];
                    break;
                    
                default:
                    dice[l][1] = dice[l][2];
                    dice[l][2] = dice[l][6];
                    dice[l][6] = dice[l][5];
                    dice[l][5] = dice[l][0];
                    break;
               
          }
//            printf("配列[%d][%d] %d ",l,i,dice[l][i]);
//
        }
//        printf("\n");
    }
    printf("Yes\n");
    return 0;
}



Measured memory_bytes: 2104
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}


//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
int main(){
  int x,y,ans=0;
  cin>>x>>y;
  if(x==1&&y==1)ans=1000000;
  else if(x==1){
    ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
  }
   else if(x==2){
    ans+=200000;
    if(y==1)ans+=300000;
     if(y==2)ans+=200000;
    if(y==3)ans+=100000;
  }
   else if(x==3){
    ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
     if(y==3)ans+=100000;
  }
   else{
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define fast_cin ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back
#define all(con) (con).begin(), (con).end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define ff(i,a,b) for(int i=a;i<=b;i++)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
 
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
 
int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
		res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}
 
const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
 
const int N = 1e5 + 10 ;
 
void solve() {
        string s;
        cin>>s;
        int n=s.length();
        while(n--)cout<<"x";
}
 
signed main() {
        fast_cin;
	
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    	#endif
	
	int tests=1;
	// cin>>tests;
	while(tests--) {
		solve();
	}
 
return 0 ;
}
 

Measured memory_bytes: 256
N,M = map(int,input().split())
AB=[[int(j) for j in input().split()] for i in range(N)]
ans=0
AB = sorted(AB)
num, ans, i,j =0,0,0,1
while num<M:
    if j<=AB[i][1]:
        ans += AB[i][0]
        num+=1
        j+=1
    else:
        i+=1
        j=1
print(ans)

Measured memory_bytes: 22376
n=int(input())
aa=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
ans=sum(aa)
ind=[0]*(10**5)
for i in aa:
  ind[i-1]+=1
for b,c in bc:
  ans+=(c-b)*(ind[b-1])
  ind[c-1]+=ind[b-1]
  ind[b-1]=0  
  print(ans)
  
  


Measured memory_bytes: 32140
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a[-1] / 2
i = bisect.bisect(a, b)
if a[i] - b < b - a[i - 1]:
    print(a[-1], a[i])
else:
    print(a[-1], a[i - 1])

Measured memory_bytes: 62832
import sys
sys.setrecursionlimit(10**6)
n,k = map(int, input().split())
a = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
for i in range(n):
    adjacent_list[i+1].append(a[i])
finished = set()
route = []
def dfs(node):
    finished.add(node)
    route.append(node)
    for i in adjacent_list[node]:
        if i not in finished:
            dfs(i)
dfs(1)
if len(route) > k:
    print(route[k])
else:
    index = route.index(adjacent_list[route[-1]][0])
    k -= index
    route = route[index:]
    print(route[k % len(route)])
        

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


int main(){
    /*#ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif*/
    
    long long n,k;
    scanf("%lld %lld",&n,&k);

    n%=k;

    printf("%lld\n",min(n,k-n));
    
    
    return 0;
}


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

int main(void) {
  string str;
  cin >> str;

  char c;
  for (int i=0; i<str.length(); i++) {
    c = str[i];
    if (c == ',') {
      str.replace(i, 1, " ");
    }
  }

  cout << str << endl;
  return 0;
}


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

int main() {
  int lst[5];
  for (int i = 0; i < 5; i++) {
    cin >> lst[i];
  }

  int x = 1;
  for (int i = 0; i < 5; i++) {
    if (x * lst[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3584
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

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

int main() {
  int n;
  cin >> n;
  vector<long long> xs(n);
  rep(i, n) cin>>xs[i];

  vector<int> skips(n);
  int sk = 0;
  for(int i=n-1; i>=0; --i) {
    sk = xs[i]==0 ? sk+1 : 0;
    skips[i] = sk;
    //cout << sk << endl;
  }

  //for(auto x : skips) cout << x << " ";

  long ans = 0;
  rep(i, n) {
    long long sum=0;
    long long xors=0;
    for (int j=i; j<n; ++j) {
      if (skips[j] > 0) {
	ans += skips[j];
	j += skips[j]-1;
	continue;
      }
      sum += xs[j];
      xors^= xs[j];
      if (sum!=xors) break;
      ans++;
    }
    //cout << i << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <deque>
#define MAXN 1000010
using namespace std;

int n,k;
int a0[MAXN],ans[MAXN];

namespace Queue{
	deque<int> Q;
	int delta;

	void rev(){ delta^=1; }
	int front(){ return Q.front()^delta; }

	void setFront(int x){
		Q.pop_front();
		Q.push_front(x^delta);
	}
}

void input(){
	scanf("%d%d",&n,&k);
	static char str[MAXN];
	scanf("%s",str+1);
	for(int i=1;i<=n;i++)
		if(str[i]=='B') a0[i]=1;
}

void gao(){
	for(int i=1;i<=n;i++) Queue::Q.push_back(a0[i]);
	while(k && !Queue::Q.empty()){
		k--;
		if(!Queue::front()) Queue::setFront(1);
		else{
			Queue::Q.pop_front();
			Queue::rev();
		}
	}
	if(!k){
		int x=0;
		while(!Queue::Q.empty()){
			ans[++x]=Queue::front();
			Queue::Q.pop_front();
		}
		for(int i=x+1;i<=n;i++)
			ans[i]=(n-i)&1;
	}else{
		for(int i=1;i<=n;i++) ans[i]=(n-i)&1;
		if((n&1)&&(k&1)) ans[1]=1;
	}
}

int main(){
	input();
	gao();
	for(int i=1;i<=n;i++) putchar('A'+ans[i]);
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

ll modpow(ll a, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) res = (res * a) % mod;
        p >>= 1;
        a = (a * a) % mod;
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    if(n == 1) {
        cout << "0\n";
        return;
    }
    ll total = modpow(10, n), no09 = modpow(8, n), no0 = modpow(9, n), no9 = modpow(9, n);
    total = (total - no0 + mod) % mod;
    total = (total - no9 + mod) % mod;
    total = (total + no09 + mod) % mod;
    cout << total << "\n";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; i + j <= n; j++) {
                int k = n - i - j;
                if (y == (10000*i + 5000*j + 1000*k)) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
using namespace std;
#define N 100000
map<int,int>prime;
map<int,int>like;

long long similer(long long x){

    return 1;
}

void set(){
    for(int i=2;i<=N;i++)prime.insert(make_pair(i,i));
}
void Eratos(int i){

for(auto it=prime.find(i);it!=prime.end();it++){
        if(it->first%i==0 && it->first>i){
        prime.erase(it);
        }
    }
}

void setprime(){
    for(auto i=prime.begin();i!=prime.end();i++){
        
        Eratos(i->first);
    
    }
}

void setlike(){

for(auto i=prime.begin();i!=prime.end();i++){
    int l=i->first;
    if(prime.find((l+1)/2)!=prime.end()){
        like.insert(make_pair(l,l));
    }
}

}
int main(){

int Q;
cin>>Q;
set();
setprime();
setlike();
int s[100001]={};
for(int i=1;i<=N;i++){
if(like.find(i)!=like.end()){
    s[i]=s[i-1]+1;
}
else{
    s[i]=s[i-1];
}

}
int l,r;
for(int i=0;i<Q;i++){
cin>>l>>r;
l--;
cout<<s[r]-s[l]<<endl;
}


 return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int x;
    cin >> x;
    int ans = 1;
    while(ans*(ans+1)/2 < x) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

struct Mod {
	static ll BASE;
	ll value = 0;
	static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
	Mod()
	: value(0) {}
	Mod(ll value)
	: value(residue(value)) {}
	Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
	void operator+=(const Mod& rhs) { *this = *this + rhs; }
	Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
	void operator-=(const Mod& rhs) { *this = *this - rhs; }
	Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
	void operator*=(const Mod& rhs) { *this = *this * rhs; }
	Mod operator/(const Mod& rhs) const { return *this * rhs.inv(); }
	void operator/=(const Mod& rhs) { *this = *this / rhs; }
	Mod inv() const {
		if (value == 0) {
			assert(false);
			throw "[Mod::inv] div by zero";
		}
		ll ans, sub;
		ll d = Mod::gcd_with_coef(value, BASE, ans, sub);
		if (d != 1) {
			assert(false);
			throw "[Mod::inv] not invertible";
		}
		return ans;
	}
	static ll gcd_with_coef(ll x, ll y, ll& out_cx, ll& out_cy) {
		if (x < 0) {
			ll d = gcd_with_coef(-x, y, out_cx, out_cy);
			out_cx *= -1;
			return d;
		}
		if (y < 0) {
			ll d = gcd_with_coef(x, -y, out_cx, out_cy);
			out_cy *= -1;
			return d;
		}
		if (x > y) {
			return gcd_with_coef(y, x, out_cy, out_cx);
		}
		if (x == 0) {
			out_cx = 0;
			out_cy = 1;
			return y;
		}
		ll q = y / x;
		ll r = y % x;
		ll d = gcd_with_coef(r, x, out_cy, out_cx);
		out_cx -= q * out_cy;
		return d;
	}
};
ll Mod::BASE = 998244353;

int main() {
	ll N, A, B, K;
	cin >> N >> A >> B >> K;
	vector<Mod> fact(N+1, 1);
	rep(i,1,N+1) {
		fact[i] = Mod(i) * fact[i-1];
	}
	vector<Mod> binom(N+1);
	rep(i,0,N+1) {
		binom[i] = fact[N] / fact[N-i] / fact[i];
	}
	Mod ans = 0;
	rep(a,0,N+1) {
		ll b = (K - a * A) / B;
		if ((K - a * A) % B != 0 || !(0 <= b && b <= N)) {
			continue;
		}
		ans += binom[a] * binom[b];
	}
	cout << ans.value << endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define MOD 998244353
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll INF = 1e17;
const double pi = 3.141592653589793;

int T;
bool isprime[1000001] = {};
vector<ll> prime;

int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll N;

  memset(isprime, true, sizeof(isprime));

  isprime[1] = false;

  for(ll i = 2; i <= 1000000 ; i++) {
  	if(isprime[i]) prime.pb(i);
  	for(ll j = i * i ; j <= 1000000 ; j += i) {
  		isprime[j] = false;
  	}
  }


  cin >> N;
  ll a = N;
  vector<ll>tmp;
  ll cnt = 0;
  for(int i = 0 ; i < prime.size() ; i++) {
  	ll cur = 1;
  	while(N > 1 && N % prime[i] == 0) {
  		N /= prime[i];	
  		cur *= prime[i];
  		tmp.pb(cur);
  	}
  }
  if(N > 1) {
  	tmp.pb(N);
  }

  for(int i = 0 ; i < tmp.size() ; i++) {
  	if(a % tmp[i] == 0) {
  		a /= tmp[i];
  		cnt++;
  	}
  	if(a == 1) break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 5192