akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int n;
	cin >> n;
	if (n == 9 || (n>10&&(n % 10 == 9 || (n - n % 10) / 10 == 9)))puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,w,z,h;vector<int> v;int main(){while(cin>>n>>w&&n){v.clear();h=0;while(n--){cin>>z;while(true){if(v.size()>z/w)break;v.push_back(0);}v[z/w]++,h=max(v[z/w],h);}double a=0.01;for(int i=0;i<v.size();i++)a+=v[i]/(h+0.0)*(1-i/(v.size()-1.0));cout<<fixed<<setprecision(9)<<a<<endl;}return 0;}

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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int x, y;
    cin >> x >> y;
    bool ans = false;
    if (y%2 == 0) {
        y /= 2;
        if (x <= y && y <= 2*x) {
            ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define int long long
//#define double long double
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	double m;
	cin >> n >> m;
	double w[n], v[n];
	rep (i, n) {
		cin >> w[i] >> v[i];
		if (i != 0) {
			w[i] /= w[0];
		}
	}
	if (w[0] > m) {
		cout << 0 << endl;
		return 0;
	}
	m /= w[0];
	w[0] = 1.0;
	map <double, int> dp;
	dp[0] = 0.0;
	rep (i, n) {
		vector <pair <double, int>> vp;
		for(auto itr = dp.begin(); itr != dp.end(); itr++) {
			if(itr->first + w[i] <= m) {
				vp.push_back({itr->first + w[i], itr->second + (int)v[i]});
			}
		}
		rep (i, vp.size()) {
			dp[vp[i].first] = max(dp[vp[i].first], vp[i].second);
		}
	}
	int ans = -1;
	for (auto itr = dp.begin(); itr != dp.end(); itr++) {
		ans = max(ans, itr->second);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import sys

N, M = map(int, input().split())

A = [list(sys.stdin.readline()) for i in range(N)]

B = [list(sys.stdin.readline()) for i in range(M)]

for x in range(N-M+1):
    for y in range(N-M+1):
        flag = 0
        for i in range(M):
            for j in range(M):
                if A[x+i][y+j] != B[i][j]:
                    flag = 1
        if flag == 0:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
def resolve():
    s = input()
    print(
        sum(
            eval(s)
            for s in [
                "".join(
                    s[i] + "+" if i < 9 and 1 << i & b else s[i] for i in range(len(s))
                )
                for b in range(2 ** (len(s) - 1))
            ]
        )
    )


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
from heapq import nlargest
 
x, y, z, k = map(int, input().split())
A, B, C = [list(map(int, input().split())) for _ in [0] * 3]
AB = nlargest(k, (a + b for a in A for b in B))
ABC = nlargest(k, (ab + c for ab in AB for c in C))
print('\n'.join(map(str, ABC)))

Measured memory_bytes: 3956
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

string S;
int len;
long long ans = 0;

int main(int argc, char *argv[])
{
  int N, t[123456], x[123456], y[123456];
  cin >> N;

  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < N; i++) {
    int d = t[i + 1] - t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if (d < dist || d%2 != dist%2) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}


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

int main() {
  
  int i,flag=0;
  string s,t;
  
  cin >> s >> t;
  for(i=0;i<s.length();i++){
    if(s[i]!=t[i]){
      flag=1;
      break;
    } 
  }
  if(!flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n;
    cin >> n;
    if ( n % 10 == 3) {
        cout << "bon" << endl;
    } else if (n % 10 == 0 ||n % 10 == 1 || n % 10 == 6 ||n % 10 == 8)  {
        cout << "pon" << endl;
    } else
    {
        cout << "hon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}



Measured memory_bytes: 2588
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char s[5];
  cin>>s;
  int ans=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
}

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

p = 0
b = 0
for c in S:
  if c == 'a':
    if p < A+B:
      p += 1
      print('Yes')
    else:
      print('No')
  if c == 'b':
    if p < A+B and b < B:
      p += 1
      print('Yes')
    else:
      print('No')
    b += 1
  if c == 'c':
    print('No')

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string name[8];
int color[8];
int perm[8];
bool used[1 << 24];
int mat[3][8][8];
int octa[8];

void make_mat()
{
	const int swap[3][8] = {
		{1, 2, 3, 0, 5, 6, 7, 4},
		{1, 5, 6, 2, 0, 4, 7, 3},
		{3, 2, 6, 7, 0, 1, 5, 4}
	};
	
	for(int m = 0; m < 3; m++){
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(swap[m][i] == j) mat[m][i][j] = 1;
				else mat[m][i][j] = 0;
			}
		}
	}
}

int encode(int a[8])
{
	int ret = 0;
	for(int i = 0; i < 8; i++){
		ret <<= 3;
		ret += a[i];
	}
	return ret;
}

void mul(int mat[8][8], int vec[8])
{
	int tmp[8];
	int sum;
	
	for(int i = 0; i < 8; i++){
		sum = 0;
		for(int k = 0; k < 8; k++) sum += mat[i][k] * vec[k];
		tmp[i] = sum;
	}
	for(int i = 0; i < 8; i++) vec[i] = tmp[i];
}

int main(void)
{
	make_mat();
	
	for(int i = 0; i < 8; i++) octa[i] = i;
	
	while(cin >> name[0]){
		
		int c = 1;
		string *p;
		
		color[0] = 0;
		for(int i = 1; i < 8; i++){
			cin >> name[c];
			p = find(name, name+c, name[c]);
			if(p == name+c) c++;
			color[i] = p - name;
		}
		
		for(int i = 0; i < (1 << 24); i++) used[i] = false;
		
		bool flag;
		int ans = 0;
		
		for(int i = 0; i < 8; i++) perm[i] = i;
		do{
			for(int i = 0; i < 8; i++) octa[i] = color[perm[i]];
			
			flag = false;
			for(int i = 0; i < 4; i++){
				mul(mat[0], octa);
				for(int j = 0; j < 4; j++){
					mul(mat[1], octa);
					for(int k = 0; k < 4; k++){
						mul(mat[2], octa);
						if(used[encode(octa)]){
							flag = true;
							goto end;
						}
					}
				}
			}
			
			end:;
			if(!flag){
				used[encode(octa)] = true;
				ans++;
			}
			
		}while(next_permutation(perm, perm+8));
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 19484
# Coins

'''
問題：
    あなたは500円玉をA枚、100円玉をB枚、50円玉をC枚持っています。
    これらの硬貨の中から何枚かを選び、合計金額をちょうどX円にする方法は何通りありますか。

    同じ種類の硬貨同士は区別できない。
    2通りの硬貨の選び方は、ある種類の硬貨についてその硬貨を選ぶ枚数が異なる時区別される。

制約：
    0 <= A,B,C <= 50
    A+B+C >= 1
    50 <= X <= 20,000
    A, B, C は整数である。
    Xは50の倍数である。

入力：
    入力は以下の形式で標準入力から与えられる。

    A
    B
    C
    X

出力：
    硬貨を選ぶ方法の個数を出力せよ。
'''

# for文を3周回してゴリゴリとく

# 入力した値を変数に入れる
five = int(input()) # 500
hundred = int(input()) # 100
fifty = int(input()) # 50
total = int(input()) # 求める合計

# 何枚使用しているかカウントする。
used50 = 0
used100 = 0
used500 = 0
usedTotal = 0
ways = 0

while used500 <= five:
    while used100 <= hundred:
        while used50 <= fifty:
            usedTotal = 50 * used50 + 100 * used100 + 500 * used500
#            print(usedTotal)
            if total == usedTotal:
                ways += 1
            used50 += 1
        used50 = 0
        used100 += 1
#        print("a")
    used50 = 0
    used100 = 0
    used500 += 1

# 2
# 2
# 2
# 100

print(ways)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
const ll mod=1e9+7;
ll fpow(ll x,ll b){ ll res=1;for(;b;b>>=1){ if(b&1)res=res*x%mod; x=x*x%mod;} return res;}
int main(){
	int n;
	cin>>n;
	vector<ll>v(n);
	ll sum=0;
	for(auto &i:v) cin>>i,sum+=i;
	ll ans=0;
	sum=(sum-v[0]+mod)%mod;
	for(int i=0;i<n-1;i++){
		ans=(ans+sum*v[i]%mod)%mod;
		sum=(sum-v[i+1]+mod)%mod;
	}
	cout<<ans%mod<<'\n';
}

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

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if (A1 + A2 + A3 < 22){
    cout << "win" << endl;
  } else{
    cout << "bust" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll N,A,B;
  cin>>N>>A>>B;

  ll qu=N/(A+B);
  ll rest=N%(A+B);

  ll ans=0;
  ans+=qu*A;
  ans+=min(A,rest);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
m,n=tuple(map(int,input().split(" ")))
lis=list(map(int,input().split(" ")))
lis.append(lis[0]+m)
min=0
for i in range(n):
    if(lis[i+1]-lis[i]>min):
        min=lis[i+1]-lis[i]
print(m-min)

Measured memory_bytes: 26444
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
short v[5005][5005]={};
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		v[a][b]=max(v[a][b],(short)(c+1));
	}
	int ret=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			v[i][j]=max(v[i][j],(short)(max(v[i-1][j-1],v[i-1][j])-1));
			if(v[i][j]) ret++;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 48920
x,n = map(int, input().split()) 

if n==0:
    print(x)
    exit()    

p = [int(x) for x in input().split()]

for i in range(150):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()


Measured memory_bytes: 9180
#include<stdio.h>
int main(){
  long long n,m,l;
  long long i,j,k;
  long long amat[101][101]={{}};
  long long bmat[101][101]={{}};
  long long ans[101][101]={{}};
  scanf("%lld %lld %lld",&n,&m,&l);
  for(j=0;j<n;j++){
    for(i=0;i<m;i++){
      scanf("%lld ",&amat[j][i]);
    }
  }
  for(j=0;j<m;j++){
    for(i=0;i<l;i++){
      scanf("%lld ",&bmat[j][i]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
      ans[i][j]+=amat[i][k]*bmat[k][j];
    }
  }
}
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      printf("%lld",ans[i][j]);
      if(j!=l-1) printf(" ");
    }
    printf("\n");
  }
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

VLL mod(VLL& base, LL p) {
	LL N = base.size();
	if (p == 0) {
		VLL res(N);
		for (LL n = 0; n < N; n++)res[n] = n;
		return res;
	}
	if (p == 1)return base;
	VLL ret = mod(base, p / 2);
	VLL res(N);
	for (LL n = 0; n < N; n++) {
		res[n] = ret[ret[n]];
	}
	if (p % 2 == 0)return res;
	for (LL n = 0; n < N; n++) {
		ret[n] = res[base[n]];
	}
	return ret;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K,M;
	cin >> N;
	VLL X(N);
	in(X);
	VLL DX(N - 1);
	for (LL n = 0; n < N - 1; n++) {
		DX[n] = X[n + 1] - X[n];
	}
	cin >> M >> K;
	VLL A(M);
	in(A);
	VLL P(N - 1);
	for (LL n = 0; n < N-1; n++) {
		P[n] = n;
	}
	for (LL m = 0; m < M; m++) {
		LL n = A[m] - 1;
		swap(P[n - 1], P[n]);
	}
	P = mod(P, K);
	VLL res(N);
	res[0] = X[0];
	for (LL n = 1; n < N; n++) {
		res[n] = res[n - 1] + DX[P[n-1]];
	}
	for (LL n = 0; n < N; n++) {
		cout << res[n] << "\n";
	}
	return 0;
}


Measured memory_bytes: 5968
using System;

namespace C___Candies
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var a = new int[2, n];
            for (var i = 0; i < 2; i++)
            {
                var input = Console.ReadLine ().Split (' ');
                for (var j = 0; j < n; j++)
                {
                    a[i, j] = int.Parse (input[j]);
                }
            }
            var max = int.MinValue;
            var b = 0;
            for (var i = 0; i < n; i++)
            {
                var c = 0;
                b += a[0, i];
                for (var j = i; j < n; j++)
                {
                    c += a[1, j];
                }
                max = Math.Max (max, (b + c));
            }
            Console.WriteLine (max);
        }
    }
}

Measured memory_bytes: 13140
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int[] A = new int[N];
    HashMap<Long, Integer> map = new HashMap<>();
    map.put(0L, 1);
    long ans = 0;
    long sum = 0;
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      sum += A[i];
      if (map.containsKey(sum)) {
        ans += map.get(sum);
        map.put(sum, map.get(sum) + 1);
      } else {
        map.put(sum, 1);
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 102664
lst = []

for i in range(20):
    r = int(input())
    lst.append(r)
    
for i in range(10):
    for j in range(9,i,-1):
        if lst[j] < lst[j-1]:
            lst[j],lst[j-1] = lst[j-1],lst[j]

for i in range(10,20):
    for j in range(19,i,-1):
        if lst[j] < lst[j-1]:
            lst[j],lst[j-1] = lst[j-1],lst[j]

W = lst[9]+lst[8]+lst[7]
K = lst[19]+lst[18]+lst[17]

print(W,K)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)

int main(){
    int N; cin >> N;
    vector<int> A(N), B(N);
    REP(i,N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(all(A));
    int cnt = 0;
    REP(i,N) {
        int n1 = lower_bound(all(A),B[i])-A.begin();
        if ((n1+i)%2) cnt++;
    }
    cout << cnt/2 << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
s=[input() for i in range(n)]

for i in range(n+2):
    for j in range(m+2):
        if i==0 or i==n+1 or j==0 or j==m+1:
            print('#',end='')
        else:
            print(s[i-1][j-1],end='')
        if j==m+1:
            print()
            

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    //a[i] , a[j] < a[k] && a[i] + a[j] > a[k]となるようなものの数

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            ans += lower_bound(a.begin() + j + 1, a.end(), a[i] + a[j]) - (a.begin() + j + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
Q = int(input())

rev_count = 0
sbf=''
saf=''
for i in range(Q):
    que = input()
    if que[0] == '1':
        rev_count +=1
    elif que[0] == '2':
        if (rev_count + int(que[2]))%2 == 0:
            saf = saf + que[4]
        else:
            sbf = que[4] + sbf

print(sbf+s+saf if rev_count %2 == 0 else (sbf+s+saf)[-1::-1])


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        d.merge(a, b);
    }
    auto gs = d.groups();
    cout << (sz(gs)-1) << endl;
    return 0;
}


Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
    	c -= b;
    	if(c <= 0 ){
    		cout << "Yes" << endl;
    		return 0;
    	}
    	a -= d;
    	if(a <= 0){
    		cout << "No" << endl;
    		return 0;
    	}
    }
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;

string V = "yuiophjklnm";

bool check(char c) {
  Rep(i, V.size()) {
    if(c == V[i]) return true;
  }
  return false;
}

signed main()
{
  string S;
  while(cin >> S, S[0] != '#') {
    bool save = check(S[0]);
    int cnt = 0;

    Reps(i, 1, S.size()) {
      if(save != check(S[i])) {
	save = 1 - save, cnt++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n;
    cin >> n;
    int ans=1e9;
    rep(i,n){
        int ai;
        cin >> ai;
        int cnt=0;
        while(ai%2!=1){
            ai/=2;
            cnt++;
        }
        ans=min(ans,cnt);
    }
    out(ans)
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int dp[401][401];
	for (int i = 0; i < 401; ++i) {
		for (int j = 0; j < 401; ++j) {
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		for (int j = 400; j >=0; --j) {
			for (int k = 400; k >=0; --k) {
				if (j + a > 400) continue;
				if (k + b > 400) continue;
				if (dp[j][k] == -1) continue;
				if (dp[j + a][k + b] == -1) {
					dp[j + a][k + b] = dp[j][k] + c;
				}
				else {
					dp[j + a][k + b] = min(dp[j][k] + c, dp[j+a][k+b]);
				}
			}
		}
	}
	int mincost = 100*50;
	int x = 1;
	while (x*ma <= 400 && x*mb <= 400) {
		if (dp[x*ma][x*mb] != -1) {
			mincost = min(mincost, dp[x*ma][x*mb]);
		}
		x++;
	}
	if (mincost == 100 * 50) cout << -1 << endl;
	else cout << mincost << endl;
	return 0;
}

Measured memory_bytes: 896
<?php
fscanf(STDIN, "%d %d %d %d", $N, $M, $X, $Y);
$x = explode(" ", trim(fgets(STDIN)));
$y = explode(" ", trim(fgets(STDIN)));
$x[] = $X;
$y[] = $Y;
echo max($x) >= min($y) ? "War" : "No War";


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

int main() {
  int a, b;
  cin >> a >> b;
  if ( a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  else if ( a * b % 2 != 0) {
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,k,s,a[N];
int main() {
	read(n);read(k);read(s);
	if(!k){
		int x=1e9;if(x==s)x--;
		rep(i,1,n)printf("%d ",x);return 0;
	}
	rep(i,1,k)a[i]=s;rep(i,k+1,n)a[i]=(s!=1e9)?1e9:1e9-1;
	rep(i,1,n)printf("%d ",a[i]);
	return 0;
}


Measured memory_bytes: 1664
n = int(input())  
red_li = [list(map(int, input().split())) for _ in range(n)]
blue_li = [list(map(int, input().split())) for _ in range(n)]
ans = 0
red_li.sort(reverse = True, key = lambda x : (x[0], x[1]))
blue_li.sort( key = lambda x : (x[0], x[1]))

def count(red, blue):
    used_red = []
    used_blue = []
    for i in red:
        if i in used_red:
            continue
        for j in blue:
            if j in used_blue:
                continue
            if i[0] < j[0] and i[1] < j[1]:
                used_red.append(i)
                used_blue.append(j)
                break
    return len(used_red)


red_li.sort(reverse = True,key = lambda x : (x[0], x[1]))
blue_li.sort( key = lambda x : (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int mod=998244353;
struct point{
    int x,y;
    point(int _x=0,int _y=0):x(_x),y(_y){}
}p[203];
inline point operator -(const point& a,const point& b){
    return point(a.x-b.x,a.y-b.y);
}
inline int cross(const point& a,const point& b){
    return a.x*b.y-a.y*b.x;
}
inline int dot(const point& a,const point& b){
    return a.x*b.x+a.y*b.y;
}
inline long long qpow(long long x,long long n){
    long long res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
       	cin>>p[i].x>>p[i].y;
	}
    long long ans=qpow(2,n);
    ans=(ans-1+mod)%mod;
    ans=(ans-n+mod)%mod;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            long long cnt=0;
            for(int k=1;k<=n;k++){
                if(cross(p[k]-p[i],p[k]-p[j])==0&&dot(p[k]-p[i],p[k]-p[j])<0)
                    ++cnt;
            }
            ans=(ans-qpow(2,cnt)+mod)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*

in:
5
0 0
0 1
0 2
0 3
1 1

out:
11

*/ 

Measured memory_bytes: 256
int main()
{
  int h,w;
  int i,j;
  scanf("%d",&h);
  scanf("%d",&w);
  while(!((h==0) && (w==0))){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if ((i%2==0) && (j%2==0)){
          printf("#");
        }else if ((i%2==0) && (j%2==1)){
          printf(".");
        }else if ((i%2==1) && (j%2==0)){
          printf(".");
        }else if ((i%2==1) && (j%2==1)){
          printf("#");
        }
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d",&h);
    scanf("%d",&w);
  }
 
 
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

const int INF = 1001001001;


int main() {

    set<char> odd = {'R', 'U', 'D'};
    set<char> even = {'L', 'U', 'D'};

    string line;
    cin >> line;

    bool is_odd = true;
    for (char c : line) {
        if (is_odd) {
            if (odd.find(c) == odd.end()) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (even.find(c) == even.end()) {
                cout << "No" << endl;
                return 0;
            }
        }
        is_odd = !is_odd;
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
typedef long long ll;
using namespace std;

int main() {
	int N; cin >> N;
	int T[N];
	for (int i = 1; i <= N; ++i) cin >> T[i];
	int M; cin >> M;
	int P[M],X[M],A[M];
	int total = 0;
	for (int i = 1; i <= M; ++i) cin >> P[i] >> X[i];
	
	for (int i = 1; i <= N; ++i) total += T[i];
	
	for (int i = 1; i <= M; ++i) {
		cout << total - T[P[i]] + X[i] << endl;
	}

}


Measured memory_bytes: 256
#include<stdio.h>
#define min(x,y)(x>y?y:x)
int main(){
    int A,B,M;
    int a[100000];
    int b[100000];
    int x[100000],y[100000],c[100000];
    int mina=999999,minb=999999;
    int ans=999999;
    scanf("%d %d %d",&A,&B,&M);
    for(int i=0;i<A;i++){
        scanf("%d",&a[i]);
        mina=min(mina,a[i]);
    }
    for(int i=0;i<B;i++){
        scanf("%d",&b[i]);
        minb=min(minb,b[i]);
    }
    ans=min(ans,mina+minb);
    for(int i=0;i<M;i++){
        scanf("%d %d %d",&x[i],&y[i],&c[i]);
        ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll a,b;
  cin>>a>>b;
  ll x[3];
  x[0]=a+a-1;
 x[1]=b+b-1;
  x[2]=a+b;
  sort(x,x+3);
  cout<<x[2];
  return 0;
 
}
 

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

int main(){
    int n,m,ans=0,temp=0;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s.at(i);
    }
    cin >> m;
    vector<string> t(m);
    rep(i,m){
        cin >> t.at(i);
    }
    rep(i,n){
        temp=0;
        rep(j,n){
            if(s.at(i)==s.at(j))temp++;
        }
        rep(j,m){
            if(t.at(j)==s.at(i))temp--;
        }
        ans=max(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N; cin >> N;
    vector<int> A(N);
    map<int, int> res;

    REP(i,N){
        cin >> A[i];
        res[A[i]]++;
    }

    ll first=0;
    for(auto x: res){
        auto n = x.second;
        first += nCr(n, 2);
    }

    REP(i,N){
        ll second = res[A[i]]>0 ? res[A[i]]-1 : 0;
        cout << first - second << endl;
    }

    return 0;
}


Measured memory_bytes: 8320
//*
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	ll a, b, c, d;

	cin >> n;

	d = n % 10;
	c = (n - d) / 10 % 10;
	b = (n - c * 10 - d) / 100 % 10;
	a = (n - b * 100 - c * 10 - d) / 1000;

	if (a == b && b == c) {
		cout << "Yes" << endl;
	}
	else if (b == c && c == d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
//*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    ll c[n];
    rep(0,i,n){
        c[i]=0;
    }
    UnionFind a(n);
    a.init(n);
    rep(0,i,m){
        ll x,y;
        cin>>x>>y;
        --x,--y;
        a.merge(x,y);
        ++c[x];
        ++c[y];
    }
    rep(0,j,k){
        ll x,y;
        cin>>x>>y;
        --x,--y;
        if(a.issame(x,y)){
            ++c[x];
            ++c[y];
        }
    }
    rep(0,i,n){
        //cout<<a.size(i)<<endl;
        //cout<<c[i]<<endl;
    }
    rep(0,i,n){
        cout<<a.size(i)-1-c[i];
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 3200
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int n, m, k;
int INF = 10e8;
typedef pair<int, int> P;
vector<P> g[3001];
int d[3001];
int ans;

void dijkstra(){
	priority_queue<P, vector<P>, greater<P> > q;
	fill(d, d+n+1, INF);
	d[0] = 0;
	q.push(P(0, 0));
	while(!q.empty()){
		P p = q.top(); q.pop();
		int t = p.second;
		for(int i=0; i<g[t].size(); i++){
			if(d[g[t][i].second] > d[t] + g[t][i].first){
				d[g[t][i].second] = d[t] + g[t][i].first;
				q.push(P(d[g[t][i].second], g[t][i].second));
			}
		}
	}
}

int main(){
	scanf("%d %d %d", &n, &m, &k);
	for(int i=0; i<m; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		g[a].push_back(P(c, b));
		g[b].push_back(P(c, a));
	}
	for(int i=0; i<k; i++){
		int t;
		scanf("%d", &t);
		g[t].push_back(P(0, 0));
		g[0].push_back(P(0, t));
	}
/*
	for(int i=0; i<n; i++){
		printf("%d\n", i+1);
		for(int j=0; j<g[i+1].size(); j++){
			printf("%d %d\n", g[i+1][j].first, g[i+1][j].second);
		}
	}
*/
	dijkstra();

//	for(int i=0; i<n+1; i++) printf("%d %d\n", i, d[i]);

	for(int i=0; i<n; i++){
		for(int j=0; j<g[i+1].size(); j++){
			int a = min(d[i+1], d[g[i+1][j].second]);
			int b = max(d[i+1], d[g[i+1][j].second]);
			int c = g[i+1][j].first;
			ans = max(ans, (int)((round(a + b + c) / 2) + 0.5));
		}
	}

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

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

int main() {
  int N, K;
  std::string S;

  std::cin >> N >> K;
  std::cin >> S;

  std::vector<int> inds = {0};

  char top = S[0];
  for(int i = 0; i < N; ++i) {
    if(top != S[i]) {
      inds.push_back(i);
      top = S[i];
    }
  }
  inds.push_back(N);

  std::vector<int> ans;
  for(int i = 0; i < (int) inds.size(); ++i) {
    if(S[inds[i]] == '0') {
      ans.push_back(inds[std::min((int) inds.size() - 1, i + 2 * K )] - inds[i]);
    } else {
      ans.push_back(inds[std::min((int) inds.size() - 1, i + 2 * K + 1)] - inds[i]);
    }
  }
  std::sort(ans.begin(), ans.end(), std::greater<int>());

  std::cout << ans[0] << std::endl;
}

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

class dice{
private:
	int D1;
	int D2;
	int D3;
	int D4;
	int D5;
	int D6;
public:
	dice(int d1,int d2,int d3,int d4,int d5,int d6){
	D1=d1;
	D2=d2;
	D3=d3;
	D4=d4;
	D5=d5;
	D6=d6;
	}
	void turn(char a){
		int front=D2;
		int back=D5;
		int top=D1;
	        int botton=D6;
		int right=D3;
		int left=D4;
		if(a=='E'){
			top=D4;
			right=D1;
			left=D6;
			botton=D3;
		}
		if(a=='N'){
			top=D2;
			front=D6;
			botton=D5;
			back=D1;
		}
		if(a=='S'){
			top=D5;
			front=D1;
			botton=D2;
			back=D6;
		}
		if(a=='W'){
			top=D3;
			left=D1;
			botton=D4;
			right=D6;
		}
		D1=top;
		D2=front;
		D3=right;
		D4=left;
		D5=back;
		D6=botton;
	}
	int get_d1(){
		return D1;
	}
	int get_d2(){
		return D2;
 	}
 	int get_d3(){
		return D3;
 	}
 	int get_d4(){
		return D4;
 	}
 	int get_d5(){
		return D5;
 	}
 	int get_d6(){
		return D6;
 	}	
};

int main(){
	int d1[6];
	int d2[6];
	int count=0;
	
	for(int i=0;i<6;i++)
		cin>>d1[i];
	dice p1(d1[0],d1[1],d1[2],d1[3],d1[4],d1[5]);
	for(int i=0;i<6;i++)
		cin>>d2[i];
	dice p2(d2[0],d2[1],d2[2],d2[3],d2[4],d2[5]);
	
	for(int i=0;i<4;i++){
		p1.turn('S');
		for(int j=0;j<4;j++){
			p1.turn('E');
			for(int k=0;k<4;k++){
				p1.turn('S');
				for(int l=0;l<4;l++){
					p1.turn('E');
					count++;
					if(p1.get_d1()==p2.get_d1() && p1.get_d2()==p2.get_d2() && p1.get_d3()==p2.get_d3() && p1.get_d4()==p2.get_d4() && p1.get_d5()==p2.get_d5() && p1.get_d6()==p2.get_d6()){
						cout<<"Yes\n";
						goto exit;
					}
					else if((p1.get_d1()!=p2.get_d1() || p1.get_d2()!=p2.get_d2() || p1.get_d3()!=p2.get_d3() || p1.get_d4()!=p2.get_d4() || p1.get_d5()!=p2.get_d5() || p1.get_d6()!=p2.get_d6()) && count==4*4*4*4){
						cout<<"No\n";
						goto exit;
					}
				}
			}
		}
	}
	
	exit:;
					
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=1e5+1;
int a[N];
long long min[N], max[N];
int main() {
	int n=rd();
	for(int i=0; i<=n; ++i) a[i]=rd();
	long long curmin=0, curmax=0;
	for(int i=n; i>=0; --i) {
		curmin=(curmin+1)/2;
		min[i]=curmin+=a[i];
		max[i]=curmax+=a[i];
	}
	if(curmin>1) {
		puts("-1");
		return 0;
	}
	long long cnt=1, ans=1;
	for(int i=1; i<=n; ++i) {
		ans+=cnt=std::min(cnt*2, max[i]);
		cnt-=a[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5648
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  string S;
  cin >> S;
  int N;
  N = S.size();
  for(int i=0;i<N;i++)
  {
    S.at(i) = 'x';
  }
  cout << S << endl;
  return 0;
}


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

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

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

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

const int N = 2e5 + 5;
int f(int n){
    int cnt = 0;
    while(n >= 2 && n % 2 == 0){
        n /= 2;
        cnt++;
    }
    return cnt;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for(auto &x : a){
        cin >> x;
        ans += f(x);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll x,y,ans=0,z;
    cin>>x>>y;
    z=y/2;
    z=min(z,x);
    ans+=z;
    x-=z;
    y-=z*2;
    if(x==0)
        ans+=(y/4);
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3620
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    string s,t;
    cin>>s>>t;
    int n=s.len;
    int m=t.len;
    int mi=mod;
    rep0(i,n-m+1){
        int x=0;
        repp(j,i,i+m){
            if(s[j]!=t[j-i]) x++;
        }
        mi=min(mi,x);
    }
    pr(mi);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<pair<ll, ll>> ab;
    rep(i,n) {
        ll a, b;
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }

    ll cnt=0;
    ll sum=0;
    sort(ab.begin(), ab.end());
    for(int i=0; i<n; i++){
        cnt += ab.at(i).second;
        if(cnt<m) sum+=ab.at(i).first * ab.at(i).second;
        else{
            cnt -= ab.at(i).second;
            while(cnt<m){
                sum+=ab.at(i).first;
                cnt++;
            }
            break;
        }
    }

    cout << sum << endl;


}

Measured memory_bytes: 2420
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int MAXM = 1000010;
const int INF = 1000000000;
const int MOD = 998244353;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int a[MAXN];

int main()
{
	
	ll n;
	cin >> n;
	if (n == 0)
	{
		puts("0");
		return 0;
	}
	ll cur = 1;
	for (int k = 0; k < 60; ++ k)
	{
		if (n>>k&1)
		{
			a[k] = 1;
			n -= cur;
		}
		cur *= -2;
	}
	for (int k = 60-1; k >= 0; -- k)
		if (a[k])
		{
			for (; k >= 0; -- k)
				printf("%d", a[k]);
			puts("");
			break;
		}
	
	return 0;
}


Measured memory_bytes: 256