akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
//#include "../../library/lib.hpp"


using namespace std;
class TaskB {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
		int n, m;
		in >> n >> m;
		vector<string> a (n), b(m);
		for(int i = 0; i < n; ++i){
			in >> a[i];
		}
		for(int i = 0; i < m; ++i){
			in >> b[i];
		}
		if(n == m){
			if(a == b){
				out << "Yes" << endl;
			}else{
				out << "No" << endl;
			}
			return;
		}
		bool fit = true;
		for(int i = 0; i < n-m; ++i){
			for(int j = 0; j < n - m; ++j){
				fit = true;
				// test current offset
				for(int k = 0; k < m; ++k){
					for(int l = 0; l < m; ++l){
//						if(a[k+i][l+j] != '#' && b[k][l] == '#'){
						if(a[k+i][l+j] != b[k][l]){
							fit = false;
						}
					}
				}
				if(fit){
					out << "Yes" << endl;
					return;
				}
			}
		}
		out << "No" << endl;
	}
};


int main() {
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  bool A = false;
  int B = 1;
  int answer;
  for(int j = 0;j < N;j++) {
    B = vec.at(B - 1);
    if(B == 2) {
      A = true;
      answer = j + 1;
      break;
    }
  }
  if(A == true) {
    cout << answer << endl;
  }
  else { 
    cout << "-1" << endl;
  }
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (1) {
        vector<vector<char>> field(15, vector<char>(15, '#'));
        string S;
        cin >> S;
        if (S == "#") break;
        int column = 1;
        int row = 1;
        for (int i = 0; i < S.length(); i++) {
            // cout << column << row << endl;
            if (S[i] == 'b') {
                field[column][row] = 'b';
                row++;
            } else if (S[i] == '/') {
                column++;
                row = 1;
            } else {
                int tmp = row;
                for (; row < (S[i] - '0') + tmp; row++) {
                    field[column][row] = '.';
                }
            }
        }
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a, b, c, d;
        swap(field[a][b], field[c][d]);

        string jfen = "";
        for (int i = 1; i < field.size() - 1; i++) {
            int cnt = 0;
            for (int j = 1; j < field[i].size() - 1; j++) {
                if (field[i][j] == 'b')
                    jfen += "b";
                else if (field[i][j] == '#') {
                    if (field[i + 1][1] != '#') jfen += "/";
                    break;
                } else {
                    cnt++;
                    if (field[i][j + 1] != '.') {
                        jfen += to_string(cnt);
                        cnt = 0;
                    }
                }
            }
        }
        cout << jfen << endl;
    }
}


Measured memory_bytes: 3288
h, w = map(int, input().split())
a = [input() for _i in range(h)]
p = 0
for i in range(h):
    x = [j for j in range(w) if a[i][j]=="#"]
    for j in range(len(x)-1):
        if x[j]+1==x[j+1]:
            continue
        else:
            import sys
            print("Impossible")
            sys.exit()
    if p==x[0]:
        p = x[-1]
    else:
        import sys
        print("Impossible")
        sys.exit()
print("Possible")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> seq(n);
  int cnt = 0;
  for(int i = 0; i < n; ++i) cin >> seq[i];
  for(int i = 0; i < n; ++i){
    if(seq[i] == i + 1) continue;
    cnt++;
    if(cnt > 2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define mod 998244353
#define int long long int
int function(int j,int k)
{
	int count=0;
	while(j<k)
	{
		j*=2;
		count++;
    }
    return count;
}
int32_t main()
{
      int n,k;
      cin>>n>>k;
      double p=0.000;
      int j;
      for(j=1;j<=n;j++)
      {
		  
		  int y=function(j,k);
		  int x=pow(2,y);
		  int value=n*x;
		  p+=(double)(1)/value;
	  }
	  cout<<setprecision(12)<<p<<endl;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {


	VVI a(3, VI(3));
	REP(i, 3)REP(j, 3)cin >> a[i][j];

	int n;
	cin >> n;
	VVI b(3, VI(3, false));

	REP(i, n) {
		int c;
		cin >> c;
		REP(j, 3)REP(k, 3) {
			if (a[j][k] == c) {
				b[j][k] = true;
			}
		}
	}

	REP(i, 3){
		bool ch = true;
		REP(j, 3) {
			if (!b[i][j])ch = false;
		}
		if (ch) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	REP(i, 3) {
		bool ch = true;
		REP(j, 3) {
			if (!b[j][i])ch = false;
		}
		if (ch) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	if (b[0][0] && b[1][1] && b[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (b[2][0] && b[1][1] && b[0][2]) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
int a100 = a * 100, b100 = b * 100;
int maxsugar = 0;
int water = 0, sugar = 0;
int maxsw = 0;
double limdence = 100.0* e / (100.0 + e); // 上限濃度％
double maxdence=0.0, dence;

for (int i = 0; i <= f / a100 ; ++i){
    for (int j = 0; j <= (f - a100*i) / b100; ++j){
        if (i + j) { // 水 0 回避
            water = a100 * i + b100 * j;
            for (int k = 0; k <= (f - water) / c; ++k){
                for (int l = 0; l <= (f - water - c*k) / d; ++l){
                    sugar = c*k + d * l;
                    dence = 100.0 * sugar / (water + sugar);
                    if (dence <= limdence && dence >= maxdence){
                        maxdence = dence;
                        maxsugar = sugar;
                        maxsw = water + sugar;
                    }
                }
            }
        }   
    }
}

cout << maxsw << ' ' << maxsugar << "\n";

return 0;
}

// 境界のチェック


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int a[n][m];
  int b[m];
  int c[n] ;
  for(int i = 0; i < n; i++) c[i] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int j = 0; j < m; j++){
    cin >> b[j];
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
       c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] <<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include<cstdio>
#include<iostream>
using namespace std;
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=1;i<3;i++)
	if(s[i]!=s[i-1]) 
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [input() for i in range(n)]
last = l[0][-1]
old = [l[0]]
check = True
for i in range(1, n):
    if l[i][0] != last or l[i] in old:
        check = False
    else:
        old.append(l[i])
        last = l[i][-1]
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string n;
  cin >> n;
  vector<int> v(n.size());
  int sum = 0;
  int amari;
  rep(i, n.size()) {
    v[i] = n[i] - '0';
    sum += v[i];
    amari += v[i] % 9;
  }

  if (amari == 0 || sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>a(4);
  for(int i=0;i<4;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout <<(a.at(0) == 1&&a.at(1)==4&&a.at(2)==7&&a.at(3)==9?"YES":"NO")<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

ll modpow(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1) {
			ans *= x;
		}
		y >>= 1;
		x *= x;
		x %= MOD;
		ans %= MOD;
	}
	return ans;
}

ll moddiv(ll x, ll y) {
	return (x * modpow(y, MOD - 2)) % MOD;
}

int main() {
	ll X, Y;
	cin >> X >> Y;
	if (X > 2 * Y) {
		cout << 0 << endl;
		return 0;
	}
	if (Y > 2 * X) {
		cout << 0 << endl;
		return 0;
	}
	ll b = 2 * X - Y;
	if (b % 3) {
		cout << 0 << endl;
		return 0;
	}
	b /= 3;
	ll a = X - 2 * b;
	//a+bCb

	ll ans = 1;
	for (ll i = 1;i <= b;i++) {
		ans *= moddiv(a + b + 1 - i, i);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[101][100001];ll n,W;ll a[101],w[101];
const ll infi=1e15;
ll solve(int idx,int W)
{
  if(idx>=n)
  {
    if(W>=0)
      return 0;
    return -infi;
  }
  if(W<0)
    return -infi;
  if(dp[idx][W]!=-1)
    return dp[idx][W];
  return dp[idx][W]=max(solve(idx+1,W),a[idx]+solve(idx+1,W-w[idx]));
}
int main()
{

  cin>>n>>W;

  for(int i=0;i<n;i++)
    cin>>w[i]>>a[i];
  memset(dp,-1,sizeof(dp));
  ll ans=solve(0,W);
  cout<<ans<<"\n";
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
	
const ll INF=3e18;
ll mult(ll a, ll b)
{
	if(a==0||b==0) return 0;
	if(a>INF/b) return INF;
	return a*b;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll cur=1;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		cur=mult(cur,x);
	}
	if(cur>ll(1e18)) cout<<-1<<'\n';
	else cout<<cur<<'\n';
}


Measured memory_bytes: 3668
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int N=gi();
        int[] A=new int[N];
        
        
        int al=0;
        int bo=0;
        for (int i=0; i<N; i++) {
            A[i]=gi();
        }
        
        Arrays.sort(A);

        for (int i=0; i<N; i++) {
            if (i%2==0) {
            	al+=A[N-i-1];
            } else {
            	bo+=A[N-i-1];
            }
        }
        
	    System.out.println(al-bo);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using ll = long long;

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  // x >= y を保証
  if(x < y){
    swap(x, y);
    swap(a, b);
  }
  
  ll ans = min({a * x + b * y, 2 * c * max(x, y), 2 * c * min(x, y) + a * (x - y)});
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 161
//D - Lunlun Number
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <functional>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;


ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int k;

    cin >> k;

    queue<ll> q;

    FOR(i, 1, 9) q.push(i);

    ll run = 0;

    REP(i, k) {
        run = q.front();
        q.pop();
        
        ll x = run%10;
        FOR(j, -1, 1){
            if (x+j<0 || x+j>9) continue;
            q.push(run * 10 + (x + j));
        }
    }

    cout << run << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
	lli n,k;
	cin>>n>>k;
	lli arr[n],dp[n];dp[0]=0;
	
	for(int i=0;i<n;i++)
	{
	cin>>arr[i];
	if(i)dp[i]=INT_MAX;
	}
	for(int i=0;i<n;i++)for(int j=i+1;j<n&&j<=k+i;j++)dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
	
	//for(int i=0;i<n;i++)cout<<dp[i]<<" ";
	cout<<dp[n-1]<<endl;	
	
	
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;

int main()
{
  int n, y;
  scanf("%d%d", &n, &y);
  y /= 1000;

  for (int i = n; i >= 0; i--)
    for (int j = n - i; j >= 0; j--)
    {
      int k = n - i - j;
      if (10 * i + 5 * j + 1 * k == y)
      {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }

  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

A_max = max(A)

M = len(bin(A_max)) - 2
L = len(bin(K)) - 2
C = [[N, 0] for j in range(max(M, L))]
for i in A:
    for j in range(M):
        if (i >> j) & 1:
            C[j][1] += 1
            C[j][0] -= 1

P = 0
for j in range(L-1, -1, -1):
    if C[j][0] >= C[j][1]:
        if P + 2 ** j <= K:
            P += 2 ** j

ans = 0
for i in A:
    ans += P ^ i

print(ans)



Measured memory_bytes: 20300
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

from collections import Counter
c = Counter(a)
ans = 0
for k,v in c.items():
    if k>v:
        ans += v
    elif k<v:
        ans += (v-k)
print(ans)

Measured memory_bytes: 99380
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    reverse(all(a));
    rep(i,n){
        if(i%2==0) b[i/2]=a[i];
        else b[n-1-i/2]=a[i];
    }
    rep(i,n) cout<<b[i]<<" ";
    cout<<endl;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(int.Parse).ToList();

            var count = 0;
            var min = int.MaxValue;

            foreach (var x in p)
            {
                if(min > x)
                {
                    min = x;
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

using ll = long long;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    complex<double> a = {A, 0};
    complex<double> b = {B, 0};
    a *= polar(1.0, M_PI / 360 * (H * 60 + M));
    b *= polar(1.0, M_PI / 30 * M);
    printf("%.11f\n", abs(a - b));
}


Measured memory_bytes: 4104
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<" ";
	}
}

Measured memory_bytes: 1536
def soin_cnt(n)
    cnt = 0
    for i in 1..n
        cnt += 1 if n%i == 0
    end
    #print "#{n} #{cnt}\n"
    cnt
end

def soin(n)
    cnt = 0
    for i in 107..n
        next if i%2 == 0
        cnt += 1 if soin_cnt(i) == 8
    end
    cnt
end

def bb
    n = gets.chomp.to_i
    if n <= 104
        puts 0
    elsif n == 105
        puts 1
    else
        puts 1+soin(n)
    end
end

bb

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


int main() {
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, n)c[i] = 0;
    repi(i, 1, n) {
        int p;
        cin >> p;
        p--;
        c[p]++;
    }
    rep(i, n) cout << c[i] << endl;
    return 0;
}



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


int n,a[15],ans;


void rec(int pos=0,int cur=1){
    if(pos==n){
        if(cur%2==0){
            ans++;
        }
        return;
    }
    rec(pos+1,cur*(a[pos+1]-1));
    rec(pos+1,cur*a[pos+1]);
    rec(pos+1,cur*(a[pos+1]+1));
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    rec();
    cout<<ans;
}


Measured memory_bytes: 256
// CODE FESTIVAL 2016 qual B
// B - Qualification simulator

#include <cstdio>
#define MAX_S 100000
using namespace std;


int N, A, B;
char s[MAX_S + 2];
int cnt_pass, cnt_b;

int main() {

  scanf("%d%d%d", &N, &A, &B);
  scanf("%s", s);
  cnt_pass = 0;
  cnt_b = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'a' && cnt_pass < A + B) {
      cnt_pass++;
      printf("Yes\n");
    } else if (s[i] == 'b' && cnt_pass < A + B && cnt_b < B) {
      cnt_pass++;
      cnt_b++;
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  return 0;

}




Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <map>

using namespace std;

void solve(long long N, vector<long long> a){
    vector<long long> c((int)1e5+1, 0);
    vector<long long> b((int)1e5+1, 0);
    map<int, int> d;
    long long ret = 0;
    int j = 0;
    for (auto&& x : a) {
        if (d.find(x) == d.end()) {
            c[j]++;
            b[j] = x;
            d[x] = j;
            j++;
        } else {
            c[d[x]]++;
        }
    }
    for (int i = 0; i < 1e5+1; i++) {
        if (b[i] == 0) {
            break;
        }
        if (c[i] != b[i] && c[i] != 0) {
            if (b[i] > c[i]) {
                ret += c[i];
            } else {
                ret += c[i] - b[i];
            }
        }
    }
    std::cout << ret << std::endl;
}


int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> a(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&a[i]);
    }
    solve(N, a);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int main(){
	FASTIO
	int n;
  	cin>>n;
  	if(n>=30)cout<<"Yes\n";
  	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int n, m;
    cin >> n >> m;

    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    from collections import deque

    def bfs(S, start_h, start_w, goal_h, goal_w, H, W):
        que0 = deque()
        que1 = deque()
        dist = [[INF] * W for _ in range(H)]
        dist[start_h][start_w] = 0
        que0.append((start_h, start_w))
        while que0 or que1:
            nh, nw = que0.popleft() if que0 else que1.popleft()
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    next_h = nh + dh
                    next_w = nw + dw
                    cost = 0 if abs(dh) + abs(dw) <= 1 else 1
                    if not (0 <= next_h < H and 0 <= next_w < W):
                        continue
                    if S[next_h][next_w] == '#':
                        continue
                    if dist[next_h][next_w] > dist[nh][nw] + cost:
                        dist[next_h][next_w] = dist[nh][nw] + cost
                        if cost == 0:
                            que0.append((next_h, next_w))
                        else:
                            que1.append((next_h, next_w))
        return dist[goal_h][goal_w] if dist[goal_h][goal_w] != INF else - 1
        
    H, W = map(int, input().split())
    Ch, Cw = (int(i) - 1 for i in input().split())
    Dh, Dw = (int(i) - 1 for i in input().split())
    S = [input() for _ in range(H)]
    
    INF = 10 ** 6
    ans = bfs(S, Ch, Cw, Dh, Dw, H, W)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99912
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
void calc_comb(vector<vector<long long>> &v);
int main(){
    ll N,P;
    cin>>N>>P;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    //偶数+偶数=偶数 奇数+奇数=偶数 偶数+奇数=奇数
    //選び方はP=1なら奇数袋を奇数個、偶数袋と奇数袋をそれぞれ奇数個
    //P=0なら全通り-P=1
    ll all=pow(2,N);
    vector<ll> oddeven(2,0);
    rep(i,N){
        if(A[i]%2) oddeven[1]++;
        else oddeven[0]++;
    }

    vector<vector<ll>> v(N+1,vector<ll>(N+1,0));
    calc_comb(v);
    ll ans=0;
    for(int i=1; i<=N; i+=2){
        ans+=v[oddeven[1]][i];
    }
    for(int i=1; i<=N; i+=2){
        for(int j=1; j<=N; j++){
            ans+=v[oddeven[1]][i]*v[oddeven[0]][j];
        }
    }
    if(P==0) ans=all-ans;
    cout<<ans<<endl;
}
void calc_comb(vector<vector<long long>> &v){
    rep(i,v.size()){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int i=1; i<v.size(); i++){
        for(int j=1; j<i; j++){
            v[i][j]=(v[i-1][j-1]+v[i-1][j]);
        }
    }
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC091E
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(Int);
            var A = ss.Next(Long);
            var B = ss.Next(Long);

            if (N < A + B - 1 || A * B < N)
            {
                sw.WriteLine(-1);
                return;
            }

            var seq = MakeSeq(N, A, B);
            var comp = Compress(seq);
            sw.WriteLine(string.Join(" ", comp));
            //---------------------------------
        }

        IEnumerable<long> MakeSeq(int N, long A, long B)
        {
            var count = A * B - N;
            var i = 0L;

            while (i < A * B)
            {
                yield return A * (B - i / A - 1) + i % A + 1;
                var step = Math.Min(count, A - 1);
                count -= step;
                i += step + 1;
            }
        }

        IEnumerable<int> Compress(IEnumerable<long> source)
        {
            var comp = source
                .OrderBy(x => x)
                .Select((k, v) => new {k, v})
                .ToDictionary(kvp => kvp.k, kvp => kvp.v);

            return source.Select(x => comp[x] + 1);
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}

Measured memory_bytes: 46856
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

if a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2:
    print('infinity')
elif (a1 > b1 and a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2) or (a1 < b1 and a1 * t1 + a2 * t2 < b1 * t1 + b2 * t2):
    print(0)
elif a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2:
    sub1 = (a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2)
    dev1 = ((b1 - a1) * t1) // sub1
    if ((b1 - a1) * t1) % sub1 == 0:
        print(dev1 * 2)
    else:
        print(dev1 * 2 + 1)
else:
    sub1 = (b1 * t1 + b2 * t2) - (a1 * t1 + a2 * t2)
    dev1 = ((a1 - b1) * t1) // sub1
    if ((a1 - b1) * t1) % sub1 == 0:
        print(dev1 * 2)
    else:
        print(dev1 * 2 + 1)


Measured memory_bytes: 3064
INF = 10**5+1
ac = [0 for i in range(INF)]
memo = [True for i in range(INF)]
for i in range(2,INF):
    if memo[i]:
        for j in range(2*i,INF,i):
            memo[j] = False

for x in range(3,INF,2):
    ac[x] = 1 if memo[x] and memo[(x+1)//2] else 0
for x in range(1,INF):
    ac[x] += ac[x-1]
Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(ac[r]-ac[l-1])

Measured memory_bytes: 54564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        Console.WriteLine(x * x * x);
    }

    static void Main()
    {
        byte[] inputBuffer = new byte[1024];
        Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 9144
#include<stdio.h>
int main(){
  int n,a,b,i,sum=0,num,ii;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    num=i;
    ii=0;
    while(num>0){
      ii+=num%10;
      num/=10;
    }
    if(ii>=a&&ii<=b)sum+=i;
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int N, v[10001]{};
  cin >> N;
  for (int x = 1; x != 100; ++x) {
    for (int y = 1; y != 100; ++y) {
      for (int z = 1; z != 100; ++z) {
        int f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= N) ++v[f];
      }
    }
  }
  for (int n = 1; n <= N; ++n) cout << v[n] << endl;
}


Measured memory_bytes: 3496
def main(n, h):
    base = 0
    count = 0

    for _h in h:
        if _h >= base:
            base = _h
            count += 1

    print(count)


if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(' ')))

    main(n, h)



Measured memory_bytes: 2940
import queue

n = int(input())

e = []
f = [{} for i in range(n)]

for i in range(n-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    e.append([a,b])
    f[a][b]=0
    f[b][a]=0

k = 0
for i in range(n-1):
    k = max(k,len(f[i]))

q = queue.Queue()
q.put(0)
used = [[0] for i in range(n)]
visited = [0]*n
visited[0]=1

while not q.empty():
    p = q.get()
    for key,c in f[p].items():
        if c == 0 and visited[key]==0:
            if used[p][-1]<k:
                col = used[p][-1]+1
            else:
                col = 1
            f[p][key] = col
            used[p].append(col)
            used[key].append(col)
            q.put(key)
            visited[key]=1

print(k)
for a,b in e:
    print(max(f[a][b],f[b][a]))












Measured memory_bytes: 122140
#include<stdio.h>
int main() {
	int a=0, b=0,c=0;
	while (a<1 || a>10) {
		scanf("%d", &a);

	}

	while (b<1 || b>10) {
		scanf("%d", &b);

	}
	while (c<1 || c>10) {
		scanf("%d", &c);

	}
	if (a == 7 && b == 5 && c == 5) {
		printf("YES\n");
	}

	else if (a == 5 && b == 7 && c == 5) {
		printf("YES\n");
	}

	else if (a == 5 && b == 5 && c == 7) {
		printf("YES\n");

	}

	else {
		printf("NO\n");
	}



	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n;
    cin>>n;
    vector<deque<int>> a(n);
    vector<int> step(n*(n-1)/2+1);
    for(int i=0;i<n;++i){
        for(int j=0;j<n-1;++j){
            int to;cin>>to;
            a[i].push_back(to-1);
        }
    }
    int m = n*(n-1)/2;
    
    queue<int> q;
    int num = 0;
    for(int i=0;i<n;++i)q.push(i);
    while(!q.empty()){
        queue<int> to;
        while(!q.empty()){
            auto cur = q.front();q.pop();
            if(step[cur] <= num and a[cur].size() and a[a[cur].front()].size() and a[a[cur].front()].front() == cur and step[a[cur].front()] <= num){
                step[cur] = step[a[cur].front()] = num+1;
                to.push(cur);
                to.push(a[cur].front());
                a[a[cur].front()].pop_front();
                a[cur].pop_front();
                m--;
            }
        }
        num++;
        if(m == 0)break;
        swap(to,q);
    }
    if(m)cout << -1<< endl;
    else cout << num << endl;
    return 0;
}



Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int INF = 1e9;

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

using graph = vector<vector<edge>>;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> C(N), R(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i] >> R[i];
	}
	vector<vector<int>> g(N);
	for (int i = 0; i < K; i++) {
		int A, B;
		cin >> A >> B; A--, B--;
		g[A].push_back(B);
		g[B].push_back(A);
	}
	graph G(N);
	for (int s = 0; s < N; s++) {
		vector<int> d(N, -1);
		queue<int> q;
		d[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			if (d[v] == R[s]) continue;
			for (int to : g[v]) if (d[to] == -1) {
				G[s].emplace_back(to, C[s]);
				d[to] = d[v] + 1;
				q.push(to);
			}
		}
	}
	vector<int> d(N, INF);
	priority_queue<pii, vector<pii>, greater<>> pq;
	pq.emplace(0, 0);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		if (d[p.second] != INF) continue;
		d[p.second] = p.first;
		for (auto e : G[p.second]) if (d[e.to] == INF) {
			pq.emplace(d[p.second] + e.cost, e.to);
		}
	}
	cout << d[N - 1] << endl;
	return 0;
}



Measured memory_bytes: 192840
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("AAA") || s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> h >> w >> a >> b;
	c = 498;
	num = (h/a) * (w/b);
	ll pos,nega;
	pos = (h * w - num) * c;
	nega = ((a * b - 1) * c + 1) * num;
	if(pos > nega){
		p("Yes");
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(i % a == 0 && j % b == 0){
					pe(-1 * (a * b - 1) * c - 1);
				}else{
					pe(c);
				}
			}
			el;
		}
	}else{
		p("No");
	}
	return 0;
}

Measured memory_bytes: 28672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <functional>
using namespace std;

template <typename T,typename E>
struct SegmentTree{
private:
    typedef std::function<T(T,T)> F;
    typedef std::function<T(T,E)> G;
    int n;
    vector<T> init;
    F f;//function for caliculate
    G g;//function for update
    std::vector<T> node;

public:
    explicit SegmentTree(
            int sz,
            F cal,
            G upd,
            vector<T> initv=vector<T>(1,0)
    ){
        n=1;
        init=initv;
        f=cal;
        g=upd;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), init[0]);
        for (int i = 0; i <sz ; ++i) node[i+n-1]=init[i+1];
        for (int i = n-2; i >= 0 ; --i) node[i]=f(node[2*i+1],node[2*i+2]);
    }

    void update(int x, E val){//x:0-indexed
        x+=n-1;
        node[x]=g(node[x],val);
        while(x>0){
            x=(x-1)/2;
            node[x]=f(node[2*x+1],node[2*x+2]);
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return init[0];//out of range
        if(p<=l&&r<=q)return node[k];

        return f(query(p,q,2*k+1,l,(l+r)/2),query(p,q,2*k+2,(l+r)/2,r));
    }
};

void solve(){
    int n,q;
    std::cin>>n>>q;
    vector<long> a(n,0);
    vector<int> m(q);
    for (int i = 1; i <= n-1; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < q; ++i) {
        cin>>m[i];
    }

    SegmentTree<long,long> st(n,
                        plus<long>(),
                        [](int a,int b){return b;},
                        a
    );

    int tp=1;
    long ans=0;
    for(size_t i = 0; i < q; i++)
    {
        if(m[i]>0)ans+=st.query(tp-1,tp+m[i]-1);
        else if(m[i]<0)ans+=st.query(tp+m[i]-1,tp-1);
        tp+=m[i];
        ans=ans%100000;
    }
    cout<<ans<<endl;
    return;
}

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


Measured memory_bytes: 7556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 if(a + b == c + d) {
   cout << "Balanced" <<endl;
 }
  else if(a + b >= c + d) {
    cout << "Left" << endl;
  }
    else {
      cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 3532
#!/usr/bin/perl

use strict;
use warnings;

my ($n, $q);
{
    my $in = <STDIN>;
    ($n, $q) = split(" ", $in);
}
my $s = <STDIN>;
chomp $s;

my (@l, @r);
{
    for (my $i=0; $i<$q; $i++)
    {
        my $in = <STDIN>;
        ($l[$i], $r[$i]) = split(" ", $in);
    }
}
my @v;
$v[0] = 0;
for (my $i=1; $i<$n; $i++)
{
    $v[$i] = $v[$i-1];
    $v[$i]++ if "AC" eq substr($s, $i-1, 2);
}
for (my $i=0; $i<$q; $i++)
{
    my $c = $v[$r[$i]-1] - $v[$l[$i]-1];
    print "$c\n";
}

Measured memory_bytes: 25088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public class Person
	{
		public int Index {get;set;}
		public HashSet<int> Friends {get;set;}
		
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		var k = p[2];
		var people = new Person[n];
		
		var friendTree = new UnionFind(n);
		
		for(int i = 0; i < n; i++)
		{
			people[i] = new Person(){Index=i, Friends=new HashSet<int>()};
		}
		
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt(-1);
			people[p[0]].Friends.Add(p[1]);
			people[p[1]].Friends.Add(p[0]);
			friendTree.Unite(p[0], p[1]);
		}
		
		
		for(int i = 0; i < k; i++)
		{
			p = Input().ToInt(-1);
			if(!friendTree.InSameTree(p[0], p[1]))
				continue;
			if(!people[p[0]].Friends.Contains(p[1]))
				people[p[0]].Friends.Add(p[1]);
			if(!people[p[1]].Friends.Contains(p[0]))
				people[p[1]].Friends.Add(p[0]);
		}
		var map = new Dictionary<int, int>();
		for(int i = 0; i < n; i++)
		{
			int key = friendTree.Root(i);
			if(!map.ContainsKey(key))
				map.Add(key, 0);
			map[key]++;
		}
		
		for(int i = 0; i < n; i++)
		{
			var pe = people[i];
			Console.Write("{0} ", map[friendTree.Root(i)] - 1 - pe.Friends.Count);
		}
		Console.WriteLine();
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

public class UnionFind
{
	private int[] par;
	public UnionFind(int n)
	{
		par = new int[n];
		for(int i = 0; i < n; i++)
			par[i] = i;
	}
	public int Root(int x)
	{
		if(par[x] == x) return x;
		return par[x] = Root(par[x]);
	}
	public void Unite(int x, int y)
	{
		int rx = Root(x);
		int ry = Root(y);
		if(rx == ry) return;
		par[rx] = ry;
	}
	public bool InSameTree(int x, int y)
	{
		return Root(x) == Root(y);
	}
}


Measured memory_bytes: 54812
n = int(input())
a = list(map(int,input().split()))
even = 0
odd = 0
fore = 0
for i in range(len(a)):
    if a[i]%4 == 0:
        fore += 1
    elif a[i]%2 == 0:
        even += 1
    else:
        odd += 1
if fore >= odd:
    print('Yes')
else:
    if even == 0 and odd - fore == 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var K = inputArray[0];

			var gcpDic = createGcdDictionady(K);
			long sum = 0;

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

				for (int n = 1; n <= K; n++) {
					var key1 = i + "_" + n;
					var firstGcp = gcpDic[key1];

					for (int m = 1; m <= K; m++) {
						var key2 = firstGcp + "_" + m;
						var gcp = gcpDic[key2];
						sum += gcp;

					}
				}
			}


			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// 最大公約数を取得するための辞書
		/// </summary>
		/// <param name="K"></param>
		/// <returns></returns>
		private static Dictionary<string, long> createGcdDictionady (long K){

			var gcdDic = new Dictionary<string, long>();

			for (int i = 1; i <= K; i++) {
				for (int n = 1; n <= K; n++) {
					var gcd = getGcd(i, n);
					var keyStr = i + "_" + n;
					gcdDic.Add(keyStr, gcd);
				}
			}
			return gcdDic;

		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		private static long getGcd(long a, long b) {
			if (a < b) {
				return getGcd(b, a);
			}
			if (b > 0) {
				return getGcd(b, a % b);
			}
			else {
				return a;
			}
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 46316
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    s=SI()
    ans=[-1]*n
    for f in range(2):
        for e in range(2):
            ans[0]=f
            ans[-1]=e
            for i,c in enumerate(s):
                if c=="o":
                    if ans[i]:ans[(i+1)%n]=ans[i-1]
                    else:ans[(i+1)%n]=1-ans[i-1]
                else:
                    if ans[i]:ans[(i+1)%n]=1-ans[i-1]
                    else:ans[(i+1)%n]=ans[i-1]
            if ans[0]==f and ans[-1]==e:
                print("".join("S" if a else "W" for a in ans))
                exit()
    print(-1)

main()

Measured memory_bytes: 4852
import math

log = math.log2
ceil = math.ceil

def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(1, N+1):
        s = ceil(log(K)-log(i))
        ans += 1/N * min(1, pow(1/2, s))
    print(ans)

if __name__ == "__main__":
    main()


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

struct line{
	ll m, b;
	ld xinter(line l)
	{
		return (ld) (b - l.b) / (l.m - m);
	}
	bool cmpx(line l, ll x)
	{
		return (l.m - m) * x + l.b - b >= 0;
	}
	ll evalx(ll x)
	{
		return m * x + b;
	}
};

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,c;
	cin >> n >> c;
	ll h[n+1];
	for (int q = 1; q <= n; q++)
	{
		cin >> h[q];
	}
	ll dp[n+1];
	dp[1] = 0;
	deque<line> dq;
	dq.push_back({-2*h[1], h[1] * h[1]});
	for (int q = 2; q <= n; q++)
	{
		while (dq.size() >= 2 && !dq.back().cmpx(dq[dq.size() - 2], h[q]))
		{
			dq.pop_back();
		}
		dp[q] = c + h[q] * h[q] + dq.back().evalx(h[q]);
		line l = {-2*h[q], h[q] * h[q]+dp[q]};
		while (dq.size() >= 2 && dq.front().xinter(l) <= dq[1].xinter(dq.front()))
		{
			dq.pop_front();
		}
		dq.push_front(l);
	}
	cout << dp[n] << "\n";
	return 0;
}


Measured memory_bytes: 8916
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC158
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int a = s[0];
            int b = s[1];
            var anslst = new List<int>();
            for(int i = 1;i<=1250;i++){
                int val = i;
                if((int)(val*0.08)==a&&(int)(val*0.1)==b){
                    anslst.Add(val);
                }
            }
            if(!anslst.Any()){
                WriteLine(-1);
                return;
            }
            anslst.Sort();
            WriteLine(anslst.First());
        }
    }
}


Measured memory_bytes: 13396