akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <list>

#define NUM 32
using namespace std;

int main()
{
    list<int> List;

    unsigned int x;
    scanf("%d", &x);
    if (x == 0)
    {
        List.push_back(0);
    }

    while (x != 0)
    {
        List.push_front(x % 2);
        x = x / 2;
    }

    for (int loop = List.size(); loop < NUM; loop++)
    {
        List.push_front(0);
    }

    list<int>::iterator itr = List.begin();
    while(itr != List.end())
    {
        printf("%d", *itr++);
    }
    printf("\n");

    itr = List.begin();
    while (itr != List.end())
    {
        if (*itr == 0)
        {
            printf("%d", 1);
        }
        else
        {
            printf("%d", 0);
        }
        itr++;
    }
    printf("\n");


    itr = List.begin();
    itr++;
    while (itr != List.end())
    {
        printf("%d", *itr++);
    }
    printf("%d\n", 0);

    printf("%d", 0);
    list<int>::reverse_iterator ritr = List.rend();
    ritr--;
    while (ritr != List.rbegin())
    {
        printf("%d", *ritr--);
    }
    printf("\n");

    return 0;
}

int main2()
{
    int a = 0000000000000000000000000000000-1;
    return 0;
}



Measured memory_bytes: 3212
h, w, a, b = [int(v) for v in input().split()]

l1 = [0] * w
l2 = [0] * w
for i in range(w):
  if i < a:
    l1[i] = "1"
    l2[i] = "0"
  else:
    l1[i] = "0"
    l2[i] = "1"

for j in range(h):
  if j < b:
    print("".join(l1))
  else:
    print("".join(l2))


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

int main(){
  int A,B;  cin >> A >> B;
  int ans = 0;
  for(int i=0;i<2;i++){
    if(A >= B){
      ans += A;
      A--;
    }else{
      ans += B;
      B--;
    }
  }
  cout << ans << endl;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b+c<a+c&&b+c<a+b) {
		cout << b + c << endl;
	}
	else if(a+c<a+b&&a+c<b+c) {
		cout << a + c << endl;
	}
	else {
		cout << a + b << endl;
	}
}

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

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

    vector<ll> a;
    for (int i = 1; i < 10; i++)
    {
        a.push_back(i);
    }

    while (1)
    {
        if (K <= a.size())
        {
            cout << a[K - 1] << endl;
            return 0;
        }
        K -= a.size();
        vector<ll> old;
        swap(old, a);
        for (ll x : old)
        {
            for (int i = -1; i <= 1; i++)
            {
                int d = x % 10 + i;
                if (d < 0 || d > 9)
                    continue;
                ll nx = x * 10 + d;
                a.push_back(nx);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  bool can = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if ((i*j) == N) can = true;
    }
  }

  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll; 
int main() {
  ll n; cin>>n;
  ll d[n];
  rep(i, n) cin>>d[i];
  ll hp=0;
  rep(i, n) {
    for(int j=i+1; j<n; j++){
      hp+=d[i]*d[j];
    }
  }
  cout << hp;
}
      

Measured memory_bytes: 256
solve3 :: [Int] -> String
solve3 abc = unwords . map show $ qsort abc

qsort [] = []
qsort (n:ns) = qsort left ++ [n] ++ qsort right
  where
    left = filter (\m -> m <= n) ns
    right = filter (\m -> n < m) ns

main = do
  temp <- getLine
  let abc = map read . words $ temp
  putStrLn $ solve3 abc



Measured memory_bytes: 3676
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 5005;
const int MM = 998244353;

vector<int> T[MX];
int D[MX];
int N, a;

pii dfs(int x){
	vector<pii> L;
	for(int c : T[x]){
		L.push_back(dfs(c));
	}
	static int arr[2][MX], *S = arr[0], *E = arr[1];
	memset(S, 0x3f, sizeof arr[0]);
	S[0] = 0;
	for(pii c : L){
		memset(E, 0x3f, sizeof arr[0]);
		for(int i = c.first; i < MX; i++){
			E[i] = min(S[i-c.first] + c.second, E[i]);
		}
		for(int i = c.second; i < MX; i++){
			E[i] = min(S[i-c.second] + c.first, E[i]);
		}
		swap(S, E);
	}
	for(int i = 0; i < MX; i++){
		if( S[i] <= D[x] ) return pii(D[x], i);
	}
	int mn = 1e9;
	for(int i = 0; i <= D[x]; i++) mn = min(mn, S[i]);
	if( mn < 1e9 ) return pii(D[x], mn);
	printf("IMPOSSIBLE\n");
	exit(0);
}

int main()
{
	scanf("%d", &N);
	for(int i = 2; i <= N; i++){
		scanf("%d", &a);
		T[a].push_back(i);
	}
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	dfs(1);
	printf("POSSIBLE\n");
}


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


int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]==a[2]){cout<<"1\n"<<endl; return 0;}
	if(a[0]!=a[1]&&a[1]!=a[2]&&a[2]!=a[0]){cout<<"3\n"; return 0;}
	cout<<2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k,ans;
int r,b,g;
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;
}
int divcnt[111111];
void Div(int n,int sum){
	for(int i=1;i*i<=n;i++){
		if(n%i!=0)continue;
		int j=n/i;
		divcnt[i]+=sum;
		if(j!=i)divcnt[j]+=sum;
		divcnt[i]%=MOD;
		divcnt[j]%=MOD;
	}
}
int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){//N,MOD
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}
signed main(){
	//lの倍数が来る確率 floor(k/l)/k
	//数列のgcdがlの倍数の確率 (floor(k/l)/k)^n
	//数列のgcdがlの倍数であるような数列が出る回数 k^n * (floor(k/l)/k)^n =floor(k/l)^n
	cin>>n>>k;
	int cnt=0;
	for(int i=k;i>=1;i--){
		int sum=modpow(k/i,n,MOD);
		int sum2=sum;
		sum2-=divcnt[i];
		sum2=(sum2+MOD)%MOD;
		Div(i,sum2);
		ans+=sum2*i%MOD;
		ans%=MOD;
		//cout<<i<<":"<<sum2<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double dot(P a, P b){return real(conj(a)*b);}
double cross(P a, P b){return imag(conj(a)*b);}
int ccw(P a, P b, P c){
  b-=a;c-=a;
  if(cross(b,c)>EPS) return 1;
  if(cross(b,c)<-EPS) return -1;
  if(dot(b,c)<-EPS) return 2;
  if(norm(b)<norm(c)) return -2;
  return 0;
}
double area(vector<P> p) {
  double area=0;
  for(int i=0; i<(int)p.size(); i++) area+=cross(p[i],p[(i+1)%p.size()]);
  return -area/2;
}
void Main() {
  int n,t=1;
  while(R n && n) {
    vector<P> v;
    rep(i,n) {
      double x,y;
      cin >> x >> y;
      v.pb(P(x,y));
    }
    printf("%d %.1f\n",t++,area(v));
  }
}

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


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

	int TIME = 0;
	int d[101];
	int f[101];
	int num;
	int graph[101][101] = {0};

void dfs(int x){
	TIME++;
	d[x] = TIME;

	for(int i=1;i<=num;i++){
		if(graph[x][i] == 1 && d[i]==0){
			dfs(i);
		}
	}
	f[x] = ++TIME;
}

int main(){
	int hon;
	int eda;
	int ver;

	cin>>num;
	for(int i=0;i<num;i++){
		cin>>eda;
		cin>>hon;
		for(int j=0;j<hon;j++){
			cin>>ver;
			graph[eda][ver]++;
		}
	}
	
	for(int i=1;i<=num;i++){
		if(d[i]==0)
			dfs(i);
	}

	for(int i=1;i<=num;i++){
		cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1200
import java.util.*;

class Main {
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        String u= s.next();
        StringBuilder b =new StringBuilder();
        for (int i = 0; i <u.length() ; i++) {
            b.append("x");
        }
        System.out.println(b.toString());

    }


}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
const int N=2e5+5;
int ans[N],fd[N],fx[N];
int poww(int a,int b,int c){
    int ans=1,base=a;
    while(b){
        if(b&1)ans=1ll*ans*base%c;
        base=1ll*base*base%c;
        b>>=1;
    }
    return ans;
}
int get(int x){
    if(x==0)return 0;
    else return 1+get(x%__builtin_popcount(x));
}
int main(){
    cin>>n>>s;
    reverse(s.begin(),s.end());
    int cnt=0;
    for(int i=0;i<n;i++)cnt+=(s[i]=='1');
    int d=0,x=0,based=1,basex=1;
    for(int i=0;i<n;i++,based=based*2%(cnt+1))if(s[i]=='1')d=(d+based)%(cnt+1);
    for(int i=0;i<n;i++)if(s[i]=='0')ans[n-i]=1+get((d+poww(2,i,cnt+1))%(cnt+1));
    if(cnt>1){
            for(int i=0;i<n;i++,basex=basex*2%(cnt-1))if(s[i]=='1')x=(x+basex)%(cnt-1);
            for(int i=0;i<n;i++)if(s[i]=='1')ans[n-i]=1+get((x+cnt-1-poww(2,i,cnt-1))%(cnt-1));
    }
    if(cnt==1){
        for(int i=0;i<n;i++)if(s[i]=='1')ans[n-i]=0;
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4520
S = input()
Q = int(input())
front = ''
end = ''
reverse = False
for i in range(Q):
    Query = input()
    if Query[0] == '1':
        reverse = not reverse 
    else:
        if (Query[2] == '1' and reverse == False) or (Query[2] == '2' and reverse == True):
            front = Query[4] + front
        else:
            end = end + Query[4]

S = front + S + end
if reverse == True:
    S = S[::-1]


print(S)
print('\n')


Measured memory_bytes: 4416
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int e;
	while(cin>>e,e) 
	{
		int m=10000000;
		for(int z = 0; z*z*z <= e; ++z)
		{
			int t=e-z*z*z;
			t=sqrt(t);
			for(int y = 0; y <= t; ++y)
			{
				m=min(m,z+y+(e-z*z*z-y*y));	
			}
		}
		cout<<m<<endl;
	}
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;


int main() {
    int a,b;
    int theta = 90;
    double x=0,y=0;
    int idx = 0;
    while(~scanf("%d,%d",&a,&b)) {
        if(a==0 && b==0) break;
        y+=a*sin(theta/180.0*3.1415926535);
        x+=a*cos(theta/180.0*3.1415926535);

        theta += b;
    }
    cout<<(int)-x<<endl<<(int)y<<endl;
    return 0;
}

Measured memory_bytes: 1204
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    a = inputStrOnebyOne()
    b = inputStrOnebyOne()
    c = inputStrOnebyOne()
    print(a[0]+b[1]+c[2])

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
n=int(input())
A=list(map(int, input().split()))
left=[]
right=[]
for i in range(n):
    if i%2==0:
        right.append(A[i])
    else:
        left.append(A[i])

if n%2==1:
    ans=right[::-1]+left
    
else:
    ans=left[::-1]+right
##print(left, right)
#print(ans)
print(*ans)

Measured memory_bytes: 26360
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc135/tasks/abc135_a

a, b = map(int, input().strip().split())
diff = abs(a-b)
if diff % 2 == 0:
    print(int((a+b)/2))
else:
    print('IMPOSSIBLE')



Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, x;
int m[51], p[51];

int f(int n, int x) {
	if (n == 0 && x == 1)return 1;
	if (x <= 1)return 0;
	if (x <= m[n] / 2)return f(n - 1, x - 1);
	if (x < m[n])return p[n - 1] + f(n - 1, x - m[n] / 2 - 1) + 1;
	if (x == m[n])return p[n];
}

signed main() {
	cin >> n >> x;
	m[0] = 1;
	p[0] = 1;
	rep(i, n) {
		m[i + 1] = m[i] * 2 + 3;
		p[i + 1] = p[i] * 2 + 1;
	}
	cout << f(n, x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n;
int p[100];
int cnt=0;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		if(i!=p[i]){
			cnt++;
		}
	}
	if(cnt==0||cnt==2)puts("YES");
	else puts("NO");
	return 0;
}


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

int main(void){
	int N,l;
	bool flag=true;
	cin >> N;
	vector<int> t(N);
	vector<int> x(N);
	vector<int> y(N);
	for(int i=0;i<N;i++){
		cin >> t.at(i) >> x.at(i) >>  y.at(i);
	}
	
	l=x.at(0)+y.at(0);
	if(l>t.at(0)||l%2!=t.at(0)%2){
		flag=false;	
	}

	for(int i=1;i<N;i++){
		l=abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1));
		if(l>t.at(i)-t.at(i-1)||l%2!=(t.at(i)-t.at(i-1))%2){
			flag=false;
			break;
		}
	}
	
	if(flag==true){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
X, Y = map(int, input().split())

import sys
if (-X+2*Y)%3 != 0 or (2*X-Y)%3 != 0:#桂馬跳びでは到達できない
    print(0)
    sys.exit()
x, y = (-X+2*Y) // 3, (2*X-Y) // 3
if x < 0 or y < 0:#盤面外
    print(0)
    sys.exit()
    
P = 1000000007

def mul(a, b):
    return ((a % P) * (b % P)) % P
 
def div(x, y):
    return mul(x, pow(y, P-2, P))
 
def comb(n, r):
    x = 1
    for i in range(n, n - r, -1):
        x = (x * i) % P
        
    y = 1
    for i in range(1, r+1):
        y = (y * i) % P
    return div(x, y)

print(comb(x + y, min(x, y)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, q, d;
	cin >> n >> d;
	vi v(n);
	vector<ll> ans(n+1), sum(n+1);
	rep(i, n) cin >> v[i];
	ans[n] = 1;
	sum[0] = d;
	rep(i, n) sum[i + 1] = min(abs(sum[i] - v[i]), sum[i]);
	
	for(int i = n - 1; i >= 0; i--){
		if(v[i] >= 2 * ans[i + 1]) ans[i] = ans[i + 1];
		else ans[i] = ans[i + 1] + v[i];
	}
	/*
	dbg(ans);
	dbg(sum);
	*/
	cin >> q;
	while(q--){
		int x; cin >> x;
		cout << (sum[x - 1] >= ans[x] ? "YES" : "NO") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n";
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pi pair<int,int>
#define pii pair<int,pair<int,int> >
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
vector<int>vp[N];
int a[N];
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    set<string>s;
    for(int i=1;i<=n;i++)
    {
        string s1;
        cin>>s1;
        s.insert(s1);
    }
    cout<<s.size()<<endl;
       
}

Measured memory_bytes: 23860
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
   
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl; 
    return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}     
int n;

int a[Sz];

bool check (int x) {
  static map <int, int> s;
  s.clear();
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] >= a[i]) {
      while (!s.empty() && s.rbegin()->x > a[i])
        s.erase (--s.end());
      int l = a[i];
      while (s[l] == x-1) {
        if (l == 1)
          return 0;
        s.erase (l--);
      }
      s[l]++;     
    }
  }
  return 1;
}  

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;    
  for (int i = 1; i <= n; i++)
    cin >> a[i];
          
  for (int i = 1; i <= n; i++) {
    if (i == n) {
      cout << 1;
      return 0;
    }  
    if (a[i] <= a[i - 1])
      break;
  }
  int l = 2, r = n, ans = r;
  while (l <= r) {
    int mid = (l+r) >> 1;
    if (check(mid)) 
      ans = mid, r = mid-1;
    else
      l = mid+1;
  }           
  cout << ans;

  return 0;
}






// Coded by Z..


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	long long l;
	cin>>l;
	cout<<fixed<<setprecision(10)<<((l*l*l)*1.0)/(27.0)<<"\n";
}

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

Measured memory_bytes: 256
def rotation(C: list) -> bool:
    for n in range(3):
        if C[0][n] != C[1][2-n]:
            return False
    return True


if __name__ == "__main__":
    C = [list(map(str, input())) for _ in range(2)]
    yes = rotation(C)
    print('YES' if yes else 'NO')


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

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

    string target = ",";
    string rep = " ";
    if (!target.empty()) {
        std::string::size_type pos = 0;
        while ((pos = s.find(target, pos)) != std::string::npos) {
            s.replace(pos, target.length(), rep);
            pos += rep.length();
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
P = list(map(int,input().split()))
Network = UnionFind(N)

for i in range(M):
    X,Y = list(map(int,input().split()))
    Network.union(X-1, Y-1)

out=0
for i in range(N):
    if Network.find(i)==Network.find(P[i]-1):
        out+=1
print(out)


Measured memory_bytes: 84392
#include<stdio.h>
#include<string.h>

#define MAX 10000

int c[MAX+1][MAX+1];

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


int LCSLength( char *X, char *Y )
{
  int i, j, m, n, maxl=0;
  char x[MAX], y[MAX];

  m = strlen(X);
  n = strlen(Y);

  x[0] = ' ';
  y[0] = ' ';
  strcpy(&x[1],X);
  strcpy(&y[1],Y);
  
  
  for( i=1; i<=m; i++ ) c[i][0] = 0;
  for( j=0; j<=n; j++ ) c[0][j] = 0;

  for( i=1; i<=m; i++ )
    {
      for( j=1; j<=n; j++ )
	{
	  if( x[i] == y[j] )
	    {
	      c[i][j] = c[i-1][j-1] + 1;
	    }
	  else if( c[i-1][j] >= c[i][j-1] )
	    {
	      c[i][j] = c[i-1][j];
	    }
	  else
	    {
	      c[i][j] = c[i][j-1];
	    }
	  maxl = max(maxl,c[i][j]);
	}
    }
  return maxl;
}


int main()
{
  int i, q;
  char X[1001], Y[1001];

  scanf("%d", &q);

  for( i=0; i<q; i++ )
    {
      scanf("%s%s", X, Y);
      printf("%d\n", LCSLength(X,Y));
      
    }

  return 0;
}
  



Measured memory_bytes: 9684
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();

        long v = x;
        int ans = 0;
        while(v <= y){
            v *= 2;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int A,B;
    cin >> A >> B;
    int h1=3*ceil((double)A/50),h2=3*ceil((double)B/50),w=100;
    A--,B--;
    bool ans1[h1][100]={};
    bool ans2[h2][100]={};
    for(int i=0;i<h1;i++){
        if(i%3==0 || i%3==2) rep(j,100) ans1[i][j]=1;
        else{
            rep(j,100){
                if(j%2==1) ans1[i][j]=1; 
            }
        }
    }
    for(int i=0;i<h2;i++){
        if(i%3==1) rep(j,100) if(j%2==0) ans2[i][j]=1;
    }
    int Acount=(h1/3)*50,Bcount=(h2/3)*50;
    int Ap=0,Bp=0;
    while(Acount!=A){
        Acount--;
        ans1[1][Ap]=1;
        Ap+=2;
    }
    while(Bcount!=B){
        Bcount--;
        ans2[1][Bp]=0;
        Bp+=2;
    }
    cout << h1+h2 << " " << 100 << endl;
    rep(i,h1){
        rep(j,100){
            if(ans1[i][j]==0) cout << '.';
            else cout << '#';
        }
        cout << endl;
    }
    rep(i,h2){
        rep(j,100){
            if(ans2[i][j]==0) cout << '.';
            else cout << '#';
        }
        cout << endl;
    }
}

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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  sort(p.begin(), p.end());

  if (n==0) cout << x << endl;
  else {
    int ans = 0;
    for (int i = 1; i <= 110; i++) {
      if (std::find(std::begin(p), std::end(p), i) != std::end(p)) continue;
      else {
        if (abs(x-ans) > abs(x-i)) ans = i;
        else break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdio.h>
void f(char a[],char b[]) {
    int i,j;
    for(i=0; a[i]!='\0'; i++);
    i--;
    for(j=0; j<=i; j++)
        b[j]=a[i-j];
        b[j]='\0';
}
int main()
{
    char a[1000],b[100];
    gets(a);
    f(a,b);
    int t=strlen(a);
    int i,s=0;
    for(i=0;a[i]!='\0';i++)
    if(a[i]!=b[i])
    s++;
    if(t%2==0)
    s=s/2;
    else
    s=(s+1)/2;
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans=0;
  cin >> N;
  vector<int> suma(N),sumb(N),sumc(N);
  cin >> suma.at(0) >> sumb.at(0) >> sumc.at(0);
  for(int i=1;i<N;i++){
    int a,b,c;
    cin >> a >> b >> c;
    suma.at(i) = max(sumb.at(i-1),sumc.at(i-1)) + a;
    sumb.at(i) = max(suma.at(i-1),sumc.at(i-1)) + b;
    sumc.at(i) = max(suma.at(i-1),sumb.at(i-1)) + c;
  }
  ans = max(suma.at(N-1),sumb.at(N-1));
  ans = max(ans,sumc.at(N-1));
  cout << ans <<endl;
}
  

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
ll lay[51], pati[51];
ll d(int n, ll x)
{
  if (n == 0)
    return 1;
  else if (x == 1)
    return 0;
  else if (1 < x && x <= 1 + lay[n - 1])
    return d(n - 1, x - 1);
  else if (x == 1 + lay[n - 1] + 1)
    return pati[n - 1] + 1;
  else if (1 + lay[n - 1] + 1 < x && x <= 1 + lay[n - 1] + 1 + lay[n - 1])
    return pati[n - 1] + 1 + d(n - 1, x - 2 - lay[n - 1]);
  else
    return pati[n - 1] + 1 + pati[n - 1];
}

int main()
{
  int N;
  ll X;
  cin >> N >> X;
  lay[0] = pati[0] = 1;
  for (int i = 1; i <= N; i++)
  {
    lay[i] = 2 * lay[i - 1] + 3;
    pati[i] = 2 * pati[i - 1] + 1;
  }
  ll ans = d(N, X);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main() {
    val list = readLine()!!.split(" ").map { it.toInt() }
    var fiveCount = 0
    var sevenCount = 0
    for (i in list) {
        if (i == 5) fiveCount++
        if (i == 7) sevenCount++
    }
    if (fiveCount == 2 && sevenCount == 1) println("YES") else println("NO")
}

Measured memory_bytes: 36320
from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
D = defaultdict(int)
for a in A:
  D[a] += 1
if D[1] == 2 and N > 2:
  print('Impossible')
elif D[min(A)] > 2:
  print('Impossible')
elif -(-max(A) // 2) != min(A):
  print('Impossible')
elif D[min(A)] != 1 + (max(A) % 2):
  print('Impossible')
else:
  for a in range(min(A) + 1, max(A) + 1):
    if D[a] < 2:
      print('Impossible')
      break
  else:
    print('Possible')

Measured memory_bytes: 3316
x,y = map(int,input().split())

if (2*x-y)%3 != 0 or 2*x-y < 0:
    print(0)
    exit()

b = (2*x-y)//3
a = x-2*b

if a < 0:
    print(0)
    exit()

mod = 10**9+7

def prepare(n, mod):
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%mod
    invs = [1]*(n+1)
    invs[n] = pow(facts[n], mod-2, mod)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % mod
    return facts, invs
facts,invs = prepare(a+b,mod)
def make_combi(facts,invs,n,r,mod):
    return facts[n]*invs[r]*invs[n-r]%mod
print(make_combi(facts,invs,a+b,a,mod))

Measured memory_bytes: 55796
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] map = new int[n+1][n+1];
			
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[i][j] = sc.nextInt();
					map[i][n] += map[i][j];
				}
				map[n][n] += map[i][n];
			}
			
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[n][i] += map[j][i];
				}
			}
			
			for(int i=0;i<n+1;i++){
				for(int j=0;j<n+1;j++){
					System.out.printf("%5d", map[i][j]);
				}
				System.out.println();
			}
		}
	}	
}

Measured memory_bytes: 23948
use proconio::input;

fn main() {
    input! {
        a: u8,
        b: u8,
        c: u8,
        d: u8,
    }

    if (a + (d - 1)) / d >= (c + (b - 1)) / b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n>>m;
    bool visited[n+1];
    int a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        visited[i]=false;
    }
    visited[n]=false;
    
    vector<int> adj[n+1];
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    bool flag=false;
    for(i=1;i<=n;i++)
    {
        if(visited[i]==false)
        {
            flag=false;
            visited[i]=true;
            for(j=0;j<adj[i].size();j++)
            {
                curr = adj[i][j];
                if(a[i]>a[curr])
                {
                    visited[curr]=true;
                }
                
                else
                {
                    flag=true;
                }
            }
            
            if(!flag) ans++;
        }
    }
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 10312
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;


class SuffixArray{
    public:
        vector<int> rank;
        vector<int> sa;
        vector<int> lcp;
        string S;
        int n;
        SuffixArray(string _S){
            S = _S;
            n = _S.size();
            rank = vector<int>(n+1);
        }
        void construct_sa(){
            sa = vector<int>(n+1);
            vector<int> buf(n+1);
            for(int i = 0; i <= n; i++){
                sa[i] = i;
                rank[i] = i < n ? S[i] : -1;
            }

            for(int k = 1; k <= n; k *= 2){
                sort(sa.begin(), sa.end(), [&, k](int i, int j){
                    return compare_sa(i, j, k);
                });

                buf[sa[0]] = 0;
                for(int i = 1; i <= n; i++){
                    buf[sa[i]] = buf[sa[i-1]] + (compare_sa(sa[i-1], sa[i], k) ? 1 : 0);
                }
                for(int i = 0; i <= n; i++) rank[i] = buf[i];
            }
        }

        // sa should be initlally constructed
        void construct_lcp(){
            lcp = vector<int>(n+1);

            int h = 0;
            lcp[0] = 0;
            for(int i = 0; i < n; i++){
                int j = sa[rank[i]-1];

                if(h > 0) h--;
                while(j+h < n && i+h < n){
                    if(S[i+h] != S[j+h]) break;
                    h++;
                }
                lcp[rank[i]-1] = h;
            }
        }
        
        void construct_both(){
            construct_sa();
            construct_lcp();
        }
    private:
        // (rank[i], rank[i+k]) vs (rank[j], rank[j+k])
        bool compare_sa(int i, int j, int k){
            if(rank[i] != rank[j]) return rank[i] < rank[j];
            else{
                int ri = i+k <= n ? rank[i+k] : -1;
                int rj = j+k <= n ? rank[j+k] : -1;
                return ri < rj;
            }
        }
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s; cin >> s;
    SuffixArray sa(s);
    sa.construct_both();
    ll n = s.size();
    ll ans = (n*(n+1))/2;
    for(int i : sa.lcp) ans -= i;
    cout << ans << endl;
}

Measured memory_bytes: 10088
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

typedef enum 
{
 SUN,MON,TUE,WED,THU,FRI,SAT 
}Days;
char days[8][8]={"SUN","MON","TUE","WED","THU","FRI","SAT",};
int ScanDays(char s[]){

}
int main(){
    char input[10];
    scanf("%s", input);
    for(int j = 0; j < 7; j ++){
        if(strcmp(input, days[j]) == 0){
            int i = 7 - j;
            printf("%d", i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b;cin>>a>>b;
	vector<vector<char>> v(100,vector<char>(100,'#'));
	for(int i = 50; i < 100; i++) {
		for(int j = 0; j < 100; j++) {
			v[i][j] = '.';
		}
	}
	int h = 0,w = 0;
	a--;b--;
	while(a > 0){
		v[h][w] = '.';
		if (w + 2 < 100){
			w += 2;
		}
		else{
			w = 0;
			h += 2;
		}
		a--;
	}
	h = 51,w = 0;
	while(b > 0){
		v[h][w] = '#';
		if (w + 2 < 100){
			w += 2;
		}
		else{
			w = 0;
			h += 2;
		}
		b--;
	}
	cout << 100 << " " << 100 << endl;
	for(int i = 0; i < 100; i++) {
		for(int j = 0; j < 100; j++) {
			cout << v[i][j];
		}
		cout << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char p[60][60];
	int a,b,i,j,k=0;
	scanf("%d %d",&a,&b);
	for(i=1;i<=a;i++)
	   scanf("%s",p[i]);
	if(a==1&&b==1)
	{
		if(p[1][0]=='#')
		printf("Yes");
		else printf("No");
	}
	else if(a==1)
	{
			for(j=0;j<b;j++)
		{
				if(j==0)
				{
					if(p[1][0]=='#'&&p[1][1]!='#')
					{
							k=1; break;
					}
				
				}
				else if(j==b-1)
				{
					if(p[1][b-1]=='#'&&p[1][b-2]!='#')
					{
							k=1; break;
					}
				
				}
				else {
				 
					if(p[1][j]=='#'&&p[1][j-1]!='#'&&p[1][j+1]!='#')
					{
							k=1; break;
					}
					
				    }}}
				    
	else if(b==1)
	{
			for(i=1;i<=a;i++)
		{
				if(i==1)
				{
					if(p[1][0]=='#'&&p[2][0]!='#')
					{
							k=1; break;
					}
				
				}
				else if(i==a)
				{
					if(p[a][0]=='#'&&p[a-1][0]!='#')
					{
							k=1; break;
					}
				
				}
				else {
				 
					if(p[i][0]=='#'&&p[i-1][0]!='#'&&p[i+1][0]!='#')
					{
							k=1; break;
					}
					
				    }			
	}}
	else
	{
		  
		  
	for(i=1;i<=a;i++)
	{
		for(j=0;j<b;j++)
		{
			if(i==1)
			{
				if(j==0)
				{
					if(p[1][0]=='#'&&p[1][1]!='#'&&p[2][0]!='#')
					{
							k=1; break;
					}
				
				}
				else if(j==b-1)
				{
					if(p[1][b-1]=='#'&&p[1][b-2]!='#'&&p[2][b-1]!='#')
					{
							k=1; break;
					}
				
				}
				else {
				 
					if(p[1][j]=='#'&&p[1][j-1]!='#'&&p[1][j+1]!='#'&&p[2][j]!='#')
					{
							k=1; break;
					}
					
				    }
				
		
		}
		else if(i==a)
		{
			if(j==0)
				{
					if(p[a][0]=='#'&&p[a][1]!='#'&&p[a-1][0]!='#')
					{
							k=1; break;
					}
				
				}
				else if(j==b-1)
				{
					if(p[a][b-1]=='#'&&p[a][b-2]!='#'&&p[a-1][b-1]!='#')
					{
							k=1; break;
					}
				
				}
				else {
				 
					if(p[a][j]=='#'&&p[a][j-1]!='#'&&p[a][j+1]!='#'&&p[a-1][j]!='#')
					{
							k=1; break;
					}
					
				    }
		}
		else{
			if(j==0)
				{
					if(p[i][0]=='#'&&p[i][1]!='#'&&p[i-1][0]!='#'&&p[i+1][0]!='#')
					{
							k=1; break;
					}
				
				}
				else if(j==b-1)
				{
					if(p[i][b-1]=='#'&&p[i][b-2]!='#'&&p[i-1][b-1]!='#'&&p[i+1][b])
					{
							k=1; break;
					}
				
				}
				else {
				 
					if(p[i][j]=='#'&&p[i][j-1]!='#'&&p[i][j+1]!='#'&&p[i-1][j]!='#'&&p[i+1][j]!='#')
					{
							k=1; break;
					}
					
				    }
		}
	}	if(k==1)break;
}
	
	

	}
	if(k==1)
	printf("No");
	else printf("Yes");
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int h, n;
    cin >> h >> n;
    vs32 a(n), b(n);
    rep (i, n) cin >> a[i] >> b[i];

    vs32 dp(h + 1, 1e9);
    dp[0] = 0;

    rep (j, h + 1)
    {
        rep (i, n)
        {
            dp[j] = MIN(dp[j], dp[MAX(0, j - a[i])] + b[i]);
        }
    }

    cout << dp[h] << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n;
    map<string,int> msin,msim;
    rep(i,n){
        string s;
        cin>>s;
        msin[s]++;
    }
    cin>>m;
    rep(i,m){
        string t;
        cin>>t;
        msim[t]++;
    }
    vector<int> score;
    for(auto u : msin){
        int x = u.second - msim[u.first];
        //cout<<u.first<<" "<<u.second<<" "<<msim[u.first]<<endl;
        score.push_back(x);
    }
    int ans = 0;
    for(auto u : score){
        if(u>ans){
            ans=u;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//**PEACE BE UPON YOU**
// AZMAYEN FAYEK SABIL
// IUT CSE SWE-19

#include <iostream>
#include <bits/stdc++.h>

#include <cmath>
#include <string>
#include <algorithm>
using namespace std;


int main()

{
    int n,m;
    cin>>n>>m;

    int i,sum=0,ans;
    int a[m];

    for(i=0;i<m;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }

    ans=n-sum;

    if(ans>=0)
    {
        cout<<ans;
    }

    else if(ans<0)
    {
        cout<<"-1";
    }



    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vi wsum(N+1,0),esum(N+1,0);
  rep(i,N) {
    wsum[i+1] = wsum[i];
    esum[i+1] = esum[i];
    if(s[i]=='W') {
      wsum[i+1]++;
    } else {
      esum[i+1]++;
    }
  }
  int ans = INF;
  rep(i,N) {
    int l = wsum[i];
    int r = esum[N]-esum[i+1];
    chmin(ans,l+r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    vs x(2);
    for (ll i = 0; i < 2; ++i) {
        cin >> x[i];
    }
    ll ans = 0;
    for (ll i = 0; i < 3; ++i) ans += x[0][i] == x[1][i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256