akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n;
int arr[100100];
inline int lowbit(int x)
{
    return x & -x;
}
int sum[200100];
void add1(int x)
{
    while(x <= 2 * n + 1)
    {
        sum[x] ++;
        x += lowbit(x);
    }
}
int query(int x)
{
    int ret = 0;
    while(x)
    {
        ret += sum[x];
        x -= lowbit(x);
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> arr[i];
    int l = 0, r = 1e9;
    LL wtd = ((LL)n * n + n) / 2 + 1 >> 1;
    while(l != r)
    {
        int mid = (l + r) / 2 + 1;
        LL tot = 0;
        memset(sum, 0, sizeof(sum));
        int tmp = n + 1;
        add1(tmp);
        for(int i = 1; i <= n; i ++)
        {
            tmp += (arr[i] >= mid ? 1 : -1);
            tot += query(tmp);
            add1(tmp);
        }
//        if(mid == 8)
//            cout << tot << endl;
        if(tot >= wtd)
            l = mid;
        else
            r = mid - 1;
    }
    cout << l << endl;
    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

ll euk(ll a, ll b) {
  if (b==0) return a;
  return euk(b, a%b);
}

void Main() {
  int n;
  cin >> n;
  vector<P> X;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    X.emplace_back(b, a);
  }
  sort(X.begin(), X.end());
  int now = 0;
  for(P p : X) {
    now += p.second;
    if (now > p.first) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main(void){
    int d=0;

    cin >> d;

    if(d==25)cout << "Christmas" << endl;
    else if(d==24)cout << "Christmas Eve" << endl;
    else if(d==23)cout << "Christmas Eve Eve" << endl;
    else if(d==22)cout << "Christmas Eve Eve Eve" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#include<map>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}


int main() {
	int N = 0, a[200008] = { 0 }, copy[200008] = { 0 }, ans = 0;
	vector<int> manji;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		
	}
	for (int i = N-1; i >= 0; i--) {
		int kazu = 0;
		for (int j = i * 2 + 1; j <= N; j += (i + 1)) {
			if (copy[j] == 1) {
				kazu++;
			}
		}
		//cout<<kazu<<endl;
		if (kazu % 2 != a[i]) {
			ans++;
			manji.push_back(i+1);
			copy[i] = 1;
		}
	}
	cout << manji.size() << endl;
	for (int i = 0; i < manji.size(); i++) {
		cout << manji[i] << ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int K;
    cin >> K;

    queue<int> q;
    rep(i, 9) {
        q.push(i+1);
        K--;
        if(!K) break;
    }
    
    while(K>0) {
        int t = q.front();
        int d = t%10;
        q.pop();
        if(d!=0) {
            q.push(t*10+(d-1));
            K--;
            if(!K) break;
        }
        q.push(t*10+d);
        K--;
        if(!K) break;
        if(d!=9) {
            q.push(t*10+(d+1));
            K--;
            if(!K) break;
        }
    }

    cout << q.back() << endl;
 
    return 0;
}

Measured memory_bytes: 768
li = []
while True:
    li.append(list(map(int, input().split())))
    if li[-1] == [0,0]:
        li.pop()
        break
for l in li:
    for i in range(l[0]):
        s = ''
        for j in range(l[1]):
            if j%2 ^ i%2 == 0:
                s += '#'
            else:
                s += '.'
        print(s)
    print('')


Measured memory_bytes: 5628
#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
import sys
from collections import defaultdict, deque

input = sys.stdin.readline

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

def main():
    N, W = map(int, input().split())
    f_inf = float('inf')
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    MAX_N = 110000
    dp = [0] * (W + 1)


    for _ in range(N):
        w, v = map(int, input().split())
        for sum_w in range(W, w-1, -1):
            a = dp[sum_w - w] + v
            if a > dp[sum_w]:
                dp[sum_w] = a
    print(dp[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	double dp[3030][3030],p,ans=0;
	int n;
	cin>>n;
	rep(i,0,3030)rep(j,0,3030)dp[i][j]=1;
	rep(i,1,n+1){
		cin>>p;
		dp[i][0]=dp[i-1][0]*(1-p);
		dp[i][i]=dp[i-1][i-1]*p;
		rep(j,1,i){
			dp[i][j]=dp[i-1][j-1]*p+dp[i-1][j]*(1-p);
		}
	}
	rep(j,1,n+1){
		if(n/2<j)ans+=dp[n][j];
	}
	print(setprecision(11)<<ans);

}

Measured memory_bytes: 71936
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], l = tmp[1];
    string[] s = new string[n];
    foreach (i; 0 .. n) {
        s[i] = readln.chomp;
    }
    s.sort!"a < b";
    s.join.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int odd = n/2 + n%2;
    int even = n/2;
    cout << odd * even << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut v: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();
    let mut ret = 0.0;
    for i in 0..n {
        for j in i+1..n{
            ret += dist(&v[i], &v[j]) as f64;
        }
    }
    let n_factorial = factorial(n) as f64;
    let offset = 2.0 * factorial(n-1) as f64;
    println!("{}", (offset * ret) / n_factorial);
}

fn dist(a: &(i32,i32), b: &(i32, i32)) -> f64{
    let mut t = ((a.0 - b.0).pow(2) + (a.1 - b.1).pow(2)) as f64;
    t.sqrt()
}

fn factorial(n: usize) -> usize {
    if n == 0 {
        1
    } else {
        n * factorial(n - 1)
    }
}

Measured memory_bytes: 4352
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt()
  println(judge(a,b))

  def judge(a: Int, b: Int): String = {
    if (a < b) "a < b"
    else if (a > b) "a > b"
    else "a == b"
  }
}

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

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

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;

bool check(string s)
{
   int k = s.size()/2;
   for(int i = 0; i <k; i++)
   {
      if(s[i] != s[i+k])
         return false;
   }
   return true;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   string s; cin >> s;
   for(int i = 0; i < s.size(); i++)
   {
      if((i+1)%2)
         cout << s[i];
   }


   return 0;
}


Measured memory_bytes: 3660
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = X()
K = i()

for i in range(K):
    if S[i] == "1":
        pass
    else:
        print(S[i])
        sys.exit()

print(1)


Measured memory_bytes: 10064
a,b,c,d = map(int,input().split())
if b < 0:
    if c >= 0:
        ans = b*c
    else:
        ans = a*c
elif a > 0:
    if d < 0:
        ans = a*d
    else:
        ans = b*d
else:
    ans = max(a*c,b*d)
print(ans)

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

int x,y;

while(1){
scanf("%d %d",&x,&y);
if(x==0&&y==0)break;
if(x<=y){
printf("%d %d\n",x,y);
}else{
printf("%d %d\n",y,x);
}
}
return 0;
}


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

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

    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    vector<int> d(n);
    d[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        d[i] = min(d[i - 1] + abs(h[i] - h[i - 1]), d[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << d[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int N,i,a,r;
int main(void){
  cin>>N>>r;
  for(i=1;i<N;i++){
    cin>>a;
    r=min(r,__gcd(r,a));
  }
  cout<<r<<endl;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
v = [0]+[int(i) for i in input().split()]+[0]
ans = 0
cnt1 = 0
m1 = []
for i in range(n+1):
    cnt1 += v[i]
    if v[i] < 0: m1.append(v[i])
    cnt2 = cnt1
    m2 = m1[:]
    for j in range(n-i+1):
        if i + j > k: break
        r = k - i - j
        cnt2 += v[n+1-j]
        if v[n+1-j] < 0: m2.append(v[n+1-j])
        m2.sort()
        s = cnt2
        s -= sum(m2[:r])
        ans = max(s,ans)
print(ans)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep (i, n) {
    cin >> a[i];
  }
  int g = a[0];
  rep (i, n) {
    g = gcd(g, a[i]);
  }
  cout << g << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
const int N=200005;
int n;
int a[N];
map<int,int>f[N];
void update(map<int,int>&f,int j,int v)
{
	if(!f.count(j)) f[j]=v;
	else f[j]=min(f[j],v);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	f[1][0]=a[1],f[1][1]=0;
	for(int i=2;i<=n;i++)
	{
		int vl=min(0,a[i]-a[i-1]),vr=max(0,a[i]-a[i-1]);
		for(auto [v,j]:f[i-1])
		{
			if(f[i-1].begin()->first<v-2) break;
			if(j+vl>0) update(f[i],v+2,0);
  	  		if(j+vl<=a[i]) update(f[i],v+1,max(j+vl,0));
  	  		if(j+vr<=a[i]) update(f[i],v,max(j+vr,0));
		}
	}
	int ans=1e9;
	for(auto [v,j]:f[n])
		ans=min(ans,v+(j>0));
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 51300
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};

int main() {
	int a,b,c;
	cin >> a >> b >> c;

    int Max = max({a,b,c}),Min =  min({a,b,c});

	cout << Max - Min << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
char c[250000];
int a=-1,z;
int main() {
	scanf("%s",c);
	for(int i=0;i<strlen(c);i++){
		if(c[i]=='A'&&a==-1){
			a=i;
		}
		if(c[i]=='Z')
			z=i;
	}
	printf("%d",z-a+1);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[110000];
int sum[20][110000];
int sz[20];
int dp[1 << 20];
int main() {
	int a, b; scanf("%d%d", &a, &b);
	for (int i = 0; i<a; i++) {
		scanf("%d", p + i);
		p[i]--;
		sum[p[i]][i + 1]++;
		sz[p[i]]++;
	}
	for (int i = 0; i<b; i++)for (int j = 0; j<a; j++) {
		sum[i][j + 1] += sum[i][j];
	}
	for (int i = 0; i<(1 << b); i++)dp[i] = 999999999;
	dp[0] = 0;
	for (int i = 0; i<(1 << b); i++) {
		int pos = 0;
		for (int j = 0; j<b; j++)if (i&(1 << j))pos += sz[j];
		for (int j = 0; j<b; j++) {
			if (i&(1 << j))continue;
			dp[i + (1 << j)] = min(dp[i + (1 << j)], dp[i] + sz[j] - sum[j][pos + sz[j]] + sum[j][pos]);
		}
	}
	printf("%d\n", dp[(1 << b) - 1]);
}


Measured memory_bytes: 14956
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {


	void Solve() {
		while (true) {
			UL N; cin >> N;
			if (N == 0) break;
			UL ans = 0;
			rep(i, N / 4) {
				UL a; cin >> a;
				ans += a;
			}
			cout << ans << endl;
		}

	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



Measured memory_bytes: 3020
import java.util.*;

public class Main {

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


        int n=scan.nextInt();
        int k=scan.nextInt();
        boolean []d=new boolean[10];
        for(int i=0;i<k;i++)
            d[scan.nextInt()]=true;


        int ans=n;
        int tmp;
        while(true){
            tmp=ans;
           while(tmp>0 && d[tmp%10]==false) {
               tmp /= 10;
           }
           if(tmp==0)
               break;
            else
                ans++;

        }
        System.out.println(ans);

    }
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int n,k,d,a; 
    cin >> n >> k;
    unordered_map<int,int> m;
    while(k--){
        cin >> d;
        for(int i=0;i<d;i++){
            cin >> a;
            m[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!m[i]) ans++;
    }
    cout << ans << "\n";
    return 0;
} 

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> str(h);
    REP(i, h)
        cin >> str[i];
    REP(i, h) {
        cout << str[i] << '\n';
        cout << str[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int D[10];
int K;
bool check(string n){
	for(int i = 0; i < n.length(); i++){
		for(int j = 0; j < K; j++){
			if(n[i] - 48 == D[j])return false;
		}
	}
	
	return true;
}

int main(){
	int N;
	cin>>N>>K;
	
	for(int i = 0; i < K; i++){
		cin>>D[i];
	}
	for(int i = N; i < 100000; i++){
		if(check(to_string(i))){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a;
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputDoubleArray(a,N) double a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //DP。i枚目まで見てj枚表になっている確率漸化式を立てる？
  //input
  inputInt(N);
  inputDoubleArray(p,N);
  
  //main
  vector<vector<double>> memo(N+10, vector<double>(N+10, 0)); //Sを左からi(0~N)文字見た&j(0~N)文字見た時の共通部分列。
  memo[0][0] = 1;
  
  for(int i=0; i<N+1; i++){
    for(int j=0; j<N+1; j++){
      //i+1枚目を見る。
      memo[i+1][j+1] += memo[i][j]*p[i];
      memo[i+1][j]   += memo[i][j]*(1-p[i]);
    }
  }
  
  // output
  double ans = 0;
  fSE(j,(N+1)/2,N) ans += memo[N][j];
  cout << setprecision(10) << ans << endl;
  
  //debug
  /*fN(i,N+1) {
    fN(j,N+1) {
      cout << memo[i][j] << " ";
    }
    cout << endl;
  }*/
  
  return 0;
}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

string S;
int od,ev,ans;
int odn,evn;

int main(){
        cin >> S;
        if(S.length()%2 == 0){
                odn = S.length()/2;
                evn = odn;
        }else{
                odn = S.length()/2 + 1;
                evn = odn-1;
        }
        //cout << odn << "," << evn << endl;

        FOR(i,0,S.length()){
                if(S[i]=='0'){
                        if(i%2==0) od++;
                        else ev++;
                }
        }
        //cout << od << "," << ev << endl;

        if(ev>od){
                ans = evn - ev + od;
        }else if(ev==od){
                ans = evn - ev + od;
        }else{
                ans = odn - od + ev;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

inline double calc_std(const vector<int>& v, double m) {
  double r = 0.0;
  for (auto s : v) {
    const auto d = static_cast<double>(s) - m;
    r += d * d;
  }
  return sqrt(r / v.size());
}

int main() {
  int n;
  for (;;) {
    cin >> n;
    if (!n)
      break;

    vector<int> v(n, 0);
    double m = 0.0;
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
      m += v[i];
    }
    m /= n;
    printf("%.8f\n", calc_std(v, m));
  }
  return 0;
}

Measured memory_bytes: 3160
<?php
    $tmp = trim(fgets(STDIN));
    $inp = explode(" ", $tmp);
    
    if($inp[0] < $inp[1]){
        echo "a < b" . PHP_EOL;
    }elseif($inp[0] > $inp[1]){
        echo "a > b" . PHP_EOL;
    }else{
        echo "a == b" . PHP_EOL;
    }


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll k;cin>>k;
    ll n=7;
    rep(i,1,k+1){
        if(n%k==0){
            cout<<i<<endl;
            return 0;
        }else{
            n=(n*10+7)%k;
        }
    }
    cout<<-1<<endl;

    return 0;
}





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

int main() {
    int K,S;
	cin >> K >> S;
    // ここまで入力
    K++;
    vector<int> it(K);
    rep(i,K) it[i] = i;
    int cnt = 0;
    rep(a,K){
        rep(b,K){
            int sum = a+b;
            auto itr = lower_bound(all(it), S-sum);
            if(itr != it.end() && S >= sum) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(void){
    ll H, W;
    cin >> H >> W;

    if(H == 1 || W == 1){
        cout << 1 << endl;
    }else{
        cout << (H * W + 1) / 2 << endl;
    }
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    
    if (N < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    
    return 0;
}


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

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll pow3[100001];
ll mod = 1000000000 + 7;

int main(){

    string s;
    cin >> s;

    vector<int> a_left(s.size()); //ある地点より右側にaが何個あるか
    vector<int> q_left(s.size()); //ある地点より左側にqが何個あるか

    vector<int> c_right(s.size()); //ある地点より右側にcが何個あるか
    vector<int> q_right(s.size()); //ある地点より右側にqが何個あるか

    for(int i = 1; i < s.size(); i++){
        a_left[i] = a_left[i-1];
        q_left[i] = q_left[i-1];
        if(s[i-1] == 'A') a_left[i] ++;
        if(s[i-1] == '?') q_left[i] ++;
    }

    for(int i = s.size()-2; i >= 0; i--){
        c_right[i] = c_right[i+1];
        q_right[i] = q_right[i+1];
        if(s[i+1] == 'C') c_right[i] ++;
        if(s[i+1] == '?') q_right[i] ++;
    }

    ll p3 = 1;
    pow3[0] = 1;
    for(ll i = 1; i <= 100000; i++){
        p3 = (p3 * 3) % mod;
        pow3[i] = p3;
    }

    ll ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'B' || s[i] == '?'){
            ll left , right;
            if(q_left[i] == 0) left = a_left[i];
            else left = a_left[i] * pow3[q_left[i] ] + q_left[i] * pow3[q_left[i] -1];
            if(q_right[i] == 0) right = c_right[i];
            else right = c_right[i] * pow3[q_right[i] ] +q_right[i]*  pow3[q_right[i] -1];
 
            left %= mod;
            right %= mod;
            //cout << "left = " << left <<" right = " << right << endl;
            ans += left * right;
            ans %= mod;
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    double a,b; cin>>a>>b;

    cout<<ceil(a/b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,count=0;
  vector<int> p(N);
  cin>>N;
  for(int i=0;i<N;i++) cin>>p[i];
  
  for(int i=0;i<N;i++){
    if(p[i]!=i+1) count++;
  }
  
  if(count==0||count==2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}
    

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int frq[123];
int main(){
	Lancer();
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++){
		frq[str[i]]++;
	}
	for (int i = 97; i < 123; i++){
		if (frq[i] == 0){
			cout << char(i);
			return 0;
		}
	}
	cout << "None";
	cout << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> odd(100010, 0), even(100010, 0);
  
  for (int i = 0; i < n; i++) {
    int v;
    if (i % 2) {
      cin >> v;
      odd[v]++;
    } else {
      cin >> v;
      even[v]++;
    }
  }
  
  int oddmax = 0, oddmax_num = 0, 
  evenmax = 0, evenmax_num = 0, oddmax2nd = 0, evenmax2nd = 0;
  
  for (int i = 1; i <= 100000; i++) {

    if (oddmax <= odd[i]) {
      oddmax2nd = oddmax;
      oddmax = odd[i];
      oddmax_num = i;
    } else if (oddmax2nd <= odd[i]) {
      oddmax2nd = odd[i];
    }
    
    if (evenmax <= even[i]) {
      evenmax2nd = evenmax;
      evenmax = even[i];
      evenmax_num = i;
    } else if (evenmax2nd <= even[i]) {
      evenmax2nd = even[i];
    }
  }
  

  if (oddmax_num == evenmax_num) {
    cout << n - max(oddmax + evenmax2nd, evenmax + oddmax2nd) << endl;
  } else {
    cout << n - oddmax - evenmax << endl;
  }
  
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        px=self.parent[x]
        if px < 0:
            return x
        if self.parent[px] < 0:
            return px
        self.parent[px] = self.parent[x] = self.root(self.parent[px]) #xをxの根に直接つなぐ
        return self.parent[x]

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


n,m=[int(i) for i in input().split()]

A=[[int(i)-1 for i in input().split()] for _ in range(m)]

ans = [0]*(m+1)
a = n*(n-1)//2
ans[0] = a

uf = UnionFind(n)
for i in range(m):
    j = m-i-1
    v1 = A[j][0]
    v2 = A[j][1]
#    print(v1,v2)
    if not uf.issame(v1,v2):
#        print(uf.parent)
        a -= uf.size(v1) * uf.size(v2)
        uf.merge(v1,v2)

    ans[i+1]=a

for i in range(m):
    print(ans[m-i-1])
    
    
    
    
    
    





Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j;
    ll n;
    cin >> n;
    ll cnt = 0;
    for (i = 2; i * i <= n; i++) {
        ll m = n;
        while (m % i == 0) m /= i;
        if (m % i == 1) cnt++;
    }
    n--;
    for (i = (ll)1; i * i < n; i++) {
        if (n % i == 0) cnt++;
    }
    cout << ++cnt << endl;
}

Measured memory_bytes: 3616
from collections import Counter
n = int(input())
li = [0]*n

for i in range(n):
    li[i] = Counter(input())

ans = [50]*26
for i in range(ord("a"),ord("z")+1):
    for j in range(n):
        ans[i-97] = min(li[j][chr(i)],ans[i-97])
s = ""
for i in range(26):
    if ans[i] != 0:
        s += chr(i + ord("a"))*ans[i]
s = list(s)
s.sort()
print("".join(s))

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
 
signed main()
{
  
  int n;string s;cin>>n>>s;
  
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string a=s.substr(0,n/2);
  string b=s.substr(n/2,n/2);
  if(a==b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int check(int tmp, int i) {
  if (i % 2 == 0) {
    return check(1 + tmp, i / 2);
  } else {
    return tmp;
  }
}

int main(void) {
  int n;
  int a;
  int tmp;
  int min = 65536;

  scanf("%d\n", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    tmp = check(0, a);

    if (tmp < min) {
      min = tmp;
    }

  }

  printf("%d\n", min);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();

        // 処理
        int out = n / 2 + (n % 2 == 0 ? 0 : 1);

        // 出力
        System.out.println(out);
    }

}

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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n;
  ll i;
  cin >> n;
  vector<ll> h(n);
  for(i = 0; i < n; i++){
    cin >> h[i];
  }
  vector<ll> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  ll a, b;
  for(i = 2; i < n; i++){
    a = dp[i - 2] + abs(h[i] - h[i - 2]);
    b = dp[i - 1] + abs(h[i] - h[i - 1]);
    dp[i] = min(a, b);
  }
  
  //cout << dp[0] spa dp[1] spa dp[2] spa dp[3] << endl;
  cout << dp[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 1792
N, X = 2, 7

N, X = 50, 4321098765432109

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


def calculate(n, x):
    p = 1
    level = 0
    dialations = [1]

    for i in range(n):
        p = 2 * p + 3
        level = level + 1
        dialations.append(p)

    # print(dialations)
    # print(level)

    res = calculate2(level, dialations, x - 1)
    print(res)


def calculate2(currentLevel, dialations, x):
    keyPoint0 = 0
    keyPoint1 = keyPoint0 + dialations[currentLevel - 1] + 1

    if currentLevel == 0:
        return 1

    if x == -1:
        return 2 * calculate2(currentLevel - 1, dialations, -1) + 1

    if x == keyPoint0:
        return 0

    if (x > keyPoint0) and (x < keyPoint1):
        return calculate2(currentLevel - 1, dialations, x - 1)

    if x == keyPoint1:
        return calculate2(currentLevel - 1, dialations, -1) + 1

    if (x > keyPoint1):
        return calculate2(currentLevel - 1, dialations, -1) + 1 + calculate2(currentLevel - 1, dialations,
                                                                             x - dialations[currentLevel - 1] - 2)


calculate(N, X)


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

vector< vector<int> > to(100005);
int visit[100005];

void DFS( int v ) {
  for ( auto nv: to[v] ) {
    if (visit[nv] == 1) continue;
    visit[nv] = 1;
    DFS(nv);
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  vector< pair<int,int> >  AI(N), BI(N);
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
//  REP(i,N) BA[i] = make_pair( B[i], A[i] );

//  sort(BA.begin(), BA.end());
//  sort(A.begin(), A.end());
//  sort(B.begin(), B.end());

  REP(i,N) AI[i] = make_pair( A[i], i );
  sort(AI.begin(), AI.end());
  REP(i,N) BI[i] = make_pair( B[i], i );
  sort(BI.begin(), BI.end());

  // N-2回のSwapでAをソートできるか判定
  bool sortok = false;
  REP(i,N)
    to[AI[i].second].push_back( BI[i].second );
  DFS(0);
  REP(i,N)
    if ( visit[i] == 0) sortok = true;
//  REP(i,N) {
//    cout << i << " : v " << visit[i] << " : ";
//    for ( auto x : to[i] ) 
//      cout << x << " ";
//    cout << endl;
//  }
//  cout << sortok << endl;
  
  bool ok = true;
  if (sortok) {
    REP(i,N) {
      if ( AI[i].first > BI[i].first ) ok = false;
    }
  } else {
    REP(i,N) {
      if ( AI[i].first > BI[i].first ) ok = false;
    }
    if (ok) {
      ok = false;
      REP(i,N-1) {
        if ( (AI[i].first <= BI[i].first) && (AI[i+1].first <= BI[i].first) ) ok = true;
      }
    }
  }
  if ( ok ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple


int a, b, n, ans=inf;

int sum(int x){
int r=0;

while(x>0){
    r+=x%10;
    x/=10;
}
return r;
}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n;

//cout << sum (22) << endl;

rep(i, 1, n-1){

ans = min(ans, sum(i)+sum(n-i) );
//cout << ans << endl;

}


cout << ans << endl;

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int ans = 0;
int n;
vector< vector<int> > data;

int check(vector<bool> &use){
    vector< int > boolMap(n, -1);

    int tmp = 0;
    for(int i = 0; i < use.size(); i++){
        if(use[i]){
            tmp ++;
            for(int j = 0; j < data[i].size(); j++){
                if(data[i][j] == -1){
                    continue;
                }
                else if(data[i][j] == 1){
                    if(use[j] != 1) return 0;
                    if( boolMap[j] == 0 ) return 0;
                    boolMap[j] = data[i][j];
                }
                else{
                    if(use[j] != 0) return 0;
                    if( boolMap[j] == 1 ) return 0;
                    boolMap[j] = 0;
                }
            }
        }
    }

    return tmp;

}

void dfs( vector<bool> &use, int depth){
    if(depth == n){
        ans = max( ans, check(use) );
        return;
    }

    for(int i = 0; i < 2; i++){
        use[depth] = i;
        dfs(use, depth + 1);
    }
}

int main(){

    cin >> n;
    data.resize(n);
    for(int i = 0; i < n; i++){
        data[i].resize(n);
        for(int j = 0; j < n; j++){
            data[i][j] = -1;
        }
    }
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            data[i][x-1] = y;
        }
    }

    if(DEBUG){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << data[i][j] << " ";
            }
            cout << endl;
        }

    }

    vector<bool> use(n);
    dfs(use, 0);

    cout << ans << endl;


}

Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 100005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int n, k, d[11];
bool ok(){
    int m = n;
    while(m>0){
        int t = m%10;
        if(d[t]) return false;
        m/=10;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=0; i<k; i++){
        int x; cin>>x; d[x]=1;
    }
    while(ok()==false) n++;
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#import sys

def gcd(a,b):
    if a>b :
        while b!=0:
            a,b = b,a%b
        return a
    else :
        while a!=0:
            a,b = b%a,a
        return b

def pff(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    return pf

A, B = map(int, input().split())
Scount = []
ans = int(0)
count= int(0)
a = int(0)
b = int(0)

a = gcd(A, B)

b = pff(a)

ans = len(b)+1

print(ans)


Measured memory_bytes: 3188
A,B,K = map(int,input().split())
x = 1
y = 100
while x <= K:
  if A%y == 0 and B%y == 0 and x != K:
    x += 1
    y -= 1
  elif A%y == 0 and B%y == 0 and x == K:
    print(y)
    break
  else:
    y -= 1

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> ab(2 * M);
  vector<int> road_num_of_each_city(N);


  for(int i = 0; i < M; i++) {
    cin >> ab.at(2 * i) >> ab.at(2 * i + 1);
  }
  
  for(int i = 0; i < ab.size(); i++) {
      for (int j = 1; j <= N; j++) {
          if(j == ab.at(i)) {
              road_num_of_each_city.at(j - 1) += 1;
          }
      }
  }
  
  for(int i = 0; i < road_num_of_each_city.size(); i++) {
      cout << road_num_of_each_city.at(i) << endl;
  }
    
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(ll i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=1)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    f(499501){
        ll tmp1=(i*(i+1))/2-a;
        ll tmp2=((i+1)*(i+2))/2-b;
        if(tmp1>=0&&tmp2>=0&&tmp1==tmp2){
            cout<<tmp2<<endl;
            debug()<<imie(i)<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  while(true){
    cin>>a>>b;
    c=b-2;
    if(a==0 && b==0) break;
    else if(a==1 && b==1){
      cout<<"#"<<"\n";
    }
    else{
      for(int i=0;i<b;i++){
	cout<<"#";
      }
      cout<<"\n";
      for(int j=0;j<(a-2);j++){
	cout<<"#";
	for(int k=0;k<c;k++){
	  cout<<".";
	}
	cout<<"#"<<"\n";
      }
      for(int i=0;i<b;i++){
	cout<<"#";
      }
      cout<<"\n";
    }
    cout<<"\n";
  }

  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main() {
	int N, M, K, A[31] = {0};
	int i,j,buf,count=0;

	scanf("%d %d",&N,&M);
	for (i = 0; i < 31;i++) {
		A[i] = 0;
	
	}
	for (i = 0;i<N;i++) {
		scanf("%d", &K);
		for (j = 0; j < K;j++) {
			scanf("%d", &buf);
			A[buf]++;
		}

	}

	for (i = 0;i<=M;i++) {
		if (A[i] == N)count++;
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 200005
ll S;
int N,T;
char s[MX];
int main(void){
    scanf("%s",s),N=strlen(s);
    F(N)if(s[i]==65)++T;
        else if(s[i]==66&&s[i+1]==67)S+=T,++i;
        else T=0;
    printf("%lld\n",S);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(d/s>t) printf("No\n");
    else if(d/s==t)
    {
        if(d%s==0) printf("Yes\n");
        else printf("No\n");
    }
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3644