akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

long long bitcount[20];

bool judge_bit(){
  bool flag = true;
  for(int i=0;i<20;i++){
    if(bitcount[i] >= 2) flag = false;
  }

  return flag;
}

void plus_bit(long long x){
  for(int i=0;i<20;i++){
    if(x & (1 << i)) bitcount[i] += 1;
  }

  return ;
}

void minus_bit(long long x){
  for(int i=0;i<20;i++){
    if(x & (1 << i)) bitcount[i] -= 1;
  }

  return ;
}

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

  for(int i=0;i<20;i++){
    bitcount[i] = 0;
  }

  int r = 0;
  bool flag = true;
  for(int l=0;l<n;l++){
    while(r < n){
      plus_bit(a[r]);
      flag = judge_bit();
      if(!flag){
        minus_bit(a[r]);
        break;
      }
      r += 1;
    }
    minus_bit(a[l]);
    ans += r-l;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
const int N=2006, M=20000;
int n, m, head[N], to[M], cap[M], cost[M], next[M], queue[65536], prev[M];
bool vis[N];
long long dis[N];
template<class T1, class T2> bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
void add_edge(int u, int v, int mx, int w) {
	to[m]=v, cap[m]=mx, cost[m]=w, next[m]=head[u], head[u]=m++;
	to[m]=u, cap[m]=0, cost[m]=-w, next[m]=head[v], head[v]=m++;
}
int main() {
	assert(scanf("%d", &n)==1);
	memset(head, -1, (2*n+6)*sizeof(int));
	for(int i=6; i<n+6; ++i) {
		int x, y, c;
		assert(scanf("%d%d%d", &x, &y, &c)==3);
		add_edge(0, i, c, 0);
		add_edge(i, 2, c, x+y);
		add_edge(i, 3, c, x-y);
		add_edge(i, 4, c,-x+y);
		add_edge(i, 5, c,-x-y);
	}
	for(int i=n+6; i<2*n+6; ++i) {
		int x, y, c;
		assert(scanf("%d%d%d", &x, &y, &c)==3);
		add_edge(i, 1, c, 0);
		add_edge(5, i, c, x+y);
		add_edge(4, i, c, x-y);
		add_edge(3, i, c,-x+y);
		add_edge(2, i, c,-x-y);
	}
	long long ans=0;
	while(true) {
		unsigned short ql=0, qr=0;
		memset(dis+1, 192, (2*n+5)*sizeof(long long));
		queue[qr++]=0;
		while(ql!=qr) {
			int v=queue[ql++];
			vis[v]=false;
			for(int i=head[v]; ~i; i=next[i])
				if(cap[i]&&cmax(dis[to[i]], dis[v]+cost[i])) {
					prev[to[i]]=i;
					if(!vis[to[i]]) vis[queue[qr++]=to[i]]=true;
				}
		}
		if(dis[1]<0) break;
		int flow=1e9;
		for(int i=1; i!=0; i=to[prev[i]^1]) cmin(flow, cap[prev[i]]);
		for(int i=1; i!=0; i=to[prev[i]^1]) cap[prev[i]]-=flow, cap[prev[i]^1]+=flow;
		ans+=dis[1]*flow;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int a,b,c,ans=0;
    scanf("%d%d%d",&a,&b,&c);
    int af=a,bf=b,cf=c;
    while(1){
        int a1,b1,c1;
        a1=a;
        b1=b;
        c1=c;
        if (a%2==1 || b%2==1|| c%2==1){
            printf("%d\n",ans);
            break;
        } else {
            a=b1/2+c1/2;
            b=c1/2+a1/2;
            c=a1/2+b1/2;
            ans++;
            if (a==af && b==bf && c==cf){
                printf("-1\n");
                break;
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
using namespace std;

int main(){

    int n,m;
    scanf("%d %d",&n,&m);
    vector<vector<int> > graph(n+1);

    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        graph[a].push_back(b);
    }
    vector<vector<int> > dist(n+1,vector<int>(3,-1));
    queue<pair<int,int> > q;
    int s,t;
    scanf("%d %d",&s,&t);
    q.push(mp(s,0));
    dist[s][0] = 0;
    while(!q.empty()){
        int u = q.front().f;
        int est = q.front().s;
        int nextEst=est+1;
        nextEst%=3;
        q.pop();
        for(int i=0;i<graph[u].size();i++){
            int v = graph[u][i];
            if(dist[v][nextEst]==-1){
                dist[v][nextEst] = dist[u][est] +1;
                q.push(mp(v,nextEst));
            }
        }
    }
    printf("%d\n",dist[t][0]==-1? -1:dist[t][0]/3);
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  int n = N;
  int sum = 0;
  while (n % 10 != 0) {
    sum += n % 10;
    n /= 10;
  }
  cout << ((N % sum == 0) ? "Yes" : "No") << endl;
  return 0;
}



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

constexpr int MAX = 100;

int main()
{
    std::array<int, MAX + 1> cnt = {0};

    int key;
    while (std::cin >> key) {
        cnt.at(key)++;
    }

    std::vector<int> modes;
    int mode = 0;
    for (auto key = 1; key <= MAX; key++) {
        if (cnt.at(key) == mode) {
            modes.push_back(key);
        } else if (cnt.at(key) > mode) {
            mode = cnt.at(key);
            modes.clear();
            modes.push_back(key);
        }
    }

    for (auto i = 0; i < modes.size(); i++) {
        std::cout << modes.at(i) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1212
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        sc.close();
        int gt=c-(a-b);
        if(gt<0)gt=0;
        System.out.println(gt);
    }
}

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

const int INF = 50;
int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n) {
    cin >> s[i];
  }

  string ans;
  for (char c='a'; c<='z'; c++){
    int small = INF;
    rep(i,n){
      int cnt = 0;
      rep(j,s[i].length()){
        if (s[i][j] == c){
          cnt++;
        }
      }
      small = min(small,cnt);
    }
    rep(i,small) ans += c;
  }

  cout << ans << endl;
}


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

int main() {
  int a, b; cin >> a >> b;
  int count = 0;

  int i;
  for (i = a; i <= b; i++){
    string s = to_string(i);
    if (s[0] == s[4] && s[1] == s[3]) {
      count++;
     }
  }
  p(count);
}


Measured memory_bytes: 256
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define fst first
#define snd second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int bf0 = (1<<0);
const unsigned int bf1 = (1<<1);
const unsigned int bf2 = (1<<2);
const unsigned int bf3 = (1<<3);
const unsigned int bf4 = (1<<4);
const unsigned int bf5 = (1<<5);
const unsigned int bf6 = (1<<6);
const unsigned int bf7 = (1<<7);


//#include <boost/format.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
namespace bm = boost::math;

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

int main(void){
  int n; cin>>n;
  vector<int> a(n);
  FOR(i,0,n){
    cin >> a[i];
  }
  auto pos = std::min_element(std::begin(a), std::end(a));
  int min_a = *pos;
  int max_a=a[0];
  
  // FOR(i,0,n){
  //   cout << a[i] <<" ";
  // }
  // cout<<endl;
  FOR(i,1,n){
    max_a = max( a[i] , max_a );
    if (a[i-1]>=a[i]+2) {
      cout << "No" << endl;
      return 0;
    }else if (a[i-1] >= a[i]) {  // a[i-1] > a[i] > a[i-1] -2 つまり a[i] = a[i-1] - 1
      if (max_a >= a[i] + 2) {
        cout << "No" << endl;
        return 0;
      }
    }
    // if (a[i] > max1) {
    //   max1 = a[i];
    //   max2 = max1;
    // }else if(a[i] > max2 ){
    //   max2=a[i];
    // }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 640
n = int(input())
min_counts = [100] * 26
for _ in range(n):
  s = input()
  counts = [0] * 26
  for c in s:
    i = ord(c) - ord('a')
    counts[i] += 1
  for i in range(26):
    min_counts[i] = min(min_counts[i], counts[i])
#print(min_counts)
ans = []
for i in range(26):
  c = chr(ord('a') + i)
  ans.append(c * min_counts[i])
print(''.join(ans))
  

Measured memory_bytes: 65208
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int r = sz(s)-1;
  while(r >= 0) {
    if(s[r] == 'r') {
      if(r-5>=0 && s.substr(r-5,6) == "eraser") {
        r -= 6;
      } else if(r-6>=0 && s.substr(r-6,7) == "dreamer") {
        r -= 7;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    } else if(s[r] == 'e') {
      if(r-4>=0 && s.substr(r-4,5) == "erase") {
        r -= 5;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    } else if(s[r] == 'm') {
      if(r-4>=0 && s.substr(r-4,5) == "dream") {
        r -= 5;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int d[210][210];
    rep(i, n) rep(j, n) d[i][j] = INF;
    rep(i, n) d[i][i] = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        rep(j, n) if (s[j] == '1') d[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    rep(i, n) rep(j, n) rep(k, n)
    {
        int len = d[i][j] + d[j][k] + d[k][i];
        if (len % 2 == 1)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = -1;
    rep(i, n) rep(j, n) ans = max(ans, d[i][j] + 1);
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();

        int[] aArr = new int[n];
        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }
        Arrays.sort(aArr);

        Integer[] fArr = new Integer[n];
        for (int i = 0; i < n; i++) {
            fArr[i] = sc.nextInt();
        }
        Arrays.sort(fArr, Comparator.reverseOrder());

        long left = 0;
        long right = 0;
        for (int i = 0; i < n; i++) {
            right = Math.max(right, (long) aArr[i] * fArr[i]);
        }

        debug(aArr, fArr);
        while (left != right) {
            debug(right, left);
            long j = (right + left) / 2;
            long result = 0;
            for (int i = 0; i < n; i++) {
                result += Math.max(0, aArr[i] - j / fArr[i]);
                if (result > k) break;
            }
            if (result <= k) {
                right = j;
            } else {
                left = j + 1;
            }
        }
        System.out.println(left);


    }

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

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


Measured memory_bytes: 167284
#include <iostream>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];

void preParse(int u){
	if(u==NIL) return;
	cout<<" "<<u;
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u==NIL) return;
	inParse(T[u].l);
	cout<<" "<<u;
	inParse(T[u].r);
}

void postParse(int u){
	if(u==NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	cout<<" "<<u;
}

int main(){
	int v,l,r,root=0;
	cin>>n;
	
	for(int i=0;i<n;i++) T[i].p=NIL;
	
	for(int i=0;i<n;i++){
		cin>>v>>l>>r;
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL) T[l].p=v;
		if(r!=NIL) T[r].p=v;
	}
	
	for(int i=0;i<n;i++) if(T[i].p==NIL) root=i;
	
	cout<<"Preorder"<<endl;
	preParse(root);
	cout<<endl<<"Inorder"<<endl;
	inParse(root);
	cout<<endl<<"Postorder"<<endl;
	postParse(root);
	cout<<endl;
	
	return 0;
}



Measured memory_bytes: 3124
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    char N[10];
    cin>>N;
    if(N[0]==N[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <bitset>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
#define	pr_line(arr,s,e) for(ll abc = s;abc < e;abc++){ if(abc != s) printf(" ");cout << arr[abc];}puts("");

#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rui(n) scanf("%u",&n)
#define rui2(a,b) scanf("%u %u",&a,&b)
#define rui3(a,b,c) scanf("%u %u %u",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define debug(str,x) cout << str << ":" << x << endl
#define ll long long
#define int64 __int64
#define ui unsigned int

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-9-29
//Author：HarryBlackCat

int arr[maxn];

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	int n;
	while(~ri(n)) {
		for(int i = 0; i < n; i++) {
			ri(arr[i]);
		}

		map<int,int> mapp;
		map<int,int>::iterator iter;
		for(int i = 0; i < n; i += 2) {
			mapp[arr[i]]++;
		}
		
		vector<pair<int,int> >one,two;
		for(iter = mapp.begin(); iter != mapp.end(); iter++) {
			one.push_back(make_pair(iter->second,iter->first));
		}

		mapp.clear();
		for(int i = 1; i < n; i += 2) {
			mapp[arr[i]]++;
		}
		for(iter = mapp.begin(); iter != mapp.end(); iter++) {
			two.push_back(make_pair(iter->second,iter->first));
		}

		sort(one.begin(),one.end(),greater<pair<int,int> >());
		sort(two.begin(),two.end(),greater<pair<int,int> >());
		

		if(one[0].second != two[0].second){
			int sum = n / 2 - one[0].first;
			sum += n / 2 - two[0].first;
			pr(sum);
		//	pr("fdfds");
		}
		else if(one[0].second == two[0].second && one[0].first == two[0].first && one[0].first == n / 2){
			pr(n / 2);//pr("fdfds");
		}
		else if(one[0].second == two[0].second){
			if(one.size() >= 2 && two.size() >= 2){
				int sum = n / 2 - one[0].first;
				sum += n / 2 - two[1].first;
				
				int sum2 = n / 2 - one[1].first;
				sum2 += n / 2 - two[0].first;
				
				pr(min(sum2,sum));
			}
			else if(one.size() == 1 && two.size() >= 2){
				int sum = n / 2 - one[0].first;
				sum += n / 2 - two[1].first;
				pr(sum);
			}
			else if(one.size() >= 2 && two.size() == 1){
				int sum = n / 2 - one[1].first;
				sum += n / 2 - two[0].first;
				pr(sum);
			}
			
		}
	}
	return 0;
}

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

int main(){
    int N; cin >> N;
    char A[N];
    rep(i,N) cin >> A[i];
    bool ans=false;
    
    rep(i,N){
        if(A[i]=='Y') ans=true;
    }
    
    if (ans) cout << "Four";
    else cout << "Three";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int mod(int val,int M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

int RS(int N, int P, int M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0;i < N;i++) {
        if(S.at(i) == '1') {
            count++;
        }
    }
    if(count == 1) {
        int count1 = 0;
        int cnt1 = 1;
        reverse(S.begin(),S.end());
        for(int i = 0;i < N;i++) {
            if(S.at(i) == '1') {
                count1 = (count1 + cnt1) % (count + 1);
            }
            cnt1 = cnt1 * 2 % (count + 1);
        }
        reverse(S.begin(),S.end());
        for(int i = 0;i < N;i++) {
            int cnt3 = 0;
            int ret = 1;
            if(S.at(i) == '1') {
                cout << 0 << endl;
                continue;
            }
            else {
                cnt3 = (count1 + RS(2,N - (i + 1),count + 1)) % (count + 1);
            }
            while(cnt3 != 0) {
                ret++;
                int cnt4 = cnt3;
                int cnt5 = 0;
                while(cnt4 > 0) {
                    cnt5 += cnt4 % 2;
                    cnt4 /= 2;
                }
                cnt3 = cnt3 % cnt5;
            }
            cout << ret << endl;
        }
        return 0;
    }
    int count1 = 0;
    int count2 = 0;
    int cnt1 = 1;
    int cnt2 = 1;
    reverse(S.begin(),S.end());
    for(int i = 0;i < N;i++) {
        if(S.at(i) == '1') {
            count1 = (count1 + cnt1) % (count + 1);
            count2 = (count2 + cnt2) % (count - 1);
        }
        cnt1 = cnt1 * 2 % (count + 1);
        cnt2 = cnt2 * 2 % (count - 1);
    }
    reverse(S.begin(),S.end());
    for(int i = 0;i < N;i++) {
        int cnt3 = 0;
        int ret = 1;
        if(S.at(i) == '1') {
            cnt3 = mod(count2 - RS(2,N - (i + 1),count - 1),count - 1);
        }
        else {
            cnt3 = (count1 + RS(2,N - (i + 1),count + 1)) % (count + 1);
        }
        while(cnt3 != 0) {
            ret++;
            int cnt4 = cnt3;
            int cnt5 = 0;
            while(cnt4 > 0) {
                cnt5 += cnt4 % 2;
                cnt4 /= 2;
            }
            cnt3 = cnt3 % cnt5;
        }
        cout << ret << endl;
    }
}

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

int main(void){
  int n, x;

  cin >> n;

  for ( int i = 1; i <= n; i++ ){
    x = i;

    if ( x % 3 == 0 ){
      cout << " " << i;
    }else{
      while(1){
	if ( x % 10 == 3 ){
	  cout << " " << i;
	  break;
	}else if( x / 10 > 0){
	  x /= 10;
	}else{
	  break;
	}
      }
    }
    
  }
  cout << endl;
  
  return 0;
}

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

int gcd(int m,int n){
	if(n==0)
		return m;
	
	return gcd(n,m%n);
}

int main(){
	while(true){
		int a,b;
		cin>>a>>b;
		
		if(cin.eof())
			break;
			
		int g=gcd(a,b);
		cout<<g<<' '<<a/g*b<<endl;
	}
	return 0;
}					

Measured memory_bytes: 3016
#include<stdio.h>

int main(){
  int s;
  char num[4];
    
  scanf("%s",num);
  
  if(num[0]== num[1] || num[1] == num[2] || num[2] == num[3]){ 
    printf("Bad");
  } else { 
    printf("Good");
    }
  

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1e5+10;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
void solve()
{
    ll a[5];
    ll res;
    rep0(i,5) {
        cin>>a[i];
        if(a[i]==0)
            res = i+1;
    }
    cout<<res<<endl;
}
int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
	ll t,n,k,sm,i;
	string s;
	cin >> s;
	sm=0;
	for(i=0;i<s.length();i++)
	{
		sm+=(ll)((int)(s[i]-48));
	}
	if(sm%9==0)
	cout << "Yes";
	else
	cout << "No";
	
	return 0;
}

Measured memory_bytes: 3632
import java.util.*
fun main(args:Array<String>) {
    val (N,M) = readLine()!!.split(" ").map(String::toInt)
    var step_list = Array(N + 1) {0L}
    (1..M).forEach {
        val i = readLine()!!.toInt()
        step_list[i] = -1L
    }
    step_list[0] = 1
    step_list[1] = if(step_list[1] < 0L) {step_list[1]} else {1L}
    // step_list[2] = if(step_list[2] < 0L) {step_list[1]} else {if(step_list[0] <0L) {1L} else {2L}}

    for (i in 2..N) {
        if(step_list[i] >= 0L) {
            step_list[i] = if(step_list[i-2] < 0L && step_list[i - 1] < 0L) {
                -1L 
            } else {
               ( if(step_list[i -2] >=0L) {step_list[i -2]} else {0L} + if(step_list[i - 1] >=0L) {step_list[i -1]} else {0L}) %  1000000007L
            } 
        }
    }

    if(step_list[N] < 0) {0} else {step_list[N]}.run(::println)
}

Measured memory_bytes: 41912
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a+b==15){
        printf("+\n");
    }
    else if(a*b==15){
        printf("*\n");
    }
    else printf("x\n");


    return 0;
}


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

a, b, c = map(int, input().split())

count = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a_temp = a // 2
    b_temp = b // 2
    c_temp = c // 2
    if a == b_temp + c_temp and b == a_temp + c_temp and c == a_temp + b_temp:
        print("-1")
        sys.exit()
    a = b_temp + c_temp
    b = a_temp + c_temp
    c = a_temp + b_temp
    count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int A[100000], N;
int main(){
  int i;
  long long mn, mx;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  if(A[N-1]!=2){
    wt_L(-1);
    putchar_unlocked('\n');
    return 0;
  }
  mx = 3;
  mn = 2;
  for(i=N-2;i>=0;i--){
    mn = (divup_L(mn,A[i])) * A[i];
    mx = (mx / A[i]) * A[i] + (A[i]-1);
    if(mx < mn){
      wt_L(-1);
      putchar_unlocked('\n');
      return 0;
    }
  }
  wt_L(mn);
  putchar_unlocked(' ');
  wt_L(mx);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180108-2

// --- original code ---
// int N, A[100000];
// {
//   int i;
//   ll mn, mx;
//   rd(N,A(N));
// 
//   if(A[N-1]!=2){
//     wt(-1);
//     return 0;
//   }
// 
//   mx = 3;
//   mn = 2;
//   for(i=N-2;i>=0;i--){
//     mn = (mn /+ A[i]) * A[i];
//     mx = (mx / A[i]) * A[i] + (A[i]-1);
//     if(mx < mn){
//       wt(-1);
//       return 0;
//     }
//   }
// 
//   wt(mn,mx);
// }


Measured memory_bytes: 640
N,K = map(int, input().split())

mod = 10**9+7

L = [0]*(K+1)
for i in range(K, 0, -1):
    if 2*i > K:
        L[i] = 1
    else:
        for j in range(2, K//i+1):
            L[i] -= L[i*j]
        L[i] += pow(K//i, N, mod)
        L[i] %= mod

ans = 0
for i in range(1, K+1):
    ans += i*L[i]
    ans %= mod
print(ans)

Measured memory_bytes: 69432
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
const int inf = 1e9 + 10;
ll n, a, b, c;
map<char, ll> cnt;
string s, ans, t = "ABC";
vector<string> v;
char get(string s) {
	char np;
	for (int i = 0; i < 3; i++) {
		if (find(all(s), t[i]) == s.end()) {
			np = t[i];
			break;
		}
	}
	return np;
}
void solve() {
	cin >> n;
	cin >> a >> b >> c;
	cnt['A'] = a; cnt['B'] = b; cnt['C'] = c;
	for (int i = 0; i < n; i++) {
		cin >> s;
		v.pb(s);
	}

	for (int i = 0; i < n; i++) {
		s = v[i];
		char np = get(s);
		//cout << np << " ";
		if (cnt[s[0]] == 0 && cnt[s[1]] == 0) {
			cout << "No";
			return;
		}
		else if (cnt[s[0]] == 1 && cnt[s[1]] == 1 && cnt[np] == 0) {
			char p = s[1], m = s[0];

			if (i + 1 < n)
				if (find(all(v[i + 1]), s[0]) != v[i + 1].end()) p = s[0], m = s[1];

			cnt[p]++;
			cnt[m]--;
			ans += p;
		}
		else {
			if (cnt[s[0]] < cnt[s[1]]) {
				cnt[s[0]]++;
				cnt[s[1]]--;
				ans += s[0];
			}
			else {
				cnt[s[1]]++;
				cnt[s[0]]--;
				ans += s[1];
			}
		}
		//cout << cnt[s[0]] << " " << cnt[s[1]] << endl;
	}
//cout << endl;
	bool f = true;
	for ( auto c : cnt) if (c.S < 0) f = false;
	if (f) {
		cout << "Yes" << endl;
		for (int i = 0; i < n; i++) cout << ans[i] << endl;
	}
	else
		cout << "No";
}

int main() {

	FASTIO;

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(25);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 7416
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int h[100010],nex[200010],to[200010],M;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
bool vis[100010];
int v[100010],p[100010],pa[100010],ma;
void dfs(int x){
	if(vis[x])return;
	vis[x]=1;
	p[++M]=v[x];
	for(int i=h[x];i;i=nex[i])dfs(to[i]);
}
int main(){
	int n,m,i,j,x,y,cnt;
	ll ans;
	scanf("%d%d",&n,&m);
	if(2*(n-m-1)>n){
		puts("Impossible");
		return 0;
	}
	ans=0;
	cnt=2*(n-m-1);
	for(i=1;i<=n;i++)scanf("%d",v+i);
	while(m--){
		scanf("%d%d",&x,&y);
		x++;
		y++;
		add(x,y);
		add(y,x);
	}
	for(i=1;i<=n&&cnt;i++){
		if(!vis[i]){
			M=0;
			dfs(i);
			sort(p+1,p+M+1);
			ans+=p[1];
			for(j=2;j<=M;j++)pa[++ma]=p[j];
			cnt--;
		}
	}
	sort(pa+1,pa+ma+1);
	for(i=1;i<=cnt;i++)ans+=pa[i];
	printf("%lld",ans);
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
string t = "ESWN";
signed main(void) {
    int i,j;
    int h,w,l;
    while(cin >> h >> w >> l, h){
        vs s(h);
        rep(i,h)cin >> s[i];
        vector<vi> dp(70,vi(100*100*10,-1));
        int sx,sy,d;
        rep(i,h)rep(j,w)rep(k,4){
            rep(p,4)if(s[i][j] == t[p]){
                sx = i;
                sy = j;
                d = p;
            }
            rep(p,4){
                int x = i + dx[(k+p)%4];
                int y = j + dy[(k+p)%4];
                if(x < 0 || x >= h || y < 0 || y >= w)continue;
                if(s[x][y] == '#')continue;
                dp[0][(i*100+j)*10 + k] = (x*100+y)*10 + (k+p)%4;
                break;
            }
        }
        rep(j,log2(l))rep(i,100*100*10)if(dp[j][i] >= 0){
            dp[j+1][i] = dp[j][dp[j][i]];
        }
        int ans = sx*1000 + sy*10 + d;
        rep(i,log2(l)+1){
            if((l>>i & 1)){
                ans = dp[i][ans];
            }
        }
        int x = ans/1000;
        ans %= 1000;
        int y = ans/10;
        int z = ans % 10;
        cout << x+1 << " " << y+1 << " " << t[z] << endl;
    }
}



Measured memory_bytes: 58684
#include <stdio.h>

int main(){
	int H, W;
	int h, w;
	int ans;

	scanf("%d %d", &H, &W);
	scanf("%d %d", &h, &w);

	ans = H*W - (H*w + W*h - w*h);

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

	int a, b, ans;
	char op;

	while (1) {

		scanf("%d %c %d", &a, &op, &b);

		if (op == '?') {
			break;
		}

		switch (op) {
		case '+':
			ans = a + b;
			break;

		case '-':
			ans = a - b;
			break;

		case '*':
			ans = a * b;
			break;

		case '/':
			ans = a / b;
			break;

		case '%':
			ans = a % b;
			break;
		}

		printf("%d\n", ans);

	}

	return 0;
}



Measured memory_bytes: 2092
N, A, B = map(int, input().split())
S = input()

passed = 0
passed_b = 0
for i in range(N):
    if S[i] == "a" and passed < A+B:
        passed += 1
        print("Yes")
    elif S[i] == "b" and passed < A+B and passed_b < B:
        passed += 1
        passed_b += 1
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 4016
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    use std::f64::consts::PI;
    let A: f64 = read();
    let B: f64 = read();
    let H: f64 = read();
    let M: f64 = read();
    // 余弦定理を使う
    let hour_rad = PI * 2.0 * ((H / 12.0) + (M / 60.0) / 12.0);
    let minute_rad = PI * 2.0 * M / 60.0;
    let diff_rad = hour_rad - minute_rad;
    let ans = (A.powi(2) + B.powi(2) - 2.0 * A * B * diff_rad.cos()).sqrt();
    println!("{}", ans)
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int max_n = 503;

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

	int n, m, q;
	cin >> n >> m >> q;

	int a[max_n][max_n];
	rep(i, max_n) rep(j, max_n) a[i][j] = 0;

	rep(i, m){
		int l, r;
		cin >> l >> r;
		a[l][r]++;
	}
	

	int b[max_n][max_n];
	rep(i, max_n) rep(j, max_n) b[i][j] = 0;

	for(int i = max_n-2; i >= 1; i--){
		for(int j = 1; j <= max_n-2; j++){
			b[i][j] = a[i][j] + b[i+1][j] + b[i][j-1] - b[i+1][j-1];
		}
	}

	rep(i, q){
		int p, q;
		cin >> p >> q;

		cout << b[p][q] << endl;
	}
}

Measured memory_bytes: 2944
n = int(input())
L = list(map(int,input().split()))
L1 = len([x for x in L if x < 0])
L.sort()
for i in range(n):
  if L[i] < 0:
    L[i] = -L[i]
#print(L)
if L1%2 == 0:
  print(sum(L))
else:
  print(sum(L)-2*min(L))

Measured memory_bytes: 14332
let () =
  let s = read_line () in
  let len = String.length s in
  let b = Buffer.create len in
  let cs = Array.init len (fun i -> s.[i]) in
  Array.iteri
    (fun i c -> if (i + 1) mod 2 = 1 then Buffer.add_char b c else ())
    cs ;
  print_endline (Buffer.contents b)

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef tuple<string, int, int> mytuple;

bool comp(const mytuple &t1, const mytuple &t2) {
	if (get<0>(t1) != get<0>(t2)) return get<0>(t1) < get<0>(t2);
	if (get<1>(t1) != get<1>(t2)) return get<1>(t1) > get<1>(t2);
	return true;
}

int main() {
	int n, p;
	string s;
	cin >> n;
	vector<mytuple> rest(n);
	for (int i = 0; i < n; i++) {
		cin >> s >> p;
		rest[i] = make_tuple(s, p, i + 1);
	}
	sort(rest.begin(), rest.end(), comp);
	for (int i = 0; i < n; i++) cout << get<2>(rest[i]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	int k, l, r;
	cin >> k >> l >> r;
	if (r - r % k >= l) puts("OK");
	else puts("NG");
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
S = list(map(int, list(input())))

L = [0] * 10
R = [0] * 10

for i in S:
  R[i] += 1

D = [0] * 1000

L[S[0]] = 1
R[S[0]] -= 1
for i in range(1, N):
  R[S[i]] -= 1
  for j in range(10):
    if L[j] == 0: continue
    for k in range(10):
      if R[k] != 0:
        D[j * 100 + S[i] * 10 + k] = 1
  L[S[i]] = 1
  

ans = 0
for i in D:
  if i == 1:
    ans += 1
print(ans)


Measured memory_bytes: 43752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = 0;
    cin >> N;
    string ans;
    if(N>999){
        ans = "ABD";
    } else{
        ans = "ABC";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int n,m;
vector<int> v[10];
ll ans;
vector<bool> used;

void dfs(int now,vector<bool>& c,int times){
  if(times==n-1){
    rep(i,c.size()){
      if(!c[i] && i!=now)return;
    }
    ans++;
    return;
  }
  vector<bool> temp;
  rep(i,c.size())temp.push_back(c[i]);
  temp[now]=true;
  rep(i,v[now].size()){
    if(!temp[v[now][i]])dfs(v[now][i],temp,times+1);
  }
  return;
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  rep(i,n)used.push_back(false);
  used[0]=true;
  dfs(0,used,0);
  cout << ans << endl;
return 0;}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	ll x,y;
	cin >>x>> y;
	int ans = 1;
	while (x < y) {
		x *= 2;
		if(x<=y) ans++;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    Int ans = 0;
    rep(i,k) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
   int str2[100], i = 0;
   char str[100];
   while ( scanf("%s", str) != EOF ) {
   while (i < 9) {
   if ( str[i] == 'o') str2[i] = 10;
   else if ( str[i] == 'x') str2[i] = 2;
   else if ( str[i] == 's') str2[i] = 0;
   i++;
   }
   if ( str2[0] + str2[1] + str2[2] == 30 ) printf("o\n");
   else if ( str2[0] + str2[1] + str2[2] == 6 ) printf("x\n");
   else if ( str2[3] + str2[4] + str2[5] == 30 ) printf("o\n");
   else if ( str2[3] + str2[4] + str2[5] == 6 ) printf("x\n");
   else if ( str2[6] + str2[7] + str2[8] == 30 ) printf("o\n");
   else if ( str2[6] + str2[7] + str2[8] == 6 ) printf("x\n");
   else if ( str2[0] + str2[3] + str2[6] == 30 ) printf("o\n");
   else if ( str2[0] + str2[3] + str2[6] == 6 ) printf("x\n");
   else if ( str2[1] + str2[4] + str2[7] == 30 ) printf("o\n");
   else if ( str2[1] + str2[4] + str2[7] == 6 ) printf("x\n");
   else if ( str2[2] + str2[5] + str2[8] == 30 ) printf("o\n");
   else if ( str2[2] + str2[5] + str2[8] == 6 ) printf("x\n");
   else if ( str2[0] + str2[4] + str2[8] == 30 ) printf("o\n");
   else if ( str2[0] + str2[4] + str2[8] == 6 ) printf("x\n");
   else if ( str2[2] + str2[4] + str2[6] == 30 ) printf("o\n");
   else if ( str2[2] + str2[4] + str2[6] == 6 ) printf("x\n");
   else printf("d\n");
   i = 0;
   }
   return 0;
}

Measured memory_bytes: 1740
# 入力
Q = int(input())
x, d, n = (
    zip(*(map(int, input().split()) for _ in range(Q))) if Q else
    ((), (), ())
)

MOD = 1000003


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

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

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


# MOD未満の整数について、階乗を求めておく
# 各クエリに対して、d^n * (x/d + (n - 1))! / ((x/d) - 1)! を回答する
f = [0 for _ in range(MOD)]
f[0] = ModInt(1)
for i in range(1, MOD):
    f[i] = i * f[i - 1]


def q(X, D, N):
    Y = (
        0 if D.x == 0 else
        X / D
    )
    return (
        X**N if D.x == 0 else
        D**N * f[Y.x + N - 1] / f[Y.x - 1] if Y.x + N - 1 < MOD else
        0
    )


ans = '\n'.join(
    str(q(X, D, N))
    for X, D, N in zip(map(ModInt, x), map(ModInt, d), n)
)

# 出力
print(ans)


Measured memory_bytes: 147620
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int d,a,b,i,c;
  double k,e,f;
  scanf("%d %d\n",&a,&b);
  for(i=0;i<100000;i++){
    k=i;
    e=k*0.08,f=k*0.1;
    c=e,d=f;
    if(c==a && d==b){
      printf("%d\n",i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}

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

kouho=0
lis=[0]*n
lis[0]=(1+p[0])/2
for i in range(0,n):
  if i>=1:
    lis[i]=lis[i-1]+(1+p[i])/2
  if i==k-1:
    kouho=lis[i]
  if i>k:
    if lis[i]-lis[i-k]>kouho:
      kouho=lis[i]-lis[i-k]
print(kouho)


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
 
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);

vector<ll> divsor(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            if(i * i != n) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
	ll n;
	cin >> n;
	ll ans = divsor(n-1).size()-1;
	for(auto x : divsor(n)){
		ll tmp = n;
		if(x == 1) continue;
		while(tmp%x == 0) tmp /= x;
		if(tmp%x == 1) ans++; 
	}
	cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 384
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

void main()
{
    auto hw = readln.split.to!(long[]);
    long h = hw[0];
    long w = hw[1];
    char[][] table;
    foreach (i; 0 .. h)
        table ~= readln.chomp.to!(char[]);

    bool[size_t] rows;
    bool[size_t] cols;

    foreach (i, r; table)
        if (r.all!(c => c == '.'))
        {
            rows[i] = true;
        }

    foreach (i; 0 .. w)
    {
        bool flag = true;
        foreach (j; 0 .. h)
            flag = flag && table[j][i] == '.';
        if (flag)
        {
            cols[i] = true;
        }
    }

    foreach (r; 0 .. h)
    {
        foreach (c; 0 .. w)
            if (!(r in rows || c in cols))
            {
                write(table[r][c]);
            }
        if (!(r in rows))
        {
            writeln;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, j, k, w;
  scanf("%d%d", &w, &n);
  int a[n], b[n], now, ans[w + 2];
  for(i = 0; i < n; ++i) scanf("%d,%d", &a[i], &b[i]);
  for(i = 1; i <= w; ++i) {
    now = i;
    for(j = 0; j < n; ++j) {
      if(a[j] == now) now = b[j];
      else if(b[j] == now) now = a[j];
    }
    ans[now] = i;
  }
  for(i = 1; i <= w; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 2608