akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=26;

void f(int x){
	for(int i=0;i<M;i++){
		if(x&1<<i) cout<<1;
		else cout<<0;
	}
	cout<<endl;
}

int n;
string s;

int main(){
	cin>>s;
	n=s.size();
	vi a(M);
	vvi dp(n+1,vi(M+1,inf));
	map<int,int> m;
	int tmp=0,res=inf,S=0;
	for(int i=0;i<n;i++) a[s[i]-'a']++;
	for(int i=0;i<M;i++) tmp+=a[i]%2;
	if(tmp<=1){
		cout<<1<<endl;
		return 0;
	}
	dp[0][M]=0;
	m[0]=0;
	for(int i=0;i<n;i++){
		int c=s[i]-'a',mn=inf;
		S^=1<<c;
		dp[i+1][M]=dp[i][c];
		for(int j=0;j<M;j++){
			int T=S^(1<<j);
			if(m.find(T)!=m.end()){
				int I=m[T];
				for(int k=0;k<=M;k++) dp[i+1][j]=min(dp[i+1][j],dp[I][k]+(k!=M||I==0?1:0));
			}
			mn=min(mn,dp[i][j]);
		}
//		if(i==1) cout<<mn<<endl;
		dp[i+1][c]=min(dp[i+1][c],mn+1);
		m[S]=i+1;
	}
	for(int i=0;i<=M;i++) res=min(res,dp[n][i]);
	cout<<res<<endl;
//	cout<<dp[6][23]<<endl;
//	cout<<dp[1][0]<<endl;
}

Measured memory_bytes: 39556
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    N = na[0]
    K = na[1]
    x = []
    y = []
    c = []
    for i in range(N):
        sa = input().split()
        x.append(int(sa[0]))
        y.append(int(sa[1]))
        c.append(True if sa[2] == 'W' else False)

    hopes = [[0 for j in range(K)] for i in range(K)]
    ysum = [[0 for j in range(K * 2)] for i in range(K)]

    score = 0
    for i in range(N):
        xmod = x[i] % K
        ymod = y[i] % K
        f = (int(x[i] / K) + int(y[i] / K)) % 2 == 1
        c[i] ^= f
        if c[i]:
            score += 1
        h = -1 if c[i] else 1
        hopes[xmod][ymod] += h

    for i in range(K):
        s = 0
        for j in range(K):
            s += hopes[i][j]
            ysum[i][j] = s
        for j in range(K):
            s -= hopes[i][j]
            ysum[i][K + j] = s

    smax = 0
    for j in range(K):
        s = 0
        for i in range(K):
            s += ysum[i][K + j]
        for i in range(K):
            s += (ysum[i][j] - ysum[i][K + j])
            smax = max(smax, s)
        for i in range(K):
            s -= (ysum[i][j] - ysum[i][K + j])
            smax = max(smax, s)

    print(score + smax)


if __name__ == '__main__':
    main()



Measured memory_bytes: 48596
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
using namespace std;

unsigned short vis[1 << 24];
char c[16][20];
bool wall[256];
int gen;

inline bool check(int u, int v){
	for(int i = 0; i < 24; i += 8){
		int p1 = v >> i & 255;
		if(p1){
			int j = i == 16 ? 0 : i + 8;
			if(wall[p1]){ return false; }
			int p2 = v >> j & 255;
			if(p1 == p2){ return false; }
			if(
				p1 == (u >> j & 255) &&
				p2 == (u >> i & 255)
			){
				return false;
			}
		}
	}
	return true;
}

int solve(int start, int goal){
	const int dif[5] = {0, -1, 1, -16, 16};

	++gen;
	queue<int> q;
	q.push(start);
	q.push(-1);
	int tm = 1;
	vis[start] = gen;
	while(1){
		int u = q.front();
		q.pop();
		if(u < 0){
			q.push(-1);
			++tm;
		}
		else{
			for(int i1 = u & 255 ? 4 : 0; i1 >= 0; --i1)
			for(int i2 = u >> 8 & 255 ? 4 : 0; i2 >= 0; --i2)
			for(int i3 = u >> 16 ? 4 : 0; i3 >= 0; --i3){
				int v = u + dif[i1] + (dif[i2] << 8) + (dif[i3] << 16);
				if(vis[v] == gen){ continue; }
				if(check(u, v)){
					if(v == goal){ return tm; }
					vis[v] = gen;
					q.push(v);
				}
			}
		}
	}
}

int main(){
	int w, h;
	while(scanf("%d%d%*d ", &w, &h), w){
		for(int i = 0; i < h; ++i){
			fgets(c[i], 20, stdin);
		}

		int goal = 0;
		int start = 0;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(c[i][j] == '#'){
					wall[i << 4 | j] = true;
				}
				else{
					wall[i << 4 | j] = false;
					if(isupper(c[i][j])){
						goal |= (i << 4 | j) << (c[i][j] - 'A') * 8;
					}
					else if(islower(c[i][j])){
						start |= (i << 4 | j) << (c[i][j] - 'a') * 8;
					}
				}
			}
		}

		printf("%d\n", solve(start, goal));
	}
}

Measured memory_bytes: 32808
from collections import deque

H, W = map(int, input().split())
S = []
for i in range(H):
    s = input()
    temp = []
    for j in range(W):
        temp.append(s[j])
    S.append(temp)

ret = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '?':
            q = deque()
            q.appendleft((i, j))
            white = 0
            black = 0
            while q:
                h, w= q.pop()
                color = S[h][w]
                if color == '?':
                    continue
                elif color == '#':
                    black += 1
                else:
                    white += 1
                S[h][w] = '?'
                cand = [(h+1, w), (h-1, w), (h, w+1), (h, w-1)]
                for hc, wc in cand:
                    if 0 <= hc < H and 0 <= wc < W and (S[hc][wc] not in [color, '?']):
                        q.appendleft((hc, wc))

            ret += black * white

print(ret)


Measured memory_bytes: 59608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define sez(a) a.size()
const int maxn=2e5+100;
const int MOD=1e9+7;
const ll INF=1e18;
const ld PI=3.141592653589793;
string z[101];
int cnt[26];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   // string s;
    int n,m,K;
    cin>>n>>m>>K;
    for(int k=0; k<=m; ++k)
    for(int r=0; r<=n; ++r){
        if (k*(n-r)+r*(m-k)==K){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<ll> scores(n);
    rep2(i, n) cin(scores[i]);

    rep3(i, k, n) {
        if (scores[i - k] < scores[i]) {
            print("Yes");
        } else {
            print("No");
        }
    }

    return 0;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  ll n = s.size();
  ll ans = 0;
  rep(i, n) if(s[i] != t[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3920
#include <cstdio>

using namespace std;

int a[10];

int main() {
    for (int i = 1; i <= 5; i++) {
        int x;
        scanf("%d", &x);
        a[x] = 1;
    }
    for (int i = 1; i <= 5; i++) {
        if (a[i] == 0) {
            printf("%d ", i); 
        }
        
    }
    return 0;
}


Measured memory_bytes: 1712
cnt = 0
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    else:
        for i in range(1,a+1):
            for j in range(1,a+1):
                if i >= j:
                    continue
                for k in range(1,a+1):
                    if i>=k or j >=k:
                        continue
                    elif i+j+k==b:
                        cnt += 1

    print(cnt)
    cnt =0


Measured memory_bytes: 5596
using System;

public class Program
{
    private int M;
    private int[] D;
    private long[] C;

    public void Solve()
    {
        var sc = new Scanner();
        M = sc.NextInt();
        D = new int[M];
        C = new long[M];
        for (int i = 0; i < M; i++)
        {
            D[i] = sc.NextInt();
            C[i] = sc.NextLong();
        }

        // どの順番で処理しても結果は変わらない

        // 隣り合うとこ足して
        // 繰り上がりなし 桁 -1 合計 -0
        // あり　桁 -0 合計　-9

        long sum = 0;
        long digit = 0;
        for (int i = 0; i < M; i++)
        {
            sum += D[i] * C[i];
            digit += C[i];
        }

        // 最終的に合計 9以下 1以上 桁 1
        long ans = (sum - 1) / 9 + digit - 1;

        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 17324
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 ans=0;

		if(A>B) ans=A+A-1;
		else if(A<B) ans=B+B-1;
		else {
			if(A-1<B) ans=A+B;
			else ans=A+A-1;
		}
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 22740
data = input().split()
W=int(data[0])
H=int(data[1])
x=int(data[2])
y=int(data[3])
r=int(data[4])
if (0 <= x - r <= W) and (0 <= x + r <= W):
	if (0 <= y - r <= H) and (0 <= y + r <= H):
		print("Yes")
	else:
		print("No")
else:
	print("No")

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

int main() {
  int a = 0, b, c = 0, d, e;
  string f;
  cin >> b;
  vector<string> g(b);
  while (c < b) cin >> g.at(c++);
  for (cin >> d; cin >> f; g.push_back(f));
  while (c--) {
    for (d = 0, e = g.size(); e--;) {
      if (g.at(c) == g.at(e)) if (e < b) d++;
      else d--;
    }
    if (d > a) a = d;
  }
  cout << a;
}

Measured memory_bytes: 3588
use std::io::prelude::*;

fn main() {
    let stdin_ = std::io::stdin();
    let mut stdin = stdin_.lock();
    let mut buf = String::new();
    let t = {
        let mut v = Vec::new();
        for _ in 0..5 {
            buf.clear();
            stdin.read_line(&mut buf).unwrap();
            v.push(buf.trim().parse::<i64>().unwrap());
        }
        v
    };

    let max = t
        .iter()
        .map(|t| if t % 10 == 0 { 0 } else { 10 - t % 10 })
        .max()
        .unwrap();
    let s = t
        .iter()
        .map(|t| t + (if t % 10 > 0 { 10 - t % 10 } else { 0 }))
        .sum::<i64>();
    let ans = s - max;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	ll a, b;
	cin >> w >> a >> b;
	ll res = max(a, b) - (min(a, b) + w);
	if (res < 0)res = 0;
	
	cout << res << endl;
	
}

Measured memory_bytes: 256
L = int(input())
A = [int(input()) for _ in range(L)]
INF = 10**20
DP = [[INF for i in range(5)] for _ in range(L)]
DP[0][0] = A[0]
DP[0][1] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][2] = (1 if A[0] % 2 == 0 else 0)
DP[0][3] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][4] = A[0]

for i in range(1, L):
    a = A[i]
    DP[i][0] = DP[i-1][0] + a
    DP[i][1] = min(DP[i-1][:2]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][2] = min(DP[i-1][:3]) + (1 if a % 2 == 0 else 0)
    DP[i][3] = min(DP[i-1][:4]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][4] = min(DP[i-1]) + a

print(min(DP[L-1]))

Measured memory_bytes: 74088
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
   ll n;
   cin>>n;
   ll a;
   vector<ll>v(n);
   rep(i,n-1) {
    cin>>a;
    v[a-1]++;
   }
   rep(i,n)cout<<v[i]<<endl;
}



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

int main() {
	int h, w;
	while(cin>>h>>w && !(h==0 && w==0))
	{
		for(int i=0; i<h; i++)
		{
			for(int j=0; j<w; j++)
			{
				if( (i%2==0) && ( j%2==0)) { cout << "#"; continue; } 
				if( (i%2==0) && ( j%2!=0)) { cout << "."; continue; } 

				if( (i%2!=0) && ( j%2==0)) { cout << "."; continue; } 
				if( (i%2!=0) && ( j%2!=0)) { cout << "#"; continue; } 
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}



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

int main(void) {
	while(1) {
		unsigned long int n, a, b, c, x;
		cin >> n >> a >> b >> c >> x;
		if (n == 0) break;
		int y[n];
		for (int i = 0; i < n; i++)
			cin >> y[i];
		int count = 0;
		int ran = x;
		// リール
		for (int i = 0; i < n; i++) {
			while (1) {
				if (ran == y[i]) {
					if ( (i+1) != n ) {
						ran = (a * ran + b) % c;
						count++;
					}
					break;
				}
				else {
					ran = (a * ran + b) % c;
					count++;
				}
				if (count > 10000)
					break;
			}
			if (count > 10000)
				break;
		}
		if (count > 10000)
			cout << "-1" <<endl;
		else
			cout << count <<endl;
	}
	return 0;
}



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



int main(){
    
    ll N,C,K;
    cin>>N>>C>>K;
    ll t[100010];
    rep(i,0,N)cin>>t[i];
    sort(t,t+N);
    t[N]=2000000000;
    ll pa,cn=0,num=0,now=0;
    rep(i,0,N){
        if(now==N)break;
        pa=t[now];
        num=1;
        while(1){
            num++;
            if(t[now+1]>pa+K){
                cn++;
                now++;
              //  cout<<9;
                break;
            }
            else if(num>C){
                cn++;
                now++;
              //  cout<<8;
                break;
            }
            else{
                now++;
               // cout<<7;
            }
        }
        
    }
    cout<<cn<<endl;
}






Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

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

int a[100005] = {};

int main(){
    int n,x;
    ull ans = 0;
    cin >> n >> x;

    rep(i,0,n)cin >> a[i];

    rep(i,1,n){
        ll sum = a[i-1] + a[i];
        if(sum > x){
            if(sum - x <= a[i]){
                ans += sum-x;
                a[i] -= sum-x;
            }else{
                a[i] = 0;
                ans += sum-x;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int K;
    cin >> K;

    vector<i64> A(K);
    rep(i,0,K) cin >> A[i];

    auto f=[&](i64 n){
        rep(i,0,K) n=n/A[i]*A[i];
        return n;
    };

    i64 mi,ma;
    {
        i64 lb=0,ub=inf64;
        while(ub-lb>1){
            i64 mid=(lb+ub)/2;
            if(f(mid)>=2) ub=mid;
            else lb=mid;
        }
        mi=ub;
    }
    {
        i64 lb=0,ub=inf64;
        while(ub-lb>1){
            i64 mid=(lb+ub)/2;
            if(f(mid)>2) ub=mid;
            else lb=mid;
        }
        ma=ub;
    }
    
    if(f(mi)>2) cout << -1 << endl;
    else cout << mi << " " << ma-1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
#include<tuple>
#include<string>

using namespace std;

int main() {

	int K;
	string s;
	cin >> K >> s;

	if (K >= s.size())cout << s << endl;
	else {
		for (int i = 0; i < K; i++)cout << s[i];
		cout << "...\n";
	}
	return 0;
}

Measured memory_bytes: 3628
import sys
N, M = map(int, input().split())
ks = [list(map(int, sys.stdin.readline().split())) for i in range(M)]
k = [i[0] for i in ks]
s = [i[1:] for i in ks]

p = list(map(int, sys.stdin.readline().split()))
ans = 0

for i in range(2 ** N):
    op = [1] * N
    for j in range(N):
        if (i >> j) & 1:
            op[j] = 0
    T = [False] * M
    for h in range(M):
        c = 0
        for l in s[h]:
            if op[l - 1]:
                c += 1
        if p[h] == c % 2:
            T[h] = True
    if all(T):
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define re register
int main()
{
	int k;
	scanf("%d", &k);
	if(k==1){puts("1\n1");return 0;}
	re int n=(k/4+(k%4!=0))<<1;
	printf("%d\n",n);
	for(re int i=0;i<n;i++)
	{
		for(re int j=0;j<n;j++)
		{
			re int x=(i+j)%n+1+(j&1)*n;
			printf("%d ",x>k?x-n:x);
		}
		puts("");
	}
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[2][n];
		int[][] d = new int[2][n];
		for(int i=0; i<2; i++) {
			for(int j=0; j<n; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		d[0][0] = a[0][0]; d[1][0] = d[0][0] + a[1][0];
		for(int i=0; i<2; i++) {
			for(int j=1; j<n; j++) {
				if(i==0) {
					d[i][j] = d[i][j-1]+a[i][j];
				} else {
					d[i][j] = Math.max(d[i-1][j]+a[i][j], d[i][j-1]+a[i][j]);
				}
			}
		}
		System.out.println(d[1][n-1]);
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}


Measured memory_bytes: 22996
#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[i];

    int ans = 0;
    int amax = 0;
    for(int i = 0;i < n - 1;i++){
        if(h[i] >= h[i + 1]){
            amax++;
        }
        else{
            ans = max(amax, ans);
            amax = 0;
        }
    }
    ans = max(amax, ans);

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
using namespace std;
int A, B, C;
int main() {
  cin >> A >> B >> C;
  set<int> s;
  s.insert(A);
  s.insert(B);
  s.insert(C);
  cout << (s.size()==2?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b)
{
    return (a%10)<(b%10);
}
int main()
{
    int a[5],ans=0;
    int len=0;
    for(int i=0;i<5;++i)
    {
        cin>>a[i];
        ans+=(a[i]/10)*10;
        if(a[i]%10) ans+=10;
        int t=10-a[i]%10;
        t%=10;
        len=max(len,t);
    }
    cout<<ans-len<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = 50 * 50 + 1

    dp = [[[0] * MAX for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for j in range(n):
            for k in range(MAX):
                dp[i][j][k] += dp[i - 1][j][k]
                if k + x < MAX:
                    dp[i][j + 1][k + x] += dp[i - 1][j][k]
    res = 0
    for j in range(1, n + 1):
        res += dp[-1][j][a * j]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 119072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
    int x=0,c=getchar(),f=0;
    for(;c>'9'||c<'0';f=c=='-',c=getchar());
    for(;c>='0'&&c<='9';c=getchar())
    x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;

char a[maxn] , b[maxn];
ll d[maxn];

int main() {
    ll n = (ll)read() , m = (ll)read();
    scanf("%s%s", a+1, b+1);

    ll c = n * m / __gcd(n, m);
    int k = 0;
    for (int i=1; i<=n; i++){
        ll id = c / n * (i-1) + 1;
        d[++k] = id;
    }

    bool flag = true;
    for (int i=1; i<=m; i++){
        ll id = c / m * (i-1) + 1;
        if (binary_search(d+1, d+k+1, id)){
            int x = lower_bound(d+1, d+k+1, id) - d;
            //cout << id << " " <<  x << endl;
            if (b[i] != a[x]){
                flag = false;
                break;
            }
        }
    }

    if (!flag)  puts("-1");
    else  printf("%lld\n", c);
    return 0;
}


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

using namespace std;

using ll = long long;

bool Solve() {
    int n;
    cin >> n;

    vector<int> a(n), ans;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    while (!a.empty()) {
        int idx = -1;
        for (int i = 0; i < a.size(); ++i) {
            if (i + 1 != a[i]) continue;
            if (idx == -1 || a[idx] < a[i]) idx = i;
        }
        if (idx == -1) return false;
        ans.push_back(a[idx]);
        a.erase(a.begin() + idx);
    }

    reverse(ans.begin(), ans.end());
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << '\n';
    }

    return true;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
 
    if (!Solve()) cout << "-1\n";

    return 0;
}


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

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0) {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
    lli i;
    rep(i,3)
    {
        string s;
        cin >> s;
        cout << s[i];
    }
	return 0;
}










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


int main(){
  int  n,k;
  cin >> n >>k ;
 int ans=0;
  int m=n-k;
  ans++;
  if(m%(k-1)==0){
    ans+=m/(k-1);
  }
  else ans+=m/(k-1)+1;
  cout << ans << endl;
   
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,D,b=0,c=0;
    cin >> N >> D;
    vector<vector<int>> vec(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  
  for (int i = 0; i < N-1; i++) {
      
      for(int k=i+1;k<N;k++){
          int a=0;
        for (int j = 0; j < D; j++) {
           a = a+(vec.at(i).at(j)-vec.at(k).at(j))*(vec.at(i).at(j)-vec.at(k).at(j));
        }
       
        c = sqrt(a);
        if(a == c*c){
            b = b+1;
        }
        
      }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
import sys
#import bisect
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
D = list(map(int, input().split()))

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a;
    cin >> a;
    for (int i = 1; i < 50001; i++) {
        if((int)(i*1.08) == a){
            pr(i);
            return 0;
        }
    }
    pr(":(");

}

Measured memory_bytes: 256
# your code goes here
N = int(input())
if(N < 105):
	print(0)
elif(N < 135):
	print(1)
elif(N < 165):
	print(2)
elif(N < 189):
	print(3)
elif(N < 195):
	print(4)
else:
	print(5)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		Map<Integer, Integer> num = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			if(num.containsKey(a[i])) {
				num.put(a[i], num.get(a[i]) + 1);
			} else {
				num.put(a[i], 1);
			}
		}
		
		int ans = 0;
		for(int key : num.keySet()) {
			int value = num.get(key);
			if(value < key) {
				ans += value;
			} else if(key < value) {
				ans += value - key;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 64120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % i == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	for (i = 0; i < isPrime.size(); i++) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
int main() {
	ll X;
	cin >> X;
	while (true) {
		if (isPrime(X)) {
			cout << X;
			break;
		}
		X++;
	}
}

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

typedef long long ll;

int  main() {
    ll N, M;
    ll ans = 0;
    cin >> N >> M;
    ll s_count;
    ll c_count;

    s_count = N;
    c_count = M/2;
    if (s_count > c_count) {
        cout << c_count << endl;
    } else {
        ans += s_count;
        M -= 2 * s_count;
        ans += M / 4;
        cout << ans << endl;
    }

}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int counter = 0;
    double yama = 0;
    double max = 0;
    double low = 0;
    while (scanf("%lf",&yama)!=EOF){
        if(counter == 0){
            max = yama;
            low = yama;
        }
        if (max < yama) {
            max = yama;
        }
        if (low > yama) {
            low = yama;
        }
        counter++;
    }
    printf("%f\n",max - low);
    return 0;
}

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

ll gcd(ll x,ll y){
    if(y > x)
        swap(x,y);
    while(true){
        int z = x%y;
        if(z==0)
            return y;
        x = y;
        y = z;
    }
}

int main(){
    int x,y;
    cin >> x>>y;
    cout << gcd(x,y)<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, a, b, c, ans, x;
	cin >> n;
	
	vector<int> ct(n + 1, 0);
	for (i = 2; i <= n; i++) {
		bool isprime = false;
		for (j = 2; j < i; j++) {
			if (i % j == 0) isprime = true;
		}
		if (isprime) continue;

		x = n;
		while (x > 1) {
			ct[i] += x / i;
			x /= i;
		}
	}

	ans = 0;
	for (a = 2; a <= n; a++) {
		if (ct[a] >= 74) ans++;
		for (b = a + 1; b <= n; b++) {
			if ((ct[a] >= 24) && (ct[b] >= 2)) ans++;
			if ((ct[b] >= 24) && (ct[a] >= 2)) ans++;
			if ((ct[a] >= 4) && (ct[b] >= 14)) ans++;
			if ((ct[b] >= 4) && (ct[a] >= 14)) ans++;
			for (c = b + 1; c <= n; c++) {
				if ((ct[a] >= 2) && (ct[b] >= 4) && (ct[c] >= 4)) 
					ans++;
				if ((ct[b] >= 2) && (ct[a] >= 4) && (ct[c] >= 4)) 
					ans++;
				if ((ct[c] >= 2) && (ct[b] >= 4) && (ct[a] >= 4)) 
					ans++;
			}
		}
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long tCookie = scan.nextLong();
		long aCookie = scan.nextLong();
		long count = scan.nextLong();
		scan.close();

		if (count <= tCookie) {
			tCookie -= count;
			System.out.println(tCookie + " " + aCookie);
			return;
		}

		if (tCookie + aCookie <= count) {
			System.out.println("0 0");
			return;
		}

		count -= tCookie;
		System.out.println("0 " + (aCookie - count));
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
#define MAX 2000000
int A[MAX];
int H;

void swap(int *a,int *b){
  int tmp=*a;
  *a=*b;*b=tmp;
}
void maxHeapify(int i){
  int l = 2*i;
  int r = 2*i+1;
  int large;
  
  if(l <= H && A[l] > A[i])
    large = l;
  else
    large = i;
  if(r <= H && A[r] > A[large])
    large = r;

  if(large != i){
    swap(&A[i],&A[large]); 
    maxHeapify(large); 
  }
}
void Insert(int x){
  int i;
  i=H;
  A[i]=x;
  while(i>=2&&A[i/2]<A[i]){
    swap(&A[i],&A[i/2]);
    i=i/2;
  }
}
int extract(void){
  int max;
  max=A[1];
  A[1]=A[H--];
  maxHeapify(1);

  return max;
}

int main(){
  char c[10];
  int i,key;

  while(1){
    scanf("%s",c);
    if(c[0]=='i'){
      H++;
      scanf("%d",&key);
      Insert(key);
    }
    else if(c[1]=='x')
      printf("%d\n",extract());
    else break;
  }
  return 0;
}



Measured memory_bytes: 5708
#include<stdio.h>
#include<string.h>
#include<algorithm>

int a[1005];
int b[1005];
int c[1005];
int dp[1 << 12];

int main() {

	int n, m, C;

	scanf("%d%d", &n, &m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		for (int j = 0; j < b[i]; j++) {
			scanf("%d", &C);
			C--;
			c[i] |= 1 << C;
		}
	}

	memset(dp, 0x7f, sizeof(dp));

	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (dp[j] >= 0) {
				dp[j | c[i]] = std::min(dp[j] + a[i], dp[j | c[i]]);
			}
		}
	}

	if (dp[(1 << n) - 1] == 2139062143) printf("-1");
	else printf("%d\n", dp[(1 << n) - 1]);

	return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <stack>

using namespace std;

int main() {

	int i;
	stack<int> n;

	while(cin >> i) {
		if(i!=0)
			n.push(i);
		else {
			cout << n.top() << endl;
			n.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 0
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n, m = in.nextInt
  val as = Array.fill(m)(in.nextInt)
  case class Match(num: Int, sticks: Int)
  val matches = Array(0,2,5,5,4,5,6,3,7,6).zipWithIndex.map{case (s, i) => Match(i, s)}
  val availables = as.map(matches).sortBy(_.num).reverse

  val digits = {
    val availableSticks = availables.map(_.sticks).distinct
    val ret = Array.fill(n + 1)(-1)
    ret(0) = 0

    for {
      i <- 1 to n
      s <- availableSticks
      if i >= s
    } ret(i) = Math.max(ret(i), ret(i - s) + 1)

    ret
  }

  def search(i: Int, d: Int, result: List[Int]): List[Int] = {
    if (d == 0) result.reverse
    else {
      val cond: Int => Boolean = s => i >= s && digits(i - s) == d - 1
      val target = availables.find(m => cond(m.sticks)).get
      search(i - target.sticks, d - 1, target.num :: result)
    }
  }

  println(search(n, digits(n), Nil).mkString)
}

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

int main() {
	// your code goes here
	long double a,b,c;
	cin>>a>>b>>c;
    long double eps = 1.0E-14;
	if(sqrt(a)+sqrt(b)+eps<sqrt(c))
	cout<<"Yes";
	else
	cout<<"No";
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

int main()
{
	int w = 0, h = 0;
	std::cin >> h >> w;
	std::vector<std::string> v;

	for (int i = 0; i < h; ++i)
	{
		std::string s;
		std::cin >> s;
		v.push_back(s);
	}
	
	for (int i = 0; i < w + 2; ++i)
		std::cout << "#";
	std::cout << std::endl;

	

	for (int i = 0; i < h; ++i)
	{
		std::string s = v[i];
		std::cout << "#" + s + "#" << std::endl;
	}

	for (int i = 0; i < w + 2; ++i)
		std::cout << "#";
	std::cout << std::endl;


	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, a: "List[int]"):
    ans = 0
    for i in range(1,(N+1)):
        if (i%2==1) and (a[i-1]%2==1):
            ans += 1

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27124
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N, K;
int main() {

	scanf("%d%d", &N,&K);

	double ans = 0;

	rep(i, N) {
		if (i + 1 >= K) {
			ans += 1;
			continue;
		}
		double l = ceil(log2(K / (i + 1.0)));
		double sub = 1;
		rep(j, l) {
			sub *= 2;
		}
		ans += 1 / sub;
	}

	printf("%.20f\n", ans/N);

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int[] p = new int[n];
			IntStream.range(0, n).forEach(i -> p[i] = scanner.nextInt());
			System.out.println(Arrays.stream(p).sorted().limit(k).sum());
		}
	}
}


Measured memory_bytes: 39324
#include <iostream>

void solve(const int& sum,
           const int& s, int limit,
           long long int& cnt,
           const int& used) {

    int tmp;
    int est_sum;

    for (int i = 0; i < 10; ++i) {
        if ((used & (1 << i)) == 0) {
            tmp = i * limit + sum;
            if (limit > 1) {
                est_sum = 9 * (limit - 1) * (limit -1);
                if (est_sum + tmp >= s) {
                    solve(tmp, s, limit - 1, cnt, used | (1 << i));
                }
            }
            else {
                if (tmp == s) {
                    ++cnt;
                    return;  
                }
                else if (tmp > s) {
                    return;
                }
            }
        }
    }
}

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

    int s, n;

    while (std::cin >> n >> s) {
        long long int cnt = 0;
        solve(0, s, n, cnt, 0);
        std::cout << cnt << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1188
let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

(* O(N) *)
let solve n vs cs =
  fold_int
    (fun res i -> res + max 0 (vs.(i) - cs.(i)))
    0
    n

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let list_to_array n a xs =
  let res = Array.make n a in
  List.iteri (fun i x -> res.(i) <- x) xs;
  res

let _ =
  let n = read_int () in
  let vs = read_ints () |> list_to_array n 0 in
  let cs = read_ints () |> list_to_array n 0 in
  solve n vs cs |> string_of_int |> print_endline

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;
use std::cmp::Ordering;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

struct UnionFind {
  par: Vec<usize>,
  rank: Vec<usize>,
}

impl UnionFind {
  fn new(n: usize) -> Self {
    let mut uf = UnionFind {par: vec![0; n], rank: vec![0; n]};
    for (i, item) in uf.par.iter_mut().enumerate() {
      *item = i;
    }
    uf
  }
  fn find(&mut self, x: usize) -> usize {
    if self.par[x] == x {
      x
    } else {
      let px = self.par[x];
      self.par[x] = self.find(px);
      self.par[x]
    }
  }
  fn unite(&mut self, x: usize, y: usize) {
    let x = self.find(x);
    let y = self.find(y);
    match self.rank[x].cmp(&self.rank[y]) {
      Ordering::Less => self.par[x] = y,
      Ordering::Greater => self.par[y] = x,
      Ordering::Equal => {
        self.par[y] = x;
        self.rank[x] += 1;
      }
    }
  }
  #[allow(dead_code)]
  fn same(&mut self, x: usize, y: usize) -> bool {
    self.find(x) == self.find(y)
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    k: usize,
    l: usize,
    pq: [(usize1, usize1); k],
    rs: [(usize1, usize1); l],
  }
  let mut upq = UnionFind::new(n);
  for &(p, q) in &pq {
    upq.unite(p, q);
  }
  let mut urs = UnionFind::new(n);
  for &(r, s) in &rs {
    urs.unite(r, s);
  }
  use std::collections::BTreeMap;
  let mut popl = BTreeMap::new();
  for i in 0 .. n {
    *popl.entry((upq.find(i), urs.find(i))).or_insert(0) += 1;
  }
  for i in 0 .. n {
    puts!("{} ", popl.get(&(upq.find(i), urs.find(i))).unwrap());
  }

  puts!("\n");
}


Measured memory_bytes: 27384