akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int n, m;
	LinkedList<E>[] edges;
	boolean[] f;
	
	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt(); m = sc.nextInt();
			int l = sc.nextInt(), k = sc.nextInt(), from = sc.nextInt(), to = sc.nextInt();
			if( (n|m|l|k|from|to) == 0 ) break;
			f = new boolean[n]; edges = new LinkedList[n];
			for(int i=0;i<n;i++) edges[i] = new LinkedList<E>();
			for(int i=0;i<l;i++) f[sc.nextInt()] = true;
			
			for(int i=0;i<k;i++) {
				int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
				edges[a].add(new E(b, c));
				edges[b].add(new E(a, c));
			}
			
			int t = dijkstra(from, to);
			System.out.println((t>=0? t: "Help!"));
		}
	}
	
	int dijkstra(int from, int to) {
		int[][] cost = new int[n][m+1];
		for(int[] a: cost) fill(a, INF);
		cost[from][m] = 0;
		PriorityQueue<Node> que = new PriorityQueue<Node>();
		que.add(new Node(from, m, 0));
		for(;!que.isEmpty();) {
			Node now = que.poll();
			if(now.v == to) return now.t;
			if(cost[now.v][now.m] != now.t) continue;
			for(E edge: edges[now.v]) for(int i=0;i<(f[now.v]? m-now.m+1:1);i++) {
				if( now.m+i-edge.c >= 0 && cost[edge.t][now.m+i-edge.c] > now.t + i + edge.c ) {
					debug(edge.t, m, m+i-edge.c, cost[edge.t][now.m+i-edge.c], now.t + i + edge.c);
					cost[edge.t][now.m+i-edge.c] = now.t + i + edge.c;
					que.add(new Node(edge.t, now.m+i-edge.c, now.t+i+edge.c));
				}
			}
		}
		
		return -1;
	}
	
	class Node implements Comparable<Node> {
		int t, m, v;
		Node(int v, int m, int t) {
			this.v = v;
			this.m = m;
			this.t = t;
		}
		@Override
		public int compareTo(Node o) {
			// TODO 自動生成されたメソッド・スタブ
			return t - o.t;
		}
	}
	
	class E {
		int t, c;
		E(int t, int c) {
			this.t = t;
			this.c = c;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
const int DAY = 30;
int main(){
  int n;
  while(cin >> n, n!=0){
    vector<long long > sison(n+1,1);
    for(int i = 0;i < n;i++){
      int f;cin >> f;
      for(int j = 0;j < f;j++){
	long long tmp;
	cin >> tmp;
	tmp = 1 << tmp;
	sison[i] = (sison[i] | (tmp));
      }
      //      cout << bitset<10>(sison[i]) << endl;
    }    
    vector<vector<long long > > dp(DAY+1,vector<long long >(n,0));
    for(int i = 0;i < n;i++){
      long long tmp = 1;
      tmp = tmp << (i+1);
      dp[0][i] = tmp;
      dp[0][i] = (dp[0][i] | 1);
      //cout << (dp[0][i]) << "ddddddddddddd" << endl;
    }
    int flag =0;
    int ans = -1;
    //    cout << all << endl;
    for(int i = 1;i <= DAY;i++){
      for(int j = 0;j < n;j++){
	dp[i][j] = dp[i-1][j];
      }
      for(int j = 0;j < n;j++){
	for(int k = 0;k < n;k++){
	  long long tmp = 1;
	  tmp = (tmp<<i);
	  if(((sison[j] & sison[k] & tmp) == tmp) && k != j){
	    dp[i][j] = dp[i][j] | dp[i][k];
	    //    cout << bitset<6>(dp[i][j]) << "$$$$$$$$$$$$$$$$$" << endl;
	    //cout << "ddddd" << i << "ddd" << j << "ddd" <<k<<endl;
	  }
	}
      }
      for(int j = 0;j < n;j++){
	//cout << (dp[i][j]) << endl;
	long long tmp = 1;
	tmp = ((tmp<<(n+1))-1);
	if(dp[i][j] == tmp){
	  ans =  i;
	  flag = 1;
	  break;
	}
      }
      if(flag == 1)break;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i = 0; i < n; i++) cin >> num.at(i);
  int ans = 0;
  for (int i = 1; i < n-1; i++){
    if ((num.at(i) > num.at(i-1)) && (num.at(i) < num.at(i+1))) ans++;
    if ((num.at(i) < num.at(i-1)) && (num.at(i) > num.at(i+1))) ans++;
  }
  cout << ans << endl;
}

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

int main(){
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q), tmp(N);
	for(int i = 0; i < Q; ++i) cin >> A[i];
	for(int i = 0; i < N; ++i) tmp[i] = 0;

	for(int k = 0; k < Q; ++k) {
		tmp[A[k] - 1] += 1;
	}

	for(int i = 0; i < N; ++i) {
		tmp[i] = K - Q + tmp[i];

		if(tmp[i] > 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;


int minans[200000];

int main(){
	int n, q;
	cin >> n >> q;
	vector<pair<int, pai > > stx(n);
	for (int i = 0; i < n; i++){
		cin >> stx[i].second.first >> stx[i].second.second >> stx[i].first;
	}
	sort(stx.begin(), stx.end());
	for (int i = 0; i < 200000; i++) minans[i] = -1;
	map<int, int> d;
	set<int> st;

	for (int i = 0; i < q; i++){
		int temp;
		cin >> temp;
		d.insert(make_pair(-1*temp, i));
		st.insert(-1*temp);
	}

	for (int i = 0; i < n; i++){
		int small = stx[i].first - stx[i].second.second + 1;
		int big = stx[i].first - stx[i].second.first;
		if (!st.empty()){
			auto smit = st.lower_bound(small);
			auto biit = st.upper_bound(big);
			for (auto iter = smit; iter != biit; iter++){
				minans[d[*iter]] = stx[i].first;
			}
			st.erase(smit, biit);
		}
	}
	for (int i = 0; i < q; i++){
		cout << minans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 25148
import sys
input = sys.stdin.readline

N, K, Q = list(map(int, input().split()))

score = [0] * N

for i in range(Q):
    a = int(input())
    score[a-1] += 1

for i in range(N):
    if Q - score[i] >= K:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4680
H,W,K = map(int,input().split())
S = [input() for _ in range(H)]
ans = [[0 for _ in range(W)] for _ in range(H)]
k = 0
for i in range(H):
  if S[i].count('#') == 0:
    for j in range(W):
      ans[i][j] = 0
  else:
    k += 1
    flag = False
    for j in range(W):
      if S[i][j] == '#':
        if flag:
          k += 1
        else:
          flag = True
      ans[i][j] = k
flag = False
for i in range(H):
  if ans[i][0] != 0:
    flag = True
    continue
  elif flag:
    for j in range(W):
      ans[i][j] = ans[i-1][j]
flag = False
for i in range(H-1,-1,-1):
  if ans[i][0] != 0:
    flag = True
    continue
  elif flag:
    for j in range(W):
      ans[i][j] = ans[i+1][j]
for i in range(H):
  print(*ans[i])


Measured memory_bytes: 47324
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)
	out := 0

	for i := 0; i < 3; i++ {
		if S[i:i+1] == T[i:i+1] {
			out++
		}
	}
	fmt.Println(out)
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int ctoi(const char c)
{
    if ('0' <= c && c <= '9') return {c - '0'};
    return -1;
}

int main()
{
    string S;
    cin >> S;

    vector<int> li;
    for (int i = 0; i < S.length() - 2; ++i)
    {
        int a = ctoi(S[i]);
        int b = ctoi(S[i + 1]);
        int c = ctoi(S[i + 2]);

        int d = 100*a + 10*b + c;

        li.pb(abs(753 - d));
    }

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

    cout << li[0] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int main()
{
    long long n;
    scanf("%lld", &n);
    for (long long i = sqrt(n);; i--)
    {
        if (n % i == 0)
        {
            i = n / i;
            int ans = 0;
            while (i)
            {
                i /= 10;
                ans++;
            }
            printf("%d", ans);
            break;
        }
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,T[107],M,P[107],X[107],wa=0;
  cin >> N;
  rep(i,N){
    cin >> T[i+1];
    wa+=T[i+1];
  }
  cin >> M;
  rep(i,M){
    cin >> P[i] >> X[i];
    cout << wa-(T[P[i]]-X[i]) << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n,m,k;
LL fac[200005],inv[200005];
LL a[200005],b[200005];
LL ans = 0;

LL kpw(LL x,LL y){
	LL ans = 1,tmp = x % N;
	while(y){
		if(y & 1) ans = (ans * tmp) % N;
		tmp = (tmp * tmp) % N;
		y >>= 1;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	fac[0] = 1; for(LL i = 1;i <= 200000;i ++) fac[i] = (fac[i - 1] * i) % N;
	inv[0] = 0; for(LL i = 1;i <= 200000;i ++) inv[i] = (inv[i - 1] + kpw(i,N - 2)) % N;
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> b[i];
	n --;
	for(LL i = 1;i <= n;i ++) a[i] = (b[i + 1] - b[i]) % N;
	for(LL i = 1;i <= n;i ++){
		ans += (((inv[n - i + 1] * fac[n]) % N) * a[n - i + 1]) % N;
		ans %= N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void){
  int a,b,c,d,t;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  t=a+b-c-d;
  if (t>0) printf("Left\n");
  else if (t==0) printf("Balanced\n");
  else printf("Right\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    string S, T, ans;
    cin >> S >> T;
    for(int i = 0; i < N; i++) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X, Y; cin >> X >> Y;
    int ans = 0;
    for(int a=0; a<=100; a++) {
        for(int b=0; b<=100; b++) {
            int x = a + b;
            int y = 2*a + 4*b;
            if(x == X and y == Y) ans++;
        }
    }

    if(ans > 0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int r,c;
  const int mod=1e9+7;
  cin>>r>>c;
  vector<vector<char>> grid(r,vector<char> (c));
  vector<vector<ll>> dp(r,vector<ll> (c,0));
  for(int i=0;i<r;i++){
  	for(int j=0;j<c;j++){
    	cin>>grid[i][j];
    }
  }
  for(int i=1;i<r;i++){
      
      if(grid[i][0]!='#')
      dp[i][0]=1;
      else break;
  }
  for(int i=0;i<c;i++){
  	if(grid[0][i]!='#')
      dp[0][i]=1;
    else break;
  }
  for(int i=1;i<r;i++){
  	for(int j=1;j<c;j++){
    	if(grid[i][j]=='#')	
      	    dp[i][j]=0;
      	else{
        	dp[i][j]=(dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
  }
  cout<<dp[r-1][c-1]<<endl;
  return 0;
  
  
}


Measured memory_bytes: 12140
function main(input){
	input=input.trim();
	const a=input.split(' ').map(Number);
	console.log(Math.abs(a[2]-a[0])<=a[3] || (Math.abs(a[1]-a[0])<=a[3] && Math.abs(a[1]-a[2])<=a[3])?'Yes':'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29572
#include <cstdio>
#include <algorithm>

using namespace std;

int a, b, c, r, p, q, s, x, y, t, i, f;

int solve(){
  t = -1;
  f = b * b - 4 * a * c;
  for(i=0;i*i<=f;i++) if(i*i == f) t = i;
  if(t >= 0){
    x = t - b;
    y = -(t + b);
    for(r=1;r<=a;r++){
      if(!(a%r)){
        p = a / r;
        for(i=0;i<2;i++){
          q = -p * x / (2 * a);
          s = -r * y / (2 * a);
          if((-p * x) % (2 * a) == 0 && (-r * y) % (2 * a) == 0 && (p > r || p == r && q >= s)) return 1;
          swap(x, y);
        }
      }
    }
  }
  return 0;
}

main(){
  while(scanf("%d%d%d",&a,&b,&c) && (a|b|c)){
    if(solve()) printf("%d %d %d %d\n",p,q,r,s);
    else printf("Impossible\n");
  }
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
typedef std::bitset<6> bit;

int main(){
  int H,W,K,black=0,ans=0;
  
  cin>>H>>W>>K;
  string str;
  vector<vector<string>> c(H,vector<string>(W,"0"));
  
  for(int i=0;i<H;i++){
    cin>>str;
    for(int j=0;j<W;j++){
      c.at(i).at(j)=str.substr(j,1);
     // cout<<c.at(i).at(j)<<" ";
    }
    //cout<<endl;
  }

  for(int H0b=0;H0b<pow(2,H)-1;H0b++){
    for(int W0b=0;W0b<pow(2,W)-1;W0b++){
      black=0;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            std::bitset<8> hight = std::bitset<8>(H0b)>>i & std::bitset<8>(1);
            std::bitset<8> wedth = std::bitset<8>(W0b)>>j & std::bitset<8>(1);
          if(hight==0 && wedth==0 && c.at(i).at(j)=="#") black++;
        }
      }
      if(black==K)ans++;
      //cout<< black;
    }  
  }
cout<< ans;
  //  cout<< std::bitset<8>(25) & std::bitset<8>("10000001");
  return 0;
}


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

int main(){
  int N,K;
  double p;
  vector<double> expected;
  cin >> N >> K;
  rep(i,N){
    cin >> p;
    expected.push_back((p+1)/2);
  }
  double max_sum = 0.0,now_sum = 0.0;
  rep(i,K){
    now_sum += expected.at(i);
  }
  max_sum = now_sum;
  
  for(int i=1;i<N-K+1;i++){ 
    now_sum -= expected.at(i-1);
    now_sum += expected.at(i+K-1);
    max_sum = max(max_sum, now_sum);
  }
  cout << fixed << setprecision(12) << max_sum << endl;
}
                   


Measured memory_bytes: 2420
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static LinkedList<Integer> divisors(int M){
    	LinkedList<Integer> d = new LinkedList<>();
    	for(int m= (int)(1+Math.sqrt(M)); m>0;m--){
    		if(m*m==M) d.add(m);
    		else if(M%m==0){
    			d.addFirst(M/m);
    			d.addLast(m);
    		}
    	}
    	return d;
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        LinkedList<Integer> d = divisors(M);
        for(int m:d){
        	if(M/m>=N){
        		System.out.println(m);
        		break;
        	}
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    if(i%2==1&&a%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    int a[n]; rep(i,n) cin>>a[i];
    long long ans=a[0]/2;
    a[0]%2?a[0]=1:a[0]=0;
    for(int i=1;i<n;i++){
        ans+=min(a[i-1],a[i]);
        a[i]=max(a[i]-a[i-1],0);
        ans+=a[i]/2;
        a[i]%2?a[i]=1:a[i]=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int prvze[5555555];
int ans[5555555];
char s[5555555];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='0')
		{
			prvze[i]=i;
		}
		else 
		{
			prvze[i]=prvze[i-1];
		}
		
	}
	/*for(int i=1;i<=n;i++)
	{
		cout<<prvze[i]<<endl;
	}*/
	//cout<<endl;
	for(int i=1;i<=n;i++)
	{
		ans[i]=ans[i-1];
		if(s[i]=='1')
		{
			if(s[i-1]=='0'&&s[i-2]=='1')
			{
				ans[i]=max(ans[i],ans[prvze[i-2]]+i-2-prvze[i-2]);
				ans[i]=max(ans[i],ans[prvze[i-2]+1]+i-2-prvze[i-2]-1);
			}
			if(s[prvze[i]-1]=='1')
			{
				ans[i]=max(ans[i],ans[prvze[i]-2]+i-prvze[i]);
			}
		}
		//cout<<ans[i]<<endl;
	}
	cout<<ans[n];
	return 0;
 } 

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M
int spf[200101]; 


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x,n,ans,t,i;
    cin>>n;
    int a[n];
    unordered_map<int,int> f,s;
    rep(i,0,n){
        cin>>a[i];
        f[a[i]]++;
    }
    sort(a,a+n);
    int c=0;
    for(int i:a){
        if(f[i]==1){
        	bool flag=1;
        	for(int j=1;j*j<=i;j++){
        		if(i%j==0 and (s[j] or s[i/j])) {
        			flag=0;break;
					}
				}
			if(flag) c++;
			}
		s[i]=1;
	}
    cout<<c;
}




 
 

Measured memory_bytes: 41440
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int a,n[4]={0,0,0,0};
    rep(i,6){
        cin>>a;
        n[a-1]++;
    }
    rep(i,4){
        if(n[i]>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);

    int count=0;
    int result=0;
    for(int i=1;i<=n;i++){
        int num=i;
        while(num>=1){
            num/=10;
            count++;
        }
        if(count%2==1){
            result++;
        }
        count=0;
    }
    printf("%d\n",result);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

bool flag1,flag2;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.length()-1]==b[0])
		flag1=true;
	if(b[b.length()-1]==c[0])
		flag2=true;
	if(flag1&&flag2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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


int main() {
vector<vector<long>> a(3,vector<long>(3));
for(int i=0;i<3;i++)for(int j=0;j<3;j++) cin>>a[i][j];
long N;
cin>>N;
vector<long> b(N);
for(int i=0;i<N;i++) cin>>b[i];

for(int k=0;k<N;k++){
  for(int i=0;i<3;i++)for(int j=0;j<3;j++) if(a[i][j]==b[k]) a[i][j]=-1;
}
bool flg =false;
for(int i=0;i<3;i++){
  if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1) flg=true;
}
for(int i=0;i<3;i++){
  if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1) flg=true;
}

if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1) flg=true;
if(a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1) flg=true;

if(flg) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string o, e; cin >> o >> e;
  int oi = 0, ei = 0;
  int o_len = o.size(), e_len = e.size();
  string ans = "";
  for (int i = 0; i < o_len + e_len; i++) {
    if (i % 2 == 0) ans += o[oi++];
    else ans += e[ei++];
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}

int main() {
  int n,m,c;cin>>n>>m>>c;
  int sum=0;
  vector<int> B(m);
  rep(i,m){
    cin>>B[i];
  }
  rep(i,n){
    int ans=0;
    rep(j,m){
      int com;cin>>com;
      ans+=com*B[j];
    }
    ans+=c;
    if(ans>0){
      sum++;
    }
  }
  cout<<sum<<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,i_len) for (ll i = 0, i##_len = (i_len); i < i##_len; i++)
#define ALL_OF(v) (v).begin(), (v).end()

int main() {

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

    ll a; cin >> a;
    string s; s.reserve(10000);
    for (ll b = 0, rl = 0, h = 0; b < a; ) {
        ll b2 = b + h + 1;
        if (b2 <= a) {
            b = b2;
            s.push_back(')');
            h++;
            if (b2 == a) {
                REP(i, h) {
                    s.push_back('(');
                }
                break;
            }
        } else {
            s.push_back('(');
            h--;
        }
    }
    reverse(ALL_OF(s));
    REP(i, s.size()) s[i] ^= ')' ^ '(';

    cout << s << endl;

}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;
}

Measured memory_bytes: 256
n = int(input())
points = []
centers = []
INF = 1e100
ans = INF

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __rmul__(self, other):
        return Point(self.x * other, self.y * other)

    def __mul__(self, other):
        return Point(self.x * other, self.y * other)

    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
        
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __truediv__(self, other):
        return Point(self.x / other, self.y / other)

    def sqdist(self, other):
        return (self.x - other.x) ** 2 + (self.y - other.y) ** 2

    def dist(self, other):
        return self.sqdist(other) ** 0.5

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def dot(self, other):
        return self.x * other.x + self.y * other.y

def three(A, B, C):
    a = B.sqdist(C)
    b = C.sqdist(A)
    c = A.sqdist(B)

    U = (a*(b+c-a)*A + b*(c+a-b)*B + c*(a + b - c)*C) / (a*(b+c-a) + b*(c+a-b) + c*(a + b - c) )
    return U

for i in range(n):
    x, y = map(int, input().split())
    points.append(Point(x,y))

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if (points[j] - points[i]).cross(points[k] - points[i]) == 0:continue
            centers.append(three(points[i], points[j], points[k]))

for i in range(n):
    for j in range(i+1, n):
        centers.append((points[i] + points[j]) / 2)

for center in centers:
    r = 0
    for i in range(n):
        r = max(r, center.dist(points[i]))
    ans = min(ans, r)
    
print(ans)
                      

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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main() { 
    ll tt = 1, n, q, m, l, r, c, i, j, k, w;
    boost;
    
    // cin >> tt;
    ll ans = 0;

    for(int _ = 1; _ <= tt; _++){
        cin >> n;
        cout << 1 - n << nl;
    }
}


Measured memory_bytes: 3644
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    //ll N;
    ll c = 0;
    string S, T;
    in >> S >> T;
    //vector<ll> X(N);
    if(S[0] == T[0])c++;
    if(S[1] == T[1])c++;
    if(S[2] == T[2])c++;
    out<<c<<endl;


}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector <int> vec(N);
  for(int i=0; i < M ; i++){
    int a,b;
    cin >> a >> b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  for(int i=0; i < N ; i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main()
{
    string s;
    cin>>s;
    int d=s.size();
    ll sum=0;
    rep(i,1<<d-1){
        bitset<10> tmp(i);
        int a=-1;
        rep(j,d-1){
            if(tmp.test(j)){
                string t=s.substr(a+1,j-a);
                ll b=stoll(t);
                sum+=b;
                a=j;
            }
        }
        string u=s.substr(a+1,d-a-1);
        ll c=stoll(u);
        sum+=c;
    }
    cout<<sum<<endl;
}

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

int gcd(int a,int b) {
    if(b == 0) return a;
    else return gcd(b,a % b);
}

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

  vector<int> A(N);
  for(int i = 0;i < N;i++) {
      cin >> A.at(i);
  }

  for(int i = 0;i < N - 1;i++) {
      A.at(i + 1) = gcd(A.at(i),A.at(i + 1));
  }

  cout << A.at(N - 1) << endl;

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) {
        cin >> p.at(i);
        p.at(i)--;
    }
    
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(p.at(i)==i) cnt++;
        else {
            ans += (cnt+1)/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)/2;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 640
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
from functools import lru_cache

INF = 1 << 60

#Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ここから書き始める
n, m, k = map(int, input().split())
uf = UnionFind(n)
dame = [set() for i in range(n)]
# print(uf)

# print(direct)
a = [0] * m
b = [0] * m
c = [0] * k
d = [0] * k
for i in range(m + k):
    x, y = map(int, input().split())
    if i < m:
        a[i] = x - 1
        b[i] = y - 1
        uf.union(x - 1, y - 1)
    else:
        c[i - m] = x - 1
        d[i - m] = y - 1
e = [set() for i in range(n)]
for i in range(m):
    if uf.same(a[i], b[i]):
        e[a[i]].add(b[i])
        e[b[i]].add(a[i])
for i in range(k):
    # if c[i] == 6 and d[i] == 4:
    #     # print(uf.same(c[i], d[i]))
    if uf.same(c[i], d[i]):
        e[c[i]].add(d[i])
        e[d[i]].add(c[i])
# print(e)
# print(uf)
for i in range(n):
    print("%d " % (uf.size(i) - len(e[i]) - 1), end="")




Measured memory_bytes: 90600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	//int ans=0;
	cin >>n;
	vector<ll>a(n);
	V ans(n,0LL);
	ll sum=0LL;
	rep(i,n){
		cin>>a[i];
		a[i]*=2LL;
		if(i%2){
			sum-=a[i];
		}else{
			sum+=a[i];
		}
	}
	ans[0]=sum/2;
	//clog<<ans[0]<<endl;
	ans[1]=(a[0]/2 -ans[0]/2)*2;
	//clog<<ans[1]<<endl;
	for(int i=2;i<n;i++){
		ans[i]=(a[i-1]/2 - ans[i-1]/2)*2;
		//ans[1]=(a[0]/2 -ans[0]/2)*2;
	}
	rep(i,n){
		cout<<ans[i];
		if(i!=n-1){
			cout<<" ";
		}
	}
	cout<<endl;
}
/*
a_1 = f_(n-1) + f_0
a_2 = f_(0) + f(1)
.
.
.
a_n = f_(n-2)+ f(n-1)

*/

/*
2*2 = f_2 + f_0  +
2*2 = f_0 + f_1  -
4*2 = f_1 + f_2  +

4*2 = 8= 2 *f_2 =.> f_2 = 4 



*/

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

const int bits=40;
int32_t main() {
    int n, k; cin>>n>>k; int a[n]; rep(i, n) cin>>a[i];
    vll elem; elem.reserve(n*(n+1)/2);
    ll pf[n+1]={0};
    rep1(i, n) {
        pf[i]=pf[i-1]+a[i-1];
        rep(j, i) elem.pb(pf[i]-pf[j]);
    }
    ll ans=0;
    for(int i=bits; i>=0; i--) {
        int cnt=0; bool vis[elem.size()]={0};
        rep(j, elem.size()) if(elem[j]&(1LL<<i)) cnt++, vis[j]=1;
        if(cnt<k) continue;
        ans|=(1LL<<i);
        vll cur; cur.reserve(cnt);
        rep(j, elem.size()) if(vis[j]) cur.pb(elem[j]);
        elem=cur;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = Integer.parseInt(scan.nextLine());
	String[] judge = {"AC", "WA", "TLE", "RE"};
    int[] count = {0, 0, 0, 0};
    
    for (int i=0; i<N; i++) {
      String tmp = scan.nextLine();
      
      switch(tmp) {
        case "AC":
            count[0]++;
         	break;
        case "WA":
            count[1]++;
         	break;
        case "TLE":
            count[2]++;
         	break;
        case "RE":
            count[3]++;
         	break;
      }
    }
    
    for (int i=0; i<4; i++) {
      System.out.println(judge[i] + " x " + count[i]);
    }
  }
}


Measured memory_bytes: 61192
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
a2 = 0 # 一番最初の値を求める X1 = total A - 1つずつ (最初以外は、ペアとなる(足してXになる)相手が存在する) 
for i in range(1, n, 2):
    a2 += a[i]
 
ans = [0] * n
ans[0] = sum_a - 2*a2
for i in range(1, n):
    ans[i] = 2*a[i-1] - ans[i-1] # 最初がわかれば、あとは漸化式 Xi + Xi+1 = 2Aiに沿って算出可能
print(*ans)

Measured memory_bytes: 64484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    if (K < A) {
        cout << A - K << " " << B << endl;
    } else if (B - (K - A) > 0) {
        cout << 0 << " " << B - (K - A) << endl;
    } else {
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int i=1,x=i,mode=0,n=in.nextInt();
		
		while(true) {
			if(mode==4)break;
			switch(mode) {
			case 0:
				x=i;
				if(x%3==0) {
					System.out.print(" "+i);
					mode=2;
				}
				else mode=1;
				break;
				
			case 1:
				if(x%10==3) {
					System.out.print(" "+i);
					mode=2;
				}
				else {
					x/=10;
					if(x>0)mode=1;
					else mode=2;
				}
				break;
				
			case 2:
				if(++i<=n)mode=0;
				else mode=4;
				break;
			}
		}
		
		System.out.println();
	}
	
}



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

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[0]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<utility>
#include<memory>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
typedef long long ll;

using namespace std;

const int mod=1e9+7;
const int INF=1<<25;

void solve(int n){
  int dp[11][11];
  fill(dp[0],dp[10],INF);
  rep(i,9) dp[i][i]=0;
  int a,b,c;
  int first=10,last=0;
  int ans1;
  ll ans2=INF,temp;
  rep(i,n){
    cin >> a >> b >> c;
    first=min(first,min(a,b));
    last=max(last,max(a,b));
    dp[a][b]=dp[b][a]=c;
  }
  REP(k,first,last+1) REP(i,first,last+1) REP(j,first,last+1){
    dp[j][i]=dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
  }
  REP(i,first,last+1){
    temp=0;
    REP(j,first,last+1){
      temp+=dp[i][j];
    }
    if(temp<ans2){
      ans2=temp;
      ans1=i;
    }
  }
  cout << ans1 << " " << ans2 << endl;

  return ;
}
int main(){
  int n;
  while(true){
    cin >> n;
    if(!n)  break;
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 3092
#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...); }

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n  >>m;
	VI a(m), b(m), c(m);
	rep(i, m){
		cin >>a[i] >>b[i];
		rep(j, b[i]){
			int cc;
			cin >> cc; c[i] |= 1<<(cc-1);
		}
	}
	const ll INF=1LL<<55;
	VL dp(1<<n, INF);
	dp[0] =0;
	rep(i, m){
		rep(j, 1<<n){
			int nj = j | c[i];
			dp[nj] = min(dp[nj], dp[j] + a[i]);
		}
	}
	
	ll ans = dp[(1<<n) -1];
	if(ans == INF) ans =-1;
	cout << ans <<"\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

int mat[10][5];

int main(){
  int h;
  while(scanf("%d", &h), h){
    rep(i,h)
      rep(j,5)
      scanf("%d", &mat[i][j]);

    int res=0;
    while(true){
      // remove stones
      bool changed=false;
      rep(i,h){
	int base=mat[i][2];
	if(base<=0) continue;
	int idx=0;
	while(idx<5){
	  if(mat[i][idx]!=base){idx++; continue;}
	  int cnt=0;
	  while(idx<5 && mat[i][idx]==base){ idx++; cnt++; }
	  if(cnt>=3){
	    changed=true;
	    res += base*cnt;
	    rep(k,cnt) mat[i][idx-k-1]=0;
	    break;
	  }
	}
      }

      if(!changed) break;

      // drop stones
      rep(i,5){
	int height=h-1;
	while(height>0){
	  bool flg=false;
	  if(mat[height][i]<=0){
	    for(int tmp=height; tmp>0; tmp--){
	      mat[tmp][i]=mat[tmp-1][i];
	      if(mat[tmp-1][i]>0) flg=true;
	    }
	    mat[0][i]=0;
	  }
	  if(mat[height][i]!=0 || !flg) height--;
	}// for
      }// rep
    }

    cout<<res<<endl;

  }
  return 0;
}

Measured memory_bytes: 1208
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    S = list(input())
    k = II()
    n = len(S)
    S2 = S[:]

    if len(set(S)) == 1:
        print(n * k // 2)
    else:
        cnt = 0
        for i in range(n-1):
            j = i + 1
            si, sj = S[i], S[j]
            if si == sj:
                S[j] = i
                cnt += 1
        if S[0] == S[-1]:
            moji = S[0]
            sl = 0
            for s in S2:
                if s == moji:
                    sl += 1
                else:
                    break
            sr = 0
            for s in S2[::-1]:
                if s == moji:
                    sr += 1
                else:
                    break

            print(cnt * k + ((sl+sr)//2 - sl//2 - sr//2) * (k - 1))
        else:
            print(cnt * k)


if __name__ == '__main__':
    solve()


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

static const int MAX = 100;
static const long long INFTY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INFTY) continue;
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INFTY) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i==j) ? 0 : INFTY);
    }
  }

  for (int i = 0; i < e; i++) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for (int i = 0; i < n; i++) if (d[i][i] < 0) negative = true;

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j) cout << " ";
        if (d[i][j] == INFTY) cout << "INF";
        else cout << d[i][j];
      }
      cout << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3204
import numpy as np


def is_good(mid, key):
    x = A - mid // F
    return x[x > 0].sum() <= key


def binary_search(key):
    bad, good = -1, 10 ** 18
    while good - bad > 1:
        mid = (bad + good) // 2
        if is_good(mid, key):
            good = mid
        else:
            bad = mid
    return good


N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
F = np.array(input().split(), dtype=np.int64)
A.sort()
F[::-1].sort()
print(binary_search(K))


Measured memory_bytes: 51800
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long int n,r,ans,t;
        cin>>n>>r;
        if(n<10)
        {
            t=100*(10-n);
            ans=r+t;
            cout<<ans<<endl;
        }
        else
            cout<<r<<endl;
return 0;
}










Measured memory_bytes: 256