akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())

switch_list = []

for i in range(m):
    s  = list(map(int, input().split()))
    s.pop(0)
    switch_list.append(s)
p_list = list(map(int, input().split()))
#print(switch_list)
#print(p_list)

ans = 0

for bit in range(1 << n): #100・・0(n+1桁)-1 =　111・・・1(n桁)となりn桁のビット演算をfor文で回す
    cnt = 0
    for j in range(0,m):
        switch_sum = 0
        for i in range(n):
            if (bit >> i) & 1 and i+1 in switch_list[j]:
                switch_sum += 1
        if switch_sum%2 == p_list[j]:
            cnt += 1
            if cnt == m:
                ans += 1

print(ans)

Measured memory_bytes: 9204
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a, b;
        a = sc.nextLong();
        b = sc.nextLong();
        if(b > a){
            System.out.println("0");
        }else{
            System.out.println(a - b);
        }
    }
}

Measured memory_bytes: 23636
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//s配列に格納した単語を、辞書順にソートする
//getline(cin, s);
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  string s;
  cin >> s;
  int acnt=0;
  int bcnt=0;
  int ccnt=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='a') acnt++;
    if(s.at(i)=='b') bcnt++;
    if(s.at(i)=='c') ccnt++;
  }
  int high_check = 0;
  int midd_check = 0;
  int loww_check = 0;

  int length = s.size();
  if(length % 3 == 0){
    high_check = length / 3;
    midd_check = length / 3;
    loww_check = length / 3;
  }
  else if(length %3 ==1){
    high_check = length / 3+1;
    midd_check = length / 3;
    loww_check = length / 3;
  }
  else if(length %3 ==2){
    high_check = length / 3+1;
    midd_check = length / 3+1;
    loww_check = length / 3;
  }
  vector<int>b(3);
  b.at(0) = acnt;
  b.at(1) = bcnt;
  b.at(2) = ccnt;
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(b.at(0) == high_check && b.at(1) == midd_check && b.at(2) == loww_check){
    cout << "YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

int main()
{
	string S;
	cin >> S;
	int ans(0), cur(0);
	for(int i(0);i<S.length();++i){
		if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C'){
			cur++;
			if(ans < cur){
				ans = cur;
			}
		}else{
			cur = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    string s;
    cin>>s;
    if (s[sz(s)-1]=='s') {
        s.pb('e');
    }
    s.pb('s');
    cout<<s<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x = in.nextInt();
		if (x == 0)
			System.out.println(1);
		else
			System.out.println(0);
	}

}


Measured memory_bytes: 35784
//Atcoder Round148 task:a
#include<iostream>
using namespace std;
int a,b;
int ab[3]{0,0,0},s=0;
int main(){
	cin>>a;
	cin>>b;
	if(a==1)s++;
	else if(a==2){
	s++;
	s++;
	}
	else if(a==3){
		s++;
		s++;
		s++;
	}
	if(b==1)s++;
	else if(b==2){
	s++;
	s++;
	}
	else if(b==3){
		s++;
		s++;
		s++;
	}
	cout<<6-s<<endl;
	return 0;
	
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
B = []
C = []
D = []

for _ in [0]*N:
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for _ in [0]*M:
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

for i in range(N):
    ans = [300000000, 0]
    for j in range(M):
        s = abs(A[i] - C[j]) + abs(B[i] - D[j])
        if ans[0] > s:
            ans = [s, j+1]
    print(ans[1])


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

int n;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	int ans = 0;
	while(1){
		bool f = false;
		for(int i=0; i<n; ++i){
			if(a[i] % 2 != 0) f = true;
			a[i] /= 2;
		}
		if(f) break;
		++ans;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
#define push_back pb
#define size sz
#define rep(i,a,n) for(int i = (a);i < (n);i++)
#define lep(i,a,n) for(int i = (a);i <= (n);i++)
#define print(X) cout << (X) << endl
typedef long long ll;
typedef vector<int> pb;
typedef pair<int,int> P;

ll n,m,l;
string s,t;

int get(int x, int y){
    int ans = (x *(100+m))/100 + (y * (100+m))/100;
    // printf("get : %d\n", ans);
    return ans;
}

int main(){
    while(cin >> n >> m >> l, (n+m+l != 0)){
        // puts("Input:");
        // cout << n << " " << m << " " << l << endl;
        int ans = -1;
        lep(i,1,l){
            lep(j,1,l){
                if((i * (100+n))/100 + (j * (100+n))/100 == l){
                    // getchar();
                    // print(get(x,y));
                    ans = max(get(i, j), ans);
                }
            }
        }
        print(ans);
    }
    return 0;
}




Measured memory_bytes: 3136
using System;

class Program {
        static void Main(string[] args) {
            int S;
            S = int.Parse(Console.ReadLine());
            int h = 0;
            int m = 0;
            int s = 0;
            
            while(S >= 3600) {
                S -= 3600;
                h++;
            }

            while(S >= 60) {
                S -= 60;
                m++;
            }

            s = S;

            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
}

Measured memory_bytes: 9188
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr(), dtype=np.int32)
counter = np.bincount(A)
case = (counter * (counter-1) // 2).sum()
answer = case - (counter[A] - 1)
print('\n'.join(answer.astype(str)))


Measured memory_bytes: 72820
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
HashSet<Integer> U=new HashSet<>();
int n=Integer.parseInt(sc.next());
for(int i=0;i<n;i++){
U.add(Integer.parseInt(sc.next()));
}
System.out.println(U.size());
}}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

int main(){
	ll n; cin >> n;
	if (n % 2) cout << n / 2 + 1 << endl;
	else cout << n / 2 << endl;
	return 0;
}

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

int main() {
	ll N,x=0,s=0;
	bool ok=1;

	cin >> N;
	vector<ll> A(N+1),m(N+1,0),r(N+1,0),p(N+1);
	rep(i,N+1)
		cin >> A.at(i);

	if(N == 0) {
		if(A.at(0) == 1)
			cout << 1;
		else
			cout << -1;
		cout << endl;
		return 0;
	}
	
	m.at(N) = A.at(N);
	rep(i,N)
		m.at(N-i-1) = m.at(N-i)+A.at(N-i-1);

	r.at(0) = 1;
	p.at(0) = r.at(0)-A.at(0);

	rep(i,N-1) {
		r.at(i+1) = min(m.at(i+1), p.at(i)*2);
		p.at(i+1) = r.at(i+1)-A.at(i+1);

		if(p.at(i+1) < 0) {
			ok = 0;
			break;
		}
	}

	if(p.at(N-1)*2>=A.at(N) && p.at(N-1)<=A.at(N))
		r.at(N) = A.at(N);
	else
		ok = 0;

	rep(i,N+1)
		x += r.at(i);
	cout << ((ok) ? x : -1) << endl;
}

Measured memory_bytes: 6428
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    s = readline().rstrip().decode()
    t = readline().rstrip().decode()
    cnt = 0
    for ss, tt in zip(s, t):
        if ss != tt:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9720
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<cstdio>
#include<unordered_set>
using namespace std;

struct mou{
	long long int height;
	long long int range;
};

int main()
{
	int n, i, j;
	long long int res = 1;
	cin >> n;
	vector<mou> mous(n);
	vector<long long int> a(n);
	vector<long long int> b(n);
	for (i = 0; i < n; i++) {
		mous[i].height = -1;
		mous[i].range = 2147483647;
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	mous[0].height = a[0];
	mous[0].range = a[0];
	for (i = 1; i < n; i++) {
		if (a[i] > a[i - 1]) {
			if (mous[i].height == -1) {
				mous[i].height = a[i];
				mous[i].range = a[i];
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		else if (a[i] == a[i - 1] && mous[i].range > a[i]) {
			mous[i].range = a[i];
		}
	}
	if (mous[n - 1].height == -1) {
		mous[n - 1].height = b[n - 1];
	}
	else if (mous[n - 1].height != b[n - 1]) {
		cout << 0 << endl;
		return 0;
	}
	if (mous[n - 1].height > mous[n - 1].range) {
		cout << 0 << endl;
		return 0;
	}
	mous[n - 1].range = b[n - 1];
	for (i = n - 2; i >= 0; i--) {
		if (b[i] > b[i + 1]) {
			if ( (mous[i].height == -1 || mous[i].height == b[i]) && b[i] <= mous[i].range) {
				mous[i].height = b[i];
				mous[i].range = b[i];
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		else if (b[i] == b[i + 1] && mous[i].range > b[i]) {
			mous[i].range = b[i];
		}
	}
	for (i = 1; i < n - 1; i++) {
		if (mous[i].height == -1) {
			res *= mous[i].range;
			res = res % 1000000007;
		}
	}
	cout << res << endl;
	return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result1{0}, result2{0};
    lol n, m; cin >> n >> m;
    VL a(500001, 0), b(500001, -1);
    FOR(i, 1, m)
    {
        lol p; string s; cin >> p >> s;
        if(s[0] == 'W')
        {
            a[p]++;
        }
        else
        {
            if(b[p] == -1)
            {
                b[p] = a[p];
                result1++;
            }
        }
        
    }
    FOR(i, 1, n)
    {
        if(b[i] != -1)
            result2 += b[i];
    }

    cout << result1 << " " << result2 << endl;
    return 0;
}

Measured memory_bytes: 11164
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n==0)break;
   var ary=[];
   while(n--){
      var hms=arr.shift().split(" ");
      var start=hms[0].split(":").map(Number);
      var end=hms[1].split(":").map(Number);
      start=start[0]*60*60+start[1]*60+start[2];
      end=end[0]*60*60+end[1]*60+end[2];
      ary.push([start,end]);
   }
   ary.sort(function(a,b){return a[0]-b[0];});
   var train=[];
   var cnt=0;
   ary.forEach(function(v){
      if(train.length==0){
         cnt++;
         train.push(v[1]);
      }else{
         train.sort(function(a,b){return a-b;});
         if(train[0]<=v[0]){
            train.shift();
            train.push(v[1]);
         }else{
            cnt++;
            train.push(v[1]);
         }
      }
   });
   console.log(cnt);
}

Measured memory_bytes: 57744
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", (n/3));
	return 0;
}

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

int main()
{
    int a,b;
    for(;;){
        cin >> a >> b;
        if(a==0&&b==0) break;
        int n;
        cin >> n;
        int x[b][a];
        int y[b][a];

        for(int i=0;i<b;i++)
            for(int j=0;j<a;j++){
                x[i][j]=0;
                y[i][j]=0;
            }


        for(int i=0;i<n;i++){
            int k,p;
            cin >> k >> p;
            x[p-1][k-1]=1;//工事中...1
        }

        for(int i=1;i<a;i++)
            if(x[0][i]==0)
                y[0][i]=1;
            else break;

        for(int i=1;i<b;i++)
            if(x[i][0]==0)
                y[i][0]=1;
            else break;

        for(int i=1;i<b;i++)
            for(int j=1;j<a;j++)
                if(x[i][j]==0)
                    y[i][j]=(y[i][j-1]+y[i-1][j]);
        cout << y[b-1][a-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    map<int, int> ma, mb;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        ma[A[i]]++;
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        mb[B[i]]++;
    }
    for(auto v: mb){
        int t = v.second + ma[v.first];
        if(t > N){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    vector<int> right(200100, 0), left(200100, -1);
    for(int i = 0; i < N - 1; i++){
        if(A[i] != A[i + 1]) right[A[i]] = i + 1;
    }
    if(right[A[N - 1]] == 0) right[A[N - 1]] = N;
    int ha = 1e9, ind = 0;
    for(int i = 0; i < N; i++){
        if(left[B[i]] == -1){
            left[B[i]] = N + i;
            if(ha > left[B[i]] - right[B[i]]){
                ha = left[B[i]] - right[B[i]];
                ind = N - ha;
            }
        }
    }
    vector<int> ans(N);
    for(int i = 0; i < N; i++){
        ans[(ind + i) % N] = B[i];
    }
    for(int i = 0; i < N; i++){
        if(i != N - 1) cout << ans[i] << ' ';
        else cout << ans[i] << endl;
    }
}


Measured memory_bytes: 25944
using System;
using System.Linq;

namespace _066
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = "";
            var i = s.Length - 1;
            while(!IsGoo(s.Substring(0,i)))
            {
                i--;
            }

            Console.WriteLine(i);

        }

        static bool IsGoo(string s)
        {
            if(s.Length % 2 == 1)
                return false;
            
            if(s.Substring(0,s.Length / 2) == s.Substring(s.Length / 2, s.Length / 2))
            {
                
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
    int odd[100001];
    int even[100001];
int main(){
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
	int v;
	cin>>v;
        if(i%2==0){
	    even[v]++;
	}else{
	    odd[v]++;
	}
    }
    
    int m=0;
    int mite=0;
    for (int i = 0; i < 100000; ++i) {
	if(even[i]>m){
	    m=even[i];
	    mite=i;
	}
    }
    int em=m;
    int emite=mite;

    m=0;
    mite=0;
    for (int i = 0; i < 100000; ++i) {
	if(odd[i]>m){
	    m=odd[i];
	    mite=i;
	}
    }
    int om=m;
    int omite=mite;

    if(emite!=omite){
	cout<<n-em-om<<endl;
    }else{
	m=0;
	mite=0;
    for (int i = 0; i < 100000; ++i) {
	if(even[i]>m&&i!=emite){
	    m=even[i];
	    mite=i;
	}
    }
    int em2=m;

    m=0;
    mite=0;
    for (int i = 0; i < 100000; ++i) {
	if(odd[i]>m&&i!=omite){
	    m=odd[i];
	    mite=i;
	}
    }
    int om2=m;
    if(em+om2>em2+om){
	cout<<n-em-om2<<endl;
    }else{
	cout<<n-em2-om<<endl;
    }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	DT i, j, q;
	DT a, b, c, n, l;
	cin >> n;
	c = 0;
	forn (i, n) {
		cin >> a;
		c += (a & 1);
	}
	if (c & 1)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int n;
		int cnt = 0;
		cin >> n;
		while(n >= 10){
			int m = 0;
			int a = n;
			for(int j = 1; j < log10(n); j++){
				int k = pow(10,j);
				m = max(m,(n/k)*(n%k));
			}
			n = m;
			if(a == n){
				cnt = -1;
				break;
			}
			cnt++;
		}
		cout << cnt << endl; 
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <stdio.h>

using namespace std;
int n,k,a[200],sum,t,x;
int main()
{
   cin>>n>>k;
   for(int i=1;i<=k;i++)
   {
       scanf ("%d",&t);
       for(int j=1;j<=t;j++)
       {
           scanf ("%d",&x);
           a[x]=1;
       }
   }
   for(int i=1;i<=n;i++)
   {
       if(!a[i])
        sum++;
   }
   printf ("%d\n",sum);
    return 0;
}


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

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

    ll A[N];
    map<ll, ll> dpA{}, dmA{};

    for (ll i=1; i<=N; i++) {
        cin >> A[i-1];
        auto itr1 = dpA.find(i+A[i-1]);
        if (itr1 != dpA.end()) dpA[i+A[i-1]]++;
        else dpA[i+A[i-1]] = 1;

        auto itr2 = dmA.find(i-A[i-1]);
        if (itr2 != dmA.end()) dmA[i-A[i-1]]++;
        else dmA[i-A[i-1]] = 1;
    }

    ll ans = 0;
    for (auto itr1 = dpA.begin(); itr1 != dpA.end(); itr1++) {
        auto itr2 = dmA.find(itr1->first);
        if (itr2 != dmA.end()) ans += itr1->second * itr2->second;
    }

    cout << ans << endl;

    return 0;
}



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

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

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°??????????????????Low_Link 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_A GRL_3_B 

auto low_link(const G& graph){
    int n=graph.size(),k=0;
    vector<int> par(n),ord(n,-1),low(n),root(n,0);

    auto dfs=[&](int v,int p,int &k){
        auto func=[&](int v,int p,int &k,auto func)->void{
            ord[v]=k++,low[v]=ord[v],par[v]=p;
            for(auto &e:graph[v]){
                if(e.to==p) continue;
                if(ord[e.to]==-1)
                    func(e.to,v,k,func),chmin(low[v],low[e.to]);
                else
                    chmin(low[v],ord[e.to]);
            }
        };
        return func(v,p,k,func);
    };

    rep(v,n) if(ord[v]==-1) dfs(v,-1,k),root[v]=1;
    return make_tuple(par,ord,low,root);
}


// Description: ????????°????????????????????? 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_B
// Required: Low-link

auto bridge(const G& graph){
    const int n=graph.size();
    vector<int> par,ord,low,root;
    tie(par,ord,low,root)=low_link(graph);

    using state=tuple<int,int>;
    vector<state> res;
    rep(v,n){
        if(par[v]==-1) continue;
        if(ord[v]<low[par[v]]||ord[par[v]]<low[v]){
            auto in=state(v,par[v]);
            if(get<1>(in)<=get<0>(in)) swap(get<0>(in),get<1>(in));
            res.push_back(in);
        }
    }
    sort(_all(res));
    return res;      
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
		add_edge(graph,b,a);
	}

	auto res=bridge(graph);
	
    for(auto &it:res){
        int a,b;
        tie(a,b)=it;
        cout << a << " " << b << endl;
    } 
	return 0;
}

Measured memory_bytes: 4428
#include<cstring>
#include<iostream>
using namespace std;
string s;
int k;
int main()
{
	cin>>k>>s;
	for(int i=0;i<s.size();i++)
	{
		if(i+1<=k)
		{
			cout<<s[i];
		}
			else
		{
			cout<<"...";
			return 0;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m,c; cin>>n>>m>>c;
	vector<int> b(m);
	for (int i=0; i<m; i++)
		cin>>b[i];
	int ret=0,a;
	for (int i=0; i<n; i++) {
		int cur=c;
		for (int j=0; j<m; j++)
			cin>>a, cur+=a*b[j];
		if(cur>0)
			ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 #include <vector>
 #include <algorithm>
#include <map>
 #include <set>
 #include <cmath>
 #include <cstring>
 #include <iomanip>
 #include <random>
 #include <chrono>
 #include <queue>
 #include <math.h>
 using namespace std;
int main(){
  int n,q;
  cin >>n >>q;
  string s;
  cin >> s;
  // AC を数える
  int b[n+10];
  int count =0;
  for (int i=0;i<n-1;i++){
    if (s.at(i)=='A') {// if
      if(s.at(i+1)=='C') count ++;
    }
    b[i]=count;
  }
  b[n-1]=b[n-2];
  
     for (int i=0;i<q;i++){
    int l,r;
    cin >>l >>r;
    l--;
    r--;
    int ans;
    int ans1,ans2;
    if(s.at(l)=='A' && s.at(l+1)=='C') {
      ans1=b[l]-1;
    }
    else {
      ans1=b[l];
    }
    if (r<n-1 ){
      if (s.at(r)=='A' && s.at(r+1)=='C') ans2=b[r]-1;
      else ans2=b[r];
    }
    else {
      ans2=b[r];
    }
    ans=ans2-ans1;
    
    
    cout << ans << endl;
  }
        
 
}
  
    
    

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

#define int long long int

int32_t main() {
  int n,d;
  cin >> n >> d;
  d *= d;
  int ans = 0;
  
  int x,y;
  while(n--) {
  	cin >> x >> y;
    x = (x*x) + (y*y);
  	if(x <= d) {
    	ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() 
{ 
    int n;
    cin>>n;
    long long int a[100007];
    for(int i=0;i<=n;i++ ){
        a[i]=INT_MAX;
    }
	a[0]=0;
    
    for(int i=1;i<=n;i++){
        
        a[i]=min(a[i],a[i-1]+1);
        long long int x=6;
        while(true){
            if(i-x>=0){
                a[i]=min(a[i],a[i-x]+1);
                x*=6;    
            }
            else{
                break;
            }
        }
        
        
        x=9;
        while(true){
            if(i-x>=0){
                a[i]=min(a[i],a[i-x]+1);
                x*=9;    
            }
            else{
                break;
            }
        }
        
    }
    
    
    cout<<a[n];
    
	return 0; 
} 


Measured memory_bytes: 1024
from functools import reduce
from itertools import accumulate
from operator import mul

MOD = 10**9 + 7


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

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

    __repr__ = __str__

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

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

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

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

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

    __radd__ = __add__

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

    __rmul__ = __mul__

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

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


# 入力
N = int(input())
A = list(map(int, input().split()))

# 調和級数の列
H = [0] + list(accumulate(1 / ModInt(i) for i in range(1, N + 1)))

# 各ブロックについて、コストを支払う回数の期待値を求めることにより、解を求める
ans = reduce(
    mul,
    map(ModInt, range(1, N + 1))
) * sum(
    a * (H[N - i + 1] + H[i] - 1)
    for i, a in enumerate(A, 1)
)

# 出力
print(ans)


Measured memory_bytes: 29600
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

#define int long long
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[100010];
    rep(i, N) cin >> A[i];
    priority_queue<int> que;
    rep(i, N) {
        que.push(A[i]);
    }
    rep(i, M) {
        int num = que.top();
        que.pop();
        que.push(num / 2);
    }
    int ans = 0;
    rep(i, N) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;



    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   string s;
   cin >> s;
   sort(all(s));
   if (s == "abc") {
      puts("Yes");
   } else {
      puts("No");
   }
   
   return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << '+';
	else if (a * b == 15) cout << '*';
	else cout << 'x';
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

やるだけ
*/

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <deque>
using namespace std;

struct state { int x, step; };

int main() {
        int k;
        scanf("%d", &k);
        deque<state> dq;
        dq.push_back((state){1, 0});
        vector<bool> used(k, false);
        while (!dq.empty()) {
                state now = dq.front();
                used[now.x] = true;
                dq.pop_front();
                if (now.x == 0) return !printf("%d\n", now.step + 1);
                if (!used[(now.x + 1) % k]) dq.push_back((state){(now.x + 1) % k, now.step + 1});
                if (!used[(now.x * 10) % k]) dq.push_front((state){(now.x * 10) % k, now.step});
        }
}


Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>

using namespace std; 

char s[100005];

int main()
{
	int n;
	cin>>n;
	cin>>s;
	
	int len;
	len=strlen(s);
	
	if(len<=n) cout<<s<<endl;
	else
	{
		for(int i=0;i<n;i++)
		{
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 3624
//56
#include<iostream>
#include<map>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>

using namespace std;

struct P{
  int x,y,t;
};

int main(){
  for(int w,h;cin>>w>>h,w|h;){
    int gx,gy;
    map<int,vector<P> > m;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	string s;
	cin>>s;
	if(s=="S"){
	  P s={j,i,0};
	  m[0].push_back(s);
	}else if(s=="G"){
	  gx=j;
	  gy=i;
	}else if(s!="."){
	  P p={j,i,0};
	  m[atoi(s.c_str())].push_back(p);
	}
      }
    }
    int l=m.rbegin()->first+1;
    P lp={gx,gy,0};
    m[l].push_back(lp);
    for(int i=1;i<=l;i++){
      for(int j=0;j<m[i].size();j++){
	int mt=1<<30;
	for(int k=0;k<m[i-1].size();k++){
	  mt=min(mt,m[i-1][k].t+abs(m[i-1][k].x-m[i][j].x)+abs(m[i-1][k].y-m[i][j].y));
	}
	m[i][j].t=mt;
      }
    }
    cout<<m[l][0].t<<endl;
  }
  return 0;
}
  
	  
	  

Measured memory_bytes: 1528
n = int(input())
s = input() #sys.stdin.readlineは最後が改行


lan0 = []
lan1 = []

if s[0]=='#':
    lan0.append(0)

cnt0=0
cnt1=0

for i in range(n):
    if s[i] == '.':
        if cnt1 > 0:
            lan1.append(cnt1)
            cnt1=0
            cnt0=1
        else:
            cnt0+=1
    if s[i] == '#':
        if cnt0 > 0:
            lan0.append(cnt0)
            cnt0=0
            cnt1=1
        else:
            cnt1+=1

if cnt0>0:lan0.append(cnt0)
if cnt1>0:lan1.append(cnt1)



from itertools import accumulate
acc0 = list(reversed(lan0))
acc0 = list(accumulate(acc0))
acc0.reverse()
acc0 = acc0+[0] +[0]


acc1 = [0] + lan1
acc1 = list(accumulate(acc1))
acc1 = [0]+acc1

ans = n
for i in range(len(acc1)):
    ans = min(ans,acc0[i]+acc1[i])

print(ans)


Measured memory_bytes: 13460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<ll> lun;

void dfs(string s){
    int x=s.back()-'0';
    lun.push_back(stoll(s));
    if(s.size()>11) return;
    if(x==0){
        dfs(s+"0");
        dfs(s+"1");
    }
    else if(x==1){
        dfs(s+"0");
        dfs(s+"1");
        dfs(s+"2");
    }
    else if(x==2){
        dfs(s+"1");
        dfs(s+"2");
        dfs(s+"3");
    }
    else if(x==3){
        dfs(s+"2");
        dfs(s+"3");
        dfs(s+"4");
    }
    else if(x==4){
        dfs(s+"3");
        dfs(s+"4");
        dfs(s+"5");
    }
    else if(x==5){
        dfs(s+"4");
        dfs(s+"5");
        dfs(s+"6");
    }
    else if(x==6){
        dfs(s+"5");
        dfs(s+"6");
        dfs(s+"7");
    }
    else if(x==7){
        dfs(s+"6");
        dfs(s+"7");
        dfs(s+"8");
    }
    else if(x==8){
        dfs(s+"7");
        dfs(s+"8");
        dfs(s+"9");
    }
    else if(x==9){
        dfs(s+"8");
        dfs(s+"9");
    }
    


}

int main(){
    dfs("1");
    dfs("2");
    dfs("3");
    dfs("4");
    dfs("5");
    dfs("6");
    dfs("7");
    dfs("8");
    dfs("9");

    sort(all(lun));
    
    int k;
    cin>>k;

    //rep(i,15) cout<<lun[i]<<" ";
    //cout<<endl;
    cout<<lun[k-1]<<endl;
}



Measured memory_bytes: 19592
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair 
using namespace std;
int a[10000];
int rez;
bool reznow=true;
int n;
int rudi;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    while(reznow!=false){
        for(int i=1;i<=n;i++){
            if(a[i]%2==1){
                reznow=false;

            }
            if(reznow==false) break;
            if(a[i]%2==0){
                a[i]/=2;
                rez++;
            }
            
        }
        if(rez==n) rudi++;
        rez=0;
    }
    cout<<rudi;
}

Measured memory_bytes: 256
"""
N M
A1 ... AN
この中から人気商品 M 個を選びます。ただし、得票数が総投票数の 1/4M 未満であるような商品は選べません。
人気商品 M 個を選べるなら Yes、選べないなら No を出力してください。
"""
n,m=map(int,input().split())
a=list(map(int,input().split()))
#print(a)
#print(a.sort())
b=sorted(a, reverse=True)
#print(s#orted(a, reverse=True))
#print(b[m-1])
#print(sum(b))
#print(sum(b)/(4*m))
if b[m-1]>= (sum(b) /(4*m)) :
  print("Yes")
else:
  print("No")
  

"""
x,y,z=map(int,input().split())
a,b,c=x,y,z
a,b=b,a
a,c=c,a
print(a,b,c)
"""

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, M;
vec G[101010], rev[101010];
int dp[101010];

//トポロジカルソート
const int MAX = 101010;

list<int> out;  // sortされた頂点が左から順番に格納される。
bool V[MAX];    //訪問したかどうか
int indeg[MAX]; //入次数

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    out.push_back(u);
    for (auto v : G[u]) {
      indeg[v]--;
      if (indeg[v] == 0 && V[v] != true) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void topoSort() {
  for (int i = 0; i < N; i++) {
    indeg[i] = 0;
  }

  for (int i = 0; i < N; i++) {
    for (auto v : G[i]) {
      indeg[v]++;
    }
  }

  for (int i = 0; i < N; i++) {
    if (indeg[i] == 0 && V[i] != true) {
      bfs(i);
    }
  }
}

int bbfs(int now) {
  if (dp[now] > 0) return dp[now];
  int res = 0;
  for (auto x : G[now]) {
    res = max(res, bbfs(x) + 1);
  }

  return dp[now] = res;
}

signed main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].pb(y);
  }

  topoSort();

  int ans = 0;
  for (auto x : out) {
    ans = max(ans, bbfs(x));
  }

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


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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a.at(i);
  
  double sum = 0, ans;
  rep(i, n) sum += 1/a.at(i);
  ans = 1/sum;
  printf("%.7f\n",ans);
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define yess cout<<"Yes\n"
#define noo cout<<"No\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
   int x,a,y,b,n,d;
   double t;
   cin>>x>>a;
   cin>>y>>b;
   cin>>n;
   if(a<b)
    no;
    else if(a==b)
    {
        if(x==y)
            yes;
        else
            no;
    }
   else
   {
       d=abs(x-y);
       t=(1.0 *d)/(a-b);
       if(t<=n)
        yes;
       else
        no;
   }
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3636
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#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 << '\n'; }
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;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double EPS = 1e-6 ; 
signed main(){
    fastio
    int n , a , b ; 
    cin >> n >> a >> b ; 
    if ( a + b == 0 ) {
        cout << 0 << endl;
        return 0 ; 
    }
    cout << ( n / (a + b) ) * a + min(a, ( n % (a + b ))) << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
 
signed main(void) {
    int D, N;
    cin >> D >> N;
    int m;
    if (D == 0) {
        if (N == 100) {
            cout << 101 << endl;
        } else {
            cout << N << endl;
        }
    } else if (D == 1) {
        if (N == 100) {
            cout << 10100 << endl;
        } else {
            cout << N * 100 << endl;
        }
    } else {
        if (N == 100) {
            cout << 1010000 << endl;
        } else {
            cout << N * 10000 << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
def count_changes(s, k, prev=None):
    count = 0
    for _ in range(k):
        for cur in s:
            if cur == prev:
                count += 1
                prev = None
            else:
                prev = cur
    return count, prev


if __name__ == '__main__':
    s = input()
    k = int(input())
    if len(set(s)) == 1:
      print((len(s) * k) // 2)
      exit()
    if k <= 10 ** 8:
        print(count_changes(s, k)[0])
    else:
        base_count, prev = count_changes(s, 3)
        d, rest = divmod(k, 3)
        res = base_count * d
        if rest:
            res += count_changes(s, rest, prev)[0]
        elif s[0] == prev:
            res += (d - 1)
        print(res)


Measured memory_bytes: 38704
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c) cout << "Yes" << ln;
    else cout << "No" << ln;
    return 0;
}

Measured memory_bytes: 256