akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;
#define all(v) v.begin(), v.end()

//コストが正の場合
//vector<vector<P>> G(N,vector<P>(0));
void graphmake(ll E,vector<vector<P>> &G){
  rep(i,E){
    ll a,b,c;
    cin >> a >> b >> c;
    G.at(a-1).push_back(P(b-1,c));
    G.at(b-1).push_back(P(a-1,c));//有向なら消す
  }
}
//vector<ll> d(N);
void dijkstra(ll s,vector<ll> &d, vector<vector<P>> &G,ll V){
  priority_queue<P,vector<P>,greater<P>> que;
  rep(i,V) d.at(i)=INF;
  d.at(s)=0;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    ll v=p.second;
    if(d.at(v)<p.first) continue;
    rep(i,G.at(v).size()){
      P e=G.at(v).at(i);
      if(d.at(e.first)>d.at(v)+e.second){
        d.at(e.first)=d.at(v)+e.second;
        que.push(P(d.at(e.first),e.first));
      }
    }
  }
}


int main(){
  ll N;
  cin >> N;
  vector<vector<P>> G(N,vector<P>(0));
  vector<ll> d(N);
  graphmake(N-1,G);
  dijkstra(0,d,G,N);
  rep(i,N){
    if(d.at(i)%2==0){
      cout << 0 << endl;
    }else{
      cout << 1 << endl;
    }
  }
}

Measured memory_bytes: 8704
#include<stdio.h>

int main(void){
  
  char moji1,moji2,moji3;
  
  moji1=getchar();
  moji2=getchar();
  moji3=getchar();
  
  ((moji1=='7')||(moji2=='7')||(moji3=='7')) ? printf("Yes") : printf("No");
  
  return 0;
}

Measured memory_bytes: 1588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n;
int dp[3][100000];

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

    cin >> n;
    for( int i=0;i<n;i++ ) for( int j=0;j<3;j++ ) cin >> dp[j][i];

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

        dp[0][i] += max( dp[1][i-1], dp[2][i-1] );
        dp[1][i] += max( dp[0][i-1], dp[2][i-1] );
        dp[2][i] += max( dp[0][i-1], dp[1][i-1] );

    }

    cout << max( dp[0][n-1], max( dp[1][n-1], dp[2][n-1] ) ) << endl;

}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		if(x < 1200) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
	}
}

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

using namespace std;

int main() {
	string n;
	cin >> n;
	int sum = 0;
	for(int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';
	}
	if(sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String token1 = sc.next();
        String token2 = sc.next();

        int result = Integer.parseInt(token1) * Integer.parseInt(token2);

        if (result % 2 != 0) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }

        sc.close();
    }
}


Measured memory_bytes: 35484
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{

    int a,i; int x[3000]; int y[3000];
    for(i=0;i<3000;i++)
    {
        scanf("%d %d",&x[i],&y[i]);
        if (x[i]==0 && y[i]==0) break;
    }
    for (i=0;i<3000;i++)
    {
        if (x[i]>y[i])
        {
            a=x[i]; x[i]=y[i]; y[i]=a;
        }
    }
    for (i=0;i<3000;i++)
    {
        if (x[i]==0 && y[i]==0) break;
        printf("%d %d\n",x[i],y[i]);
    }

}



Measured memory_bytes: 2612
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int sx,sy,gx,gy,n;
vector<P> v;
const int inf=1e8;

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

	cin>>sx>>sy>>gx>>gy>>n;
	int xt=1,yt=1;
	if(sx>gx) xt*=-1,gx*=-1,sx*=-1;//swap(sx,gx),swap(sy,gy);
	if(sy>gy) yt*=-1,gy*=-1,sy*=-1;//t=1,swap(sy,gy);
	REP(i,n) {
		int x,y;cin>>x>>y;
		x*=xt,y*=yt;
		if(x<sx||x>gx||y<sy||y>gy) continue;
		//if(t) y=-y;
		v.pb(P(x,y));
	}
	//if(t) REP(i,v.size()) v[i].se=-v[i].se;
	sort(ALL(v));

	int sz=v.size();
	int dp[sz];
	fill(dp,dp+sz,inf);
	REP(i,sz) {
		*lower_bound(dp,dp+sz,v[i].se)=v[i].se;
	}
	int num=lower_bound(dp,dp+sz,inf)-dp;
	double ans=((gx-sx)+(gy-sy))*100.-num*20.+num*20*PI/4;
	if(num==(gx-sx)+1||num==(gy-sy)+1) ans+=20*PI/4;
	printf("%.15lf\n",ans);

	return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, M, W, T;
map<string, Pi> data;
vector<Pi> city;
vector<map<string, int>> buy;

int dist(Pi a, Pi b) {
  return llabs(a.first-b.first)+llabs(a.second-b.second);
}

int tsp[7][1<<7];
int calcTSP(int bit, int now, int S) {
  int& res = tsp[now][bit];
  if(~res) return res;
  if(bit == S) return dist(city[now], Pi(0, 0));
  res = inf;
  for(int i = 0; i < N; i++) {
    if((bit>>i)&1) continue;
    if((S>>i)&1) chmin(res, calcTSP(bit|1<<i, i, S)+dist(city[now], city[i]));
  }
  return res;
}
int knap[1<<7][10010];
void calcKnapsack() {
  memset(knap, -1, sizeof(knap));
  for(int S = 0; S < 1<<N; S++) {
    knap[S][0] = 0;
    for(int i = 0; i < N; i++) {
      if(!((S>>i)&1)) continue;
      for(auto&& p : buy[i]) {
	int w = data[p.first].first;
	int sp = data[p.first].second;
	int bp = p.second;
	for(int j = 0; j <= W-w; j++) {
	  if(knap[S][j] == -1) continue;
	  chmax(knap[S][j+w], knap[S][j]+sp-bp);
	}
      }
    }
    for(int i = 0; i < W; i++) chmax(knap[S][i+1], knap[S][i]);
  }
}

int dp1[1<<7];
int dp[10010];
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M >> W >> T;
  for(int i = 0; i < M; i++) {
    string s; int v, p;
    cin >> s >> v >> p;
    data[s] = Pi(v, p);
  }
  buy.resize(N);
  for(int i = 0; i < N; i++) {
    int l, x, y;
    cin >> l >> x >> y;
    city.push_back(Pi(x, y));
    for(int j = 0; j < l; j++) {
      string r; int q;
      cin >> r >> q;
      buy[i][r] = q;
    }
  }
  fill(dp1, dp1+(1<<7), inf);
  for(int S = 0; S < 1<<N; S++) {
    memset(tsp, -1, sizeof(tsp));
    for(int i = 0; i < N; i++) {
      if((S>>i)&1) chmin(dp1[S], calcTSP(1<<i, i, S)+dist(city[i], Pi(0, 0)));
    }
  }
  calcKnapsack();
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for(int i = 0; i <= T; i++) {
    for(int S = 0; S < 1<<N; S++) {
      if(dp[i] == -1) continue;
      if(i+dp1[S] <= T) chmax(dp[i+dp1[S]], dp[i]+knap[S][W]);
    }
  }
  int ans = 0;
  for(int i = 0; i <= T; i++) chmax(ans, dp[i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13312
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	int b,x=0,i;
	char a[10],c[100];
	scanf("%s %d",a,&b);
	for(i=1;i<=b;i++)
	{
		scanf("%s",c);
		strncat(c,c,10);
		if((strstr(c,a))!=NULL)
		{
			x++;
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define repp(i, l, r) for (long long i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    set<long double> suger;
    set<long double> water;
    for (int i = 0; a * i * 100 <= f; i++) {
        for (int j = 0; b * j * 100 <= f; j++) {
            if (a * i * 100 + b * j * 100 > f) continue;
            water.insert(a * i * 100 + b * j * 100);
        }
    }
    for (int i = 0; c * i <= f; i++) {
        for (int j = 0; d * j <= f; j++) {
            if (c * i + d * j > f) continue;
            suger.insert(c * i + d * j);
        }
    }
    pair<ll, ll> res = {f , 0};
    long double conce = 0.0;
    const long double satu = (long double)(e) / (100 + e) * 100;
    for (auto w : water) {
        for (auto s : suger) {
            if (w + s > f) continue;
            if (w + s == 0) continue;
            long double n = (s * 100) / (w + s);
            if (satu + pow(10,-9) < n) continue;
            if (conce <= n) {
                res = {w, s};
                conce = n;
            }
        }
    }
    cout << res.first + res.second << " " << res.second << "\n";
    cerr << fixed << setprecision(10) << (long double)(100 * res.second) /
                (long double)(res.first + res.second)
         << "\n";
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

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

	vector<vector<ll>> g(15,vector<ll>(15,-1));

	rep(i,n){
		ll m;
		cin>>m;
		rep(j,m){
			ll x,y;
			cin>>x>>y;
			x--;
			g.at(i).at(x) = y;
		}
	}

	ll ans = 0;
	rep(i,1<<n){
		vector<ll> d(n);
		rep(j,n){
			if (i>>j&1)
			{
				d.at(j)=1;
			}
		}
		bool ok = true;
		rep(j,n){
			if (d.at(j))
			{
				rep(k,n){
					if (g.at(j).at(k) == -1) continue;
					if (g.at(j).at(k) != d.at(k)) ok = false;
				}
			}
			
		}

		if (ok) ans = max((int)ans,__builtin_popcount(i));
	}

	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    string str;
    while(cin >> str){
        char c = str[0];
        int cnt = 0;
        for(int i = 1;i < str.length();++i){
            if(str[i] != c){
                c = str[i];
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef	long long ll;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int N, K, C;
	cin >> N >> K >> C;

	string s; cin >> s;

	vector<int> dp(N+1);
	dp[N] = 0;
	for (int i(N-1); i >= 0; --i)
	{
		dp[i] = dp[i+1];
		if (s[i] == 'o')
			dp[i] = max(dp[i], 1 + dp[min(N, i+C+1)]);
	}
	
	int l(0);
	while (l < N and K > 0)
	{
		int r = l;
		int cnt(0);
		while (r < N and dp[r] >= K and cnt <= 1)
		{
			cnt += s[r++] == 'o';
		}
		if (cnt==1)
			for (int i(l); i < r; ++i)
				if (s[i] =='o')
				{
					cout << i+1 << '\n';
					break;
				}
		--K;
		for (int i(l); i < r; ++i)
			if (s[i] =='o')
			{
				l = i+C+1;
				break;
			}
	}
}



Measured memory_bytes: 2580
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int K = sc.nextInt();
        long[] a = new long[n+1];
        for(int i=1;i<=n;i++) a[i] = sc.nextLong();
        long[] sum = new long[n+1];
        for(int i=1;i<=n;i++) sum[i] = sum[i-1]+a[i];
        ArrayList<Long> cur = new ArrayList<>();
        ArrayList<Long> next = new ArrayList<>();
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                cur.add(sum[j]-sum[i-1]);
            }
        }
        long ans = 0;
        for(int i=45;i>=0;i--){
            if(cur.size()<K) break;
            long now = (long) Math.pow(2,i);
            for(int j=0;j<cur.size();j++){
                if((cur.get(j)&now)>0) next.add(cur.get(j));
            }
            if(next.size()<K){
                next = new ArrayList<>();
            }else{
                cur = next;
                next = new ArrayList<>();
                ans += now;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  string ans = "No";
  for (int n = 0; n <= N; n++)
    for (int m = 0; m <= M; m++)
      if (n * (M - m) + m * (N - n) == K) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<char,char> mp;
map<char,char> inv;
int cnt[26];
int main(){
	memset(cnt,0,sizeof(cnt));
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(cnt[s[i]-'a']){
			if(mp[s[i]]!=t[i]){
				cout<<"No"<<endl;
				return 0;
			}
			continue;
		}
		else{
			cnt[s[i]-'a']++;
			mp[s[i]]=t[i];
		}
	}
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<t.size();i++){
		if(cnt[t[i]-'a']){
			if(mp[t[i]]!=s[i]){
				cout<<"No"<<endl;
				return 0;
			}
			continue;
		}
		else{
			cnt[t[i]-'a']++;
			mp[t[i]]=s[i];
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
typedef long long ll;
#define N 100010
using namespace std;
ll scope[N];
ll squ[2];
bool cmp(int x,int y)
{
    return x<y;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(scope,0,sizeof(scope));
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&scope[i]);
        }
        sort(scope,scope+n,cmp);
        for(int i=n-1;i>=0;i--)
        {
            if(cnt==2)break;
            if(scope[i]==scope[i-1])
            {
                i--;
                squ[cnt]=scope[i];
                cnt++;
            }

        }
        if(cnt!=2)printf("0\n");
        else printf("%lld\n",squ[0]*squ[1]);
    }
    return 0;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string s;
  string t;
  cin >> s;
  cin >> t;
  rep(i,s.size()){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3592
n, a, b, c, d = map(int, input().split(' '))
s = input()
def rock(a,b):
    tmp = 0
    result = 1
    for i in s[a:b]:
        if tmp==2:
            result = 0
            break
        if i =='#':
            tmp +=1
        else:
            tmp=0
    return result
def main():
    result =0
    if c<d:
        result = min(rock(a,c-1),rock(b,d-1))
    else:
        result = min(rock(a,c-1),rock(b,d-1))
        if result ==1:
            result = 0
            for i in range(b-1,d):
                if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
                    result = 1
    if result ==0:
        print('No')
    else:
        print('Yes')

main()

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

int n;
string s[2];
vector<int> v;
long long MOD = 1000000007;

int main() {
	cin>>n;
	for(int i = 0; i < 2; i++){
		cin>>s[i];
	}
	
	v.push_back(0);
	char bc = s[0][0];
	for(int i = 1; i < n; i++){
		if(bc == s[0][i]){
			v[v.size()-1] = 1;
		}else{
			v.push_back(0);
		}
		bc = s[0][i];
	}
	
	long long ans;
	if(v[0] == 0) ans = 3;
	else ans = 6;
	
	for(int i = 1; i < v.size(); i++){
		if(v[i-1] == 0){
			ans = (ans * 2) % MOD;
		}else{
			if(v[i] == 0) ans = (ans * 1) % MOD;
			else ans = (ans * 3) % MOD;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    #define REP(i,n) for(ll i=0; i<(ll)(n); i++)
     
    typedef long long ll;
    typedef pair<int,int> p;
     
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
     
    #define MAX_N 100001
     
    ll N, L, T;
    int main(){
        ios::sync_with_stdio(false);
        cin >> N >> L >> T;
        vector<ll> ans;
        ll diff = 0;
        REP(i, N) {
            ll x, w;
            cin >> x >> w;
            ll pos;
            if(w==1) {
                pos = (x+T)%L;
                diff += (x+T)/L;
            } else {
                pos = ((x-T)%L+L)%L;
                diff -= (T-x+L-1)/L;
            }
            ans.push_back(pos);
        }
        sort(ans.begin(),ans.end());
        diff=(diff%N+N)%N;
        rotate(ans.begin(), ans.begin()+diff, ans.end());
        REP(i,N) cout << ans[i] << endl;
        return 0;
    }

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

string s;

int main() {
	cin >> s;
	
	int x = 0, y = 0;
	inc(i, SI(s)) {
		if((i % 2 == 0) == (s[i] == '0')) { x++; }
		if((i % 2 == 0) == (s[i] == '1')) { y++; }
	}
	
	cout << min(x, y) << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, std::vector<long long> A){
  For(times,K){
    vector<ll> next(N);
    For(i,N){
      ll l=max(0LL,i-A[i]),r=min(N,i+A[i]+1);
      next[l]+=1;
      if(r<N)next[r]-=1;
    }
    For(i,N-1){
      next[i+1]+=next[i];
    }
    if(next==A)break;
    A=move(next);
  }
  REP(N){
    cout<<A[i];
    if(i==N-1)cout<<endl;
    else cout<<" ";
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 6764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];

int main() 
{
	int A, B, C;
	cin >> A>> B>> C;
	int ans = 0;
	if (A == B && B == C)
	{
		ans = 1;
	}
	else if (((A == B) && (B != C)) || ((B == C) && (A != B)) || ((A == C) && (B != C)))
	{
		ans = 2;
	}
	else
	{
		ans = 3;
	}
	
	cout << ans << endl;

	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	String s;
	int id;
	
	StringBuilder fnc(){
		StringBuilder sb = new StringBuilder();
		int cnt = 0;
		while(true){
			if(id==s.length()) return sb;
			char c = s.charAt(id);
			id++;
			if(c=='[') sb.append(fnc());
			else if(c==']') return sb.reverse();
			else if(c=='+') cnt++;
			else if(c=='-')	cnt--;
			else{
				int x = c-65;
				if(x==-2) x = 65;
				else if(x+cnt>=0) x = 65 + (x+cnt)%26;
				else x = 91 + (x+cnt)%26;
				sb.append((char)x);
				cnt = 0;
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			s = sc.next();
			if(s.equals(".")) break;
			id = 0;
			System.out.println(fnc());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}	
}

Measured memory_bytes: 17392
#include <iostream>

using namespace std;
typedef long long lint;

lint A, B;
lint ans;

lint GCD(lint a, lint b)
{
    lint r;
    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

lint LCM(lint a, lint b) { return (a * b) / GCD(a, b); }

void resolve()
{
    cin >> A >> B;
    ans = LCM(A, B);
    cout << ans << endl;
}

int main()
{
    resolve();
    return 0;
}


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

bitset<4000001>bit;
int main(){
	int n;scanf("%d",&n);
	int sum=0;
	bit[0]=1;
	rep(i,n){
		int a;scanf("%d",&a);
		bit|=bit<<a;
		sum+=a;
	}
	for(int i=(sum+1)/2;;i++){
		if(bit[i]){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1664
N = int(input())
A = sorted(list(map(int,input().split())),key=lambda x:abs(x))

a = 0
for i in A:
  if i < 0:
    a += 1
  elif i == 0:
    a = -1
    break

ans = 0
if a == -1 or a % 2 == 0:
  ans = sum([abs(x) for x in A])
else:
  ans = abs(A[0]) * -1
  for a in A[1:]:
    ans += abs(a)
print(ans)

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

typedef vector<int> vi; 
typedef pair<int,int> p;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pmod 1000000007
#define INF 1000000000000000000
#define pi atan(1)*4
#define modi 1000000

void solve(){
	
	ll n;
	
	cin >> n;
	
	string s;
	
	ll c0 = 0, c1 = 0, c2 = 0, c3 = 0;
	
	for(ll i = 0; i < n; i++){
		cin >> s;
		
		if(s == "AC"){
			c0++;
		}
		else{
			
			if(s == "WA"){
				c1++;
			}
			else{
				
				if(s == "TLE"){
					c2++;
				}
				else{
					c3++;
				}
				
			}
			
		}
		
	}

	cout << "AC x " << c0 << endl;
	cout << "WA x " << c1 << endl;
	cout << "TLE x " << c2 << endl;
	cout << "RE x " << c3 << endl;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	
	ifstream fin ("text.in");
    ofstream fout ("text.out");   
	
	ll t = 1;
	
	
	while(t--) solve();
	
	return 0;
}

Measured memory_bytes: 3664
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, sz[N];
vector < int > vec, path, g[N];

void dfs(int v, int par) {
    path.eb(v);
    if (v == n) vec = path;
    sz[v] = 1;
    for (auto to : g[v]) {
        if (to == par) continue;
        dfs(to, v);
        sz[v] += sz[to];
    }
    path.pop_back();
}

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

    cin >> n;
    forn(i, 1, n - 1) {
        int x, y;
        cin >> x >> y;
        g[x].eb(y);
        g[y].eb(x);
    }

    dfs(1, 0);

    int sum = 0;
    forn(i, 0, sz(vec) - 1) {
        vec[i] = sz[vec[i]];
        if (i != sz(vec) - 1) vec[i] -= sz[vec[i + 1]];
        sum += vec[i];
    }
    vec[0]--; vec[sz(vec) - 1]--;
    sum -= 2;

    int sum2 = 0;
    forn(i, 0, (sz(vec) + 1) / 2 - 1) {
        sum -= vec[i];
        sum2 += vec[i];
        if (sum2 > sum) {
            cout << "Fennec\n";
            return 0;
        }
    }

    cout << "Snuke\n";

	return 0;
}


Measured memory_bytes: 61304
N = int(input())
S = input()
ws = [0]*N
w_c = 0
for i in range(0, N):
    if S[i] == "W":
        w_c += 1
    ws[i] += w_c
es = [0]*N
e_c = 0
for i in reversed(range(0, N)):
    if S[i] == "E":
        e_c += 1
    es[i] += e_c
res = 3*10**5
for i in range(0, N):
    if i - 1 == 0:
        if es[0] < res:
            res = es[1]
        continue
    if i + 1 == N:
        if ws[i] < res:
            res = ws[i-1]
        continue
    t = ws[i-1] + es[i+1]
    if t < res:
        res = t
print(res)

Measured memory_bytes: 27168
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#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 INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int n, m;
  cin >> n >> m;
  ll sum = 0;
  vector<int> a;
  rep(i, n)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
    sum += tmp;
  }

  double criteria = double(sum) / 4 / double(m);
  int count = 0;
  rep(i, n)
  {
    if (criteria <= a[i])
    {
      count++;
    }
  }
  if (m <= count)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int ans = 0;
		for (int i = 0; i < 4; i++)
			ans += scanner.nextInt();
		System.out.println(ans / 60);
		System.out.println(ans % 60);
	}
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int INF = 1e9 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n), dp(n, INF);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j <= min(n - 1, i + k); j++) {
            dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int MAXN = 1000006;
int n,m,l[MAXN],mx;
vector< int > par[MAXN];

int markit(int x){
    if(par[x].size() == 0)
        return 0;
    if(l[x] != -1)
        return l[x];
    int mx =0;
    for(int i=0;i<par[x].size();i++){
        if(markit(par[x][i]) > mx)
            mx = markit(par[x][i]);
    }
    l[x] = 1+mx;
    return l[x];
}

void markation(){
    for(int i=0;i<n;i++)
        if(l[i] == -1)
            l[i] = markit(i);
}

int main (){
    memset(l,-1,sizeof(l));
    int a,b;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        par[a-1].push_back(b-1);
    }
    markation();
    int bestx = 0;
    for(int i=0;i<n;i++) {
        if(l[i] > bestx)
            bestx = l[i];
    }
    cout<<bestx;
    return 0;
}


Measured memory_bytes: 32768
def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
            
x, y = map(int, raw_input().split())

print gcd(x, y)

Measured memory_bytes: 6408
#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>;

int main() {
  int n,k;
  cin >> n >> k;
  vector<double> s(n+1);
  s[0]=0.0;
  for(int i=1; i<=n; i++) {
    int m;
    cin>> m;
    s[i]=s[i-1]+(m+1)/2.0;
  }
  double mx = 0.0;
  rep(i,n-k+1) {
    mx=max(mx,s[i+k]-s[i]);
  }
  printf("%.9f", mx);
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  int h[n];
  int i;
  for(i=0;i<n;i++){
  	cin>>h[i];
  }
  
  int w=h[0];
  int count=1;
  	for(int j=1;j<n;j++){
  		if(h[j]>=w){
  			w=h[j];
  			count++;
		  }
	  }
  
  
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
s = input()
r, g, b = s.count("R"), s.count("G"), s.count("B")
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        try:
            k = j + (j - i)
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
        except:
            pass
print(r * g * b - cnt)

Measured memory_bytes: 73764
n = int(input())
p = [int(input()) for _ in range(n)]

q = [n for _ in range(n)]
for i in range(n):
    q[p[i] - 1] = i

stay_num_cnt = 0
cnt = 0
t = 0
for x in q:
    if x >= t:# x == tはあり得ない
        cnt += 1
    else:
        cnt = 1
    t = x
    stay_num_cnt = max(stay_num_cnt, cnt)
print(n - stay_num_cnt)#, q)

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

int main(void){
    int n;
    vector<int> s(1010);
    double sum,na2;
    cout<<fixed<<setprecision(12);
    while(1){
        cin>>n;
        if(n==0)break;
        sum=0,na2=0;
        for(int i=0;i<n;i++){
            cin>>s.at(i);
            sum+=s.at(i);
        }
        for(int i=0;i<n;i++){
            na2+=pow(s.at(i)-sum/n,2);
        }
        cout<<sqrt(na2/n)<<endl;
    }
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 3e5+100;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
 
 
#define popcount __builtin_popcountll
 
ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

vector<ll> Ans, Adj[lim];
set<ll> S[lim];
ll Array[lim], Vis[lim];
pair<ll,ll> P[lim];

ll dfs(ll node,ll Vis[]) {
    ll countA=1;
    Vis[node]=1;
    for(auto i: S[node]) {
        if(!Vis[i]) countA+= dfs(i,Vis);
    }

    return countA;
}

int main(){

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

    #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
    
    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    string A,B;
    A = "Yes", B="No";
    cin>>n>>m;
    rep(i,1,m) {
        cin>>a>>b;
        S[a].insert(b);
        S[b].insert(a);
    }

    rep(i,1,n) {
        if(!Vis[i]) ans = max(ans,dfs(i,Vis));
    }

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

Measured memory_bytes: 54324
#include <bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=(t);++i)
using namespace std;
const int N=105,P=1e9+7;
int add(int x,int y){ x+=y; return x>=P?x-P:x; }
int mul(int x,int y){ return 1ll*x*y%P; }
void upd(int &x,int y){ x=add(x,y); }
int n=50,f[N][N],C[N][N],ans;
int main(int argc,char *argv[]){
	scanf("%d",&n); 
	C[0][0]=1; f[1][0+n]=n,f[1][-1+n]=n;
	rep(i,1,n){ C[i][0]=1; rep(j,1,i)C[i][j]=add(C[i-1][j-1],C[i-1][j]); }
	rep(i,1,n-1)rep(j,-n,n)if(f[i][j+n])rep(a,0,n-i)rep(b,0,n-a-i){
		if((!a&&!b)||(j+a-b)%2!=0||j<-a-b||j>a+b||(j&1)!=((a+b)&1))continue;
		upd(f[i+a+b][(j+a-b)/2+n],mul(f[i][j+n],mul(C[a+b][a],C[n-i][a+b])));
	}
	printf("%d\n",f[n][0+n]); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,f,ff,s=0;
    cin>>n;
    long long a[n];
    f(i,0,n){
        cin>>a[i];
        if(i==0){
            f=a[i];
            ff=i;
        }
        else{
            if(f<a[i]){
                f=a[i];
                ff=i;
            }
        }
    }
    f(i,0,n){
        if(i!=ff){
            if(a[i]>s){
                s=a[i];
            }
        }
    }
    f(i,0,n){
        if(i!=ff){
            cout<<f<<endl;
        }
        else{
            cout<<s<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5184
N,M,Q = map(int,input().split())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    A[L][R] += 1
B = [[0 for _ in range(N+2)] for _ in range(N+2)]
for i in range(N,0,-1):
    for j in range(1,N+1):
        B[i][j] = A[i][j]+B[i+1][j]+B[i][j-1]-B[i+1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(B[p][q])

Measured memory_bytes: 60272
#include<stdio.h>
#define N 501

static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  tt++;
  d[u] = tt;
  for ( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int i, u;
  for ( i = 0; i < n; i++ ) color[i] = WHITE;
  tt = 0;
  for ( u = 0; u < n; u++ ){
    if ( color[u] == WHITE ) dfs_visit(u);
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}


main(){
  int u, k, v; 
  int i, j;

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  dfs();

  return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    int k;
    int cnt=1;
    cin >> k;
    queue<string> q;
    rep(i,9) q.push(to_string(i+1));
    while(cnt<k){
        string s=q.front(); q.pop();
//        cout << s << endl;
        rep(i,10){
            if(1>=abs((s[s.size()-1]-'0')-i)){
                q.push(s+to_string(i));
            }
        }
        cnt++;
    }
    cout << q.front() << endl;
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        if(i%2) continue;
        if(A[i]%2==0) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import numpy as np

N,K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" "))) # consumption coefficient of members
F = list(map(int, input().split(" "))) # difficulty of food

# pair fastest eaters (low consumption coefficient) with most difficult foods
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)

maxT = np.max(A*F)
# use binary search to find lowest possible T
left = -1
right = maxT
while left+1< right:
    mid = (left+right)//2
    if np.maximum(0, A - (mid//F)).sum() <= K:
        right  = mid
    else:
        left = mid
print(right)



Measured memory_bytes: 43616
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

output:
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
"""

import sys


class Node(object):
    def __init__(self):
        # init node as a single leaf node.
        self.parent = -1
        self.children = []
        self.index = -1


def pre_parse(v):
    print(' ' + str(v.index), end='')
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        pre_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        pre_parse(node_list[right_child_idx])

    return None


def in_parse(v):
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        in_parse(node_list[left_child_idx])

    print(' ' + str(v.index), end='')

    if right_child_idx != -1:
        in_parse(node_list[right_child_idx])

    return None


def post_parse(v):
    if not v.children:
        return None
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        post_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        post_parse(node_list[right_child_idx])

    print(' ' + str(v.index), end='')

    return None


def generate_tree(_array):
    # add info of each node of a ordered tree
    for each in _array:
        idx, *children = [int(x) for x in each]
        # assert len(children) == 2 and idx >= 0
        node_list[idx].index = idx
        node_list[idx].children = children

        for child_idx in children:
            # non-existent node: no parent
            if child_idx == -1:
                continue
            node_list[child_idx].parent = idx

    # find root node
    root_idx = [x.index for x in node_list if x.parent == -1][0]
    root_node = node_list[root_idx]

    # tree walk in 3 ways
    print('Preorder')
    pre_parse(root_node)
    print('\n' + 'Inorder')
    in_parse(root_node)
    print('\n' + 'Postorder')
    post_parse(root_node)
    print('')

    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.split(), _input[1:]))
    # assert len(array) == array_length

    node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array)

Measured memory_bytes: 7852
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static long[][] selfCon, selfUncon;
    static long mod = 1000000000+7;
    static int n;
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),  B = sc.nextInt(),T = sc.nextInt();
        int ans = T/A*B;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char tmp = s[0];
  int num = 0;
  for (int i = 1; i < s.size(); i++) {
    if (tmp != s[i]) {
      num++;
    }
    tmp = s[i];
  }

  rep(i, k) {
    if (num >= 2) {
      num -= 2;
    } else if (num == 1) {
      num = 0;
    }
    if (num == 0) {
      break;
    }
  }

  int ans = n - num - 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512