akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;

int main()
{
    string s;
    cin>>s;
    int mx=0,cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R'){
            cnt++;
            mx=max(mx,cnt);
        }
        else cnt=0;
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3588
#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>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
int num[200010];
int C[200010];
int sum=0;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		A[i]--;
		num[A[i]]++;
	}
	REP(i,N){
		C[i]=num[i]*(num[i]-1)/2;
		sum+=C[i];
	}
	REP(i,N){
		int R=sum-C[A[i]];
		//DEB(R)END
		R+=(num[A[i]]-1)*(num[A[i]]-2)/2;
		cout<<R<<endl;
	}
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W;
    cin >> H >> W;
    VS s(H);
    rep(i, 0, H) cin >> s[i];
    rep(h, 0, H){
        rep(w, 0, W){
            if(s[h][w] == '.') continue;
            bool f = false;
            rep(i, 0, 4){
                ll nh = h + d1[i];
                ll nw = w + d2[i];
                if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
                if(s[nh][nw] == '#') f = true;
            }
            if(!f){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char S[3];
    scanf("%s",S);
    for(int i=0;i<2;i++){
        if(S[i]!=S[i+1]){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
# この回答は
# mnbvmar さんの回答を参考に実装してる
# https://atcoder.jp/contests/agc044/submissions/13537408
# 自力で解法を得たわけではない

memo = {}
INF = 10 ** 18

t = int(input())

a = 0
b = 0
c = 0
d = 0

def solve(n):
  global memo, a, b, c, d
  
  if n == 0:
    return 0
  if n in memo:
    return memo[n]
  ans = INF
  
  # ansの最大値の検証
  # n を すべて+1枚で実現できる場合、ans の初期値を変更
  if n <= (INF/d):
    ans = n * d
  
  # d の後に 2で割るケース
  for p in range(-1, 2):
    # p = dとして選択できるパターン
    x = n + p
    if x < 0 or x % 2 != 0:
      continue
    # y = d の後に2で割った値
    y = x // 2
    if y < n:
      ans = min(ans, a + (abs(p) * d) + solve(y))
  
  # d の後に 3で割るケース
  for p in range(-2, 3):
    x = n + p
    if x < 0 or x % 3 != 0:
      continue
    y = x // 3
    if y < n:
      ans = min(ans, b + (abs(p) * d) + solve(y))
  
  # d の後に 5で割るケース
  for p in range(-4, 5):
    x = n + p
    if x < 0 or x % 5 != 0:
      continue
    y = x // 5
    if y < n:
      ans = min(ans, c + (abs(p) * d) + solve(y))
  
  memo[n] = ans
  return ans
    

def test():
  # 1回分の入力受付
  global memo, a, b, c, d
  n, a, b, c, d = map(int, input().split())
  # メモ初期化
  memo = {}
  # 計算し、結果を表示
  #print(n, a, b, c, d)
  print(solve(n))

for i in range(t):
  test()

Measured memory_bytes: 82408
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int sum=0;
	int n=N;
	while (n != 0) {
		sum += n % 10;
		n /= 10;
	}
	if (N%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	C := []int64{}
	S := []int64{}
	F := []int64{}
	for i := 0; i < N-1; i++ {
		c, s, f := fsc.NextInt64(), fsc.NextInt64(), fsc.NextInt64()
		C = append(C, c)
		S = append(S, s)
		F = append(F, f)
	}
	for i := 0; i < N; i++ {
		var result int64
		result = 0
		var now int64
		now = 0
		for j := i; j < N-1; j++ {
			c := C[j]
			s := S[j]
			f := F[j]
			result += c
			if now <= s {
				result += s - now
				now = s
			} else {
				x := (now - s + (f - 1)) / f
				nxt := s + f*x
				result += nxt - now
				now = nxt
			}
			now += c
		}
		fmt.Println(result)
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  double inv = 0;
  for (int i = 0; i < n; i++) inv += 1.0 / v[i];
  printf("%9lf\n", 1 / inv);
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll N,K;
    cin >> N >>K;
    ll A[N],tmp[N];
    rep(i,N) {
        cin >> A[i];
        tmp[i]=A[i];
    }

    ll flg=0,kaisu=0,left,right,n1=0,n2=N-1,tot;

    while(flg!=N && kaisu<K){
        flg=0;
        tot=0;
        rep(i,N) tmp[i]=0;
        rep(i,N){
            left=max(n1,i-A[i]);
            right=min(n2,i+A[i]+1);
            tmp[left]++;
            if(i+A[i]+1<=n2) tmp[right]--;
        }
        rep(i,N){
            tot +=tmp[i];
            A[i]=tot;
            if(A[i]==N) flg++;
        }
        kaisu++;
    }


        rep(i,N-1){
            cout << A[i] <<" " ;
        }
        cout << A[N-1] << endl;



    return 0;


}

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

#define ll long long
#define tc                int T;cin>>T;while(T--)
int a[100000];
int main()
{
	int n, c, b ; cin >> n;
	for (int& e : a)cin >> e;
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e : {i + 1, i + 2}) {
			if (e < n)
				if ((dp[i] + abs(a[e] - a[i])) < dp[e])
					dp[e] = dp[i] + abs(a[e] - a[i]);
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll X,b[100001],l[100001],u[100001];
	scan(N>>X);
	vector<pair<pll,pll> > ULB;
	ll iniscore=0;
	rep(i,N){
		ll u,l,b;
		scan(b>>l>>u);
		ULB.push_back({{u*(X-b)+l*b,l},{b,u}});
		iniscore-=b*l;
	}
	sort(ULB.rbegin(),ULB.rend());
	ll pointsum[100001]={};
	rep(i,N) pointsum[i+1]=pointsum[i]+ULB[i].first.first;
	ll Tmin=-1,Tmax=X*N;
	while(Tmin+1<Tmax){
		ll Tmid=(Tmin+Tmax)/2;
		ll pmax=0;
		ll maxnum=Tmid/X;
		ll hanpanum=Tmid%X;
		rep(hanpa,N){
			ll allpoint=ULB[hanpa].first.first,l=ULB[hanpa].first.second,b=ULB[hanpa].second.first,u=ULB[hanpa].second.second;
			ll hanpapoint=l*min(hanpanum,b)+max((hanpanum-b)*u,0LL);
			ll p;
			if(hanpa<maxnum){
				p=pointsum[maxnum+1]-allpoint+hanpapoint;
			}
			else{
				p=pointsum[maxnum]+hanpapoint;
			}
			pmax=max(pmax,p);
		}
		//printf("T:%lld maxnum:%lld hanpanum:%lld iniscore:%lld pmax:%lld score:%lld\n",Tmid,maxnum,hanpanum,iniscore,pmax,iniscore+pmax);
		if(iniscore+pmax>=0){
			Tmax=Tmid;
		}
		else{
			Tmin=Tmid;
		}
	}
	prin(Tmax);
	return 0;
}


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

int main(void)
{
	int city[51];
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=50;i++)
		city[i]=0;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		city[a]++;
		city[b]++;
	}
	
	for(int i=1;i<=n;i++)
		cout<<city[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
def solve(n, k, q, a)
  t = [q, a].min
  if n == t * t
    @ans += 1
    t -= 1
  end
  return if k == 1
  t.downto(t/k) do |x|
    solve(n - x * x, k - 1, Math.sqrt(n - x * x).to_i, x)
  end
end

while n = gets.to_i
  break if n == 0
  @ans = 0
  solve(n, 4, Math.sqrt(n).to_i, n)
  puts @ans
end

Measured memory_bytes: 8672
# 086A

# 2つの正整数a,b：標準入力
# スペース区切りの入力を整数として受け取る例
# split関数 → 文字列から指定した規則に従って切り分けを行う
a, b = map(int, input().split())

# a＊bで割った余りをif-elseで条件分布

num = (a * b) % 2

if num == 0:
    print('Even')
else:
    print('Odd')

Measured memory_bytes: 9156
#include <iostream> // cout, endl, cin
#include <vector> // vector
using namespace std;

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

	int m = n % 1000;
	if (m == 0) {
		cout << 0 << endl;
	}
	
	else{
		cout << 1000-m << endl;
	}
}


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

int	main()
{
	int	N;
	cin >> N;
	int	A;
	vector<int>	tail_vec(N, -1);
	auto	comp = greater<int>();
	for (int i = 0; i < N; ++i) {
		cin >> A;
		*upper_bound(tail_vec.begin(), tail_vec.end(), A, comp) = A;
	}
	auto	end = lower_bound(tail_vec.begin(), tail_vec.end(), -1, comp);
	cout << end - tail_vec.begin() << endl;
}


Measured memory_bytes: 768
import java.util.*;

class Main{
 public static void main(String[] args){
  Scanner s = new Scanner(System.in);

 int []a = new int[10];
 for(int i=0; i<a.length; i++){
  a[i] = s.nextInt();
}
 Arrays.sort(a);
 for(int i=9; i>6; i--){
  System.out.println(a[i]);
}
}
}

Measured memory_bytes: 17172
def main():
    from math import gcd
    from itertools import product
    k = int(input())
    l = range(1,k+1)
    ans = k*(k+1)//2
    for i,j,k in product(l,l,l):
        if i==j==k:
            continue
        else:
            g = gcd(i,j)
            g = gcd(g,k)
            ans += g

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 67708
while True:
    n=int(input())
    if n==0:break

    a=[0]*10
    
    for i in range(n):
        b=int(input())
        a[b]+=1
    for i in range(10):
        if a[i]==0:
            print("-")
        else:
            print("*"*a[i])



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

int main() {
  string A;
  cin >> A;
  int ans=0;
  for(int i=0;i<4;i++){
  if(A[i]=='+'){
    ans++;
  }
  else{
    ans--;
  }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++) cout << "x";
    cout << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> A(n);
	rep(i, n) cin >> A[i];
	sort(A.begin(), A.end());
	cout << A[n - 1] - A[0] << endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i

Q = gets.to_s
arry = Q.split('')

if N % 2 == 1
	puts "No"
else
	arry1 = arry[0 ... (N/2)]
    arry2 = arry[N/2 ... -1]
	  if  arry1 == arry2
	  	puts 'Yes'
	  else
	  	puts 'No'
	  end
end

Measured memory_bytes: 1788
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 2019;
int add(int a, int b)
{
    a+=b;
    while(a>=MOD) a-=MOD;
    return a;
}
void radd(int &a, int b)
{
    a=add(a,b); 
}
int mult(int a, int b)
{
    return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
    a=mult(a,b);
}
int modpow(int a, int b)
{
    int r=1;
    while(b)
    {
        if(b&1) r=mult(r,a);
        a=mult(a,a);
        b>>=1;
    }
    return r;
}
int choose(int a, int b)
{
    if(a<0||b<0) return 0;
    if(a<b) return 0;
    if(b==0) return 1;
    if(a==b) return 1;
    return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
    return modpow(a,MOD-2);
}
void init(int _n)
{
    fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
    fact.resize(_n+1);
    ifact.resize(_n+1);
    inv.resize(_n+1);
    pow2.resize(_n+1);
    pow2[0]=1;
    ifact[0]=1;
    fact[0]=1;
    for(int i=1;i<=_n;i++)
    {
        pow2[i]=add(pow2[i-1],pow2[i-1]);
        fact[i]=mult(fact[i-1],i);
        //ifact[i]=mult(ifact[i-1],inv[i]);
    }
    ifact[_n] = inverse(fact[_n]);
    for(int i=_n-1;i>=1;i--)
    {
        ifact[i] = mult(ifact[i + 1], i + 1);
    }
    for(int i=1;i<=_n;i++)
    {
        inv[i] = mult(fact[i-1],ifact[i]);
    }
}


void solve(){
    string s ;
    cin >> s ;
    int n = sz(s) ;
    map<int,vi> mp ;
    mp[0].push_back(-1) ;
    reverse(all(s)) ;
    int rem = 0 ;
    for(int i = 0 ; i < n ; i++){
        int cur = add(mult(s[i]-'0', modpow(10, i)),rem) ;
        rem = cur ;
        mp[cur].pb(i) ;
    }
    int ans = 0 ;
    for(int i = 0 ; i <= 2019 ; i++){
        ans += sz(mp[i])*(sz(mp[i])-1)/2 ;
    }
    cout << ans ;
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


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

int main(){
  char c;
  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

#define long long long int
using namespace std;

// @author: pashka

vector<vector<int>> g;
vector<int> a;
vector<int> dp;
vector<int> ans;
int cur = 0;

void dfs(int x, int p) {
    int l = -1;
    int r = dp.size();
    while (r > l + 1) {
        int m = (l + r) / 2;
        if (dp[m] < a[x]) {
            l = m;
        } else {
            r = m;
        }
    }
    int cur_ = cur;
    cur = max(cur, r);    
    int save = dp[r];
    dp[r] = min(dp[r], a[x]);
    ans[x] = cur;
    for (int y : g[x]) {
        if (y == p) continue;
        dfs(y, x);
    }
    dp[r] = save;
    cur = cur_;
}


int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    a.resize(n);
    g.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dp.resize(n + 1, INT_MAX);
    dp[0] = INT_MIN;
    ans.resize(n);    
    dfs(0, -1);
    for (int i = 0; i < n; i++) cout << ans[i] << " ";

    return 0;
}

Measured memory_bytes: 30876
#include<iostream> 
using namespace std; 
  
int main ()
{
 int x,z,a,b;
  cin>>x;
  z=x*800;
  if (x>15){
    a=x/15;
  b=z-(a*200);
    cout<<b;}
  else
  { cout<<z;}
    return 0;
}

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

#define ff first
#define ss second
#define pb push_back

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

const int N = 200006;

int main() {
	int n;
	ll v[N];
	scanf("%d", &n);
	ll sum = 0;
	for(int i = 0; i < n; i++){
		scanf("%lld", v+i);
		sum += v[i];
	}
	ll lef = 0, rig = sum;
	ll ans = sum;
	for(int i = 0; i < n; i++){
		lef += v[i];
		rig -= v[i];
		ll dif = abs(rig - lef);
		ans = min(ans, dif);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<complex>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second



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

	if(!(a > 8 || b > 8)) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();
        if(D == 0){
            if(N == 100){
                System.out.println(101);
            }else{
                System.out.println(N);
            }
        }
        if(D == 1){
            if(N == 100){
                System.out.println(10100);
            }else{
            System.out.println(N * 100);
            }
        }
        if(D == 2){
            if(N == 100){
                System.out.println(1010000);
            }else{
            System.out.println(N * 10000);
            }
        }
    }
}
    

Measured memory_bytes: 35540
import java.io.*;
import java.util.*;


public class Main
{

	
	
	

	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);

	static int inf=(int)2e9;



	static class node1
		{
			int data,weight;
			node1 link=null;
			node1(int d,int w)
			{
				data=d;weight=w;
			}
		}
		static class linkl
		{
			node1 front=null,end=null;
		
			void inst(int d,int w)
			{
				node1 newnode=new node1(d,w);
				if(front==null){front=newnode;end=newnode;}
				else
				{
					end.link=newnode;end=newnode;
				}
			}
		}
		static class node_4graph
		{
			linkl l;
			node_4graph()
			{
				l=new linkl();
			}
		}
		static class graph
		{
			node_4graph[] arr;int[] vis,col;
	
			graph(int n)
			{
				arr=new node_4graph[n];
				vis=new int[n];
				col=new int[n];

				for(int i=0;i<n;i++)
				{
					node_4graph lw=new node_4graph();
					arr[i]=lw;
				}
			}
			void insert(int x,int y,int w)
			{
				arr[x].l.inst(y,w);
				arr[y].l.inst(x,w);
			}
			void BFS()
			{
	
				for(int i=1;i<arr.length;i++)
				{
					if(vis[i]==0)
					{
						Queue<Integer> q=new LinkedList<Integer>();
	
						q.add(i);
						
						vis[i]=1;
						col[i]=1;
	
						while(q.size()!=0)
						{
							int u=q.poll();
							node1 temp=arr[u].l.front;
							while(temp!=null)
							{
								if(vis[temp.data]==0)
								{
									vis[temp.data]=1;
									q.add(temp.data);

									if(temp.weight%2==0) col[temp.data]=col[u];
									else if(col[u]==0) col[temp.data]=1;
									else col[temp.data]=0;
								}
								temp=temp.link;
							}
						}
						
					}
				}
				
			}
		
		}




	
	public static void main(String[] args)throws IOException{
		
			
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

			int n=Integer.parseInt(br.readLine());
			String[] s;

			graph gr=new graph(n);


			for(int i=0;i<n-1;i++)
			{
				s=br.readLine().split(" ");
				int fd=Integer.parseInt(s[0])-1;
				int df=Integer.parseInt(s[1])-1;
				gr.insert(fd,df,Integer.parseInt(s[2]));
					
			}

			gr.BFS();

						
			for(int i=0;i<n;i++) out.println(gr.col[i]);
			
			
			out.close();

	}
}

Measured memory_bytes: 69316
#include<stdio.h>
#define LEN 4

int main(void)
{
	int n;
	int arr[LEN];
	int a, b, c, d;
	int i;
	
	scanf("%d", &n);
	for(i=0;i<=3;i++){
		arr[i] = n % 10;
		n = n / 10;
	}
	d = arr[0];
	c = arr[1];
	b = arr[2];
	a = arr[3];
	
	if(a+b+c+d==7){
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	}else if(a+b+c-d==7){
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}else if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	}else if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	}else if(a-b+c+d==7){
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	}else if(a-b+c-d==7){
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	}else if(a-b-c+d==7){
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	}else if(a-b-c-d==7){
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
	}
	return 0;
}

Measured memory_bytes: 128
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
  S=input()
  if S=='AC':
    ac+=1
  if S=='WA':
    wa+=1
  if S=='TLE':
    tle+=1
  if S=='RE':
    re+=1


print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(ac,wa,tle,re))

Measured memory_bytes: 9056
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int a, k;
	cin >> a >> k;
	int n = 1;
	for (int i = 0; i < a; i++)
	{
		if (n * 2 <= n + k)
		{
			n *= 2;
		} 
		else
		{
			n += k;
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){

    int N;
    int temp;
    vector<int> W;

    int T_p=0;
    int T_b=0;
    int diff=0;

    cin >> N;

    for(int i=0;i<N;i++){
        cin>>temp;
        T_b +=temp;
        W.push_back(temp);
    }

    diff = abs(T_b-T_p);

    for(int i=0;i<W.size();i++){
        T_p += W[i];
        T_b -= W[i];
        if(diff<abs(T_b-T_p)){
            break;
        }else{
            diff=abs(T_b-T_p);
        }
    }
        
        cout<<diff<<endl;

    



}

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

#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define all(v) v.begin(),v.end()

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

    ll t=1,tc;
    //cin>>t;
    for(tc=1;tc<=t;tc++){
      ll x;
      cin>>x;
      if(x>=30)cout<<"Yes";
      else cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3648
import Data.List
 
main = do
  n <- fmap read getLine
  s <- getLine
  print $ maximum [let (s1, s2) = splitAt (i-1) s in (let tmp = (let alph = sort.nub in alph s1 ++ alph s2) in length tmp - length (nub tmp)) | i <- [2..n]]

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll a = 0, b = 0;
  REP(i, n){
    if(s[i] == 'R') a++;
  }
  ll ans = max(a, b);
  REP(i, n){
    if(s[i] == 'R') --a;
    else b++;
    ll now = max(a, b);
    chmin(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int n,k;
signed main(){
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  vector<int> sum(n+1,0);
  rep1(i,n){
      sum[i]=sum[i-1]+a[i-1];
  }
  vector<int> sub;
  rep(i,n){
      rep1(j,n){
          if(i>=j)continue;
          sub.push_back(sum[j]-sum[i]);
      }
  }
  int res=0;
  for(int i=60;i>=0;--i){
      int cnt=0;
      vector<int> buf;
      rep(j,sub.size()){
          if(sub[j]&(1ull<<i)){
              ++cnt;
              buf.push_back(sub[j]);
          }
      }
      if(cnt>=k){
          sub=buf;
          res|=(1ull<<i);
      }
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 6388
import java.util.Scanner;
 
public class Main {
  public static void main ( String[] args ) {

    Scanner sc = new Scanner ( System.in ); 

    int A = sc.nextInt();
    int B = sc.nextInt(); 
    int C = sc.nextInt(); 
	int Z = 0;
		
		if (A-B >= C ) {
			Z = 0;
		} else {
			Z = C - (A-B);
		}
      
		System.out.println(Z);
    
  }
}

Measured memory_bytes: 26688
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve_it0(n, a, b, c, d):
    p = [[0]]
    for i in range(1, n):
        q = set()
        for x in p[-1]:
            for k in range(c, d + 1):
                q.add(x - k)
                q.add(x + k)
        p.append(sorted(q))
    for l in p:
        print(l)
    if b - a in p[-1]:
        return 'YES'
    return 'NO'


def solve_it1(n, a, b, c, d):
    x = b - a
    for i in range(n + 1):
        left = - i * d + (n - 1 - i) * c
        right = - i * c + (n - 1 - i) * d
        if left <= x <= right:
            return 'YES'
    return 'NO'


def solve():
    n, a, b, c, d = read_int_list()
    res1 = solve_it1(n, a, b, c, d)
    # res0 = solve_it0(n, a, b, c, d)
    # assert res0 == res1
    return res1


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;



int main()
{
	int n,p;
	si(n);
	int curr=0;
	vi v;
	rep(i,1,n+1)
	{
		si(p);
		if(p==i)
			curr++;
		else
		{
			v.pb(curr);
			curr=0;
		}
	}
	v.pb(curr);
	int ans=0;
	rep(i,0,v.size())
		ans+=(v[i]+1)/2;
	pr(ans);
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
int main(){
    int d[100],n,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    for(int j=0;j<n-1;j++){
        for(int k=j+1;k<n;k++){
            sum+=d[j]*d[k];
        }
    }
    printf("%d\n",sum);
    return 0;
}


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

int main(void){
	double q;

	while(cin>>q && q!=-1){
		double x = q / 2;

		while( fabs(pow(x,3) - q) >= 0.00001 * q ){
			x = x - (pow(x,3) - q) / (3 * pow(x,2));
		}

		printf("%.6lf\n",x);
	}

	return 0;
}

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

using namespace std;
const int N = 2e5 + 3;
pair<int, int> p[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d %d", &p[i].second, &p[i].first);
	sort(p, p + n);
	int cur = 0;
	for (int i = 0; i < n; ++i) {
		if (cur + p[i].second <= p[i].first) {
			cur += p[i].second;
		} else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define m 1000000007
long long int dp[110000];
int main() {
	int n;
	cin>>n;
	int a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<=n;i++)
	dp[i]=m;
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		if(i+1<n)dp[i+1]=min(dp[i+1],abs(a[i]-a[i+1])+dp[i]);
		if(i+2<n)dp[i+2]=min(dp[i+2],abs(a[i]-a[i+2])+dp[i]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4772
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

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

	bool flg = false;

	int a = N;
	int keta = 0;
	int last = 0;
	while (true)
	{
		if (a < 10)
		{
			last = a;
			break;
		}

		int b = a % 10;
		if (b != 9)
		{
			flg = true;
		}

		keta++;
		a /= 10;
	}

	int ans = 0;
	if (flg)
	{
		ans = keta * 9;
		ans += (last - 1);
	}
	else
	{
		ans = keta * 9;
		ans += last;
	}
	cout << ans << endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmax(a,b) (a = max(a,b))
using namespace std;
typedef vector<int> vi;

const string dir = "URDL";
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int Hini, Hmax;
  while(cin >> Hini >> Hmax, Hini){
    int h,w;
    cin >> h >> w;
    vector<string> g(h);
    rep(i,h)cin >> g[i];

    int cost[26] = {}, t;
    cin >> t;
    rep(i,t){
      char c; int d;
      cin >> c >> d;
      cost[c-'A'] = d;
    }

    vi trap(1,0);
    int s, x=0, y=0;
    cin >> s;
    rep(i,s){
      char c; int n;
      cin >> c >> n;
      int d = dir.find(c);
      rep(k,n){
	x += dx[d]; y += dy[d];
	trap.push_back(cost[ g[y][x]-'A' ]);
      }
    }

    int p;
    cin >> p;
    vi potion(p);
    rep(i,p)cin >> potion[i];

    vector<vi> dp(trap.size()+1, vi(1<<p,0));
    dp[0][0] = Hini;

    rep(i,trap.size()){
      rep(bit,1<<p){
	int cur = dp[i][bit];
	if(cur==0)continue;

	chmax(dp[i+1][bit], cur-trap[i]);
	rep(j,p){
	  if( (bit>>j)&1 )continue;
	  int nxt = min(cur+potion[j], Hmax);
	  chmax(dp[i+1][bit | (1<<j)], nxt - trap[i]);
	}
      }
    }
    
    bool f = false;
    rep(bit,1<<p)f |= (dp[trap.size()][bit]>0);
    cout << (f?"YES":"NO") << endl;
  }
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A >= B) cout << "delicious" << endl;
  else if(B - A <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

int n, m, Q, p, q, l, r, x[510][510], s[510][510];

int main(){
	cin >> n >> m >> Q;
	memset(x, 0, sizeof(x));
	memset(s, 0, sizeof(s));
	for (int i = 0; i < m; ++i){
		cin >> l >> r;
		x[l][r]++;
	}
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + x[i+1][j+1];
		}
	}
	
	for (int i = 0; i < Q; ++i){
		cin >> p >> q;
		printf("%d\n", s[q][q] - s[p-1][q] - s[q][p-1] + s[p-1][p-1]);
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

int main() {
	int N;
	cin >> N;
	
	string X;
	cin >> X;
	reverse(ALL(X));
	
	vector<int> dp(N + 100);
	dp[0] = 0;
	FOR(i, 1, N + 10) {
		int p = 0;
		REP(j, 30) if (i >> j & 1) ++p;
		dp[i] = dp[i % p] + 1;
	}
	
	
	int bp = 0;
	REP(i, N) if (X[i] == '1') ++bp;
	
	int base[3] {}; // -1, 0, 1
	REP(i, 3) {
		int bias = i - 1;
		// bias >= 0
		if (bp + bias == 0) continue;
		// bp + bias 個で割る
		REP(j, N) if (X[j] == '1') {
			base[i] += mod_pow(2, j, bp + bias);
			base[i] %= bp + bias;
		}
	}
	
	reverse(ALL(X));
	REP(i, N) {
		int bias = X[i] == '1' ? -1 : 1;
		
		if (bp + bias == 0) {
			puts("0");
			continue;
		}
		int ch = mod_pow(2, N - 1 - i, bp + bias);
		if (X[i] == '1') ch = (-ch + bp + bias) % (bp + bias);
		int nem = (ch + base[bias == -1 ? 0 : 2]) % (bp + bias);
		printf("%d\n", dp[nem] + 1);
	}
	
	return 0;
}


Measured memory_bytes: 4456
#include <stdio.h>
#include <iostream>
using namespace std;

class ChessBoard {
private:
	char chess_board[8][8];
public:
	ChessBoard();
	void putQueen(int row, int col);
	void removeQueen(int row, int col);
	bool put8Queen(int col);
	bool isPut(int col);
	bool canPut(int row, int col);
	void disp();
};

ChessBoard::ChessBoard()
{
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			chess_board[i][j] = '.';
		}
	}
}

void ChessBoard::putQueen(int row, int col)
{
	chess_board[row][col] = 'Q';
}

void ChessBoard::removeQueen(int row, int col)
{
	chess_board[row][col] = '.';
}

bool ChessBoard::put8Queen(int col)
{
	if (col >= 8) return true;
	for (int i = 0; i < 8; i++) {
		if (isPut(col)) {
			if (put8Queen(col + 1)) return true;
		}		
		else if (canPut(i, col)) {
			putQueen(i, col);
			if (put8Queen(col + 1)) return true;
			removeQueen(i, col);
		}
	}
	return false;
}

bool ChessBoard::isPut(int col)
{
	for (int i = 0; i < 8; i++) {
		if (chess_board[i][col] == 'Q') return true;
	}
	return false;
}

bool ChessBoard::canPut(int row, int col)
{
	int i, j;
	for (i = 0; i < 8; i++) {
		if (chess_board[i][col] == 'Q') return false;
	}

	for (j = 0; j < 8; j++) {
		if (chess_board[row][j] == 'Q') return false;
	}

	i = row; j = col;
	while (i < 8 && j < 8) {
		if (chess_board[i][j] == 'Q') return false;
		i++;
		j++;
	}
	i = row; j = col;
	while (i >= 0 && j >= 0) {
		if (chess_board[i][j] == 'Q') return false;
		i--;
		j--;
	}
	
	i = row; j = col;
	while (i < 8 && j >= 0) {
		if (chess_board[i][j] == 'Q') return false;
		i++;
		j--;
	}
	i = row; j = col;
	while (i >= 0 && j < 8) {
		if (chess_board[i][j] == 'Q') return false;
		i--;
		j++;
	}
	
	return true;
}

void ChessBoard::disp()
{
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cout << chess_board[i][j];
		}
		cout << endl;
	}
}

int main(void)
{
	int k;
	cin >> k;
	
	ChessBoard cb;

	for (int i = 0; i < k; i++) {
		int r, c;
		cin >> r >> c;
		cb.putQueen(r, c);
	}

	cb.put8Queen(0);
	cb.disp();
	
	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
bool chmin(ll&a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll&a,ll b){if(a<b){a=b;return true;}return false;}
#define debg cout<<"debg"<<endl
void printVec(const vector<ll>&a){
  for(auto elm:a)cout<<elm<<" ";
  cout<<endl;
}
signed main(){
  
  string s;
  cin>>s;
  ll n=(ll)s.size();
  string w,b;
  rep(i,n){
    if(i&1){w+='0';b+='1';}
    else {w+='1';b+='0';}
  }
  ll x=0,y=0;
  rep(i,n){
    if(s[i]!=w[i])x++;
    if(s[i]!=b[i])y++;
  }
  cout<<(min(x,y))<<endl;

  return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int ans = -1;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        ans = a * b;
    }
    printf("%d\n", ans);
    return 0;
}



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

int main() {
    int n, cnt=0;
    cin>>n;

    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    for(int i=n-1;i>0;i--){
        if(h.at(i)>=h.at(i-1))cnt++;
        else if(h.at(i-1)-h.at(i)==1){
            cnt++;
            h.at(i-1)--;
        }
    }
    if(cnt==n-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int mygetchar()
{
#ifdef WIN32
	return _getchar_nolock();
#else
	return getchar_unlocked();
#endif
}
inline int read()
{
	int x = 0, f = 1;
	char c = mygetchar();
	while (!isdigit(c))
	{
		if (c == '-') f = -1;
		c = mygetchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = mygetchar();
	}
	return x * f;
}

const int MOD = 998244353;
inline void add(int &x, int y) {x += y; if (x >= MOD) x -= MOD;}
inline int inc(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int mul(int x, int y) {return (ll)x * y % MOD;}
inline int qpow(int x, int y)
{
	int res = 1;
	for (; y; y >>= 1, x = mul(x, x))
		if (y & 1) res = mul(res, x);
	return res;
}

const int MAXN = 6005;
int n, X, c[MAXN][MAXN], ans = 0;

inline int Solve(int len)
{
	int res = 0;
	if (len * 2 < X || X & 1) res = 1;
	for (int i = 0; i < len; i ++)
	{
		if (len + i < X)
			add(res, c[len][i]);
		else if ((len + i - X) & 1)
		{
			int S = len + i, l = (S - X + 1) / 2;
			if (len > l + l && i >= l + l) add(res, c[len - l - l][i - l - l]);
		}
	}
	return res;
}
int main()
{
	n = read(), X = read();
	for (int i = 0; i <= n * 2; i ++) c[i][0] = 1;
	for (int i = 1; i <= n * 2; i ++)
		for (int j = 1; j <= i; j ++)
			c[i][j] = inc(c[i - 1][j], c[i - 1][j - 1]);
	for (int i = 0; i <= n; i ++)
		add(ans, mul(c[n][i], Solve(n - i)));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 139392
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  int red, blue;
  red = count(s.begin(), s.end(), '0');
  blue = count(s.begin(), s.end(), '1');
  cout << min(red, blue) * 2 << endl;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;
inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')
	    f=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*f;
}
const int MAXN=1e5+5;
int n,m,fa[MAXN];
struct EDGE {
	int u,v;
}e[MAXN];
ll ans[MAXN],sz[MAXN];
int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	n=read();
	m=read();
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	for(int i=1;i<=n;++i)fa[i]=i,sz[i]=1;
	ans[m]=(ll)n*(n-1)/2;
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) ans[i-1]=ans[i];
		else{
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	for(int i=1;i<=m;++i)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int main()
{
   int n, i, v, j, k;
   int a[1000];

   scanf("%d", &n);
   
   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }

   for(i = 0; i < n; i++){
      printf("%d", a[i]);

      if(i != n-1){
         printf(" ");
      } else if(i == n-1){
         printf("\n");
      }
   }

   for(i = 1; i <= n-1; i++) {
      v = a[i];
      j = i - 1;
 
      while(j >= 0 && a[j] > v){
         a[j+1] = a[j];
         j--;
         a[j+1] = v;
      }

      for(k = 0; k < n; k++){
         printf("%d", a[k]);

         if(k != n-1){
            printf(" ");
         } else if(k == n-1){
            printf("\n");
         }
      }
   }

return 0;

}
 





Measured memory_bytes: 1916
N, M = map(int, input().split())
L = [[i] + list(map(int, input().split()))+[0] for i in range(M)]
L.sort(key=lambda x: (x[1], x[2]))
c = 1
d = 0
for i in range(M):
    if d == L[i][1]:
        c += 1
        L[i][3] = c
    else:
        L[i][3] = 1
        c = 1
        d = L[i][1]
L.sort()
[print(str(L[i][1]).zfill(6) + str(L[i][3]).zfill(6)) for i in range(M)]


Measured memory_bytes: 40448
#abc163  Sum of Large Numbers
n, k = map(int, input().split())
def Funmy(a, N):
    return (8+3*a*N + 3*N -2*a*a)*a/6

total =Funmy(n+1,n) -Funmy(k-1,n)
m = 7 + 10**9
output = (total)%m
print(int(output))

Measured memory_bytes: 9192
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
    double x1,y1,x2,y2;
    double x,y;
    cin>>x1>>y1>>x2>>y2;
    x=pow(x2-x1,2);
    y=pow(y2-y1,2);
    
    cout<<fixed<<setprecision(6)<<sqrt(x+y)<<endl;
    
    return 0;
}



Measured memory_bytes: 3288