akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl p(m), k(m,0);
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		p[i]=a;
		rep(j,b){
			ll t;cin>>t;
			t--;
			k[i]+=(1<<t);
		}
	}
	vvl dp(m+1,vl(1<<n,LINF));
	dp[0][0]=0;
	rep(i,m){
		dp[i+1]=dp[i];
		rep(s,1<<n){
			// puta(i+1,s|k[i],dp[i][s],p[i]);
			chmin(dp[i+1][s|k[i]], dp[i][s]+p[i]);
		}
	}
	ll ans=dp[m][(1<<n)-1];
	if(ans==LINF)puta(-1);
	else puta(ans);
	return 0;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
#define maxn 310
const int p=1e9+7;
const int inv2=500000004;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,ans,flg=true,D[maxn],f[maxn][maxn][2],jc[maxn],inv[maxn],ifac[maxn];
void Add(int &x,int y)
{
	x+=y;
	if(x>=p)
		x-=p;
}
int mul(int x,int y)
{
	return 1ll*x*y%p;
}
int main()
{
	read(n);
	jc[0]=inv[0]=ifac[0]=1;
	jc[1]=inv[1]=ifac[1]=1;
	for(int i=2;i<=n;i++)
	{
		jc[i]=mul(jc[i-1],i);
		inv[i]=mul(p-p/i,inv[p%i]);
		ifac[i]=mul(ifac[i-1],inv[i]);
	}
	for(int i=1;i<=n;i++)
	{
		read(D[i]);
		flg&=D[i]==2;
	}
	if(flg)
	{
		printf("%d\n",mul(jc[n-1],inv2));
		return 0;
	}
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)	
			for(int k:{0,1})
			{
				if(!f[i][j][k])
					continue;
				if(D[i+1]>0)
					Add(f[i+1][j][k],mul(ifac[D[i+1]-1],f[i][j][k]));
				if(D[i+1]>1)
					Add(f[i+1][j+1][k],mul(ifac[D[i+1]-2],f[i][j][k]));
				if(D[i+1]>2&&!k)
					Add(f[i+1][j+1][1],mul(ifac[D[i+1]-3],f[i][j][k]));
			}
	for(int i=3;i<n;i++)
		Add(ans,mul(mul(jc[i-1],inv2),mul(jc[n-i-1],f[n][i][1])));
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,input().split())

def x(s):
    try:
        s.index("##")
    except:
        return True
    else:
        return False

n,a,b,c,d=intinput()
s=input()
if c<d:
    if x(s[a-1:d]):
        print("Yes")
    else:
        print("No")
else:
    try:
        s[b-2:d+1].index("...")
    except:
        print("No")
    else:
        if x(s[a - 1:c]):
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3572
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

/*
struct UnionFind {
	vector<int> data;
	UnionFind(int v) : data(v, -1) { }
	int root(int x) {
		return data[x] < 0 ? x : (data[x] = root(data[x]));
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int size(int x) {
		return -data[root(x)];
	}
	void merge(int x, int y) {
		x = root(x), y = root(y);
		if(x != y) {
			if(size(y) > size(x)) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};
*/

const int INF = (int)1e9;

int W, H; 
char B[60][11];
int Bid[60][10];
vector<int> down;
int num;

void dfs(int i, int j, int num) {
	for(int d = 0; d < 4; ++d) {
		const int dy[4] = { 0, 1, 0, -1 };
		const int dx[4] = { 1, 0, -1, 0 };
		int ny = i + dy[d];
		int nx = j + dx[d];
		if(0 <= ny && ny < H && 0 <= nx && nx < W && B[ny][nx] != '.' && B[i][j] == B[ny][nx] && Bid[ny][nx] == -1) {
			Bid[ny][nx] = num;
			dfs(ny, nx, num);
		}
	}
}

pair<int, int> ground(int id) {
	int L = INF, R = -INF;
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			if(Bid[i][j] == id && ((i > 0 && Bid[i - 1][j] != -1 && Bid[i][j] != Bid[i - 1][j]) || (i == 0))) {
				L = min(L, j);
				R = max(R, j);
			}
		}
	}
	return make_pair(L, R + 1);
}

double gravity(int id) {
	vector<int> sum(W, 0);
	queue<int> Q;
	Q.push(id);
	while(!Q.empty()) {
		int nextId = Q.front(); Q.pop();
		for(int i = 0; i < H; ++i) {
			for(int j = 0; j < W; ++j) {
				if(Bid[i][j] == nextId) sum[j]++;
			}
		}
		for(int k = 0; k < num; ++k) {
			if(down[k] == nextId) Q.push(k);
		}
	}
	double S = 0;
	int c = 0;
	for(int j = 0; j < W; ++j) {
		S += j * sum[j];
		c += sum[j];
	}
	return S / c + 0.5;
}

int main() {
	ios::sync_with_stdio(false);
	while(true) {
		cin >> W >> H;
		if(W == 0 && H == 0) break;
		for(int i = H - 1; i >= 0; --i) {
			cin >> B[i];
		}
		memset(Bid, -1, sizeof(Bid));
		num = 0;
		for(int i = 0; i < H; ++i) {
			for(int j = 0; j < W; ++j) {
				if(B[i][j] != '.' && Bid[i][j] == -1) {
					Bid[i][j] = num;
					dfs(i, j, num);
					++num;
				}
			}
		}
		
		#if 0
		for(int i = H - 1; i >= 0; --i) {
			for(int j = 0; j < W; ++j) {
				if(Bid[i][j] == -1) cout << '.';
				else cout << Bid[i][j];
			}
			cout << endl;
		}
		#endif
		
		down.assign(num, -2);
		for(int id = 0; id < num; ++id) {
			for(int i = 0; i < H; ++i) {
				for(int j = 0; j < W; ++j) {
					if(Bid[i][j] == id && ((i > 0 && Bid[i - 1][j] != -1 && Bid[i][j] != Bid[i - 1][j]) || (i == 0))) {
						if(i == 0) down[id] = -1;
						else down[id] = Bid[i - 1][j];
					}
				}
			}
			
			// cout << "down[" << id << "] = " << down[id] << endl;
		}
		
		bool ok = true;
		for(int id = 0; id < num; ++id) {
			double gr = gravity(id);
			// cout << "gravity(" << id << ") = " << gravity(id) << endl;
			auto ret = ground(id);
			// cout << "L = " << ret.first << ", R = " << ret.second << endl;
			if(gr <= ret.first || ret.second <= gr) ok = false;
		}
		cout << (ok ? "STABLE":"UNSTABLE") << endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long int MAX_N = 100000;

int main(int argc, char const *argv[]) {
  long long int n, ans = 0;
  cin >> n;
  vector<long long int> a;
  for (size_t i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());

  for (size_t i = 0; i < a.size(); ) {
    vector<long long int>::iterator lb = lower_bound(a.begin(), a.end(), a[i]);
    long long int iter = lb - a.begin();
    long long int cnt = 0;
    vector<long long int>::iterator lbp = lower_bound(a.begin(), a.end(), a[i]-1), ubn = upper_bound(a.begin(), a.end(), a[i]+1);
    cnt += ubn - lbp;
    if (cnt > ans) ans = cnt;
    i = upper_bound(a.begin(), a.end(), a[i]) - a.begin();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
n,a,b=map(int,input().split())
t=a+b
for s in list(input()):
  if str(s)=="a" and t>0:
    t-=1
    print("Yes")
  elif str(s)=="b" and t>0 and b>0:
    b-=1
    t-=1
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4708
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n= sc.nextInt();
    String s=sc.next();
    int count =1;
    for(int i=0;i<n-1;i++) {
      if(s.charAt(i+1) != s.charAt(i) ) {
        count++;
      } 
    }
    System.out.println(count);
}
}


Measured memory_bytes: 24276
<?php
class In {
    private $array = [];
    private $length = 0;
    private $count = 0;

    function __construct()	{
        while (!feof(STDIN)) {
            $str = trim(fgets(STDIN));
            $this->array = array_merge($this->array, explode(' ', $str));
        }
        $this->length = count($this->array);
    }
    
    public function get(int $i){
        $this->array[$i];
    }

    public function next() {
        return $this->array[$this->count++];
    }
    public function hasNext() {
        return $this->count < $this->length;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
    public function nextString() {
        return (string)$this->next();
    }
}

class Out {
    public static function line($str = "") {
        echo $str . PHP_EOL;
    }
}

class Str{
    public $str = [];
    public $length;
}

function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

$in = new In();

$s = new Str();
$t = new Str();
$x = new Str();

$s->length = $in->nextInt();
$t->length = $in->nextInt();
$s->str = str_split($in->nextString());
$t->str = str_split($in->nextString());
$x->length = lcm($s->length, $t->length);

function calcPos($n){
    global $x;

    $ret = [1];
    $cnt = 0;
    while(true){
        $temp = ++$cnt * $x->length / $n + 1;
        $ret[] = $temp;
        if($cnt >= $n - 1){
            break;
        }
    }
    return $ret;
}

$ans = $x->length;

$pos = calcPos($s->length);
$cnt = count($pos);
for ($i = 0; $i < $cnt; ++$i) { 
    $x->str[$pos[$i]] = $s->str[$i];
}

$pos = calcPos($t->length);
$cnt = count($pos);
for ($i = 0; $i < $cnt; ++$i) { 
    if(array_key_exists($pos[$i], $x->str) && $x->str[$pos[$i]] != $t->str[$i]){
        $ans = -1;
        break;
    }
    $x->str[$pos[$i]] = $t->str[$i];
}

Out::line($ans);

Measured memory_bytes: 31220
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

string str;

int main(int argc, const char * argv[]) {
    
    /////////
    //write//
    /////////
    
    cin >> str;
    int i=0;
    int cnt = 0;
    while(i<str.size()){
        if(i>=str.size()-2){
            bool kasanari = false;
            while(i<str.size()){
                if(str[i] == str[i+1]){
                    kasanari =true;
                }
                i++;
            }
            if(kasanari)cnt+=1;
            else cnt+=2;
            break;
        }
        if(i==str.size()-3){
            bool kasanari = false;
            while(i<str.size()){
                if(str[i] == str[i+1]){
                    kasanari =true;
                }
                i++;
            }
            if(kasanari)cnt+=2;
            else cnt+=3;
            break;
        }
        if(i==str.size()-4){
            bool kasanari = false;
            while(i<str.size()){
                if(str[i] == str[i+1]){
                    kasanari =true;
                }
                i++;
            }
            if(kasanari)cnt+=3;
            else cnt+=4;
            break;
        }
        if(str[i] == str[i+1]){
            cnt+=2;
            i+=3;
        }
        else{
            cnt++;
            i++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 640
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    N: usize,
    K: usize,
    mut A: [usize;N]
  }

  let mut current = 1;
  let mut pattern = vec![current];
  let mut memo: HashMap<usize, usize> = HashMap::new();
  while pattern.len() < K {
    let next = A[current-1];
    
    if current == next {
      println!("{}", next);
      return
    }
    
    if let Some(_) = memo.get_mut(&next) {
      let mut loop_start_index = 0;
      let pattern_len = pattern.len();
      for (i, v) in pattern.iter().enumerate() {
        if v == &next {
          loop_start_index = i;
            break;
        }
      }

      let loop_count = pattern.len() - loop_start_index;
      let left = K - loop_start_index;
      println!("{}", pattern[loop_start_index + (left % loop_count)]);
      return;
    } else {
      memo.insert(current, next);
      pattern.push(next);
    }
    current = next;
  }

  println!("{}", A[current-1]);
}

Measured memory_bytes: 12304
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int a, b; cin >> a >> b;
  if (b % a == 0) print(a + b);
  else print(b - a);
  
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll x;
	cin >>x;
	ll ans = 0;
	ll w=x;
	ll z = w / 500;
	ans += z*1000;
	w %= 500;
	z = w / 5;
	ans += z * 5;
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    int A=0;
    scanf("%d",&n);
    
    int h[n+1];
    int ans[n+1];
    for(int i=1;i<=n;i++){
        scanf("%d",&h[i]);
        ans[i]=0;
    }
    h[0]=0;
    h[n+1]=h[n]+1;
    
    for(int i=1;i<=n;i++){
        if(h[i]>=h[i-1]){
            for(int j=1;j<=n-i+1;j++){
                if(h[i]>=h[i+j] && h[i+j-1]>=h[i+j]){
                    ans[i]=j;
                }else{
                    if(A<ans[i]){
                        A=ans[i];
                    }
                    i=i+j-1;
                    break;
                }
            }
        }
    }
    
    printf("%d",A);
    return 0;
}



Measured memory_bytes: 896
io = STDIN
s=io.gets.chomp
k=io.gets.to_i
def div(str)
  str.each_byte.chunk_while{|x,y|x==y}.map{|ar|ar.size}
end
def cnt(struct)
  struct.map{|i|i/2}.inject(:+)
end
if s.size==1
  puts cnt(div(s*k))
elsif s.split(//).uniq.size==1
  puts cnt([s.size*k])
elsif s[0]==s[-1]
  struct=div(s)
  left=struct[0..-2]
  mid=struct[1..-2]
  right=struct[1..-1]
  if k==1
    puts cnt(div(s))
  elsif k==2
    puts cnt(left)+cnt(right)+cnt([left[0]+right[-1]])
  else
    connect=left[0]+right[-1]
    puts cnt(left)+cnt([connect]+right)+cnt([connect]+mid)*(k-2)
  end
else
  puts cnt(div(s))*k
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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 modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> z(n);
    vector<ll> dp(n,123451234512345);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    for (int i = 0; i < k + 1; i++) {
        if (i == n)break;
        dp[i] = abs(z[i] - z[0]);
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < k+1; j++) {
            if (i - j < 0)continue;
            if (j >= n)continue;
            dp[i] = min(dp[i], dp[i - j] + abs(z[i] - z[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
}

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

int main(){
    int A, B, coin=0;
    cin >> A >> B;

    if(A < B){
        coin += B;
        B--;
    }else{
        coin += A;
        A--;
    }
    if(A < B){
        coin += B;
        B--;
    }else{
        coin += A;
        A--;
    }

    cout << coin << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
namespace mp = boost::multiprecision;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr u64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef pair<i64,i64> P;
typedef v(i64) vi;
typedef v(vi) vvi;
typedef v(P) vp;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  vvi G(N+1);
  i64 a, b;
  rep(i,M){
    cin >> a >> b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vi ans(N+1,-1);

  queue<i64> que;
  que.push(1);
  ans[1] = 0;

  while(!que.empty()){
    i64 cur = que.front();
    que.pop();
    for(auto &p:G[cur]){
      if(ans[p]!=-1) continue;
      ans[p] = cur;
      que.push(p);
    }
  }

  cout << "Yes\n";

  rep(i,2,N+1){
    cout << ans[i] << "\n";
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main()
{
	string a;
	cin>>a;
	int cnt=0;
	
	if(a[0]=='1')cnt++;
	if(a[1]=='1')cnt++;
	if(a[2]=='1')cnt++;
	cout<<cnt;
	
	return 0;
 } 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scn = new Scanner(System.in);
		int arare = scn.nextInt();
		int count = 0;

		String[] arares = new String[arare];

		//各あられの色を配列に格納
		for(int i=0; i<arare; i++) {
				arares[i] = scn.next();
		}
		//配列をリストに変換
		List<String> listA=Arrays.asList(arares);

		//重複した値を削除
		List<String> listB = new ArrayList<String>(new HashSet<>(listA));


			for(int j=0; j<listB.size(); j++) {
				if(listB.contains("P"))
					count++;
				else if(listB.contains("W"))
					count++;
				else if(listB.contains("G"))
					count++;
				else if(listB.contains("Y"))
					count++;
			}
			if(count==3)
				System.out.println("Three");
			else
				System.out.println("Four");
	}
}


Measured memory_bytes: 23252
import java.util.Scanner;

/**
 * A - 9x9
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 九九として計算したい数値
        int a = sc.nextInt();
        int b = sc.nextInt();

        if( 1 <= a && a <= 9 && 1 <= b && b <= 9 ) {
            System.out.println( a * b );
        }
        else {
            System.out.println( -1 );
        }

        sc.close();
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a && b && !c) || (!a && !b && c)) puts("Open"); 
    else puts("Close");
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp [101][100001];
ll solve(ll n,ll v[],ll w[],ll W,ll N)
{
    
    if(n>=N||W<=0)
    return 0;
    if(w[n]>W)
    return dp[n][W]=solve(n+1,v,w,W,N);
    if((dp[n][W])!=-1)
    return dp[n][W];
    ll ans=max(v[n]+solve(n+1,v,w,W-w[n],N),solve(n+1,v,w,W,N));
    dp[n][W]=ans;
    return dp[n][W];
}
int main()
{
    ll n,W;
    cin>>n>>W;
    ll v[n],w[n],i,j;
    for(i=0;i<=100;i++)
    {
        for(j=0;j<=100000;j++)
        dp[i][j]=-1;
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
        cin>>v[i];
    }
   
    cout<<solve(0,v,w,W,n);
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<cstdint>

int const MAXN  = 2e5;
int64_t const MAXNN = 1<<18;
int64_t const INF = 1e12;
int N, Q, A, B, x;

struct seg_tree {
  int64_t base_;
  int64_t data_[MAXNN*2-1];
  int N_;

  void add_all(int64_t v) { base_ += v; }
  void init() {
    base_ = 0;
    for(N_ = 2; N_ <= N;) N_<<=1;
    std::fill_n(data_, N_*2-1, INF);
   }
  void set(int k, int64_t v) { set_inner(k, v - base_); }
  int64_t query(int a, int b) { return base_ + query_inner(a, b, 0, 0, N_); }
  void set_inner(int k, int64_t v) {
    k += N_-1;
    data_[k] = v;
    while(k > 0) {
      k = (k-1)/2;
      data_[k] = std::min(data_[k*2+1], data_[k*2+2]);
    }
  }
  int64_t query_inner(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return data_[k];
    int m = (l+r)/2;
    int64_t vl = query_inner(a, b, k*2+1, l, m);
    int64_t vr = query_inner(a, b, k*2+2, m, r);
    return std::min(vl, vr);
  }
};

seg_tree dpm, dpp;

inline int64_t cost(int x){ return std::max(x, -x); }
inline void set(int x, int64_t v) { dpm.set(x, v-x); dpp.set(x, v+x); }

int main() {
  int prev_x, x;
  std::cin >> N >> Q >> A >> B;
  dpm.init();
  dpp.init();
  std::cin >> x;
  set(A, cost(B - x));
  set(B, cost(A - x));
  for(int i = 1; i < Q; ++i) {
    int prev_x = x;
    std::cin >> x;
    int64_t tmp = std::min(dpm.query(1, x+1) + x, dpp.query(x, N+1) - x);
    dpp.add_all(cost(x - prev_x));
    dpm.add_all(cost(x - prev_x));
    set(prev_x, tmp);
  }
  int64_t ans = INF;
  for(int i = 1; i <= N; ++i) ans = std::min(ans, dpp.data_[i+dpp.N_-1]+dpp.base_-i);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[10],b[10],cl=0,cr=0,minl=1000,minr=1000;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>a[i];
    if(a[i]) ++cl;
    else ++cr;
  }
  for(int i=0;i<n;++i) cin>>b[i];
  if(cl==0||cr==0) cout<<"0"<<endl;
  else{
    for(int i=0;i<n;++i){
      if(a[i]) minr=min(minr,b[i]);
      else minl=min(minl,b[i]);
    }
    cout<<minl+minr<<endl;
  }
  return 0;
}



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

using namespace std;

int main(){
	
	int n;
	
	string s;
	
	cin >> n;
	cin >> s;
	
	if (s.length() % 2 != 0){
		cout << "No";
	} else {
		if (s.substr(0, s.length()/2) == s.substr(s.length()/2, s.length())){
			cout << "Yes";
		} else {
			cout << "No";
		}
	}
	
	
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int number_of_days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    number_of_days[a] = b;
    int res = 0;
    for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= number_of_days[i]; j++) {
			res += i == j;
		}
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;
typedef long double ld;


ll n;
vector< pll > v;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll f(ll X, ll Y)
{
        return (X*X + Y*Y);
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cout << setprecision(12) << fixed;
        cin >> n;
        ll ans = 0;
        ll X = 0;
        ll Y = 0;
        for(ll i=0;i<n;i++) {
                ll u,vv;
                cin >> u >> vv;
                v.pb(make_pair(u, vv));
                X += u;
                Y += vv;
                ans = max(ans , f(X, Y));
        }
        ll itr = 100005;
        while(itr--){
                X=0; Y=0;
                shuffle(v.begin(), v.end(), rng);
                for(ll i=0;i<n;i++){
                        //X += v[i].first; Y += v[i].second;
                        //ans=max(ans, f(X, Y));
                        if(f(X+v[i].first , Y + v[i].second) > f(X , Y)) {
                                X += v[i].first; Y += v[i].second;
                        }
                        ans= max(ans, f(X, Y));
                }
        }
        ld aa = 1.0*ans; aa = (ld)sqrt(aa);
        cout << aa << endl;
        return 0;
}


Measured memory_bytes: 384
fun main() {
    val (n, K) = run {
        val (n, k) = readLine()!!.split(' ').map { it.toLong() }
        n.toInt() to k
    }

    val t = Array(60) { IntArray(n + 1) }
    t[0] = IntArray(1) + readLine()!!.split(' ').map { it.toInt() }.toIntArray()

    for (i in 0 until 59) {
        for (j in 1..n) {
            t[i + 1][j] = t[i][t[i][j]]
        }
    }

    val ans = run {
        var k = K
        var v = 1
        for (i in (0 until 60).reversed()) {
            val l = 1L shl i
            if (l <= k) {
                v = t[i][v]
                k -= l
            }
        }
        v
    }

    println(ans)
}


Measured memory_bytes: 116260
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5;

int N;
string A, B, C;

int main() {

    cin >> N >> A >> B >> C;

    int ans = 0;
    REP (i, N) {
        if (A[i] == B[i] && B[i] == C[i]) continue;
        else if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) ans++;
        else ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

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

    String[] strs = reader.readLine().split(" ");
    int[] list = new int[strs.length];
    for (int i = 0; i < strs.length; i++)
      list[i] = Integer.parseInt(strs[i]);

    sort(list);
    for (int i = 0; i < list.length - 1; i++)
      System.out.print(list[i] + " ");
    System.out.println(list[list.length - 1]);
  }

  public static void sort(int[] array) {
    for (int i = 0; i < array.length - 1; i++) {
      for (int j = 0; j < array.length - 1; j++) {
        if (array[j] < array[j + 1]) {
          int stack = array[j];
          array[j] = array[j + 1];
          array[j + 1] = stack;
        }
      }
    }
  }

}

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

int main(){
  int count=0;
  string s,t;
  cin >> s>>t;
  for(int i=0;i<s.size();i++){
    if(s.at(i)==t.at(i)){
      count++;
    }
  }
  cout <<s.size()-count;
}

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s_reverse(string s) {
  string ret = "";
  for(int i = s.length()-1; i >= 0; i--) {
    ret += s[i];
  }
  return ret;
}

int main() {
  int n;
  while(cin >> n, n) {
    string s; cin >> s;
    for(int i = 0; i < n; i++) {
      string tmp = "";
      int cnt = 1;
      for(int j = 1; j < s.size(); j++) {
        if(s[j] == s[j-1]) cnt++;
        else {
          string t = "";
          while(cnt != 0) {
            t += cnt%10 + '0';
            cnt /= 10;
          }
          tmp += s_reverse(t) + s[j-1];
          cnt = 1;
        }
      }
     
      if(cnt != 0) {
        string t = "";
        while(cnt != 0) {
          t += cnt%10 + '0';
          cnt /= 10;
        }
        tmp += s_reverse(t) + s[s.size()-1];
      }
      s = tmp;
    }
    cout << s << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define repr(i, n) for(int i = n;i >= 0;--i)
#define reparr(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
	int n;
	string s;
	cin>>s>>n;
	reparr(i,s){
		if(s[i]!='1'){
			cout<<s[i]<<endl;
			break;
		}else{
			if(i==n-1){
				cout<<1<<endl;
				break;
			}

		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int n = sc.nextInt();
			
			int[] alpha = new int[26];
			Arrays.fill(alpha, Integer.MAX_VALUE);
			
			for(int i = 0; i < n; i++){
				
				int[] inner_alpha = new int[26];
				for(final char c : sc.next().toCharArray()){
					inner_alpha[c - 'a']++;
				}
				
				for(int j = 0; j < 26; j++){
					alpha[j] = Math.min(alpha[j], inner_alpha[j]);
				}
			}
			
			for(int i = 0; i < 26; i++){
				for(int j = 0; j < alpha[i]; j++){
					System.out.print((char)(i + 'a'));
				}
			}
			System.out.println();
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34 - rank 100
// 71 12 58 - rank 4
// 72 13 24

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i =0; i < n; ++i) {
        int a;
        cin >> a;
        ++mp[a - 1];
        ++mp[a];
        ++mp[a + 1];
    }
    int b = 0;
    for (auto p : mp) {
        b = max(b, p.second);
    }
    cout << b << "\n";

}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 4736
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
	}

	let mut ans = 0usize;
	let r = (n as f64).sqrt() as usize + 1;
	for a in 1..=r {
		for b in a..n {
			let ab = a * b;
			if ab >= n {
				break;
			}
			ans += 1;
			if a != b {
				ans += 1;
			}
			//println!("{}, {}, {}", a, b, n-ab);
		}
	}

	println!("{}", ans);
}


Measured memory_bytes: 2200
#include <iostream>
using namespace std;
int main()
{
    int n = 0, x = 0;
    cin >> n;
    if(n == 1)
    {
        cout << 1;
    }
    else if(n >= 2 && n <= 3)
    {
        cout << 2;
    }
    else if(n >= 4 && n <= 7)
    {
        cout << 4;
    }
     else if(n >= 8 && n <= 15)
    {
        cout << 8;
    }
    else if(n >= 15 && n <= 31)
    {
        cout << 16;
    }
    else if(n >= 32 && n <= 63)
    {
        cout << 32;
    }
    else if(n >= 64 && n <= 100)
    {
        cout << 64;
    }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  char s[100001];
  cin >> s;
  int n=strlen(s);
  vi check(26,0);
  REP(i,n) {
    int x=s[i]-'a';
    check[x]++;
  }
  int ans=-1;
  REP(i,26) {
    if(ans==-1&&check[i]==0) ans=i; 
  }
  if(ans!=-1) {
    char a='a'+ans;
    cout << a << endl;
  } else {
    cout << "None" << endl;
  }
  return 0;
}


Measured memory_bytes: 3676
use v5.18;
use warnings;
use Data::Dumper;

sub get_str {
  chomp(my $str = <>);
  $str;
}

my %cards = map { $_ => [ split //, get_str ] } "a" .. "c";

my $winner = rec("a");
say uc $winner;

sub rec {
  my $now = shift;
  my $next = shift @{ $cards{$now} };
  return $now unless $next;
  rec($next);
}


Measured memory_bytes: 1920
using System;

namespace B___Addition_and_Multiplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var res = 1;

            for (int i = 0; i < N; i++)
                res = Math.Min(res * 2, res + K);

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

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

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> conn(n);
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		conn[a].push_back(b);
		conn[b].push_back(a);
	}
	vector<int> done(n);
	int single = 0, bcount = 0, nbcount = 0;
	for(int r = 0; r < n; ++r){
		if(done[r]){ continue; }
		vector<int> passed;
		queue<int> q;
		q.push(r);
		done[r] = 1;
		while(!q.empty()){
			const int u = q.front();
			q.pop();
			passed.push_back(u);
			for(const int v : conn[u]){
				if(done[v]){ continue; }
				done[v] = -done[u];
				q.push(v);
			}
		}
		int b = 1, s = passed.size();
		for(const auto u : passed){
			for(const auto v : conn[u]){
				if(done[u] == done[v]){ b = 0; }
			}
		}
		if(s == 1){
			++single;
		}else if(b){
			++bcount;
		}else{
			++nbcount;
		}
	}
	ll answer =
		static_cast<ll>(n) * single * 2 -
		static_cast<ll>(single) * single;
	answer +=
		static_cast<ll>(bcount) * bcount * 2;
	answer +=
		static_cast<ll>(bcount + nbcount) * nbcount * 2 -
		static_cast<ll>(nbcount) * nbcount;
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 7932
/*
* @Author: _dp95
* @Date:   2019-06-28 01:59:08
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 3*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

char c[ MAX ][ MAX ] ;
int dp[ MAX ][ MAX ], m, n ;

void sol( ){
    dp[ 0 ][ 0 ] = ( c[ 0 ][ 0 ] != '#' ) ;
    for( int i = 1 ; i < m ; i++ ){
        if( c[ 0 ][ i ] == '#' )
            dp[ 0 ][ i ] = 0 ;
        else
            dp[ 0 ][ i ] = dp[ 0 ][ i - 1 ] ;
    }
    for( int i = 1 ; i < n ; i++ ){
        if( c[ i ][ 0 ] == '#' )
            dp[ i ][ 0 ] = 0 ;
        else
            dp[ i ][ 0 ] = dp[ i - 1 ][ 0 ] ;
    }
    for( int i = 1 ; i < m ; i++ ){
        for( int j = 1 ; j < n ; j++ ){
            if( c[ i ][ j ] == '#' )
                dp[ i ][ j ] = 0 ;
            else{
                dp[ i ][ j ] = ( dp[ i ][ j - 1 ] + dp[ i - 1 ][ j ] ) % MOD ;
            }
        }
    }
    cout << dp[ m - 1 ][ n - 1 ] % MOD << nl ;
}

int main( ){
  timesaver ;
  cin >> m >> n ;
  for( int i = 0 ; i  < m ; i++ ){
    for( int j = 0 ; j  < n ; j++ ){
        cin >> c[ i ][ j ] ;

    }
  }
  sol(  ) ;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl



signed main(void){
    string S;
    cin >> S;
    int N=S.size();N++;
    int A[514514];
    REP(i,N){
        A[i]=-INF;
    }
    if(S[0]=='<'){
        A[0]=0;
    }
    if(S[N-2]=='>'){
        A[N-1]=0;
    }
    REP(i,N-2){
        if(S[i]=='>' && S[i+1]=='<'){
            A[i+1]=0;
        }
    }
    
    REP(i,N-1){
        if(S[i]=='<' && A[i]!=-INF){
            A[i+1]=max(A[i+1],A[i]+1);
        }
    }
    RREP(i,N-1){
        if(S[i]=='>' && A[i+1]!=-INF){
            A[i]=max(A[i],A[i+1]+1);
        }
    }
    int Ans=0;
    REP(i,N){
        Ans+=A[i];
        //cout << A[i] << " ";
    }//cout << endl;
    cout << Ans << endl;
    
    return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vll p(N);
  REP(i,N) IN(p[i]);
  REP(i,N) p[i]+=1;

  vec_print(p);

  double tmp = 0.0;
  REP(i,K) tmp += p[i];
  double ans = tmp;
  REP(i,N-K){
    tmp -= p[i];
    tmp += p[i+K];
    chmax(ans,tmp);
  }

  printf("%.12lf\n", ans/2);

  return 0;
}

Measured memory_bytes: 3328