akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define ll long long 
using namespace std;
const int MAXN=2010;
const ll mod=998244353;
ll f[MAXN][MAXN],s[MAXN][MAXN],s1[MAXN][MAXN],f1[MAXN][MAXN];
int n,k;
void init(int k,int n)
{
	for (int i=1;i<=k;i++) f[1][i]=2,s[1][i]=s[1][i-1]+2;
	for (int i=2;i<=n;i++)
	{
	for (int j=1;j<=k;j++)
	 f[i][j]=(f[i-1][j]+s[i-1][j-1]*2)%mod;
	for (int j=1;j<=k;j++) s[i][j]=(s[i][j-1]+f[i][j])%mod;
    }  
    for (int i=1;i<=k;i++) f1[1][i]=1,s1[1][i]=s1[1][i-1]+1;
    for (int i=2;i<=n;i++)
     {
     	for (int j=1;j<=k;j++)
     	 f1[i][j]=s1[i-1][j];
     	for (int j=1;j<=k;j++) s1[i][j]=(s1[i][j-1]+f1[i][j])%mod; 
	 }
} 

int main()
{
	scanf("%d%d",&k,&n);
	init(k,n);
	for (int i=2;i<=k*2;i++)
	{
		ll ans=0;
		int t=0,sum=0;
		if (i&1) t=i/2; else t=i/2-1;
		if (i>k) {
			t-=(i-1-k);
		}
	    if (i%2==0) sum=k-1-t*2; else sum=k-t*2;
		for (int j=0;j<=k;j++) s[0][j]=1,s1[0][j]=1;
		for (int j=0;j<=n;j++)
		 ans=(ans+s[j][t]*s1[n-j][sum]%mod)%mod;
		if (i%2==0)
		{
			for (int j=0;j<n;j++)
			 ans=(ans+s[j][t]*s1[n-j-1][sum]%mod)%mod;
		 } 
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 126336
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (s, w) = get_tuple!(usize, usize);
    if w >= s {
        println!("unsafe")
    } else {
        println!("safe")
    }
}


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

using namespace std;


int main(){
  int a,b,m;
  cin>>a>>b>>m;
  int p1[a],p2[b];
  int min1=INT_MAX;
  int min2=INT_MAX;
  for(int i=0;i<a;i++){
      cin>>p1[i];
      min1= min(min1,p1[i]);
  }
  for(int i=0;i<b;i++){
      cin>>p2[i];
      min2=min(min2,p2[i]);
  }
  int minc= min1+min2;
  int x,y,z;
  int lc;
  for(int i=0;i<m;i++){
      cin>>x>>y>>z;
      lc= p1[x-1]+p2[y-1]-z;
      minc=min(minc,lc);
  }
  cout<<minc;
  
  
  return 0;
}
 

Measured memory_bytes: 1024
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int h, n;
	cin >> h >> n;
	v32 arr(n, 0);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = 0; i < n; i++)
		h -= arr[i];
	if (h <= 0)
		cout << "Yes" << ln;
	else
		cout << "No" << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val a = nextInt()
    println(n*n-a)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 29784
n = int(input())
a = list(map(int, input().split()))
m = max(a)
y = [0] * (m + 1)
for i in a:
    x = i
    while x <= m:
        y[x] += 1
        x += i
ans = 0
for j in a:
    if y[j] == 1:
        ans += 1

print(ans)

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

int main()
{
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> C;
	if( C == 'A' )
		cout << 'T' << endl;
	else if( C == 'G' )
		cout << 'C' << endl;
	else if( C == 'C' )
		cout << 'G' << endl;
	else if( C == 'T' )
		cout << 'A' << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<int, int> mp;
    int n; cin >> n;
    rep(i, n) {
        int a; cin >> a;
        mp[a]++;
    }
    int aa = -1, bb  =-1;
    for (auto e : mp) {
        if (e.second >= 4) {
            aa = e.first;
            bb = e.first;
        } else if (e.second >= 2) {
            bb = aa;
            aa = e.first;
        }
    }
    if (aa == -1 || bb == -1) {cout << 0 << endl; return 0;}
    cout << (ll)aa * bb << endl;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);


using ll = long long;
using namespace std;
using ld = long double;

ll gcd(ll x,ll y)
{
    ll t;
    while (x%y!=0)
    {
        t=y;
        y=x%y;
        x=t;
    }
    return y;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    ll a,b;
    cin >> a >> b;
    ll g = gcd(a,b);
    int ans=1;
    for(ll i=2; i*i<=g && g!=1; ++i)
        if (g%i==0)
    {
        ans++;
        while (g%i==0) g/=i;
    }
    if (g>1) ans++;
    cout << ans;
    return 0;
}



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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n+1);
    for (auto& x: a) {
        cin >> x;
    }
    long long res = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        int y = min(x, a[i]);
        res += y, x -= y, a[i] -= y;
        y = min(x, a[i+1]);
        res += y, x -= y, a[i+1] -= y;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());
    for (int i = 0; i < Y; i++) cin >> B[i];
    sort(B.begin(), B.end(), greater<long long>());
    for (int i = 0; i < Z; i++) cin >> C[i];
    sort(C.begin(), C.end(), greater<long long>());

    vector<long long> v;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            for (int k = 0; k < Z; k++) {
                if ((i + 1) * (j + 1) * (k + 1) <= K) 
                    v.push_back(A[i] + B[j] + C[k]);
                else
                    break;
            }
        }
    }
    sort(v.begin(), v.end(), greater<long long>());
    for (int i = 0; i < K; i++)
        cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 1532
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll d[256];

bool bellman_ford(int n, vector<edge>& E, int s, ll d[]) {
	fill(d, d + n, LLONG_MAX); d[s] = 0;
	for (int i = 0; i < n; i++) {
		bool updated = false;
		for (int j = 0; j < E.size(); j++) {
			edge e = E[j];
			if (d[e.u] < LLONG_MAX && d[e.v] > d[e.u] + e.w) {
				d[e.v] = d[e.u] + e.w;
				updated = true;
			}
		}
		if (!updated) return true;
	}
	return false;
}

string check(int N, string s) {
	vector<edge> E;
	for (int u = 0; u < N; u++) {
		E.push_back(edge{u, N + u, 0});
		E.push_back(edge{N + u, u, 1});
		int v;
		v = u * 2 % N;
		E.push_back(edge{N + u, v, 0});
		E.push_back(edge{v, N + u, 0});
		v = (u * 2 + 1) % N;
		E.push_back(edge{N + u, v, 1});
		E.push_back(edge{v, N + u, -1});
	}
	for (int u = 0; u < N; u++) {
		if (s[u] == '0')
			E.push_back(edge{N + u, u, 0});
		if (s[u] == '1')
			E.push_back(edge{u, N + u, -1});
	}
	if (!bellman_ford(N * 2, E, 0, d)) return "";
	string t(N, ' ');
	for (int u = 0; u < N; u++)
		if (d[u] == d[N + u]) t[u] = '0';
		else t[u] = '1';
	return t;
}

int main() {
	int w; cin >> w;
	string s; cin >> s;
	int N = s.length();
	string t = check(N, s);
	if (t != "") {
		cout << t << endl;
		return 0;
	}
	for (int i = N - 1; i >= 0; i--) {
		if (s[i] == '0') {
			s[i] = '1';
			string t = check(N, s);
			if (t != "") {
				cout << t << endl;
				return 0;
			}
		}
		s[i] = '?';
	}
	cout << "no" << endl;
}

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

int main() {
  int a,b,c;
  long long x,y;
  long long price = 0;
  
  cin >> a >> b >> c >> x >> y;
  
  if(a + b > c * 2){
    // C2枚の方が安い
    if(x <= y){
      price += c * x * 2;
      if(b <= c * 2) price += (y - x) * b;	// b1枚買ったほうが安い
      else price += (y - x) * c * 2;		// c2枚買ったほうが安い
    }else{
      price = c * y * 2;
      if(a <= c * 2) price += (x - y) * a;	// b1枚買ったほうが安い
      else price += (x - y) * c * 2;		// c2枚買ったほうが安い
    }
  }else{
    // A,Bそれぞれ買ったほうが安い
      price += a * x;
      price += b * y;
  }
  
  cout << price;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

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

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

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/

int main()
{
	ll i,j,k,a,b,ans=0;
	char c;
	ll N,M,T;

	ll done[100010] = {0};
	vector<ll> mp[100010];
	map<ll, ll> ways;
	ll anss[100010] = {0};
	cin >> N;
	for(i=0;i<N-1;++i)
	{
		cin >> j >> k;
		mp[j-1].push_back(k-1);
		mp[k-1].push_back(j-1);
		ways[((j-1)<<16|(k-1))] = i;
	}
	ll ans_c = 0;
	for(i=0;i<N;++i)
	{
		if(ans_c<mp[i].size())
		{
			ans_c=mp[i].size();
		}
	}
	queue<pair<ll,ll> > q;
	q.push(make_pair(0, -1));
	while(!q.empty())
	{
		ll nx = q.front().first;
		ll bc = q.front().second;
		q.pop();
		done[nx] = 1;
		ll use = 1;
		for(i = 0; i < mp[nx].size(); ++i)
		{
			if(use == bc)
				use++;
			ll nnx = mp[nx][i];
			if(done[nnx])
				continue;
			q.push(make_pair(nnx, use));
			anss[ways[MIN(nx,nnx)<<16|MAX(nx,nnx)]] = use;
			use ++;
		}
	}
	cout << ans_c << endl;
	for(i=0;i<N-1;++i)
	{
		cout << anss[i] << endl;
	}
	return 0;
}




















Measured memory_bytes: 14592
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b
ans = 100000000
n = int(input())
stones = input()
black = 0
white = 0
for c in stones:
    if c == ".":
        white += 1
ans = white
for c in stones:
    if c == ".":
        white -= 1
    else:
        black += 1
    tmp = black + white
    if ans > tmp:
        ans = tmp

print(ans)

"""
10 
....##....#########.

"""

Measured memory_bytes: 3500
/*  `-._:  .:'   `:::  .:\           |\__/|           /::  .:'   `:::  .:.-'
        \      :          \          |:   |          /         :       /    
         \     ::    .     `-_______/ ::   \_______-'   .      ::   . /      
          |  :   :: ::'  :   :: ::'  :   :: ::'      :: ::'  :   :: :|       
          |     ;::         ;::         ;::         ;::         ;::  |       
          |  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:|       
          /     :           :           :           :           :    \       
         /______::_____     ::    .     ::    .     ::   _____._::____\      
                       `----._:: ::'  :   :: ::'  _.----'                    
                              `--.       ;::  .--'                           
                                  `-. .:'  .-'                               
                                     \    /                        
                                      \  /                                   
                                       \/  */

//ヾ(⌐■_■)ノ♪ ◢◤
#include <bits/stdc++.h>
#define int long long int
using namespace std;
main()
{
    int n,w;
    cin>>n>>w;
    int a[n][2];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1];
    int dp[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<w+1;j++)
            dp[i][j]=0;
    }
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<w+1;j++)
        {
            if(j>=a[i-1][0])
                dp[i][j]=max(a[i-1][1]+dp[i-1][j-a[i-1][0]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
}
                
                

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define sort stable_sort
using namespace std; 
 
int _;
 
int ans;
string s;
  
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> s;
	for(int i=0,len=s.size();i<len;i++)
		ans += s[i]-'0';
	printf(ans%9 ?"No\n":"Yes\n");
	return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int a[114514];
signed main(){
	ic(a) ic(b)
	if(a<10&&b<10)c(a*b)
	else c(-1)
} 	

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<sstream>
#include<cstdio>
#include<algorithm>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
int a;cin >> a;
cout << a + a*a + a*a*a;
return 0;

}

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

#define int long long
#define vec vector
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sq(x) (x)*(x)
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

using namespace std;
typedef pair<long long, long long> PII;
typedef long double ld;

signed main()
{
    vec < vec < int > > q(3, vec < int > (3));
    for(auto &i: q) for(auto &j: i) cin >> j;
    int n;
    cin >> n;
    vec < vec < int > > used(3, vec < int > (3, 0));
    int a;
    for(int i = 0; i < n; ++i){
        cin >> a;
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                if(q[j][k] == a) used[j][k] = 1;
            }
        }
    }
    vec < int > ans;
    if(used[0][0]+used[1][1]+used[2][2] == 3 ||
       used[0][2] + used[1][1]+used[0][2] == 3) return cout << "Yes", 0;
    for(int i = 0; i < 3; ++i)
        ans.pb(used[i][0]+used[i][1]+used[i][2]),
        ans.pb(used[0][i]+used[1][i]+used[2][i]);
    sort(all(ans));
    if(ans[ans.size()-1] == 3) return cout << "Yes", 0;
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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, K;
	cin >> N >> K;
	double ans = 0;
	REP(i, N) {
		int s = i + 1;
		double p = 1.0;
		while (s < K) {
			s *= 2;
			p *= 0.5;
		}
		ans += p;
	}
	ans /= (double)N;
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
v = list(map(int,input().split()))

v.sort()

total = 0
for i in range(N):
    if i == 0:
        total +=v[i] * 1/(2**(N-i-1))
    else:
        total +=v[i] * 1/(2**(N-i))

print(total)

Measured memory_bytes: 61880
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {

    let nx = read_vec::<usize>();
    let N = nx[0];
    let x = nx[1];
    let mut a: Vec<isize> = read_vec();

    // ソートしてxが無くなるまで引いていく
    let mut res = x as isize;
    let mut i: usize = 0;
    a.sort();
    while (res >= 0) && (i < N) {
        res -= a[i];
        i += 1;
    }


    // N回未満ならそれを出力
    if i < N {
        println!("{}", i-1);
    }
    else{
        if res == 0 {
            println!("{}", N);
        }
        else {
            println!("{}", N-1);
        }
    }

}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  
  bool ok = true;
  for (int i = N - 2; i >= 0; i--) {
    if (H.at(i) == H.at(i + 1) + 1) H.at(i)--;
    else if (H.at(i) > H.at(i + 1) + 1) {
      ok = false;
      break;
    }
  }
  
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int k, s; cin >> k >> s;
	int cnt = 0;
	/*
	TLE
	rep(i, k + 1)rep(j, k + 1)rep(l, k + 1){
		if(i + j + l == s) cnt++;
	}
	*/
	rep(i, k + 1)rep(j, k + 1){
		// i + j = s - z
		if(i + j <= s && s - i - j <= k) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;

#define all(a) a.begin(), a.end()
#define pb push_back

void solve() {
    int n; cin >> n;
    vi ints;
    vi floats;

    ll GIGA = 1e9;
    ll res = 0;

    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        int posdot = -1;
        for (int it = 0; it < s.size(); it++) {
            if (s[it] == '.') posdot = it;
        }

        if (posdot == -1) {
            ints.pb(stoi(s) * GIGA);
            res--;
        } else {
            string t = s.substr(posdot + 1, s.size() - posdot - 1);
            while (t.size() < 9) t += '0';
            string tt = s.substr(0, posdot);
            ints.pb(stoi(tt) * GIGA + stoi(t));
            if (stoi(t) == 0) res--;
        }
    }


    int mx = 70;

    vvi cnt(mx, vi(mx));
    for (auto i : ints) {
        int twos = 0;
        int fives = 0;
        while (i % 2 == 0) {
            twos++;
            i /= 2;
        }
        while (i % 5 == 0) {
            fives++;
            i /= 5;
        }
        cnt[twos][fives]++;
    }

    for (int i = mx - 1; i > -1; i--) {
        for (int j = mx - 1; j > -1; j--) {
            if (i < mx - 1) cnt[i][j] += cnt[i + 1][j];
            if (j < mx - 1) cnt[i][j] += cnt[i][j + 1];
            if (i < mx - 1 && j < mx - 1) cnt[i][j] -= cnt[i + 1][j + 1];
        }
    }

    for (auto f : ints) {
        int twos = 0, fives = 0;
        while (f % 2 == 0) f /= 2, twos++;
        while (f % 5 == 0) f /= 5, fives++;
        twos = max(0, 18 - twos);
        fives = max(0, 18 - fives);
        res += cnt[twos][fives];
    }
    cout << res / 2;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 5332
import bisect
import collections
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
m = collections.deque([])
for i in range(0, n):
    j = bisect.bisect_left(m, a[i])
    if j == 0:
        m.appendleft(a[i])
    else:
        m[j - 1] = a[i]
print(len(m))

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

int main() {
ll n,k;
cin >> n >>k;

ll ans = min(n,n - (n/k) * k);
ans = min(ans,abs(n-(n/k + 1)*k));
//cout << n <<" "<<n - (n/k) * k<<" "<<abs(n-(n/k + 1)*k) << endl;
cout << ans <<endl;
return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
a=[int(input()) for i in range(n)]
a.sort()
q=deque()
for i in range(n//2):
  if i%2==0:
    q.appendleft(a[n-i-1])
    q.append(a[i])
  else:
    q.appendleft(a[i])
    q.append(a[n-i-1])
ans=0
q1=list(q)
if n%2==0:
  for i in range(n-1):
    ans+=abs(q1[i]-q1[i+1])
  print(ans)
else:
  for i in range(len(q1)-1):
    ans+=abs(q1[i]-q1[i+1])
  print(ans+max(abs(a[n//2]-q1[0]),abs(a[n//2]-q1[len(q1)-1])))

Measured memory_bytes: 9000
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> minus, plus;
    plus.push_back(0);
    minus.push_back(0);
    rep(i, n){
        ll x;
        cin >> x;
        if(x < 0)minus.push_back(-1*x);
        else plus.push_back(x);
    }
    sort(ALL(minus));

    ll ans = INF;

    rep(i, plus.size()){
        if(i > k)break;
        if(minus.size() -1 + i < k)continue;

        ans = min(ans, plus[i] + 2*minus[k-i]);
        ans = min(ans, 2*plus[i] + minus[k-i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define all(a) (a.begin(),a.end())

using ll = long long;
using namespace std;
template<typename... Args>
void read(Args&... args)
{((cin >> args), ...);}

template<typename... Args>
void write(Args... args)
{((cout << args << " "), ...);}

template<typename... Args>
void writeln(Args... args)
{((cout << args << " "), ...); cout << "\n";}

template<typename T>
void read(vector<T> &a)
{for (auto &ele : a) cin >> ele;}

template<typename T>
void writeln(vector<T> &a)
{for (auto &ele : a) cout << ele << ' '; cout << "\n";}

const pii dxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
const pii fxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, { -1, -1}, { -1, 1}, {1, -1}};



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(false);
//	int t;cin >> t;while(t--) solve();
	int n;
	read(n);
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		int u, v;
		read(u, v);
		if (u == v) a[i] = 1;
	}
	for (int i = 0; i < n - 2; ++i) {
		if (a[i] == 1 && a[i + 1] == 1 && a[i + 2] == 1) {
			writeln("Yes");
			return 0;
		}
	}
	writeln("No");
	return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << 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
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair


signed main(){
    CIN(x);
    YES(x==7||x==5||x==3);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int H,W,i,j;
  while(1){
    cin >>H>>W;
    if(H>0&&W>0){
      for(i=0;i<H;i++){
        for(j=0;j<W;j++){
          cout<<"#";
        }cout<<endl;
      }cout<<endl;
    }
    else if(H==0&&W==0)break;
    
  }
}



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

int main(){
  string s;cin>>s;
  int n=s.size();
  bool ans=1;
  int sum=0;
  for(int i=1;i<n;i++){ 
    if(i>1&&i<n-1&&s[i]=='C'){
      sum++;
      continue;
    }
    if('a'>s[i]||s[i]>'z')ans=0;
  }
  if(s[0]!='A'||sum!=1)ans=0;
  cout<<(ans?"AC":"WA");
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int x;
	cin >> x;

	cout << (1 ^ x) << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3648
def dfs(base, dic, swap, ma):
    if len(base) == ma:
        print(base)
    else:
        num = max(map(lambda x: swap[x], base)) + 1
        for i in range(num + 1):
            dfs(base + dic[i], dic, swap, ma)


n = int(input().strip())
dic = {0: "a",
       1: "b",
       2: "c",
       3: "d",
       4: "e",
       5: "f",
       6: "g",
       7: "h",
       8: "i",
       9: "j",
       }
swap = {v: k for k, v in dic.items()}
dfs("a", dic, swap, n)


Measured memory_bytes: 56920
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/23
Solved on 2019/3/
@author: shinjisu
"""


# ABC 069 C - 4-adjacent

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    d.dmp((N), 'N')
    A = getIntList()
    d.dmp((A), 'A')
    odd, two, four = 0, 0, 0
    for e in A:
        if e % 4 == 0:
            four += 1
        elif e % 2 == 0:
            two += 1
        else:
            odd += 1
    d.dmp((odd, two, four), 'odd, two, four')
    if two > 0:
        odd += 1
    d.dmp((odd, four), 'odd, four')
    if four+1 >= odd:
        return 'Yes'
    else:
        return 'No'


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 14252
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

// UnionFind
class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) {
        par.resize(n, -1);
    }

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

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

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

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    int connect = n;
    for (int i = 0; i < m; i++) {
        int a,b;cin >> a >> b;
        a--;b--;
        if (uf.unite(a,b)) connect--;
    }
    cout << connect - 1 << endl;
    return 0;
}

/////////////////////////////////////////

Measured memory_bytes: 3788
N = int(input())
Ds = list(map(int,input().split()))
M = int(input())
Ts = list(map(int,input().split()))

sDs = [-1]+sorted(Ds)
sTs = sorted(Ts)

ind = 0
for t in sTs:
    flg = False
    for j in range(ind+1,len(sDs)):
        if sDs[j] == t:
            ind = j
            flg = True
            break
    if not flg:
        print("NO")
        break
if flg:
    print("YES")
        

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> a(N + 1), b(N + 1);
    for(int i = 1; i <= N; i++) cin >> a[i];
    int count = 0;
    for(int i = N; i >= 1; i--){
        for(int j = i; j <= N; j += i) a[i] += b[j];
        if(a[i] % 2 == 1){
            b[i] = 1;
            count++;
        }
    }
    cout << count << endl;
    for(int i = 1; i <= N; i++){
        if(b[i] == 1){
            cout << i;
            count--;
            if(count == 0) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int lcs(string x, string y) {
    static int c[1001][1001];
    int m = x.size();
    int n = y.size();
    int max1 = 0;
    x = ' ' + x;
    y = ' ' + y;
    for (int i = 0; i <= m; i++)c[i][0] = 0;
    for (int j = 1; j <= n; j++)c[0][j] = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (x[i] == y[j])c[i][j] = c[i - 1][j - 1] + 1;
            else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            max1 = max(max1, c[i][j]);
 
        }
    }
    return max1;
}
 
int main() {
    string s1, s2;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 7100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-12;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define REP(i, s, e) for ( int i = s; i <= e; i++ )  

const double INF = 1e12;
typedef complex<double> P,point;
typedef vector<P> G,polygon;
namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);}}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);}};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}
double getArea(P a, P b , P c){
		b-=a, c-=a;
		return fabs( b.real() * c.imag() - c.real() * b.imag() ) / 2.0; 
}
int main(){
	double a,b,c,d;
	while(cin >> a >> b >> c >> d , a || b || c || d){
		L one = L(P(a,b),P(c,d));
		cin >> a >> b >> c >> d;
		L two = L(P(a,b),P(c,d));
		cin >> a >> b >> c >> d;
		L three = L(P(a,b),P(c,d));
		double ret = 0;
		
		if(intersectSS(one,two) && intersectSS(two,three) && intersectSS(one,three)){
			ret = getArea( crosspoint(one,two) , crosspoint(two,three) , crosspoint(one,three) );
		}
		if(ret >= 1900000){
			cout << "dai-kichi" << endl;
		}else if(ret >= 1000000){
			cout << "chu-kichi" << endl;
		}else if(ret >= 100000){
			cout << "kichi" << endl;
		}else if(ret > 0){
			cout << "syo-kichi" << endl;
		}else{
			cout << "kyo" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
set<int> digits(int num) {
    set<int> ret;
    while (num != 0) {
        int tmp = num % 10;
        ret.insert(tmp);
        num /= 10;
    }
    return ret;
}

int main() {
    int n, k; cin >> n >> k;
    set<int> d;
    rep(i, k) {
        int x; cin >> x;
        d.insert(x);
    }

    for (int i = n; i < 1000'000; i++) {
        set<int> result;
        auto ds = digits(i);
        set_intersection(d.begin(), d.end(),
                         ds.begin(), ds.end(),
                         inserter(result, result.end()));
        if (result.empty()) {
            cout << i << endl;
            break;
        }
    }
}


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

typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    int n;  cin >> n;
  
    vector<ll> x(n), y(n);

    for(int i=0; i<n; i++) cin >> x.at(i) >> y.at(i);

    ll res=n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) continue;
            ll dx = x[j]-x[i], dy=y[j]-y[i];

            ll sub=0;
            for(int i2=0; i2<n; i2++){
                for(int j2=0; j2<n; j2++){
                    if(i2==j2) continue;
                    if(x[i2]+dx==x[j2] && y[i2]+dy==y[j2]) sub += 1;
                }
            }
            res = min(res, n-sub);
        }
    }

    cout << res << endl;


}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

b=[0]*n

for i in range(1,n+1):
    now=n-i+1
    tmp=0
    j=now+now
    while(j<=n):
        if b[j-1]==1:
            tmp+=1
        j+=now
    tmp=tmp%2
    if tmp==a[now-1]:
        pass
    else:
        b[now-1]=1
# print(b)
anscount=0
ans=[]
for i in range(n):
    if b[i]==1:
        anscount+=1
        ans.append(i+1)
print(anscount)
print(" ".join(map(str,ans)))


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  bool r = n % 2 == 0;
  for (int i = 0; r && i < n / 2; i++) r &= s[i] == s[i + n / 2];
  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#include<limits.h>
/*競技プログラミングでよく使う関数とかテクニック*/
int INF = INT_MAX /10; //とりあえずめっちゃ大きい数字を用意しておくと便利

//aとbの中身を入れ替える。
void swap (int *a, int *b){
    int t = *a; *a = *b;*b = t;
}
//////////////////////////////////



int main(void){
    int N,M,i,x,tmp,r,TLCM,j,k,dif,a,Ntemp,Mtemp;
    int l=0;
    int difsum=0;
    int str[1000];
    int max=0,min=100;
    
    scanf("%d %d",&N,&M);
    Ntemp=N;
    Mtemp=M;
    
    for(i=0; i<N; i++){
        scanf("%d", &str[i]);
    }
    
    x=N*M;
    
    if(N<M)swap(&N,&M);
    
    r = N % M;
    while(r!=0){
        N = M;
        M = r;
        r = N % M;
    }
    
    TLCM=x/M;
    //printf("TLCM=%d\n",TLCM); debug
    
    a=TLCM/Mtemp;
    //printf("a=%d\n",a); debug
    
    for(k=0; k<a; k++){
        //printf("hello%d\n",k); debug
        for(j=0; j<Mtemp; j++){
            //printf("Mtemp=%d\n",Mtemp); debug
            if(str[l]>=max){
                max=str[l];
            }
            //printf("%d\n",max); debug
            if(str[l]<=min){
                min=str[l];
            }
            //printf("%d\n",min); debug
            dif=max-min;
            //printf("%d\n",dif); debug
            l++;
            if(l==Ntemp){
                l=0;
            }
        }
        difsum += max - min;
        max=-10000000;
        min=10000000;
    }
    
    
    printf("%d\n",difsum);
    
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ci const int&
#define ID(id,x,y) ((id-1)*6+1+x*3+y)
using namespace std;
int n,m,Q,g,mod,rm,qu,qv,qw,u[50010],v[50010],w[50010],f[300010],ex[2][1000010];
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int getf(ci x){
	return f[x]==x?x:f[x]=getf(f[x]);
}
void Merge(int x,int y){
	if((x=getf(x))==(y=getf(y)))return;
	f[x]=y;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&Q,&mod);
	for(int i=1;i<=m;++i)scanf("%d%d%d",&u[i],&v[i],&w[i]),g=gcd(g,abs(w[i]-w[1]));
	if(!g)g=mod;
	mod=gcd(mod,3*g),rm=w[1]%g;
	for(int i=1;i<=6*n;++i)f[i]=i;
	for(int i=1;i<=m;++i)for(int j=0;j<3;++j)Merge(ID(u[i],0,j),ID(v[i],1,((j<<1)+(w[i]-rm)/g)%3)),Merge(ID(u[i],1,j),ID(v[i],0,((j<<1)+(w[i]-rm)/g)%3));
	for(int i=0,pw=1;i<mod;++i,(pw<<=1)>=mod?pw-=mod:0)ex[i&1][(1ll*pw*rm)%mod]=1;
	for(int i=1;i<=Q;++i){
		scanf("%d%d%d",&qu,&qv,&qw);
		for(int j=0;j<2;++j)for(int k=0;k<3;++k)if(ex[j][((qw+rm-k*g)%mod+mod)%mod]&&getf(ID(qv,0,0))==getf(ID(qu,j,k))){
			puts("YES");
			goto Skip;
		}
		puts("NO");
		Skip:;
	}
	return 0;
}

Measured memory_bytes: 13236
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
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;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string N; cin >> N;
    int out=0;
    for(int i=0;i<4;i++){
        if(N[i]=='2') out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3596