akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 10000;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n,t=0;
	cin >> n;
	vector<int>vec(n);
	rep(i, n) {
		cin >> vec[i];
		t += vec[i];
	}
	for (int i = 1; i < n; i += 2) {
		t -= vec[i] * 2;
	}
	cout << t;
	for (int i = 0; i < n - 1; i++) {
		t=vec[i] * 2 - t;
		cout << " " << t;
	}
	cout << endl;
}




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

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

	int n; cin >> n;
	queue<int> a;
	for(int i = 0; i < (1 << n); i++) {
		int t; cin >> t; a.push(t);
	}
	while(a.size() > 1){
		int s = a.front();
		a.pop();
		int t = a.front();
		a.pop();
		if(s == t) a.push(t);
		else a.push(max(s - t, t - s));
	}
	cout << a.front() << endl;
	return 0;	
}

Measured memory_bytes: 1408
n = int(input())
def digsum(x):
  ret = 0
  while x > 0:
    ret += x % 10
    x //= 10
  return ret
ans = 10**5
for i in range(1, (n+1)//2+1):
  ans = min(ans, digsum(i) + digsum(n-i))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() 
{
	int a,b;
    char op;
    while(1) {
    	cin >> a >> op >> b;
    	if(op=='?')
        		break;
	else if(op== '+') 
        		cout << a+b << endl;
    	else if(op== '-') 
        		cout << a-b << endl;
    	else if(op== '*') 
        		cout << a*b << endl;
    	else if(op== '/') 
    		cout << a/b << endl;
    }
	return 0;
}



Measured memory_bytes: 3060
d='URLD'
h,w,n=map(int,input().split())
b=[h,w,w,h]
r,c=map(int,input().split())
o=[h-r+1,c,w-c+1,r]
s=input()
t=[dict(zip(d,d[::-1]))[i] for i in input()]
a=0
for i,j in enumerate(d):
  x=o[i]
  for k in range(n):
    x+=(s[k]==j)
    if x>b[i]:a=1
    if x>1:x-=(t[k]==j)
print('YNEOS'[a::2])

Measured memory_bytes: 63932
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#include <tuple>
#define Rep(i, n) for(int i=0;i<n;++i)
#define ll long long

using namespace std;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;

int main () {
  scanf("%d", &N);
  vector<pair<int, int> > v(N);

  int a;
  Rep(i, N) {
    scanf("%d", &a);
    v[i] = make_pair(a, i+1);
  }

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

  Rep(i, N-1) {
    printf("%d ", v[i].second);
  }
  printf("%d", v[N-1].second);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define INF (1<<30)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
static const int MAX=100000;
static const int NMAX=50;
int N,M;
vector <P> a(NMAX),c(NMAX);
vector<int> d(NMAX),ans(NMAX);;
int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>a[i].first>>a[i].second;
    for(int i=0;i<M;i++)cin>>c[i].first>>c[i].second;

    for(int i=0;i<N;i++)d[i]=INF;
        
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            int dis=abs(c[j].first-a[i].first)+
                    abs(c[j].second-a[i].second);
            if(d[i]>dis){
                d[i]=dis;
                ans[i]=j;
            }
        }
    }
    for(int i=0;i<N;i++)cout<<ans[i]+1<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



int main() {

	string ans,s;
	cin>>s;
	
	for(int i=0;i<s.length();i+=2){
		ans+=s[i];
	}
	cout<<ans<<endl;
	
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    string s;
    cin >> n >> s;
    if(n%2==1) cout << "No\n";
    else{
        string t="";
        rep(i,n/2) t+=s[i];
        t+=t;
        cout << (s==t?"Yes\n":"No\n");
    }
    return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        s1,s2,s3 = (int(_) for _ in input().split())
        t.append(s1)
        x.append(s2)
        y.append(s3)

    if x[0] + y[0] > t[0]:
        print('No')
        return
    
    for i in range(1,N):
        d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
        if  d > t[i] - t[i-1]:
            print('No')
            return
        if (t[i] - t[i-1])%2 != d %2:
            print('No')
            return
        
    print('Yes')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 12292
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	vector<string> s(3);
	cin >> s[0] >> s[1] >> s[2];

	int32_t _index[3], _len[3];
	for (int32_t i = 0; i < 3; i++) {
		_index[i] = 0;
		_len[i] = s[i].size();
	}
	int32_t turn = 0;

	while (true) {
		if (_index[turn] >= _len[turn])
			break;

		int32_t next_turn = s[turn][_index[turn]] - 'a';
		_index[turn]++;
		turn = next_turn;
	}

	char res = 'A' + turn;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  int n; cin >>n;
  int first=0,second=0,shit;
  for(int i=0; i<n; i++){
    int x; cin >>x;
    if(x>=first){second=first; first=x; shit=i;}
    else if(x>second) second=x;
  }
  for(int i=0; i<n; i++){
    if(i==shit) cout <<second<<endl;
    else cout <<first<<endl;
  }
return 0;}

Measured memory_bytes: 3624
s = input()
ls = [int(i) for i in s]
n = len(ls)
i = 1
ans = ls[0]

def dfs(i, s, ans):
    if i==n:
        #print(i, 'floor', s, ans)
        return ans==7, s, ans
    else:
        #print(i, 'left', s, ans)
        p = i + s.count('+') + s.count('-')
        s_temp = s[:p]+'-'+s[p:]
        ans_temp = ans - ls[i]
        tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
        if tf:
            return True, s_temp, ans_temp
        else:
            #print(i, 'right', s, ans)
            p = i + s.count('+') + s.count('-')
            s_temp = s[:p]+'+'+s[p:]
            ans_temp = ans + ls[i]
            tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
            return tf, s_temp, ans_temp
            

tf, s, ans = dfs(1, s, ans)
print(s+'=7')

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N,C[202020];
ll nc[202020];
ll i,j,k,ans[202020];
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &C[i]);
    }
    ans[0] = 0;
    ans[1] = 1;
    if(C[0]!=C[1])
        nc[C[0]] = 1;
    fornum(i,1,N){
        if(C[i]==C[i+1]){
            ans[i + 1] = ans[i];
            continue;
        }
        ans[i+1] = (ans[i] + ans[nc[C[i]]])%MOD;
        nc[C[i]] = i+1;
        //printf("%lld,%lld,%lld\n", C[i],nc[C[i]],ans[i+1]);
    }
    printf("%lld", ans[N]);

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            int m = i - 1;
            int x = n / i;
            if(0 <= x && x < m){
                // cout << m << endl;
                ans += m;
            }
            if(i * i != n){
                m = n / i - 1;
                x = i;
                if(0 <= x && x < m){
                    // cout << m << endl;
                    ans += m;
                }
            }
        }
    }
    cout << ans << endl;
}

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

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

int main(){
    int N;
    cin >> N;
    string s[N];
    rep(i, N) cin >> s[i];
    int M;
    cin >> M;
    string t[M];
    rep(i, M) cin >> t[i];
    map<string, int> mp;
    rep(i, N){
        mp[s[i]]++;
    }
    rep(i, M){
        mp[t[i]]--;
    }
    int mx = 0;
    for(auto p : mp){
        mx = max(mx, p.second);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,Q;
int a[200007],b[200007];
int P[200007];
int ans[200007];
vector<pair<int,int>> edges[200007];



signed main(){
    scanf("%lld %lld",&N,&Q);
    rep(i,N-1){
        scanf("%lld %lld",&a[i],&b[i]);
        a[i]--;b[i]--;
        edges[a[i]].pb( mp(b[i],0) );
        edges[b[i]].pb( mp(a[i],0) );
    }
    rep(i,Q){
        int p,x;
        scanf("%lld %lld",&p,&x);p--;
        P[p]+=x;
    }
    int d[200007];
    rep(i,N){d[i]=LLINF;}
    priority_queue< pair<int,int> , vector< pair<int,int> >, greater< pair<int,int> > > q;
    q.push(mp(P[0],0));
    while(!q.empty()){
        pair<int,int> p=q.top();q.pop();
        int now=p.second;int cost=p.first;
        if(d[now]<=cost)continue;
        d[now]=cost;
        rep(e,edges[now].size()){
            int to=edges[now][e].first;int cst=P[to];
            if(d[to]>cost+cst){
                q.push(mp(cost+cst,to));
            }
        }
    }
    rep(i,N){
        if(i<N-1)printf("%lld ",d[i]);
        else printf("%lld\n",d[i]);
    }
}


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

using namespace std;

int vis[305];
int num[305];
int qx[305];
int a[305][305];

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    int mn=40000;
    for(int j=0;j<m;j++)
    {
        int now=0;
        int mm=0;
        for(int i=0;i<n;i++)
        {
            while(qx[a[i][vis[i]]]==1)
            {
                vis[i]++;
            }
            num[a[i][vis[i]]]++;
            if(num[a[i][vis[i]]]>now)
            {
                now=num[a[i][vis[i]]];
                mm=a[i][vis[i]];
            }
        }
        mn=min(num[mm],mn);
        //cout<<mm<<' '<< num[mm]<<endl;
        //num[mm]=0;
        qx[mm]=1;
        for(int i=0;i<n;i++)
        {
            num[a[i][vis[i]]]--;
        }
    }
    cout <<mn<< endl;
    return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
H = list(map(int, input().split()))
K = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    K[a - 1].append(H[b - 1])
    K[b - 1].append(H[a - 1])
ans = 0
for i, k in enumerate(K):
    if len(k) != 0 and H[i] > max(k):
        ans += 1
    elif len(k) == 0:
        ans += 1
print(ans)

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n, m; cin >> n >> m;
    vector<int> d(m);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a; a--;
            d[a]++;
        }
    }

    int cnt = 0;
    for(int i = 0; i < m; i++) cnt += (d[i] == n);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int A[N],n;

int part(int p,int q){
  int x,i,j,w;

  x=A[q];
  i=p-1;
  for(j=p;j<=q-1;j++){
    if(A[j]<=x){
      i=i+1;
      w=A[i];
      A[i]=A[j];
      A[j]=w;
    }
  }
  w=A[i+1];
  A[i+1]=A[q];
  A[q]=w;
  return i+1;
}

int main(){
  int i,r;

  scanf("%d",&n);
  
  for(i=0;i<=n-1;i++){
    scanf("%d",&A[i]);
  }
  
  r=part(0,n-1);
  
  for(i=0;i<=n-1;i++){
    if(i){
      printf(" ");
    }
    if(i==r){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==r){
      printf("]");
    }
  }
  
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
typedef long long ll;
#define endl "\n"
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
using namespace std;
ll dp[100005][10];
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int n;
	cin >> n;
	ll a[n], b[n], c[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
	for(int i = 0; i < n; i++){
		dp[i+1][0] = a[i+1]+ max(dp[i][1],dp[i][2]);
		dp[i+1][1] = b[i+1] + max(dp[i][0], dp[i][2]);
		dp[i+1][2] = c[i+1] + max(dp[i][1],dp[i][0]);
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;

typedef vector<char>::iterator ite;
int drop[100000];
int main() {
    char S[100000];
    cin >> S;
    int N = strlen(S);
    vector<char> blocks;
    for (int i=0; i<N; i++) {
        blocks.push_back(S[i]);
    }
    int score = 0;

    ite head = blocks.begin();
    ite tail = head + 1;
    if (tail == blocks.end()) {
        cout << 0 << endl;
        return 0;
    }

    while (head != blocks.end() && tail != blocks.end()) {
        if (*head != *tail) {
            score += 2;
            ite next = blocks.erase(head, tail+1);
            if (next == blocks.begin()) {
                head = next;
                if (head == blocks.end()) {
                    break;
                }
                tail = head + 1;
            } else {
                head = next - 1;
                tail = next;
            }
        } else {
            head++;
            tail++;
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 512
/* Atcoder abc149c
 * See tasks at: https://atcoder.jp/contests/abc149/tasks/abc149_c
 */
#include <iostream>
#include <vector>
#include <algorithm>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int x;
    cin >> x;
    
    for (int n=x;; n++)
    {
        bool divided = false;
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0)
            {
                divided = true;
                break;
            }
        }

        if (!divided)
        {
            cout << n;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


const int MAX = 510000;//階乗の配列数
const int MOD = 1000000007;

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

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
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 main(){
  int n, k;
  cin >> n >> k;
  COMinit();
  ll ans=0;
  int nk=min(n, k);
  rep(m, nk+1){
    ans+=(COM(n, m)*COM(n-1, m))%MOD;
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for (ll i = (a); i < (b); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
    string n;
    cin >> n;
    rep(i, 3)
    {
        if (n[i] == n[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++){
    string s = to_string(i);
      if(s[0]==s[4] && s[1]==s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<ll>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int d,g;
    int p,c;
    cin>>d>>g;
    g/=100;
    vector<vi> dp(d+1,vi(g+1,INF));
    dp[0][0]=0;

    REP(i,d){
        cin>>p>>c;
        c/=100;
        REPR(j,g){
            if(dp[i][j]==INF)continue;
            dp[i+1][j]=dp[i][j];
            REP(k,p+1){
                int youso=j+k*(i+1)+(k==p)*c;
                if(youso>g)youso=g;
                chmin(dp[i+1][youso],dp[i][j]+k);
            }
        }
    }

    cout<<dp[d][g]<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int A[3], i;

	scanf("%d %d %d", &A[0], &A[1], &A[2]);
	qsort(A, 3, sizeof(int), asc);
	printf("%d", abs((A[0] - A[1]) + (A[1] - A[2])));

	return 0;
}

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

int main()
{

  string s;
  string ans ;
  cin >> s;
  char saigo = s[s.size()-1];
  if (saigo =='3') ans = "bon";
  else if (saigo == '0' || saigo == '1' || saigo == '6' || saigo =='8') ans = "pon";
  else ans = "hon";
  cout << ans << endl;


}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int max = Math.max(a, Math.max(b, c));
        
        System.out.println(a+b+c-max);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
  map<string, int> c; c["A"] = c["B"] = c["AB"] = c["O"] =0;
  int i; char k; string s;
  while (cin >> i >> k >> s) c[s]++;
  cout << c["A"] << endl << c["B"] << endl << c["AB"] << endl << c["O"] << endl;
}

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

int main()
{
  int N; cin >> N;
  int ans = 0;
  
  if(N >= 64) ans = 64;
  else if(N >= 32) ans = 32;
  else if(N >= 16) ans = 16;
  else if(N >= 8) ans = 8;
  else if(N >= 4) ans = 4;
  else if(N >= 2) ans = 2;
  else ans = 1;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
  int i=0,j=0,x=0;
  char ch,p[101]={},s[101]={};
 
  //input p
  while(1){
 
    scanf("%c",&ch);
 
    if(ch != '\n'){
 
      p[i]=ch;
 
      i++;
 
    } else {
 
      break;
 
    }
 
  }
 
  i=0;
 
  //input s
  while(1){
 
    scanf("%c",&ch);
     
    if(ch != '\n'){
 
      s[i]=ch;
 
      i++;
 
    } else {
 
      break;
 
    }
 
  }
 
  i=0;
   
  //search
  while(1){
 
    if(s[j] != '\0'){
       
      if(p[i] != '\0'){
     
    if(p[i] == s[j]){
       
      i++;
      j++;
       
    } else {
 
 
      x++;
      i=x;
      j=0;
 

       
    }   
     
      } else {
 
    if(j != 0){
 
      i=0;
 
    } else {
 
      printf("No\n");
 
      break;
 
    }
 
      }
       
    } else {
 
      printf("Yes\n");
 
      break;
 
    }
 
  }
 
  return 0;
   
}
       
 
      

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
# define ll int
#define mmm 1000000007
#define pb push_back

									//nestedcode

 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll n,k,i;
   cin>>n;
   ll a[n+5];
   for(i=0;i<n;i++){
   	cin>>a[i];
   }
   
   k = 1;
   for(i=0;i<n;i++){
   	if(a[i] == k){
   		k++;
	   }
   }
   
   if(k == 1){
   	cout<<-1;
   }else{
   	cout<<n-k+1;
   }
  
 }   

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static final int mod = (int)1e9 + 7;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] A = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int[] dp = new int[1 << N];
        dp[0] = 1;

        for (int mask = 1; mask < (1 << N); mask++) {
            int person = Integer.bitCount(mask) - 1;
            for (int b = 0; b < N; b++) {
                if (((mask >> b) & 1) == 1 && A[person][b] == 1) {
                    dp[mask] += dp[mask ^ (1 << b)];
                    dp[mask] %= mod;
                }
            }

        }
        System.out.println(dp[(1 << N) - 1]);
    }
}


Measured memory_bytes: 30676
N, X, M = map(int, input().split())

id = [-1] * M
a = []
l = 0
tot = 0
while id[X] == -1:
    a.append(X)
    id[X] = l
    l += 1
    tot += X
    X = X ** 2 % M

c = l - id[X]
s = 0
for i in range(id[X], l):
    s += a[i]

ans = 0
if N <= l:
    for i in range(N):
        ans += a[i]
else:
    ans += tot
    N -= l
    ans += s * (N // c)
    N %= c
    for i in range(N):
        ans += a[id[X] + i]

print(ans)


Measured memory_bytes: 69920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    vector<string> week= {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    int count = 0;
    string s; cin >> s;
    rep(i,7) {
        if (s == week[i]) {
            count =i;
        }
    }
    cout << (count ==6 ? 7:6 - count )<< endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
//#pragma GCC optimize("Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int h, w, ch, cw, dh, dw;
char s[N][N];
bool mark[N][N];
int warp[N][N];
void dfs(int x, int y)
{
    //cout << x << " " << y << " " << warp[x][y] << '\n';

    if (x == dh && y == dw)
        return;

    int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
    bool flag = false;
    rep(i, 0, 4)
    {
        int xx = x + dx[i], yy = y + dy[i];
        if (xx >= 1 && xx <= h && yy >= 1 && yy <= w && s[xx][yy] == '.')
        {
            if (!mark[xx][yy])
            {
                flag = true;
                mark[xx][yy] = true;
                warp[xx][yy] = warp[x][y];
                dfs(xx, yy);
            }
            else
            {
                if (warp[x][y] < warp[xx][yy])
                {
                    warp[xx][yy] = warp[x][y];
                    dfs(xx, yy);
                }
            }
        }
    }

    int wx[] = {1, -1, 1, -1}, wy[] = {-1, 1, 1, -1};
    rep(i, 0, 3)
    {
        rep(j, 0, 3)
        {
            rep(k, 0, 4)
            {
                int xx = x + wx[i] * i, yy = y + wy[i] * j;
                if (xx >= 1 && xx <= h && yy >= 1 && yy <= w && s[xx][yy] == '.')
                {
                    if (!mark[xx][yy])
                    {
                        flag = true;
                        mark[xx][yy] = true;
                        warp[xx][yy] = warp[x][y] + 1;
                        dfs(xx, yy);
                    }
                    else
                    {
                        if (warp[x][y] + 1 < warp[xx][yy])
                        {
                            warp[xx][yy] = warp[x][y] + 1;
                            dfs(xx, yy);
                        }
                    }
                }
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin >> h >> w;
    // cin >> ch >> cw;
    // cin >> dh >> dw;
    // rep(i, 1, h + 1)
    // {
    //     string in;
    //     cin >> in;
    //     rep(j, 1, w + 1)
    //     {
    //         s[i][j] = in[j - 1];
    //     }
    // }
    // mark[ch][cw] = true;
    // dfs(ch, cw);
    // if (mark[dh][dw])
    //     cout << warp[dh][dw] << endl;
    // else
    //     cout << -1 << endl;

    string n;
    cin >> n;
    int cnt = n.length();
    int res = 0;
    while (cnt)
    {
        res += n[cnt - 1] - '0';
        cnt--;
    }

    if (res % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
int x,y;
int a,b;

int main(){
	scanf("%d%d",&x,&y);
	if(x==2||y==2){
		printf("No\n");
	}else{
		if(x==4||x==6||x==9||x==11){
			a=0;
		}else{
			a=1;
		}
		if(y==4||y==6||y==9||y==11){
			a=0;
		}else{
			b=1;
		}
		if(a==b){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a[21];
  cin >> n;
  int ans=0;
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=1; i<n-1; i++) {
  	if(a[i]<a[i+1] && a[i]>a[i-1]) ans++;
  	if(a[i]<a[i-1] && a[i]>a[i+1]) ans++;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
#encoding utf 8

n, k = map(int, input().split())

pos = list(int(i) for i in input().split())

ans = abs(pos[0])+abs(pos[0]-pos[k-1])

for i in range(n-k+1):
    val = 0
    val += abs(pos[i] - pos[i+k-1])
    val += min(abs(pos[i]), abs(pos[i+k-1]))

    if val < ans:
        ans = val
print(ans)


Measured memory_bytes: 14568
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m*n/gcd(m,n);}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

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

  int n,a,b;
  while(cin >> n >> a >> b){
    cout << min(a,b) << " " << max(0,a+b-n) << endl;
  
  }
  
  return 0;
}


Measured memory_bytes: 256
def selection_sort(a, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        if i != minj:
            tmp = a[i]
            a[i] = a[minj]
            a[minj] = tmp
            cnt += 1
    return a, cnt

a = []
n = int(input())
s = input()
a = list(map(int, s.split()))
a, cnt = selection_sort(a, n)
print(*a)
print(cnt)

Measured memory_bytes: 7720
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans=0;
    for(int i=0; i<=7; i++){
        string a=s.substr(0,i)+s.substr(i+s.size()-7,7-i);
        if(a=="keyence"){
            ans=1;
            break;
        }
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[100000];
	bool b[30];
	int l,k;
	cin>>a;
	l=strlen(a);
	memset(b,false,sizeof(b));
	for(int i=0;i<l;i++)
	{
		b[a[i]-96]=true;
	}
	k=0;
	for(int i=1;i<=26;i++)
	{
		if(b[i]==false)
		{
			k=i;
			break;
		} 
	} 
	if(k>0) cout<<(char)(k+96)<<endl; else cout<<"None"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int x = 1; x <= N; x++) {
    if (x * 108 / 100 == N) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n){
        cin >> a[i+1];
    }

    vector<int> aa(n+1,0);
    vector<int> b(n+1,0);

    for(int i=n;i>0;i--){
        if(i>n/2){
            aa[i]=a[i];
            if(aa[i]==1){
                b[i]++;
            }
        }else{
            if(b[i]%2!=a[i]){
                aa[i]++;
                b[i]++;
            }
        }
        if(aa[i]==1){
            for(int j=1;j*j<=i;j++){
                if(i%j==0){
                    b[j]++;
                    if(j!=i/j){
                        b[i/j]++;
                    }
                }
            }
        }
    }
    vector<int> ans;
    rep(i,n){
        if(aa[i+1]==1){
            ans.push_back(i+1);
        }
    }
    // rep(i,n){
    //     cout << b[i+1] << " ";
    // }cout << endl;
    // rep(i,n){
    //     cout << aa[i+1] << " ";
    // }cout << endl;

    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << " ";
    }cout << endl;

    return 0;
}

Measured memory_bytes: 3832
def onlyA(s, n)
  s.size <= n && s.count('A') == s.size
end

s = gets.chomp

cs = "KIHBR".chars
ns = [1, 0, 0, 1, 1]

5.times do |i|
  fs = s.split(cs[i], -1)
  if fs.size != 2
    puts :NO
    exit
  end
  if not onlyA(fs[0], ns[i])
    puts :NO
    exit
  end
  s = fs[1]
end

if onlyA(s, 1)
  puts :YES
else
  puts :NO
end


Measured memory_bytes: 2044
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d,dif,now=1,M=INF,cnt=0;
    cin>>n>>a>>b>>c>>d;
    dif=d*(n-1)+a-b;
    // cout<<dif<<endl;
    if(dif<0){
        cout<<"NO"<<endl;
        return 0;
    }
    if(c==d && c==0){
        if(a==b){
            cout<<"YES"<<endl;
        } else{
            cout<<"NO"<<endl;
        }
        return 0;
    }
    if(c==d){
        if(dif%(2*d)==0){
            cout<<"YES"<<endl;
        } else{
            cout<<"NO"<<endl;
        }
        return 0;
    }
    for(ll i=c+d;i<=2*d;i++){
        if(M>dif%i){
            M=dif%i;
            now=i;
        }
        if(M<(n-1-dif/now)*(d-c)+1){
            break;
        }
    }
    cnt+=dif/now;
    dif%=now;
    if(dif<=d-c){
        cnt++;
    } else{
        cnt+=dif/(d-c);
        if(dif%(d-c)!=0) cnt++;
    }
    if(cnt<n){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef long long ll;
string text="abcdefghijklmnopqrstuvwxyz";
const int mx=1e5+7;
const ll m=1e9+7;
ll lazy[4*mx];
int a[mx];
ll tree[4*mx];
//void init(int node,int b,int e)
//{
//    if(b==e){
//        tree[node]=a[b];
//        return;
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    init(l,b,m);
//    init(r,m+1,e);
//    tree[node]=tree[l]*tree[r];
//}
//int query(int node,int b,int e,int i,int j)
//{
//    if(i>e || j<b)return 1;
//    if(b>=i && e<=j){
//        return tree[node];
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    int p1=query(l,b,m,i,j);
//    int p2=query(r,m+1,e,i,j);
//    return p1*p2;
//}
//void update(ll node, ll b, ll e, ll i, ll j, ll x)
//{
//    if (i > e || j < b)
//        return;
//    if (b >= i && e <= j)
//    {
//        tree[node].sum += ((e - b + 1) * x);
//        tree[node].prop += x;
//        return;
//    }
//    ll Left = node * 2;
//    ll Right = (node * 2) + 1;
//    ll mid = (b + e) / 2;
//    update(Left, b, mid, i, j, x);
//    update(Right, mid + 1, e, i, j, x);
//    tree[node].sum = (tree[Left].sum+ tree[Right].sum + ((e - b + 1) * tree[node].prop));
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int l = node * 2;
//    int r = node * 2 + 1;
//    int m = (b + e) / 2;
//    update(l, b, m, i, newvalue);
//    update(r, m + 1, e, i, newvalue);
//    tree[node] = (tree[l] * tree[r]);
//}
//void update(int node,int b,int e,int l,int r,int val)
//{
//    if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>e || b>r || e<l)return;
//    if(b>=l && e<=r){
//        tree[node]+=(e-b+1)*val;
//        if(b!=e){
//            lazy[node*2]+=val;
//            lazy[node*2+1]+=val;
//        }
//        return;
//    }
//    int mid=(b+e)/2;
//    update(node*2,b,mid,l,r,val);
//    update(node*2+1,mid+1,e,l,r,val);
//    tree[node]=tree[node*2]+tree[node*2+1];
//}
//int query(ll node,ll b,ll e,ll l,ll r)
//{
//     if(b>e || b>r || e<l)return 0;
//     if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>=l && e<=r){
//        return tree[node];
//    }
//    ll mid=(b+e)/2;
//    ll p1=query(node*2,b,mid,l,r);
//    ll p2=query(node*2+1,mid+1,e,l,r);
//    return p1+p2;
//}
vector <ll> v;
int main()
{
    ll x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}


Measured memory_bytes: 256
n = int(input())

mbits = []

while abs(n) > 0:
    mbits.append(n % 2)
    n = n // 2 * (-1)

if len(mbits) == 0:
    mbits = [0]

ans = map(str, reversed(mbits))
ans = ''.join(ans)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

    int N; cin >> N;
    vel T(N); rep(i,N) cin >> T[i];

    ll ans = 1;
    rep(i,N) {
        ans = (ans  / __gcd(ans, T[i]) * T[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

r = II()
import math
print(math.pi*r*2)

Measured memory_bytes: 9048