akhauriyash/Code-Regression huggingface dataset:
h,m=map(int,input().split())
l=[0]*(m+1)
for i in range(h):
  a,*b=map(int,input().split())
  for f in b:
    l[f]+=1
ls=sorted(l,reverse=True)
asd=1
fg=0
while True:
  de=ls.pop(0)
  if de==h:
    fg+=1
  else:break
print(fg)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <set>

int main(void)
{
	int ans = 0;
	int n = 0, q = 0;
	std::cin >> n;
	std::vector<int> S(n);
	for (auto &a : S)
		std::cin >> a;
	std::cin >> q;
	for (size_t i = 0; i < q; i++)
	{
		int in = 0;
		std::cin >> in;

		for(auto a  :S)
			if (a == in) {
				ans++;
				break;
			}
	}

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

Measured memory_bytes: 3092
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();
   int c = sc.nextInt();
   int d = sc.nextInt();
 
   if(Math.abs(a-c)<=d||Math.abs(a-b)<=d&&Math.abs(b-c)<=d) System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 200001
#define Max 10000
typedef struct{
    int num,id;
    char mark;
}card;

void swap(card *a,card *b){
    card tmp =*a;
    *a=*b,*b=tmp;
}
int partition(card *A,int p, int r){
    int x = A[r].num;
    int i = p-1;
    for(int j=p;j<r;j++){
        if(A[j].num<=x){
            i+=1;
            swap(&A[i],&A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}
 
void Quicksort(card *A,int p,int r){
    if(p<r){
        int q=partition(A,p,r);
        Quicksort(A,p,q-1);
        Quicksort(A,q+1,r);
    }
}

int isStable(card *a,int n){
    int i;
    for(i=0;i<n-1;i++){
        if(a[i].num==a[i+1].num && a[i].id>a[i+1].id) return 0;
    }
    return 1;
}
int main()
{
    int n;
    card A[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf(" %c %d",&A[i].mark,&A[i].num);
        A[i].id=i;
    }
    Quicksort(A,0,n-1);

    printf("%s\n",isStable(A,n)?"Stable":"Not stable");
    for(int i=0;i<n;i++)
        printf("%c %d\n",A[i].mark,A[i].num);

  return 0;
}


Measured memory_bytes: 3016
# AOJ 1564: String Compression
# Python3 2018.7.13 bal4u

f = [0]*128
ch0, ch9n, cha, chzn = ord('0'), ord('9')+1, ord('a'), ord('z')+1

def act(start, end, n):
	while True:
		for i in range(start, end):
			if f[i] == 0: continue
			f[i] -= 1; S.append(i)
			n -= 1
			if n <= 0: return

S = list(input())
w = len(S)
for s in S: f[ord(s)] += 1
n1 = sum(f[ch0:ch9n]); n2 = w-n1
S = []
if n1 > 0: act(ch0, ch9n, n1)
if n2 > 0: act(cha, chzn, n2)
ans, i = w, 0
while i < w:
	j = i+1
	while j < w and S[j] == S[j-1]+1: j += 1
	if j-i > 3: ans -= j-i-3
	i = j
print(ans)



Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	string s;
	cin >> s;
	bool flag = false;
	if(s[0] == s[1] && s[2] == s[3] && s[3] == s[1]){
		cout << "No" <<endl;
		return 0;
	}
	if(s[0] == s[1] && s[2] == s[3]) flag = true;
	else if(s[1] == s[2] && s[0] == s[3]) flag = true;
	else if(s[0] == s[2] && s[1] == s[3] ) flag = true;

	if(flag) cout << "Yes" <<endl;
	else cout << "No" << endl;

  return 0;
}


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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    q.push(a);
  }
  
  for(int i = 0; i < m; i++){
    int a = q.top();
    a /= 2;
    q.pop();
    q.push(a);
  }
  
  long long cost = 0;
  for(int i = 0; i < n; i++){
    cost += q.top();
    q.pop();
  }
  
  cout << cost << endl;
  
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << s.find_last_of('Z') - s.find_first_of('A') + 1 << endl;
  return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char str[131072];
char S[131072];
int inv[46000];
bool ok;
int p;
pair<int,int> eq(int a);
pair<int,int>ter(int a){
	if(S[a]=='('){
		pair<int,int> t=eq(a+1);
		t.second++;
	//	printf("t%d %d %d\n",a,t.first,t.second);
		return t;
	}else{
		int at=a;
		int now=0;
		while('0'<=S[at]&&S[at]<='9'){
			now=(now*10+S[at]-'0')%p;
			at++;
		}
	//	printf("t%d %d %d\n",a,now,at-1);
		return make_pair(now,at-1);
	}
}
pair<int,int>fac(int a){
	pair<int,int> t=ter(a);
	int ret=t.first;
	while(S[t.second+1]=='*'||S[t.second+1]=='/'){
		if(S[t.second+1]=='*'){
			t=ter(t.second+2);
			ret=ret*t.first%p;
		}else{
			t=ter(t.second+2);
			ret=ret*inv[t.first]%p;
			if(t.first==0)ok=false;
		}
	//	t.second++;
	}
//	printf("f%d %d %d\n",a,ret,t.second);
	return make_pair(ret,t.second);
}
pair<int,int> eq(int a){
	pair<int,int> t=fac(a);
	int ret=t.first;
	while(S[t.second+1]=='+'||S[t.second+1]=='-'){
		if(S[t.second+1]=='+'){
			t=fac(t.second+2);
			ret=(t.first+ret)%p;
		}else{
			t=fac(t.second+2);
			ret=(p+ret-t.first)%p;
		}
	//	t.second++;
	}
//	printf("e%d %d %d\n",a,ret,t.second);
	return make_pair(ret,t.second);
}
int main(){
	while(1){
		gets(str);
		if(str[0]=='0')return 0;
		ok=true;
		p=0;
		int at=0;
		while('0'<=str[at]&&str[at]<='9'){
			p*=10;
			p+=str[at++]-'0';
		}
		inv[1]=1;
		for(int i=2;i<p;i++)inv[i]=p-p/i*inv[p%i]%p;
		at++;
		int v=0;
		for(int i=at;str[i];i++){
			if(str[i]!=' ')S[v++]=str[i];
		}
		S[v]=0;
		int res=eq(0).first;
		if(!ok)printf("NG\n");
		else printf("%s = %d (mod %d)\n",S,res,p);
		//printf("%s\n%s\n",str,S);
	}
}

Measured memory_bytes: 1276
N, K = map(int, input().split())
 
score = N
counter_tmp = 0
ans = 0
 
 
for i in range(N):
    counter_tmp = 0
    score = i + 1
    while score < K:
        score = score * 2
        counter_tmp += 1
    ans += 1 / (N * (2 ** counter_tmp))
 
print(ans)

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

int main(){
	double n;
	while(cin >> n){
		if(n > 91.00) cout << "heavy" << endl;
		else if(n > 81.00) cout << "light heavy" << endl;
		else if(n > 75.00) cout << "middle" << endl;
		else if(n > 69.00) cout << "light middle" << endl;
		else if(n > 64.00) cout << "welter" << endl;
		else if(n > 60.00) cout << "light welter" << endl;
		else if(n > 57.00) cout << "light" << endl;
		else if(n > 54.00) cout << "feather" << endl;
		else if(n > 51.00) cout << "bantam" << endl;
		else if(n > 48.00) cout << "fly" << endl;
		else cout << "light fly" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

satis = int(0)
before_value = int(100)

for value in a:
  satis += b[value-1]
  if before_value == (value-1):
    satis += c[value-2]
  before_value = value

print(satis)

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

int main(){
  int a,b,c,d;
  cin>>a;
  d=0;
  for(b=1;b<=3;b++){
    c=a%10;
    a=a/10;
    d=a%10;
    if(c==d){
      	cout << "Bad";
    	return 0;
            }
  }
  cout << "Good";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int H[20];
    for(int i=0;i<N;i++)
        cin >> H[i];
    
    // N個の旅館
    int ans = 0;
    for(int i=0;i<N;i++){
        bool flag = true;
        for(int j=0;j<i;j++){
            if(H[j] > H[i])
                flag = false;
        }
        if(flag)
            ans++;
    }
    
    cout << ans << endl;    

}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,N;
    cin >> H >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll sum = 0;
    rep(i,0,N) sum += A[i];
    if(sum >= H){
        print("Yes");
    }else{
        print("No");
    }

}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		
		Scanner Cf=new Scanner(System.in);
		int a=Cf.nextInt();
		int b=Cf.nextInt();
		if(a+b==15) {
			System.out.println("+");
		}
		else if(a*b==15) {
			System.out.println("*");
		}
		else {
			System.out.println("x");
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	std::string s, t;

	std::cin >> s;

	t = "keyence";

	for (size_t start = 0; start < s.length(); start++) {
		for (size_t remove_str_size = 0; remove_str_size < s.length() - start; remove_str_size++) {
			std::string tmp = s;
			tmp.erase(tmp.begin() + start, tmp.begin() + start + remove_str_size);
			if (tmp == t) {
				std::cout << "YES" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "NO" << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = Integer.parseInt(sc.next());
    int g = Integer.parseInt(sc.next()) / 100;
    int sum;
    int[] p = new int[d];
    int[] c = new int[d];
    int ans = Integer.MAX_VALUE;
    for(int i = 0; i < d; i++) {
      p[i] = Integer.parseInt(sc.next());
      c[i] = Integer.parseInt(sc.next()) / 100;
    }
    int count;
    for(int i = 0; i < 1 << d; i++) {
      sum = 0;
      count = 0;
      int[] used = new int[d];
      for(int j = 0; j < d; j++) {
        if((1 & i >> j) == 1) {
          sum += p[j] * (j + 1) + c[j];
          count += p[j];
          used[j] = 1;
        }
      }
      for(int j = d - 1; j >= 0; j--) {
        if(sum >= g) break;
        if(used[j] == 0) {
          for(int k = 0; k < p[j] - 1; k++) {
            sum += j + 1;
            count++;
            if(sum >= g) break;
          }
        }
      }
      if(sum >= g) ans = Math.min(ans, count);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int H, W;
    cin >> H >> W;
    vector<string> B(H, string(W, '.')), R(H, string(W, '.'));

    rep(i, H) {
        (i & 1 ? B[i] : R[i]) = string(W, '#');
        B[i][0] = R[i][W - 1] = '.';
        R[i][0] = B[i][W - 1] = '#';
    }

    rep(i, H) rep(j, W) {
        char c;
        cin >> c;
        if(c == '#') B[i][j] = R[i][j] = '#';
    }

    rep(i, H) cout << B[i] << endl;
    cout << endl;
    rep(i, H) cout << R[i] << endl;

    return 0;
}

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

int main()
{
        int r, c;
        cin >> r >> c;

        int A[r+1][c+1];

        for (int i = 0; i < r; ++i) {

                int c_sum = 0;
                for (int j = 0; j < c; ++j) {

                        int tmp;
                        cin >> tmp;
                        A[i][j] = tmp;
                        c_sum += tmp;
                }
                A[i][c] = c_sum;

        }

        for (int i = 0; i < c+1; ++i) {

                int r_sum = 0;
                for (int j = 0; j < r; ++j) {

                        r_sum += A[j][i];

                }
                A[r][i] = r_sum;
        }

        for (int i = 0; i < r+1; ++i) {
                for (int j = 0; j < c+1; ++j) {
                        cout << A[i][j];
                        if (j != c) cout << " ";
                }
                cout << endl;
        }






}



Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using Graph = vector<vector<long long>>;

int main() {
  long long N, M;
  cin >> N >> M;
  Graph G(N);
  vector<long long> wp(N, -1);
  for (long long i = 0; i < M; i++) {
    long long a, b; cin >> a >> b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> dist(N, -1);
  queue<long long> que;
  dist[0] = 0;
  que.push(0);
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    for (long long nv : G[v]) {
      if (dist[nv] != -1) continue;
      dist[nv] = dist[v] + 1;
      if (wp[nv] == -1 ) {
        wp[nv] = v;
      } else if (wp[nv] < v) {
        cout << "No" << endl;
        return 0;
      }
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for (long long i = 1; i < N; i++) {
    cout << (wp[i]+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 13660
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
char s[N];
int n,dp[N],mask[N];
unordered_map<int,int> hs;
int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0]=0;
	hs[0]=0;
	rep(i,1,n+1) {
		mask[i]=mask[i-1]^(1<<(s[i]-'a'));
		dp[i]=1<<30;
		if (hs.count(mask[i])) {
			dp[i]=min(dp[i],hs[mask[i]]+1);
		}
		rep(j,0,26) {
			if (hs.count(mask[i]^(1<<j))) dp[i]=min(dp[i],hs[mask[i]^(1<<j)]+1);
		}
		if (!hs.count(mask[i])) hs[mask[i]]=dp[i];
		else hs[mask[i]]=min(hs[mask[i]],dp[i]);
	}
	printf("%d\n",dp[n]);
}


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

int main(){
  int a,c=0;
  cin >> a;
  vector<int>b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  sort(b.begin(),b.end());
  for(int i=0;i<a-1;i++){
    if(b.at(i)==b.at(i+1)) c++;
  }
  if(c==0) cout <<"YES";
  else cout <<"NO";
}


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

int main(){
  int a,b,c=1,i=0;
  cin >> a >> b;
  while(1){
      if(b==1)
      break;
    c += a-1;
    i++;
    if(c>=b)
    break;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll INF = 1e9 + 10 ;
const ll N = 110 ; 
int main(){
    fastio
    int n ; 
    cin >> n ;
    vector<int> A(n) , B(n) , C(n - 1);
    for(int i = 0; i < n; i++){
        cin >> A[i] ; 
        A[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> B[i] ; 
    }
    for(int i = 0; i < n - 1; i++){
        cin >> C[i] ; 
    }
    int last = -2 ;
    int ans = 0 ; 
    for(int i = 0; i < n; i++){
        ans += B[A[i]];
        if ( A[i] == last + 1 ){
            ans += C[last];
        }
        last = A[i];
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll a; cin>>a;
	set <ll> s;
	s.insert(a);
	for(int i=2;;i++)
	{
	    if(a&1)
	    {
	        a = 3*a + 1;
	        if( s.find(a)!=s.end() ){ cout<<i; return 0; }
	        s.insert(a);
	        continue;
	    }
	    a = a/2;
	    if( s.find(a)!=s.end() ){ cout<<i; return 0; }
	    s.insert(a);
	    //cout<<a<<' ';
	}
	
	return 0;
}


Measured memory_bytes: 256
class Node:
    __slots__ = ["string", "index"]
    def __init__(self, string, index):
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        out = [None]*(self.index+1)
        for i, c in enumerate(s[:self.index]):
            out[i] = Node(parent+c, self.index)
        out[i+1] = Node(parent+s[self.index], self.index+1)
        return out

def main():
    n = int(input())
    root = Node("a", 1)
    children = [root]
    for _ in range(n-1):
        parents, children = children, []
        for parent in parents:
            children.extend(parent.get_children())
    for child in children:
        print(child.string)

if __name__ == "__main__":
    s = "abcdefghij"
    main()

Measured memory_bytes: 21816
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	int dpl[n+1];
	int dpr[n+1];
	dpl[0]=0;dpr[0]=0;
	int index=INT_MIN;
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='x')
			dpl[i]=dpl[i-1];
		else if(index+c<i)
		{
			dpl[i]=dpl[i-1]+1;
			index=i;
		}
		else
			dpl[i]=dpl[i-1];
	}
	dpr[0]=0;
	index=INT_MIN;
	for(int i=1;i<=n;i++)
	{
		if(s[n-i]=='x')
			dpr[i]=dpr[i-1];
		else if(index+c<i)
		{
			dpr[i]=dpr[i-1]+1;
			index=i;
		}
		else
			dpr[i]=dpr[i-1];
	}
	for(int i=0;i<n;i++)
	{
		int left=i;
		int right=n-i-1;
		if(s[i]=='o' && dpl[left]+dpr[right]+1>=k && dpl[left]+dpr[right]<k)
			cout<<i+1<<endl;
	}
}












Measured memory_bytes: 6840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (op != '?') {
		switch (op) {
			case '+':
				cout << a + b << endl;
				break;
			case '-':
				cout << a - b << endl;
				break;
			case '*':
				cout << a * b << endl;
				break;
			case '/':
				cout << a / b << endl;
				break;
			default:
				assert(false);
		}
		cin >> a >> op >> b;
	}

	return 0;
}



Measured memory_bytes: 3124
/*
 * 16-8-28_ABC044_B.cpp
 *
 *  Created on: 2016/08/28
 *      Author: ryoma
 */

#include<iostream>
#include<string>


using namespace std;

int a[26];

int main(){
	string w;
	cin >> w;
	for(int i=0;i<w.length();i++){
		int n = w[i]-'a';
		a[n] = !a[n];
	}
	bool ok = true;
	for(int i=0;i<26;i++){
		if(a[i]){
			ok = false;
					break;
		}
	}
	cout<<(ok? "Yes":"No")<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
constexpr int MOD=1e9+7;

const int mod = 2019 ; 



int main() {
    string s  ; 
    cin >> s ; 
    ll ans = 0 ; 
    int suff = 0;
    int power = 1  ;
    int n = s.size() ; 
    map<int,int> cnt ; 
    cnt[suff]++; 
    for(int i = n -1 ; i >= 0 ; --i) {
        int digit = s[i] - '0' ; 
        suff = (suff + digit * power ) % mod ; 
        power = (power * 10 ) % mod ; 
        ans += cnt[suff] ; 
        cnt[suff]++;
    } 

    cout << ans << endl ;

    return 0 ; 
}

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

//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  /*Cだけrep(j,m)に入れないでcinするのが分からなくて
  n*(m+1)行列にCもAも入れようとしてた*/
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,n) {
    cin >> c.at(i); //c[i]
    rep(j,m)
      cin >> a.at(i).at(j); //a[i][j]
  }
  
  int all = 1<<n; //2^n 全通り
  /*わざわざ分けて定義しなくて良い*/
  //int INF = 1200001; //10^5円を12冊買った場合より高い
  //int ans = INF; //求める最小値　起こりえない金額で初期化
  int ans = 1200001; 
  /*以下3つ定義＆初期化する場所気をつける*/
  //int cost = 0; //買った参考書の合計金額
  //vector<int> level(m); //j番目のアルゴリズムの理解度
  //bool ok = true; //全アルゴリズムで理解度がxより高いか判定
  
  rep(mask,all){ //全通り試す。bit全探索
    vector<int> level(m); //前に試した場合でのlevel引きずらないために宣言する場所に注意
    int cost = 0; //上に同じ
    rep(i,n){
      /*n→0の順で並んでるから右にiずらせばi番目の参考書の0/1が最下位bitにくる*/
      if(mask>>i&1){ //i番目の参考書買ってれば //1&1だけ1
        cost += c[i];
      	rep(j,m)
          level[j] += a[i][j];
      }
    }
    bool ok = true; //上に同じ。前に試した場合でfalse入っちゃってても戻せる。使う直前で宣言すると無難かな
    rep(j,m){
      if(level[j]<x)
        ok = false;
    }
    if(ok)
      //chmin(ans,cost);
      /*cost[i]とcost[i+1]の大小ずっと比べてくとかじゃないからchminじゃなくて良い*/
      ans = min(ans,cost);
  }
  if(ans==1200001)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int n, s, ans = 0;
void dfs(int cnt, int sum, int now);
int main() {
    while (1) {
        cin >> n >> s;
        if (n == 0 && s == 0) break;
        ans = 0; //when call dfs next time, ans should start from 0
        dfs(0, 0, 0);
        cout << ans << endl;
    }
}
void dfs(int cnt, int sum, int now) {
    if (now > 9) {
        if (cnt == n && sum == s) {
            ans++;
        }
        return;
    }
    dfs(cnt + 1, sum + now, now + 1);
    dfs(cnt, sum, now + 1);
    return;
}



Measured memory_bytes: 3104
n = gets.to_i
h = {}
n.times do
  s = gets
  h[s.chomp]=1
end

for m in ["S", "H", "C", "D"] do
  for i in 1..13 do
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end
end


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

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> ss(n);
  rep(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ss[i] = s;
  }
  sort(ss.begin(), ss.end());
  ll ans = 0;
  ll cnt = 0;
  for (int i = 1; i < n; i++) {
    if (ss[i - 1] == ss[i]) {
      cnt++;
    } else {
      ans += (cnt + 1) * cnt / 2;
      cnt = 0;
    }
  }
  ans += (cnt + 1) * cnt / 2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6360
# coding: utf-8
# Your code here!
n1=int(input())
n2=int(input())
n3=int(input())
n4=int(input())
n5=int(input())
n6=int(input())
n7=int(input())
n8=int(input())
n9=int(input())
n10=int(input())
n11=int(input())
n12=int(input())
n13=int(input())
n14=int(input())
n15=int(input())
n16=int(input())
n17=int(input())
n18=int(input())
n19=int(input())
n20=int(input())

n1,n2,n3,n4,n5,n6,n7,n8,n9,n10=sorted([n1,n2,n3,n4,n5,n6,n7,n8,n9,n10])
n11,n12,n13,n14,n15,n16,n17,n18,n19,n20=sorted([n11,n12,n13,n14,n15,n16,n17,n18,n19,n20])

print(n8+n9+n10,n18+n19+n20)



Measured memory_bytes: 5612
#include<stdio.h>
#define MAX 100000

int main(){
  int n,i,A[MAX + 1];


  scanf("%d",&n);

  for(i = 1;i < n + 1;i++){
    scanf("%d",&A[i]);
  }

  for(i = 1;i < n + 1;i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(i / 2 >= 1){
      printf("parent key = %d, ",A[i / 2]);
    }
    if(i * 2 <= n){
      printf("left key = %d, ",A[i * 2]);
    }
    if(i * 2 + 1 <= n){
      printf("right key = %d, ",A[i * 2 + 1]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2148
#include <cstdio>
int h,m,s;main(){while(scanf("%d%d%d",&h,&m,&s)&&h!=-1){int r=7200-(h*60+m)*60-s;for(int i=0;i<2;i++,r*=3){printf("%02d:%02d:%02d\n",r/60/60,(r/60)%60,r%60);}}return 0;}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;
int main() {
	int a, b, c, r = 0;
	cin >> a >> b >> c;
	vector<int> d;
	d.push_back(a);
	d.push_back(b);
	d.push_back(c);
	for (int i = 0; i < 3; ++i) {
		int e = d[i];
		for (int j = i + 1; j < 3; ++j) {
			if (e == d[j]) {
				++r;
				break;
			}
		}
	}
	r = 3 - r;
	cout << r << endl;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
const ll inf = 1e18;
void tc(){
    int n;
    cin >> n;
    vector<ll> a;
    ll x = 1;
    for(int i = 0; i < n; i++){
        ll y;
        cin >> y;
        a.PB(y);
        if(y == 0){
            cout << 0;
            return;
        }
    }
    for(auto y : a){
        if(x > inf / y){
            cout << -1;
            return;
        }else{
            x = x * y;
        }
    }
    cout << x;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 4284
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	string s;
	int k;
	cin>>s>>k;
	
	string t=s+s;
	llong cnt=0;
	llong cntt=0;
	for(int i=1;i<t.size();++i){
		if(t[i-1]==t[i]){
			if(0<=i and i<s.size()) cnt++;
			if(i>=s.size()) cntt++;
			t[i]='0';
		}
	}
	
	bool jud=(t[0]==t[t.size()-1]);
	
	llong ans;
	if(jud) ans=cnt+cntt*(k-1);
	else ans=cnt*(k/2+k%2)+cntt*(k/2);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def main():
    def readline_and_rstrip() -> str:
        s = sys.stdin.readline()
        return s.rstrip()

    n = int(readline_and_rstrip())
    a = [int(_) for _ in readline_and_rstrip().split()]

    a.sort(reverse=True)

    if n == 2:
        print(a[0])
    elif n == 3:
        print(a[0] + a[1])
    elif (n - 2) % 2 == 0:
        middle_len = (n - 2) // 2
        a_middle = a[1:1 + middle_len]
        print(a[0] + sum(map(lambda x: x * 2, a_middle)))
    else:
        middle_len = (n - 2) // 2
        a_middle = a[1:1 + middle_len]
        print(a[0] + sum(map(lambda x: x * 2, a_middle)) + a[1 + middle_len])


if __name__ == '__main__':
    main()


Measured memory_bytes: 31528
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
 ll n,d;cin>>n>>d;
 vector<pair<ll,ll>>  po;
 while(n--)
 {  int x,y;cin>>x>>y;
    po.pb({x,y});
 }
 int res=0;
 for(auto i:po)
 {  ll tp=(i.F*i.F+i.S*i.S);
    //tp=sqrt(tp);
    if(tp<=d*d)
    res++;
 }
 p(res);
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 14440
#include <bits/stdc++.h>
#define ll          long long int
#define pii         pair<int,int>
#define uu          first
#define vv          second
#define fastIO      ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

const int MAX = 2e5 + 5;
const ll INF = 1e18;
int main()
{
    fastIO;
    string s1, s2;
    cin>>s1>>s2;
    int n1 = s1.size();
    int n2 = s2.size();
    
    vector< vector<int> > dp(n1+1 , vector<int>(n2+1));
    
    s1 = '*' + s1;
    s2 = '*' + s2;
    
    for(int i =1 ; i <=n1 ; i++)  {
        for(int j =1 ; j <=n2 ; j++ ) {
            if(s1[i] == s2[j]) dp[i][j] = dp[i-1][j-1] + 1;
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
        }
    }
    
    int val = dp[n1][n2];
    string ans = "";
    
    int tmp1 = n1 , tmp2 = n2;
    
    while(tmp1>=1 && tmp2 >=1) {
        
        if(s1[tmp1] == s2[tmp2]) {
            ans += s1[tmp1];
            tmp1--;
            tmp2--;
        }
        else if(dp[tmp1][tmp2-1]  > dp[tmp1-1][tmp2]) tmp2--;
        else tmp1--;
    }
    
    reverse(ans.begin(), ans.end());
    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 38572
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#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 unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    int H, W;
    cin >> H >> W;

    vector<int> c(26);
    rep(i, H)
    {
        string s;
        cin >> s;
        for (auto x : s)
        {
            c[x - 'a']++;
        }
    }

    int cnt1;
    int cnt2;
    int cnt4;

    if (H % 2 == 0 && W % 2 == 0)
    {
        cnt1 = 0;
        cnt2 = 0;
        cnt4 = H * W - cnt1 - cnt2;
    }
    else if (H % 2 != 0 && W % 2 != 0)
    {
        cnt1 = 1;
        cnt2 = H + W - 2;
        cnt4 = H * W - cnt1 - cnt2;
    }
    else
    {
        if (H % 2 != 0)
        {
            int tmp = H;
            H = W;
            W = tmp;
        }

        cnt1 = 0;
        cnt2 = H;
        cnt4 = H * W - cnt1 - cnt2;
    }

    cnt2 /= 2;
    cnt4 /= 4;

    rep(i, 26)
    {
        if (c[i] == 0) continue;

        cnt4 -= c[i] / 4;
        c[i] %= 4;

        cnt2 -= c[i] / 2;
        c[i] %= 2;

        cnt1 -= c[i];
        c[i] %= 1;
    }

    if (cnt1 == 0 && cnt2 == 0 && cnt4 == 0)
    {
        cout << "Yes" << endl;
    }
    else if (cnt1 == 0 && cnt4 < 0 && 2 * cnt4 + cnt2 == 0)
    {
        //4の一部を2に回してトータルを0にできる
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      string s;
      cin >> s;
      string ans;
      rep(i,s.size()){
          if(s[i]!='B'){
              ans.push_back(s[i]);
          }
          else{
              if(ans.size()==0)continue;
              else ans.pop_back();
          }
      }
      cout << ans << endl;
  }

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>

struct city{
  int num,pref,year;
  char nums[13];
};

int comp1(const void *p1,const void *p2){
  struct city n1=*(const struct city *)p1;
  struct city n2=*(const struct city *)p2;

  return (n1.pref!=n2.pref) ? (n1.pref-n2.pref) : (n1.year-n2.year) ;
}

int comp2(const void *p1,const void *p2){
  struct city n1=*(const struct city *)p1;
  struct city n2=*(const struct city *)p2;

  return n1.num-n2.num;
}

int main(void){
  int N,M;
  int i,j,k=1;
  
  scanf("%d%d",&N,&M);
  struct city *cities;
  cities=(struct city *)calloc(M,sizeof(struct city));

  for(i=0;i<M;i++){
    cities[i].num=i;
    scanf("%d%d",&cities[i].pref,&cities[i].year);
  }

  qsort(cities,M,sizeof(struct city),comp1);
  
  int p;
  for(i=0,p=-1;i<M;i++){
    if(p!=cities[i].pref){
      p=cities[i].pref;
      k=1;
    }
    sprintf(cities[i].nums,"%06d%06d",cities[i].pref,k);
    ++k;
  }

  qsort(cities,M,sizeof(struct city),comp2);

  for(i=0;i<M;i++) printf("%s\n",cities[i].nums);
  
  free(cities);
  return 0;
}


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

unsigned long long gcd(unsigned long long a,unsigned long long b){
    if (a < b)
        return gcd(b, a);
    unsigned long long r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    unsigned long long a, b;
    cin >> a >> b;
    
    unsigned long long tmp = gcd(a,b);
    int cnt = 1;
    for (unsigned long long cut = 2; cut * cut < tmp ;++cut){
        if(tmp % cut == 0){
        while(tmp % cut == 0)tmp /= cut;
        cnt++;
        }
    }
    if(tmp != 1)
        cnt++;

    cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

ll f(ll a)
{
    ll brojKeceva = (a + 1) / 2LL;
    ll nesto = 1LL;

    if(brojKeceva % 2 == 0)
    {
        nesto = 0LL;
    }

    if(a % 2 == 0)
    {
        return nesto^a;
    }

    else
    {
        return nesto;
    }
}

int main()
{
    ll a, b;

    cin >> a >> b;

    ll f1 = f(a - 1);
    ll f2 = f(b);
    ll fe = f1^f2;

    cout << fe << '\n';

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def cost(N, points, pointToIndex, p, q):
  s = 0

  visited = [False for _ in range(N)]
  for i in range(N):
    if visited[i]: continue

    s += 1
    visited[i] = True

    k = 1
    while (points[i][0] + p * k <= points[-1][0]) and (points[i][1] + q * k <= points[-1][1] or points[i][1] + q * k >= points[-1][1]):
      np = (points[i][0] + p * k, points[i][1] + q * k)
      if np in pointToIndex and not visited[pointToIndex[np]]:
        visited[pointToIndex[np]] = True
        k += 1
      else:
        break

  return s

def main():
  N = readInts()[0]
  points = [tuple(readInts()) for _ in range(N)]
  points.sort()

  ans = N

  pointToIndex = {}
  for i, point in enumerate(points):
    pointToIndex[point] = i

  for i in range(N-1):
    for j in range(i+1, N):
      p = points[j][0] - points[i][0]
      q = points[j][1] - points[i][1]
      ans = min(ans, cost(N, points, pointToIndex, p, q))

  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, m, q = io.read("*n", "*n", "*n")
local t = {}
for iq = 1, q do
  local a, b, c, d = io.read("*n", "*n", "*n", "*n")
  t[iq] = {a, b, c, d}
end

local function combination_get_map(n)
  local combmap = {}
  for i = 1, n do
    combmap[i] = {}
    local ret = 1
    for j = 1, i do
      ret = mfl(ret * (i + 1 - j) / j)
      combmap[i][j] = ret
    end
  end
  return combmap
end
local function combination_get_count(combmap, n, k)
  if k < 0 then return 0
  elseif n < k then return 0
  elseif k == 0 then return 1
  else return combmap[n][k]
  end
end

local function combination_get_array(combmap, n, k, idx)
  local rem = k
  local retary = {}
  for i = 1, n do
    local useCnt = combination_get_count(combmap, n - i, rem - 1)
    local unuseCnt = combination_get_count(combmap, n - i, rem)
    if idx <= useCnt then
      rem = rem - 1
      table.insert(retary, i)
    else
      idx = idx - useCnt
    end
  end
  return retary
end

local combmap = combination_get_map(n + m - 1)
local combcnt = combination_get_count(combmap, n + m - 1, n)
local ans = 0
for i = 1, combcnt do
  local ary = combination_get_array(combmap, n + m - 1, n, i)
  for j = 1, n do
    ary[j] = ary[j] - j + 1
  end
  local r = 0
  for iq = 1, q do
    local a, b, c, d = unpack(t[iq])
    if ary[b] - ary[a] == c then
      r = r + d
    end
  end
  ans = mma(ans, r)
end
print(ans)


Measured memory_bytes: 2752
N,C=map(int, input().split())
D=[list(map(int, input().split())) for _ in range(C)]
clr=[[0 for _ in range(C) ] for _ in range(3)]
cost=[[0 for _ in range(C) ] for _ in range(3)]

for i in range(N):
    ci=list(map(int, input().split()))
    for j, cij in enumerate(ci):
        clr[(i+j)%3][cij-1]+=1 

for i in range(3):
    for j in range(C):
        for k in range(C):
            cost[i][k]+=(D[j][k])*clr[i][j]

ans=1000*500*500
for i in range(C):
    for j in filter(lambda x:x!=i,range(C)):
        for k in filter(lambda x:x!=i and x!=j, range(C)):
            #print(cost[0][i]+cost[1][j]+cost[2][k])
            ans=min(cost[0][i]+cost[1][j]+cost[2][k], ans)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5, mod = 1e9 + 7;
ll quickpow(ll x, ll k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}
struct e{
    int cnt, id;
}a[maxn];
vector<int> g[maxn];
bool cmp(e a, e b){return a.cnt > b.cnt;}
bool cmp2(int a, int b){return a > b;}

int num[maxn], cost[maxn], cp = 2;
ll ans = 0;
void dfs(int u, int p)
{
    if (p != -1) ans += min(num[u], num[p]);
    for (int i = 0; i < g[u].size(); ++i){
        if (g[u][i] == p) continue;
        dfs(g[u][i], u);
    }
}
void dfs2(int u, int p)
{
    vector<e> vi;
    for (int i = 0; i < g[u].size(); ++i){
        if (g[u][i] == p) continue;
        vi.push_back(e{g[g[u][i]].size(), g[u][i]});
    }
    sort(vi.begin(), vi.end(), cmp);
    for (int i = 0; i < vi.size(); ++i){
        if (vi[i].id == p) continue;
        num[vi[i].id] = cost[cp];
        ++cp;
    }
    for (int i = 0; i < vi.size(); ++i){
        if (vi[i].id == p) continue;
        dfs2(vi[i].id, u);
    }
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int u, v;
    int m = n - 1;
    while (m--){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i){
        a[i].id = i;
        a[i].cnt = g[i].size();
    }
    for (int i = 1; i <= n; ++i) cin >> cost[i];
    sort(a + 1, a + 1 + n, cmp);
    sort(cost + 1, cost + 1 + n, cmp2);
    num[a[1].id] = cost[1];
    dfs2(a[1].id, -1);
    dfs(a[1].id, -1);
    cout << ans << '\n';
    for (int i = 1; i <= n; ++i) cout << num[i] << (i == n ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main () {
	int x, y;
	cin >> x >> y;
	while ((x > 0) || (y > 0)) {
		if (x > y) {
			cout << y << " " << x << endl;
		} else cout << x << " " << y << endl;
		cin >> x >> y;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000

void CountingSort(int[],int n);

int B[2000000];

int main()
{
  int n,i,A[2000000];

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      scanf("%d",&A[i+1]);
    }
  CountingSort(A,n);
  for(i = 1;i <= n;i++)
    {
      if(i > 1) printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");

  return 0;
}
void CountingSort(int A[],int n)
{
  int i,j,C[MAX];
  for(i = 0;i <= MAX;i++)
    {
      C[i] = 0;
    }
  for(j = 1;j <= n;j++)
    {
      C[A[j]]++;
    }
  for(i = 1;i <= MAX;i++)
    {
      C[i] = C[i] + C[i-1];
    }
  for(j = n;j >= 1;j--)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
}



Measured memory_bytes: 17400