akhauriyash/Code-Regression huggingface dataset:
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}



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



int main(void){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    vector <int> nums;
    int now = 1; //今見ているかず
    int cnt = 0;//nowがいくつ並んでいるか
    rep(i,n){
        if(s[i] == (char)('0'+ now)){
            cnt++;
        }
        else{
            nums.push_back(cnt);
            now = 1-now; //0と1を切り替える
            cnt = 1; //新しいのを計算するため
        }
    }
    if(cnt != 0){
        nums.push_back(cnt);
    }
    //1-0-1-0-1っていう感じで欲しいので、0で終わってしまうものには1を最後尾につける
    if(nums.size() % 2 == 0){
        nums.push_back(0);
    }
    
    int add = 2 * k + 1;
    int ans = 0;
    
    for(int i=0;i<nums.size();i+=2){
        int tmp = 0;
        int left = i;
        int right = min(i+add,(int)nums.size());
        for(int j=left;j<right;j++){
            tmp += nums[j];
        }
        ans = max(tmp,ans);
    }
    
    cout << ans << endl;
    
    return 0;
}








Measured memory_bytes: 1020
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		StringBuffer sb = new StringBuffer();
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		char[] s = in.next().toCharArray();

		Deque<Integer> st = new ArrayDeque<>();
		Deque<Integer> st2 = new ArrayDeque<>();

		for (int i = 0; i < s.length; i++) {
			if (s[i] == '(') {
				st.push((int)s[i]);
				sb.append(s[i]);
			} else if (s[i] == ')') {
				if (!st.isEmpty()) {
					st.pop();
					sb.append(s[i]);
				} else {
					sb.append(s[i]);
					st2.push((int)s[i]);
				}

			}
		}

		while (!st.isEmpty()) {
			st.pop();
			sb.append(')');
		}

		while (!st2.isEmpty()) {
			st2.pop();
			sb.insert(0, '(');
		}

		System.out.println(sb.toString());

	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{

    int menu[5];
    REP(i,5)  cin >> menu[i];

    vector<P> pv;
    REP(i,5){
    	if(menu[i]>=100) pv.push_back(P((menu[i]-100-1)%10,menu[i]));
    	else if(menu[i]>=10) pv.push_back(P((menu[i]-1)%10,menu[i]));
		else pv.push_back(P(menu[i]-1,menu[i]));
    }
    sort(ALL(pv));

    int sum = 0;
    FOR(i,1,5){
    	sum += ((pv[i].second-1)/10+1)*10;
    }
    sum += pv[0].second;

    cout << sum << endl;


}


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

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int mod = 998244353;
const int MAXN = (int)3e5 + 5;

int fact[MAXN];

int rev[MAXN];

ll a, b, k;

int n, ans;

int binPow(int a, int b, int m = mod) {
    int ret = 1;

    while (b > 0) {
        if (b & 1) {
            ret = (ret * 1ll * a) % m;
        }

        a = (a * 1ll * a) % m;
        b >>= 1;
    }

    return ret;
}

void pre() {
    fact[0] = rev[0] = 1;

    for (int i = 1; i < MAXN; ++i) {
        fact[i] = (fact[i - 1] * 1ll * i) % mod;
        rev[i] = binPow(fact[i], mod - 2);
    }
}

void addMod(int &a, int b, int m = mod) {
    a += b;

    if (m <= a) {
        a -= m;
    }
}

int C(int n, int k) {
    if (k < 0 || k > n) {
        return 0;
    }

    return fact[n] * 1ll * rev[k] % mod * rev[n - k] % mod;
}


int main() {
    pre();

		scanf("%d %lld %lld %lld", &n, &a, &b, &k);

    for (int x = 0; x <= n; ++x) {
        ll left = k - x * a;

        if (left < 0) {
            break;
        }

        if (left % b == 0 && left / b <= n) {
            int y = left / b;
            addMod(ans, C(n, x) * 1ll * C(n, y) % mod);
        }
    }

    printf("%d\n", ans);



    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int A,B,C,D;
	int L;
	int i;
	int x,y;
	scanf("%d",&L);
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	if(A%C==0){
		x=A/C;
	}
	else{
		x=A/C+1;
	}
	if(B%D==0){
		y=B/D;
	}
	else{
		y=B/D+1;
	}
	if(x>y){
		i=L-x;
		printf("%d\n",i);
	}
	else{
		i=L-y;
		printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<cstdlib> 
#include<cstring>
using namespace std;
int read()
{
	int x=0,f=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int abs(int n)
{
	if (n>=0) return n;
	else return -1*n;
}
bool kl[110];
long long sum=0;
int main()
{
	int n,k,x;
	n=read(); k=read(); 
	for (int i=1; i<=n; i++) {
		x=read();
		if (kl[i]==0 && abs(k-x)<abs(x)) sum+=abs(k-x);
		else sum+=abs(x);
	}
	cout<<sum*2;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n; cin >> n;
		vector<int> L(n);
		rep (i, n) {
			cin >> L[i];
		}
		int ans = 0;
		sort(all(L));
		rep (b, n) {
			rep (a, b) {
				int ab = L[a] + L[b];
				//c = [l , r)
				//半開区間,bが含まれるように候補を探すことに注意する
				int l = b + 1;
				//r >= a + bとなる数値が登場する箇所を二部探索
				int r = lower_bound(all(L), ab) - L.begin();	
				//条件を満たすのはr < a + bとなる数値なので求める
				ans += max(0, r - l);
			}
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
#include<queue>
#include<map>
using namespace std;

int gcd_2(int A, int B) {
	int a = A;
	int b = B;
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int gcd_3(int a, int b, int c) {
	return gcd_2(gcd_2(a, b), c);
}

int main() {
	int K;
	cin >> K;
	int ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				ans += gcd_3(a, b, c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( int val ){
	
	cout << val << endl;
}

int main( int argc , char ** argv ){
	
	int N = 0 ;
	string s  , t ;
	cin >> N >> s >> t;

	int ans = N * 2;

	string _s;
	string _t;
	int count = 0;
	for(int i = 1 ; i <= N ; i ++){
		_s = s.substr( N-i );
		_t = t.substr(0 , i);
		//cout << _s << " , " << _t << endl;
		if(_s == _t ) count = _s.length();
	}

	ans -= count;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn=10;
int e[maxn][maxn];

void floyed()
{
	for(int k=0;k<maxn;k++)
	{
		for(int i=0;i<maxn;i++)
		{
			for(int j=0;j<maxn;j++)
			{
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
			}
		}
	}
}

int main()
{
	int H,W,i,j;
	int temp,num;
	while(~scanf("%d %d",&H,&W))
	{
		num=0;
		for(i=0;i<maxn;i++)
		{
			for(j=0;j<maxn;j++)
				scanf("%d",&e[i][j]);
		}
		floyed();
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				scanf("%d",&temp);
				if(temp==1 || temp==-1)
					continue;
				num += e[temp][1];	
			}
		}
		printf("%d\n",num);
	}
	return 0;
}

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

int main(){
  int l,r,d, ans=0;
  cin >> l >> r >> d;
  for(int i=l;i<=r;){
    if(i%d==0){
      ans++;
      i+=d;
    }
    else{
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
using namespace std;

// #define LOCAL
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

#ifdef LOCAL
#define MAX 50
#endif

#ifndef LOCAL
#define MAX 530
#endif

int cnt = 0;
int buffer[MAX*MAX][4];

void makeEven(int D[MAX][MAX], int h, int w) {
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			if (D[i][j] % 2 == 0) continue;
			if (i == h - 1 && j == w - 1) continue;
			if (j < w - 1 && i < h - 1) {
				if (D[i][j + 1] % 2 == 0 && D[i + 1][j] % 2 != 0) {
					buffer[cnt][0] = i + 1; buffer[cnt][1] = j + 1;
					buffer[cnt][2] = i + 2; buffer[cnt][3] = j + 1;
					cnt++;
					D[i][j]--; D[i + 1][j]++;
				}
				else {
					buffer[cnt][0] = i + 1; buffer[cnt][1] = j + 1;
					buffer[cnt][2] = i + 1; buffer[cnt][3] = j + 2;
					cnt++;
					D[i][j]--; D[i][j + 1]++;
				}
			}
			else if (j == w - 1) {
				buffer[cnt][0] = i + 1; buffer[cnt][1] = j + 1;
				buffer[cnt][2] = i + 2; buffer[cnt][3] = j + 1;
				cnt++;
				D[i][j]--; D[i + 1][j]++;
			}
			else {
				buffer[cnt][0] = i + 1; buffer[cnt][1] = j + 1;
				buffer[cnt][2] = i + 1; buffer[cnt][3] = j + 2;
				cnt++;
				D[i][j]--; D[i][j + 1]++;
			}
		}
	}
}

int main() {
	int h, w; scanf("%d %d", &h, &w);
	int D[MAX][MAX] = { 0 };
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			int k; scanf("%d", &k);
			D[i][j] = k;
		}
	}

	makeEven(D, h, w);

	printf("%d\n", cnt);
	FOR(i, 0, cnt) {
		printf("%d %d %d %d\n", buffer[i][0], buffer[i][1], buffer[i][2], buffer[i][3]);
	}

#ifdef LOCAL
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			printf(" %d", D[i][j]);
		}
		printf("\n");
	}
#endif

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;
	for(int i=0; i<n; i++){
		if(s[k-1]==s[i]){
			cout << s[i];
		} else {
			cout << "*";
		}
	}
	cout << endl;

	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>vec(n);
  int a,b;
  
  for(int i=0;i<m;i++){
    cin >> a >> b ;
    
    vec.at(a-1) += 1;
    vec.at(b-1) += 1;
  }
  
  for(int i=0;i<n;i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
int a,b,c,x;
cin>>a>>b>>c>>x;
int ret=0;
rep(i,a+1)rep(j,b+1)rep(k,c+1){
if(500*i+100*j+50*k==x)ret+=1;
}
cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
S=input()
p=1
head=""
tail=""
Q=int(input())
for _ in range(Q):
  q=input()
  if q=='1':
    p^=1
  else:
    a,f,c=q.split()
    f=int(f)%2
    if p==0:
      f=(f+1)%2
    if f:
      head+=c
    else:
      tail+=c
if p:
  S=head[::-1]+S+tail
else:
  S=tail[::-1]+S[::-1]+head
print(S)

Measured memory_bytes: 9804
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i,n) {
        set<char> se;
        se.insert(a[i]);
        se.insert(b[i]);
        se.insert(c[i]);
        ans += se.size()-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1e9+5
#define mx 200005
//#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
const int inf = 1e9+5;
/*
select -> -1 = nothing
select ->  0 = a
select ->  1 = b
select ->  2 = c
*/
int ans = 0;
int arr[mx][4];
int fun(int *a,int *b,int *c,int n,int i,int select)
{
    if(i==(n))
        return arr[i][select] = 0;
    else if(arr[i][select]!=(-1))
    {
        return arr[i][select];
    }
    else if(select == 0)
    {
        return arr[i][select] = max( (a[i]+fun(a,b,c,n,i+1,1)) ,max( (b[i]+fun(a,b,c,n,i+1,2)) ,(c[i]+fun(a,b,c,n,i+1,3)) )  );
    }
    else if(select == 1)
    {
        return arr[i][select] = max(b[i]+fun(a,b,c,n,i+1,2) , c[i]+fun(a,b,c,n,i+1,3));
    }
    else if(select == 2)
    {
        return arr[i][select] = max(a[i]+fun(a,b,c,n,i+1,1) , c[i]+fun(a,b,c,n,i+1,3));
    }
    else if(select == 3)
    {
        return arr[i][select] = max(b[i]+fun(a,b,c,n,i+1,2) , a[i]+fun(a,b,c,n,i+1,1));
    }
}
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    for(int i=0;i<mx;i++)
    {
        for(int j=0;j<4;j++)
        {
            arr[i][j]=(-1);
        }
    }
    cout<<fun(a,b,c,n,0,0)<<endl;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define brep1(i,n) for(int i=n-1;i>=1;i--)

vector<int> a;
int n;

bool check(int x){//x文字以内で要件を満たせるかどうか
    map<int,int>mp;
    rep1(i,a.size()){
        if(a[i-1]<a[i])continue;//後ろに文字追加してるだけなのでスキップ
        if(x==1)return false;
        mp[a[i]]++;//a[i]文字目の番号を+1
        mp.erase(mp.upper_bound(a[i]),mp.end());//a[i]より後ろはリセット
        brep1(j,a[i]+1){
            if(mp[j]>=x){
                if(j==1) return false;//最初の文字を越えて繰り上がるようなら失敗
                mp[j]=0;mp[j-1]++;//繰り上がり
            }
            else break;//繰り上がり処理の終了
        }
    }
    return true;//最後までいったら成功
}

int main(void){
    cin >> n;
    rep(i,n){int num;cin >>num;a.emplace_back(num);}
    int min=0;int max=n;
    while(max-min>1){//min<x<=maxでxを二部探索
        int mid = (max+min)/2;
        if(check(mid))max=mid;
        else min = mid;
    }
    cout << max << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cmath>

using namespace std;
double w,h,v,t,x,y,p,q;
struct Point{double x,y;};

Point P(int X,int Y){
    Point po;
    po.x=X*w;
    if(X%2==0) po.x+=p;
    else po.x+=w-p;
    po.y=Y*h;
    if(Y%2==0) po.y+=q;
    else po.y+=h-q;
    return po;
};

bool isIn(Point p){
    return pow(p.x-x,2)+pow(p.y-y,2)<=v*v*t*t;
}

int main(){
    long long int n=0;
    cin>>w>>h>>v>>t>>x>>y>>p>>q;
    for(int X=0;true;X++){
        int Y_lo=0,Y_hi=10e6;
        if(!isIn(P(X,Y_lo))) break;
        while(true){
            if(abs(Y_lo-Y_hi)<=1){
                if(isIn(P(X,Y_hi))){
                    n+=Y_hi+1;
                }else{
                    n+=Y_lo+1;
                }
                break;
            }
            int Y_mid=(Y_lo+Y_hi)/2;
            Point p = P(X,Y_mid);
            if(isIn(p)){
                Y_lo=Y_mid;
            }else{
                Y_hi=Y_mid;
            }
        }
    }
    for(int X=0;true;X++){
        int Y_lo=-10e6,Y_hi=-1;
        if(!isIn(P(X,Y_hi))) break;
        while(true){
            if(abs(Y_lo-Y_hi)<=1){
                if(isIn(P(X,Y_lo))){
                    n+=abs(Y_lo);
                }else{
                    n+=abs(Y_hi);
                }
                break;
            }
            int Y_mid=(Y_lo+Y_hi)/2;
            Point p = P(X,Y_mid);
            if(isIn(p)){
                Y_hi=Y_mid;
            }else{
                Y_lo=Y_mid;
            }
        }
    }

    for(int X=-1;true;X--){
        int Y_lo=0,Y_hi=10e6;
        if(!isIn(P(X,Y_lo))) break;
        while(true){
            if(abs(Y_lo-Y_hi)<=1){
                if(isIn(P(X,Y_hi))){
                    n+=Y_hi+1;
                }else{
                    n+=Y_lo+1;
                }
                break;
            }
            int Y_mid=(Y_lo+Y_hi)/2;
            Point p = P(X,Y_mid);
            if(isIn(p)){
                Y_lo=Y_mid;
            }else{
                Y_hi=Y_mid;
            }
        }
    }
    for(int X=-1;true;X--){
        int Y_lo=-10e6,Y_hi=-1;
        if(!isIn(P(X,Y_hi))) break;
        while(true){
            if(abs(Y_lo-Y_hi)<=1){
                if(isIn(P(X,Y_lo))){
                    n+=abs(Y_lo);
                }else{
                    n+=abs(Y_hi);
                }
                break;
            }
            int Y_mid=(Y_lo+Y_hi)/2;
            Point p = P(X,Y_mid);
            if(isIn(p)){
                Y_hi=Y_mid;
            }else{
                Y_lo=Y_mid;
            }
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    ll n, k, count = 1; cin >> n >> k;
    while(n>=k){
        n /= k;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
const int mod=998244353;
int fac[500100],ifac[500100];
int ex(re int a,re int b)
{
	re int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=1ll*ans*a%mod;
	return ans;
}
int main()
{
	re int n,k,ans=0;
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(re int i=1;i<=k;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[k]=ex(fac[k],mod-2);
	for(re int i=k;i;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	if((!(k%2))&&n<=k/2)
	{
		ans=(1ll*fac[k-1]*ifac[k/2]%mod*ifac[k/2-1]+1ll*(mod-fac[k-1])*ifac[k-n+1]%mod*ifac[n-2])%mod;
	}
	for(re int i=std::max(k/2+1,n);i<=k;i++)
	{
		ans=(ans+1ll*fac[k]*ifac[i]%mod*ifac[k-i])%mod;
		re int p=i-n+1;
		if(p<=k-i)ans=(ans+1ll*(mod-fac[k])*ifac[k-i-p]%mod*ifac[i+p])%mod;
	}
	printf("%d\n",ans);
}

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N,A,B=map(int, input().split())
S = input()
tmp1 = 0
tmp2 = 0

for i in range(0,N):
    if tmp1 < A+B:
        if S[i] == "a":
            tmp1 += 1
            print("Yes")
        elif (S[i] == "b") & (tmp2 < B):
            tmp1 += 1
            tmp2 += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 78164
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > vp;
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;A--;B--;
    vp.emplace_back(B,A);
  }
  sort(ALL(vp));
  int removed = -1;
  int ANS = 0;
  for (int i = 0; i < M; i++)
  {
    // DEBUG(removed);
    // DEBUG(vp[i].first,vp[i].second,"\n");
    if(vp[i].second <= removed && vp[i].first > removed)
    {

    }
    else
    {
      removed = vp[i].first - 1;
      ANS++;
    }
    
  }
  cout<<ANS<<endl;
  
  
  
  
  
    
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>  
using namespace std;  
#define _for(i,a,b) for(int i=a;i<=b;i++)  
long long n,m;  
int main(int argc, char const *argv[])  
{  
    cin>>n>>m;  
    if(n==1&m==1)cout<<1<<endl;  
    else if(n==1)cout<<m-2<<endl;  
    else if(m==1)cout<<n-2<<endl;  
    else cout<<(n-2)*(m-2)<<endl;  
    return 0;  
} 

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> s(n);
  for (int i = 0; i < n; i++)
  {
    int m;
    cin >> m;
    s[i].resize(m);
    for (int j = 0; j < m; j++)
      cin >> s[i][j];
  }
  long long ans = 0;
  priority_queue<int> priq;
  for (int i = n - 1; i >= 0; i--)
  {
    int size = s[i].size();
    for (int j = 0; j < size; j++)
      priq.push(s[i][j]);
    ans += priq.top();
    priq.pop();
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 19196
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input!{
        Sa: chars,
        Sb: chars,
        Sc: chars
    }
    let mut turn: usize = 0;
    let mut a: usize = 0;
    let mut b: usize = 0;
    let mut c: usize = 0;
    let winner;

    loop {
        if turn == 0 {
            if a >= Sa.len() {
                winner = 0;
                break;
            }
            let ch = Sa[a];
            turn = if ch == 'a' { 0 } else if ch == 'b' { 1 } else { 2 };
            a += 1;
        } else if turn == 1 {
            if b >= Sb.len() {
                winner = 1;
                break;
            }
            let ch = Sb[b];
            turn = if ch == 'a' { 0 } else if ch == 'b' { 1 } else { 2 };
            b += 1;
        } else if turn == 2 {
            if c >= Sc.len() {
                winner = 2;
                break;
            }
            let ch = Sc[c];
            turn = if ch == 'a' { 0 } else if ch == 'b' { 1 } else { 2 };
            c += 1;
        }
    }
    println!("{}", if winner == 0 { 'A' } else if winner == 1 { 'B' } else { 'C' });
}

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

int main(){

    int score[200];
    fill(score,score+200,0);
    for(char ch = '2'; ch <= '9'; ch++)
        score[ch]=ch-'0';
    score['T']=score['J']=score['Q']=score['K']=10;
    int n;
    cin>>n;
    while(n--){
        int aNum=0;
        int cs=0;
        for(int i = 0; i<2; i++){
            char ch;
            cin>>ch;
            if(ch=='A')
                aNum++;
            else
                cs+=score[ch];
        }
        string str;char ch;
        for(int i = 0; i < 8; i++){
            cin>>ch;
            str+=ch;
        }
        if(cs==10&&aNum==1){
            cout<<"blackjack"<<endl;
            continue;
        }
        else if(aNum==1&&cs>=7)
            cout<<cs+11<<endl;
        else if(aNum==0&&cs>=17)
            cout<<cs<<endl;
        else{
            bool b=false;
            bool ok=false;
            int fs=0;
            char ch;
            for(int i = 0; i < str.size(); i++){
                ch=str[i];
                if(ch=='A')
                    aNum++;
                else
                    cs+=score[ch];
                for(int j = 0; j <= min(1,aNum); j++){
                    int ccs=(cs+j*11+(aNum-j));
                    if(j==1&&ccs==17)
                        continue;
                    else if(j==0&&ccs==17){
                        fs=ccs;ok=true;break;
                    }
                    if(ccs>21){
                        if(j==0){
                            b=true;break;
                        }
                        continue;
                    }
                    else if(ccs>17){
                        fs=ccs;ok=true;break;
                    }
                }
                if(ok||b)
                    break;
            }
            if(b)
                cout<<"bust"<<endl;
            else
                cout<<fs<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	char c; 
	cin >> c;
	PRI((char)(++c));
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    vector<int> menu(5);
    rep(i, 5) cin >> menu.at(i);

    vector<int> v = {0, 1, 2, 3, 4};
    int sum = 10000000;
    do {
        int tmp = 0;
        rep(i, 5) {
            while(tmp % 10 != 0) tmp++;
            tmp += menu.at(v.at(i));
        }
        sum = min(sum, tmp);
    } while (next_permutation(all(v)));

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int A,B,C;
	int i,max,sum;
	
	scanf("%d %d %d",&A,&B,&C);
	
	sum = A + B + C;
	max = A;
	if(max < B)	max = B;
	if(max < C)	max = C;
	
	printf("%d\n",10 * max + (sum - max));
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, w; cin >> s >> w;
    if (s <= w) cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main(){while(true){
	string s1;
	cin>>s1;
	if(s1==".")
		return 0;
	string s2;
	cin>>s2;
	if(s1==s2){
		cout<<"IDENTICAL"<<endl;
		continue;
	}
	string t1=s1;
	string t2=s2;
	while(true){
		size_t d1b=t1.find('\"');	//d1_begin
		if(d1b==string::npos)
			break;
		t1.replace(d1b,1,"@");

		size_t d1e=t1.find('\"');	//d1_end
		t1.replace(d1e,1,"@");

		size_t d2b=t2.find('\"');	//d2_begin
		if(d2b==string::npos)
			break;
		t2.replace(d2b,1,"@");

		size_t d2e = t2.find('\"');	//d2_end
		t2.replace(d2e,1,"@");
		
		string u1=s1;
		u1.replace(d1b+1,d1e-d1b-1,"");
		string u2=s2;
		u2.replace(d2b+1,d2e-d2b-1,"");
		if(u1==u2){
			t1=u1;
			t2=u2;
			break;
		}
	}
	if(t1==t2){
		cout<<"CLOSE"<<endl;
	}else{
		cout<<"DIFFERENT"<<endl;
	}
}}


Measured memory_bytes: 3152
S = input()
List = list(S)
s_l = set(List)
n = 10
res= ""
flag = False
for i in range(97,123):
  if not chr(i) in s_l:
    res = chr(i)
    flag = True
    break
if flag:
  print(res)
else:
  print("None")

Measured memory_bytes: 9764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		if(S[0] == S[N-1]){
			Console.WriteLine( N%2 == 0 ?"First":"Second");
		}else{
			Console.WriteLine( N%2 == 1 ?"First":"Second");
		}
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3032
n=input()
p=""
for i in range(len(n)):
	if int(n[i])>7:
		p+="3"*(len(n)-i)
		break
	elif int(n[i])==7:
		p+="3"
	elif int(n[i])==6:
		p+="2"
		p+="3"*(len(n)-i-1)
		break
	elif int(n[i])==5:
		p+="2"
	elif int(n[i])==4:
		p+="1"
		p+="3"*(len(n)-i-1)
		break
	elif int(n[i])==3:
		p+="1"
	else:
		p+="0"
total=0
for i in range(len(n)):
	total+=int(p[-i-1])*(4**i)
def tet(x):
	q=""
	while x!=0:
		q+=str(x%4)
		x//=4
	if len(q)==0:
		q="0"
	return q[::-1]
ans=[]
cnt=0
for i in range(total):
	if tet(i+1).count("0")==0:
		ans.append(tet(i+1))
for i in range(len(ans)):
	if ans[i].count("1") and ans[i].count("2")\
	and ans[i].count("3"):
		cnt+=1
print(cnt)

Measured memory_bytes: 5144
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
def BinaryIndexSearch_floor(p, SL):
	"""
	search the minimum number among the larger numbers than the ginven nymber "n". 
	return the index of it under the list sorted.
	"""
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] > p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[l] > p:
				return l
			elif SL[r] > p:
				return r
			else:
				return -1

		center = l + ((r-l) // 2)

		if SL[center] <= p:
			l = center + 1
			continue

		else:
			r = center
			continue

def BinaryIndexSearch_ceil(p, SL):
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] < p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[r] < p:
				return r
			elif SL[l] < p:
				return l
			else:
				return -1
		center = l + ((r-l) // 2)

		if SL[center] < p:
			l = center 
			continue

		else:
			r = center - 1
			continue

inf = float("inf")
for i in range(Q):
	xx = x[i]
	I_s_r = BinaryIndexSearch_floor(xx, s)
	I_t_r = BinaryIndexSearch_floor(xx, t)
	I_s_l = A-1 if I_s_r == -1 else I_s_r - 1
	I_t_l = B-1 if I_t_r == -1 else I_t_r - 1

	s_r = inf if I_s_r == -1 else s[I_s_r] - xx
	t_r = inf if I_t_r == -1 else t[I_t_r] - xx
	s_l = inf if I_s_l == -1 else xx - s[I_s_l]
	t_l = inf if I_t_l == -1 else xx - t[I_t_l]

	ans = []

	ans.append(min(s_r,t_l) + s_r + t_l)
	ans.append(min(t_r,s_l) + t_r + s_l)
	ans.append(max(s_r,t_r))
	ans.append(max(s_l,t_l))

	print(min(ans))

Measured memory_bytes: 16160
import std.stdio, std.c.string;

void main() {
  int pair[2002];
  int ans[4001];
  
  for(int i = 0; i <= 1000; i++)
    for(int j = 0; j <= 1000; j++)
      pair[i + j]++;
  
  for(int i = 0; i <= 2000; i++) {
    for(int j = 0; j <= 2000; j++) {
      ans[i + j] += pair[i] * pair[j];
    }
  }

  for(int n; readf("%d\n", &n);) ans[n].writeln;
}

Measured memory_bytes: 1092
//https://atcoder.jp/contests/abc122/tasks/abc122_b
#include <iostream>
#include <string>
using namespace std;

int main() {
    string S;
    cin >> S;
    int size = (int)(S.length());
    int ans = 0;
    int max = 0;
    for(int i=0;i<size;i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')
        {
            max++;
        }else
        {
            max=0;
        }
        if(ans<max)ans=max;
        
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N,M;cin>>N>>M;
  if(abs(N-M) >1)cout<<0<<endl;
  else if(abs(N-M)==1){
    cout<<(kaijoMOD(N)%MOD)*(kaijoMOD(M)%MOD)%MOD<<endl;
  }
  else{
    cout<<(2*(kaijoMOD(N)%MOD)%MOD)*(kaijoMOD(M)%MOD)%MOD<<endl;
    
  }
}





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

int main(){
    long long int N, K, Q;
    cin >> N >> K >> Q;

    vector<long long int> c(N, 0);

    for(long long int i = 0, A; i < Q; ++i){
        cin >> A;
        ++c[A-1];
    }

    for(long long int i = 0; i < N; ++i){
        if(K+c[i]-Q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
n, m, c = map(int, input().split())
b = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for i in range(n)]
count = 0

for x in [sum([a_ij * b_j for a_ij, b_j in zip(a[i], b)]) for i in range(n)]:
  if x + c > 0:
    count += 1
print(count)

Measured memory_bytes: 3060
'use strict';

function Main(input) {
	let N = Number(input);
  let x = parseInt(N / 100);
  let y = parseInt((N - x * 100) / 10);
  let z = N - x * 100 - y * 10;
  
  if (x === 7 || y === 7 || z === 7) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29616
n = gets.to_i
d = gets.split.map &:to_i

if d[0] != 0
    puts 0
    exit
end

keys = []
counts = {}


d.each do |di|
    counts[di] ||= 0
    counts[di] += 1
    keys[di] = true
    if counts[0] > 1
        puts 0
        exit
    end
end

if keys.all?
    a = 1
    m = keys.size - 1
    (1..m).each do |i|
        a *= counts[i-1] ** counts[i]
    end
    puts a % 998244353
else
    puts 0
end


Measured memory_bytes: 65316
#include <iostream>

using namespace std;
int mp[55][55];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            char c;
            cin>>c;
            if(c=='.')
                mp[i][j]=0;
            if(c=='#')
                mp[i][j]=-1;
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]!= -1)
            {
                if(mp[i-1][j-1]==-1)
                    mp[i][j]++;
                if(mp[i-1][j]==-1 )
                    mp[i][j]++;
                if(mp[i-1][j+1]==-1)
                    mp[i][j]++;
                if( mp[i][j-1]==-1)
                    mp[i][j]++;
                if(mp[i][j+1]==-1)
                    mp[i][j]++;
                if(mp[i+1][j-1]==-1)
                    mp[i][j]++;
                if(mp[i+1][j]==-1)
                    mp[i][j]++;
                if(mp[i+1][j+1]==-1)
                    mp[i][j]++;
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]==-1)
                cout<<'#';
            else cout<<mp[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    vector<int> tmp(n);
    rep(i, n) tmp[i] = i + 1;
    int a = 0;
    int b = 0;
    int cnt = 0;
    do{
        cnt++;
        if(tmp == p){
            a = cnt;
        }
        if(tmp == q){
            b = cnt;
        }
    }while(next_permutation(all(tmp)));
    cout << abs(a - b) << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 998244353LL;

const int N = 1e6;
ll fac[N], ifac[N];

ll inv(ll a){
	ll ans = 1;
	
	for(ll n = MOD-2; n>0; n/=2){
		if(n%2 == 1) ans = (ans*a) % MOD;
		a = (a*a) % MOD;
	}

	return ans;
}

ll comb(int n, int a){
	ll ans = fac[n];
	ans = (ans*ifac[a])%MOD;
	ans = (ans*ifac[n-a])%MOD;
	return ans;
}

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

	ll n, a, b, k;
	cin >> n >> a >> b >> k;

	fac[0] = 1;
	ifac[0] = 1;

	for(int i=1; i<=n; i++){
		fac[i] = (fac[i-1] * i) % MOD;
		ifac[i] = (ifac[i-1] * inv(i)) % MOD;
	}

	ll ans = 0;

	for(int i=0; i<=n; i++){
		ll ta = i;
		ll tb = (k-ta*a) / b;

		if(ta*a+tb*b == k && 0 <= tb && tb <= n){
			ans += (comb(n, ta) * comb(n, tb)) % MOD;
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    double r,a,b;
    cin>>r;
    
    a=r*r*3.141592653589;
    b=2*r*3.141592653589;
    
    printf("%f %f\n",a,b);
}


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

int main() {

	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans1 = 0;
	ll sum1 = 0;
	for (int i = 0; i < n; i++) {
		sum1 += a[i];
		if (i % 2 == 0) {
			if (0 < sum1) {}
			else if (sum1 < 0) {
				ans1 += -1 * sum1 + 1;
				sum1 = 1;
			}
			else { // sum1 == 0
				sum1 += 1;
				ans1 += 1;
			}
		}
		else { // i % 2 != 0
			if (0 < sum1) {
				ans1 += sum1 + 1;
				sum1 = -1;
			
			}
			else if (sum1 < 0) {}
			else { // sum1 == 0
				sum1 += -1;
				ans1 += 1;
			}
		}
	}
	ll ans2 = 0;
	ll sum2 = 0;
	for (int i = 0; i < n; i++) {
		sum2 += a[i];
		if (i % 2 != 0) {
			if (0 < sum2) {}
			else if (sum2 < 0) {
				ans2 += -1 * sum2 + 1;
				sum2 = 1;
			}
			else { // sum1 == 0
				sum2 += 1;
				ans2 += 1;
			}
		}
		else { // i % 2 == 0
			if (0 < sum2) {
				ans2 += sum2 + 1;
				sum2 = -1;

			}
			else if (sum2 < 0) {}
			else { // sum2 == 0
				sum2 += -1;
				ans2 += 1;
			}
		}
	}
	cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	
	if ((a - 1) / d >= (c - 1) / b) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int32_t main(){ fast;
	string s; cin>>s;
	vector<string> a = {"RRR", "RRS", "RSR", "SRR", "SSS", "SSR", "SRS", "RSS"};
	vector<int> ans = {3, 2, 1, 2, 0, 1, 1, 1};
	debug(sz(ans));
	debug(sz(a));
	rep(i, sz(a)){
		if(s == a[i]){
			cout<<ans[i];
			return 0;
		}
	}
}


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

const int maxn=100010;
int n,k;
int cnt;
char s[maxn],t[maxn];
int len;

int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	for(int i=1;i<n;i++) if(s[i]==s[i+1]) cnt++;
	for(int i=1;i<=n;i++)
		if(s[i]!=s[i-1]) t[++len]=s[i];
	int num=(len-1)/2;
	if(num>=k) cnt+=2*k;
	else 
	{
		cnt+=2*num;
		if(len%2==0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)


Measured memory_bytes: 357624
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a < b){
if(a < c){
if(b < c){
printf("Yes\n");
}else{
no();
}
}else{
no();
}
}else{
no();
}
return 0;
}
int no(){
printf("No\n");
return 0;
}

Measured memory_bytes: 1816