akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>x(n);
    for(int i=0;i<n;i++)cin >> x[i];
    int ans=1000000000;
    for(int i=1;i<=100;i++){
        int min=0;
        for(int r=0;r<n;r++){
            min += (x[r]-i)*(x[r]-i);
        }
        if(min<ans)ans=min;
    }
    cout << ans;
}

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

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

  int sum = 0;
  int cnt = 10000000;
  int ans;

  for (int i = 0; i < n; i++) {
    sum += i;
  }
  sum += n * l;
  for (int i = 0; i < n; i++) {
    if (cnt > abs(i + l)) {
      cnt = abs(i + l);
      ans = sum - i - l;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

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

x = [ai % 2 for ai in a]
for i_inv in range(N):
    i = (N - 1) - i_inv
    j = 2
    xi = x[i]
    # print("#", i, a[i])
    while (i + 1) * j - 1 < N:
        # print("##", (i + 1) * j - 1, x[(i + 1) * j - 1])
        xi ^= x[(i + 1) * j - 1]
        j += 1
    x[i] = xi

print(sum(x))
ans = []
for i, xi in enumerate(x):
    if xi == 1:
        ans.append(i + 1)

if sum(x) > 0:
    print(' '.join(map(str, ans)))

Measured memory_bytes: 19892
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	map<string,int> m;
	string s;
	while(cin>>s)++m[s];
	string often ,longest;
	for(map<string,int>::iterator it=m.begin();it!=m.end();++it){
		if(longest.length() < it->first.length())
			longest = it->first;
		if(m[often] < it->second)
			often = it->first;
	}
	cout<<often<<' '<<longest<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int               long long
// #define ld               long double
#define endl "\n";
#define lb lower_bound
#define ub upper_bound
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];

int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// int t;
// cin >>t;
// while(t--){

string s;
cin >>s;
for(int i=0; i<3;i++){
	cout << s[i];
}
cout << endl;
// }



return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int ans;

    int a = 0, z = s.length()-1;

    while(s[a]!='A'){
        a++;
    }
    while(s[z]!='Z'){
        z--;
    }

    ans = z - a + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		byte[] array = new byte[n];
		for (int i = 0; i < array.length; i++) {
			array[i] = sc.nextByte();
		}
		byte minJ = 0;
		int count = 0;
		for (byte i = 0; i < array.length; i++) {
			minJ = i;
			for (byte j = i; j < array.length; j++) {
				if (array[j] < array[minJ]) {
					minJ = j;
				}
			}
			if (i != minJ) {
				swap(array, minJ, i);
				count++;
			}
		}
		for (int i = 0; i < array.length - 1; i++) {
			System.out.print(array[i] + " ");
		}
		System.out.println(array[array.length - 1]);
		System.out.println(count);
	}

	static void swap(byte[] array, int x, int y) {
		byte tmp = array[x];
		array[x] = array[y];
		array[y] = tmp;
	}
}


Measured memory_bytes: 26476
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] str = new String[N];

		for(int i=0;i<N;i++){
			str[i]=sc.next();
		}
		
		boolean Flg = true;
		
		//重複チェック
		String hikaku ="";
		int cnt = 0;
		for(int i=0;i<N;i++) {
			hikaku = str[i];
			for(int j=0;j<N;j++) {
				if(str[j].equals(hikaku)) {
					cnt++;
				}
			}
		}
		//重複なし
		if(cnt==N) {
			String matubi = "";
			for(int i=0;i<N-1;i++) {
				matubi = String.valueOf(str[i].charAt(str[i].length()-1));
				if(!matubi.equals(String.valueOf(str[i+1].charAt(0)))) {
					Flg= false;
				}
			}
		}else {
			Flg=false;
		}
		
		if(Flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 23764
N = int(input())
A1 = [int(a) for a in input().split()]
A2 = [int(a) for a in input().split()]

if N == 1:
    print(A1[0] + A2[0])
    exit()

cum_A1 = [A1[0]] * N
for i in range(1, N):
    cum_A1[i] = cum_A1[i - 1] + A1[i]
cum_A2 = [A2[0]] * N
for i in range(1, N):
    cum_A2[i] = cum_A2[i - 1] + A2[i]

best_total = 0
for down in range(N):
    total = cum_A1[down]
    total += cum_A2[-1]
    if down >= 1:
        total -= cum_A2[down - 1]

    best_total = max(total, best_total)

print(best_total)


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

int w,d;
int h1[10],h2[10];
bool f[10];
int main(){
    while(cin>>w>>d,w||d){
        fill_n(f,10,false);
        for(int i=0;i<w;i++)cin>>h1[i];
        for(int i=0;i<d;i++)cin>>h2[i];

        int ans=0;

        for(int i=0;i<w;i++){
            for(int j=0;j<d;j++){
                if(!f[j]&&h1[i]==h2[j]){
                    f[j]=true;
                    break;
                }
            }
            ans+=h1[i];
        }

        for(int i=0;i<d;i++)if(!f[i])ans+=h2[i];

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

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

typedef long long ll;

const long double PI = (acos(-1));


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

  int a, sum = 0;
  
  for (int i = 0; i < 3; i++){
    cin >> a;
    sum += a;
  }

  if (sum > 21){
    cout << "bust" << endl;
  }else {
    cout << "win" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

hash = {}
n.times do
  a, b = gets.split.map(&:to_i)
  hash.key?(a) ? hash[a] += b : hash[a] = b
end

hash.sort.each do |result, v|
  k -= v
  if k <= 0
    puts result
    break
  end
end

Measured memory_bytes: 9864
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a;
  cin >> a;
  
  
  if(a[0]==a[1]&&a[1]==a[2]){
    cout << "Yes" << endl;
  }else if(a[1]==a[2]&&a[2]==a[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
import collections
import string

def solve(s):
    s = s.lower()
    counter = collections.Counter(s)
    lows = string.ascii_lowercase
    cnt = [counter[ch] for ch in lows]
    for (ch, n) in zip(lows, cnt):
        print('{0} : {1}'.format(ch, n))

if __name__ == '__main__':
    s = ''
    while True:
        try:
            s += input()
        except:
            break
    solve(s)

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

int main(){
    string A, B;
    cin >> A >> B;

    map<string, int> mp;
    cin >> mp[A];
    cin >> mp[B];

    string U;
    cin >> U;

    if(U == A) mp[A]--;
    else mp[B]--;

    cout << mp[A] << " " << mp[B] << endl;

    return 0;
}

Measured memory_bytes: 256
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split())
fC = B // C - (A - 1) // C
fD = B // D - (A - 1) // D
l = lcm(C, D)
fCD = B // l - (A - 1) // l
print(B - A + 1 - (fC + fD - fCD))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef pair<string, bool> psb;

int n;
char al[25];
string s;
vector<psb> can[26];

int main(){
    REP(i, 25){
        al[i] = 'a'+i;
    }

    while(1){
        cin >> s;
        if(s=="#") break;

        REP(i, 26) can[i].clear();
        can[25].push_back(make_pair(s, false));

        for(int i=24; i>=0; i--){
            REP(j, can[i+1].size()){
                psb p = can[i+1][j];

                vector<int> c;
                REP(k, p.first.size()){
                    if(p.first[k] == al[i]){
                        c.push_back(k);
                    }
                }

                if(!p.second){
                    psb np = p;
                    if(c.size()>0) np.second = true;
                    can[i].push_back(np);
                }

                REP(k, c.size()){
                    psb np = p;
                    np.first[c[k]] = al[i]+1;
                    np.second = false;
                    can[i].push_back(np);
                }
            }
        }

        vector<string> output;
        REP(i, can[0].size()){
            string c = can[0][i].first;
            REP(j, 25){
                REP(k, c.size()){
                    if(al[j]+1 == c[k]){
                        c[k] = al[j];
                        break;
                    }
                }
            }
            if(c==s) output.push_back(can[0][i].first);
        }

        sort(output.begin(), output.end());
        cout << output.size() << endl;
        if(output.size()<=10){
            REP(j, output.size()){
                cout << output[j] << endl;
            }
        } else {
            REP(j, 5){
                cout << output[j] << endl;
            }
            REP(j, 5){
                cout << output[output.size()-5+j] << endl;;
            }
        }
    }
}

Measured memory_bytes: 11568
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000001


int main(){

	int H,W;
	cin>>H>>W;
	
	int x,y,X,Y;
	cin>>y>>x>>Y>>X;
	y--;x--;Y--;X--;
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	
	vector<vector<int>> dis(H,vector<int>(W,Inf));
	dis[y][x] = 0;
	deque<pair<int,int>> Q;
	Q.emplace_back(y,x);
	
	while(Q.size()!=0){
		int u = Q.back().first,v = Q.back().second;
		Q.pop_back();
		for(int i=u-2;i<=u+2;i++){
			for(int j=v-2;j<=v+2;j++){
				if(i<0||i>=H||j<0||j>=W)continue;
				if(S[i][j]=='#')continue;
				if(dis[i][j]<=dis[u][v])continue;
				if(abs(i-u)+abs(j-v)==1){
					dis[i][j] = dis[u][v];
					Q.emplace_back(i,j);
				}
				else{
					if(dis[i][j]>dis[u][v]+1){
						dis[i][j] = dis[u][v] + 1;
						Q.emplace_front(i,j);
					}
				}
			}
		}
	}
	
	if(dis[Y][X]==Inf)cout<<-1<<endl;
	else cout<<dis[Y][X]<<endl;
	
	return 0;
}

Measured memory_bytes: 9540
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	TreeMap<String, TreeSet<Integer>> map = new TreeMap<String, TreeSet<Integer>>();
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;sc.hasNext();) {
			String key = sc.next();
//			if(key.equals("0")) break;
			int value = sc.nextInt();
			if(map.containsKey(key)) {
				TreeSet<Integer> list = map.get(key);
				list.add(value);
				map.put(key, list);
			}
			else {
				TreeSet<Integer> list = new TreeSet<Integer>();
				list.add(value);
				map.put(key, list);
			}
		}
		for(Map.Entry<String, TreeSet<Integer>> entry: map.entrySet()) {
			System.out.println(entry.getKey());
			TreeSet<Integer> list = entry.getValue();
			for(java.util.Iterator<Integer> i=list.iterator();i.hasNext();) {
				int ind = i.next();
				System.out.print(ind);
				if(i.hasNext()) System.out.print(" ");
				else System.out.println();
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main(){
  vector<string> s(3);

  for(int i=0; i<3; i++) cin >> s.at(i);
  for(int i=0; i<3; i++) cout << (char)(s.at(i).at(0)-32);
  cout << endl;
  
 

  return 0;
}


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

ll N, A, B;
ll h[100000];

//n回で倒しきれるか
bool jud(ll n){
  ll cnt = 0;
  for(int i=0;i<N;i++){
    ll tmp = h[i];
    tmp -= n * B;
    if(tmp > 0){
      cnt += (tmp + (A-B) - 1) / (A-B);
    }
  }

  if(cnt > n) return false;
  else return true;
}

//==========================================================
int main(){
  cin >> N >> A >> B;
  for(int i=0;i<N;i++) cin >> h[i];

  ll l = 0LL;
  ll r = 2000000000LL;
  while(r - l > 1LL){
    ll mid = (l + r) / 2LL;
    if(jud(mid)) r = mid;
    else l = mid;
  }

  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= print . ( `div` 2 ) . succ . uncurry (+) . mp


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

int trace(int A[],int n){
	int sw=0;
	int minj=0;
	for(int i=0;i<n-1;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(A[minj]>A[j]){
					minj=j;
			}
			
		}
			swap(A[i],A[minj]);
				if(minj!=i) sw++;
	}
	return sw;
}

int main(){
	int A[100],sw,N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	sw = trace(A,N);
	
	for(int i=0;i<N;i++){
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	return 0;
	
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
const ll INF = 999999999999999;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, g, h, x, y, z, p, q, m, n, t, r, k, w, l, ans, i, j;
string S, T;
vl A, B;
void solve() {
    if(S.length() <= k)
        cout << S << endl;
    else
        cout << S.substr(0, k) << "..." << endl;
}
int main() {
    // cout<<fixed<<setprecision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k >> S;
    solve();
}

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

using namespace std;

string attacks(int H, int N, vector<int>& A) {
	int sum = accumulate(A.begin(), A.end(), 0);
	return (sum >= H) ? "Yes" : "No";
}

int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << attacks(H, N, A);
	return 0;
}

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll n;
ll memo[1001000][2][2];
ll rec(ll now, ll z, ll o){
    if(now == n && z && o) return 1;
    if(now == n) return 0;
    if(memo[now][z][o] != -1) return memo[now][z][o];

    ll res = 0;
    res += rec(now + 1, 1, o);
    res %= MOD;
    res += rec(now + 1, z, 1);
    res %= MOD;
    res += rec(now + 1, z, o) * 8;
    res %= MOD;
    return memo[now][z][o] = res;
}
int main(void){
    cin >> n;
    rep(i, 1001000) rep(j, 2) rep(k, 2) memo[i][j][k] = -1;
    cout << rec(0, 0, 0) << endl;
}


Measured memory_bytes: 112972
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){ 
	int ans = 0;
	string N;
	cin >> N;

	for (int i = 0; i < N.size(); ++i){
		if (N[i] == '2')
			++ans;
	}

	cout << ans << endl;

	return 0;
}

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

int main () {
    int n;
    cin >> n;
    if (n <= 111){
        cout << 111;
    } else if (n <= 222){
        cout <<222;
    } else if (n <= 333){
        cout <<333;
    } else if (n <=444){
        cout <<444;
    } else if (n <=555){
        cout <<555;
    } else if (n<=666) {
        cout <<666;
    } else if (n <= 777){
        cout << 777;
    } else if (n<= 888){
        cout <<888;
    } else if (n<= 999){
        cout <<999;
    }
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

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

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d - b == 1)
		cout << "0";
	else
		cout << "1";
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,l,s=0;
  cin>>n;
  vector<int> v(n);
  for(i=0;i<n;i++)
   cin>>v[i];
   sort(v.rbegin(),v.rend());s+=v[0];j=n-2;
   for(i=1;i<=n-1;i++)
   {
     if(j>=2) {
       s+=2*v[i];j=j-2;
     }
     else if(j>=1)
     {
       s+=v[i];break;
     }
     else break;
   }
   cout<<s;
}

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

int main(){
  string S;
  cin >> S;
  
  int bl = 0;
  
  bl += (S.at(0)=='7');
  bl += (S.at(1)=='7');
  bl += (S.at(2)=='7');
  
  if(bl!=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

  

Measured memory_bytes: 3628
object Main extends App {
    val stdin = new java.util.Scanner(new java.io.BufferedInputStream(System.in))
    val stdout = new java.io.PrintWriter(new java.io.BufferedOutputStream(System.out))

    while (stdin.hasNext()) {
        val lhs = stdin.next()
        val rhs = stdin.next()
        val foo = (p:Int) => lhs(p) == rhs(p) : Boolean
        val bar = (0 to lhs.length() - 1).filterNot(foo).size : java.lang.Integer
        stdout.printf("%d\n", bar)
    }

    stdin.close()
    stdout.close()
}

Measured memory_bytes: 58852
n=int(input())
hatsugen=[]
for i in range(n):
	a=int(input())
	tmp=[]
	for j in range(a):
		tmp.append(list(map(int,input().split())))
	hatsugen.append(tmp)

honest=0
binstr="0" + str(n+2) + "b"
for i in range(2**n):
	hl = list(map(int,format(i,binstr)))
	hl = hl[2:]
	
	flag=True
	
	for j,hatsu in enumerate(hatsugen):
		for hat in hatsu:
			if hat[1] != hl[hat[0]-1]:
				if hl[j] == 1:
					flag = False

	

	if flag:
		honest = max(honest,hl.count(1))

print(honest)




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

int main() {
  string s;
  cin >>s;
  map<char,int>mp;
  for(char x:s){
    if(mp.count(x)){
      mp.at(x)++;
    }else{
      mp[x]=1;
    }
  }
  int num=0;
  auto begin=mp.begin(),end=mp.end();
  for(auto iter=begin;iter!=end;iter++){
    num=iter->second;
    //cout<<num<<endl;
    if(num%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

m = 30000

main = do
  n :: Z <- readLn
  ps <- readLnList
  let pinv = array (1,n) $ zip ps [1..]
  let as = [m*i + pinv!i | i<-[1..n]]
  let bs = [m*(n+1-i) | i<-[1..n]]
  printList as
  printList bs


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = String.valueOf(N);
        int sum = 0;
        for(int i = 0; i < s.length(); i++){
            sum += Integer.parseInt(s.substring(i, i+1));
        }

        if(N % sum == 0) System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }

}


Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	

	ll N, H;
	cin >> N >> H;
	vector<pair<ll, ll>> A(N); //  繰り返し   一発。
	for (int i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}


	sort(A.begin(), A.end(), greater<pair<ll, ll>>());



	ll ans = 0;



	if (N >= 2) {

		ll check = 0; // final のインデックス

		ll max_sec = A[0].first;
		ll min_fin = A[0].second;

		for (int i = 0; i < N; i++) {
			if (A[i].first != max_sec) {
				min_fin = A[i - 1].second;
				A.erase(A.begin() + (i - 1));
				break;
			}
			else if (i == N - 1) {
				min_fin = A[i].second;
				A.erase(A.begin() + i);
			}
		}

		vll final(N - 1);
		for (int i = 0; i < N - 1; i++) {
			final[i] = A[i].second;
		}

		sort(final.begin(), final.end(), greater<ll>());


		while(true) {

			ans++;

			// 終わらせれるとき
			if (H <= min_fin) {
				cout << ans;
				return 0;
			}

			// つなぐとき
			else if(check < N-1 && max_sec < final[check]){
				H -= final[check];
				check++;
				if (H <= 0) {
					cout << ans;
					return 0;
				}
			}

			// その後が定まるとき
			else {
				H -= max(max_sec, min_fin);
				if (H % max_sec == 0) {
					cout << ans + H / max_sec;
				}
				else {
					cout << ans + H / max_sec +1;
				}
				return 0;
			}

		}
	}
	else {

		while(true){
			
			ans++;

			if (H <= max(A[0].first, A[0].second)) {
				cout << ans;
				return 0;
			}
			else {
				H -= A[0].first;
			}


		}




	}


}




Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        string S=cin.next();
        string ans="";
        int zenhan=int.Parse(S[0].ToString())*10+int.Parse(S[1].ToString());
        int kouhan=int.Parse(S[2].ToString())*10+int.Parse(S[3].ToString());
        if(zenhan>12||zenhan==0)
        {
          if(kouhan==0||kouhan>12)ans="NA";
          else ans="YYMM";
        }
        else
        {
          if(kouhan==0||kouhan>12)ans="MMYY";
          else ans="AMBIGUOUS";
        }
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
        return b;        
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  if (b < a) swap(a, b);
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  } else {
    long long mov = a - 1;
    long long x = mov + 1 + (((b - mov - 1) - 1) / 2);
    mov = n - b;
    x = min(x, mov + 1 + ((n - (a + mov + 1)) / 2));
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N;
  	cin >> N;
    for(int i=1; i<=3; i++){
    	N %= 10;
    }
  	if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9){
    	cout << "hon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
    	cout << "pon" << endl;
    }else if(N == 3){
    	cout << "bon" << endl;
    }



}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	while(x%111) x++;
	cout<<x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import math
def comb(a,b):
    c = int(math.factorial(a)//(math.factorial(a-b)*math.factorial(b)))
    return c
N,P = map(int,input().split())
A = list(map(int,input().split()))
A = [i%2 for i in A]
odd = A.count(1)
even = A.count(0)
if P == 0:
    sumo = 0
    for i in range(odd+1):
        if i%2 == 0:
            sumo += comb(odd,i)
    ans = sumo*(2**even)
else:
    sumo = 0
    for i in range(odd+1):
        if i%2 == 1:
            sumo += comb(odd,i)
    ans = sumo*(2**even)
print(ans)
    

Measured memory_bytes: 3064
//2019/04/07
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		int X = sc.nextInt();

		int[] A = new int[M];

		int r = 0;

		int l = 0;

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

			A[i] = sc.nextInt();

			if(A[i]<X) l++;

			else r++;
		}

		int ans = Math.min(r, l);

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    char pre = 0;
    while(N--) {
        char c;
        cin >> c;
        if(pre != c) ans++;
        pre = c;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  int k=a+b;
  int r=b;
  string v;
  cin>>v;
  for(int i=0;i<n;i++){
    if(v[i]=='a'){
      if(k>0){
        cout<<"Yes"<<endl;
        k--;
      }
      else cout<<"No"<<endl;
    }
    if(v[i]=='b'){
      if(k>0&&b>0){
        cout<<"Yes"<<endl;
        k--;b--;
      }
      else cout<<"No"<<endl;
    }
    if(v[i]=='c')cout<<"No"<<endl;
  }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int N=610,mod=1e9+7;
int a[N],cnt2,b[N],c[N];
int n,ans;
int f[N][N/2][N/2],cnt,tot,cnt1;
void add(int &a,int b)
{
	a+=b; if(a>=mod)a-=mod;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<2*n;i+=2)
		if(a[i]==-1 && a[i+1]==-1)
			cnt++;
		else
			if(a[i]!=-1 && a[i+1]!=-1)
			{
				b[a[i]]=b[a[i+1]]=1;
			}
			else
			{
				if(a[i]!=-1)b[a[i]]=2;
				if(a[i+1]!=-1)b[a[i+1]]=2;
			}
	for(int i=1;i<=2*n;i++)
		if(b[i]==2)
			c[++tot]=1,cnt1++; //x,-1
		else
			if(!b[i])
				c[++tot]=0; //未出现
	f[tot][0][0]=1;
	for(int i=tot;i;i--)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
				if(f[i][j][k])
				{
					int x=f[i][j][k];
					if(c[i])
					{
						add(f[i-1][j+1][k],x);
						if(k)
							add(f[i-1][j][k-1],x);
					}
					else
					{
						add(f[i-1][j][k+1],x);
						if(j)
							add(f[i-1][j-1][k],1ll*x*j%mod);
						if(k)
							add(f[i-1][j][k-1],x);
					}
				}
	ans=f[0][0][0];
	for(int i=2;i<=cnt;i++)
		ans=1ll*ans*i%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 219392
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  while(cin>>s,s[0]!='#') {
    int j = s.length() - 1;
    int n = 1;
    int dir = 0;
    while(j > 0) {
      if(s[j] == 'h') {
        if(n == 1) dir = 0;
        else {
          dir *= 2;
          dir -= 90;
        }
        j -= 5;
      } else {
        if(n == 1) dir = 90;
        else {
          dir *= 2;
          dir += 90;
        }
        j -= 4;
      }
      n *= 2;
    }
    n /= 2;
    while(dir % 2 == 0 && dir > 0 && n > 1) {
      dir /= 2;
      n /= 2;
    }
    cout << dir;
    if(n > 1) cout << "/" << n;
    cout << endl;
  }
  return 0;
}

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

int main() {
  int A, B,C,D;
  cin >> A >> B >> C >> D;
  
	if (A+B  >C+D) {
    cout << "Left" << endl;
  }
  	else if (A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  	else{
      cout<<"Right"<<endl;
}}

Measured memory_bytes: 3568
a = input()
N = int(a)
H = list(map(int,input().split()))

flag = 1
H[0] = H[0] - 1

for i in range(1,N):
    if H[i-1] < H[i]:
        H[i] = H[i] - 1
    elif H[i-1] > H[i]:
        flag = 0
        break
if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 20608
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>

using namespace std;
#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


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

    if(a == b && b == c && a % 2 == 0){
        cout << -1 << endl;
        return 0;
    }

    ll count = 0;

    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        ll at=a,bt=b,ct=c;
        a = (bt/2)+(ct/2);
        b = (at/2)+(ct/2);
        c = (at/2)+(bt/2);
        count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3156
N=int(input())
A=[int(x) for x in input().split()]
ne=1
c=0

if 1 not in A:
    print(-1)
    exit()


for i in range(N-1):
    if A[i]==ne:
        c+=1
        ne+=1
if A[-1]==ne:
    c+=1
print(N-c)


Measured memory_bytes: 26140
#include <iostream>
#include <vector>
#include <stack>
#include <string>
class IMos {
	std::vector<std::vector<int>> vec;
	bool is_ready{ false };
public:
	IMos(int height, int width) :vec( height, std::vector<int>(width, 0) ) {}
	void fill(int left, int right, int top, int bottom) {
		if (is_ready) throw "mathod IMos::fill called after IMos::ready called";
		++vec[bottom][left];
		if (top + 1 < vec.size()) --vec[top + 1][left];
		if (right + 1 < vec[0].size()) --vec[bottom][right + 1];
		if (top + 1 < vec.size() && right + 1 < vec[0].size()) ++vec[top + 1][right + 1];
	}
	void ready() {
		for (auto i = 0; i < vec.size(); ++i) {
			for (auto j = 1; j < vec[0].size(); ++j) {
				vec[i][j] += vec[i][j - 1];
			}
		}
		for (auto j = 0; j < vec[0].size(); ++j) {
			for (auto i = 1; i < vec.size(); ++i) {
				vec[i][j] += vec[i - 1][j];
			}
		}
		is_ready = true;
	}
	const std::vector<int> &operator[](int x) const {
		if (!is_ready) throw "method IMos::operator[] called before IMos::ready called";
		return vec[x];
	}
	int height() const { return vec.size(); }
	int width() const { return vec[0].size(); }
};
enum class Color {
	Black, White
};
void fill(int x, int y, Color color, int k, IMos &black, IMos &white) {
	auto mod_x = x % k;
	auto mod_y = y % k;
	auto is_same_color = (x / k + y / k) % 2 == 0;
	if ((color == Color::White && is_same_color) || (color == Color::Black && !is_same_color)) {
		white.fill(0, mod_x, mod_y, 0);
		if (mod_x + 1< k && mod_y + 1< k) white.fill(mod_x + 1, k - 1, k - 1, mod_y + 1);
		if (mod_x + 1< k) black.fill(mod_x + 1, k - 1, mod_y, 0);
		if (mod_y + 1< k) black.fill(0, mod_x, k - 1, mod_y + 1);
	}
	else {
		black.fill(0, mod_x, mod_y, 0);
		if (mod_x + 1< k && mod_y + 1< k) black.fill(mod_x + 1, k - 1, k - 1, mod_y + 1);
		if (mod_x + 1< k) white.fill(mod_x + 1, k - 1, mod_y, 0);
		if (mod_y + 1< k) white.fill(0, mod_x, k - 1, mod_y + 1);
	}
}

int main() {
	int n, k;
	std::cin >> n >> k;
	IMos white(k, k), black(k, k);
	{
		int x, y;
		std::string c;
		for (auto i = 0; i < n; ++i) {
			std::cin >> x >> y >> c;
			if (c == "W") {
				fill(x, y, Color::White, k, black, white);
			}
			else {
				fill(x, y, Color::Black, k, black, white);
			}
		}
	}
	black.ready(); white.ready();
	int max{ 0 };
	for (auto i = 0; i < k; ++i) {
		for (auto j = 0; j < k; ++j) {
			if (black[i][j] > max) max = black[i][j];
			if (white[i][j] > max) max = white[i][j];
		}
	}
	std::cout << max << std::endl;
}

Measured memory_bytes: 8192
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

public class Main {
	public static void main(String[] args) {
		Graph g = new Graph();
		g.loadAdjList();
		g.call_DFS(0);
		boolean[] if_visited = g.getVisited();
		for (int i = 0; i < if_visited.length; i++) {
			if (if_visited[i] == false) {
				g.call_DFS(i);
			}
		}
		g.show_result();
	}
}

class Graph {
	
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private boolean[] if_visited;
	private int[] discover_time;
	private int[] complete_time;
	private int[] id;
	private static int timestamp = 1;
	
	public boolean[] getVisited() {
		return if_visited;
	}
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		if_visited = new boolean[totalVertex];
		discover_time = new int[totalVertex];
		complete_time = new int[totalVertex];
		id = new int[totalVertex];
		
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			if_visited[idx1] = false;
			id[idx1] = i;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void DFS(int id) {
		if(!if_visited[id]) {
			if_visited[id] = true;
			discover_time[id] = timestamp;
			timestamp += 1;
			Iterator<Integer> i = adjList.get(id).listIterator();
			while(i.hasNext()) {
				int n = i.next();
				DFS(n);
			}
			complete_time[id] = timestamp++;
		}else {
			
		}
		
	}
	
	public void call_DFS(int id) {
		DFS(id);
	}
	
	
	public void show_result() {
		for (int i = 0; i < totalVertex; i++) {
			System.out.print(id[i] + 1 + " ");
			System.out.print(discover_time[id[i]] + " ");
			System.out.println(complete_time[id[i]]);
		}
	}
	
}


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

int main()
{
    int n;
    scanf("%d", &n);

    vector<int> v;
    for (int i = 0; i < n; ++i)
    {
        static int x;
        scanf("%d", &x);
        if (v.empty() || -v.back() >= x)
            v.push_back(-x);
        else
        {
            int i = upper_bound(v.begin(), v.end(), -x) - v.begin();
            v[i] = -x;
        }
    }

    printf("%d\n", (int)v.size());
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int k;
  cin >> k;
  int ans = 0;
  LOOP1(a,k)LOOP1(b,k)LOOP1(c,k){
    ans += gcd(a,gcd(b,c));
  }
  cout << ans <<  endl;
}


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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <complex>
//#include <fstream>

using namespace std;

// deq notes ½Êô½É¨¯éxNgZ http://www.deqnotes.net/acmicpc/2d_geometry/

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// àÏ (dot product) : a&#8901;b = |a||b|cosÆ
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

// _cªüªa,bãÉ é©È¢©(2)
int is_point_on_line(P a, P b, P c) {
  // |a-c| + |c-b| <= |a-b| Èçüªã
  return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

// _a,bð[_Æ·éüªÆ_cÆÌ£
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

struct CIRCLE{
	P p;
	double r;
};

int main()
{
//	cut here before submit 
//	freopen("testcase.hide-and-seek", "r", stdin);
	int n, m;
	int i,j;

	while (cin >> n && n ) {
		vector <CIRCLE> c(n);
		for (i = 0; i < n; ++i ){
			cin >> c[i].p.real() >> c[i].p.imag() >> c[i].r;
		} // end for
		cin >> m;
		vector <P>  taro(m), oni(m);
		for (j = 0; j < m; ++j ){
			cin >> taro[j].real() >> taro[j].imag() >> oni[j].real() >> oni[j].imag();
		} // end for
		for (j = 0; j < m; ++j ){
			vector <bool> in_taro (n, false ), in_oni (n, false );
			for (i = 0; i < n; ++i ){
				double dis_t = abs (taro[j] - c[i].p );
				double dis_o = abs (oni[j] - c[i].p );
				if (dis_t < c[i].r ){ // in circle[i]
					in_taro[i] = true;
				} // end if
				if (dis_o < c[i].r ){
					in_oni[i] = true;
				} // end if
			} // end for
			bool match = true;
			for (i = 0; i < n; ++i ){
				if (in_taro[i] == in_oni[i] ){
					continue;
				}else{
					match = false;
					break;
				} // end if
			} // end for
			if (!match ){
				cout << "Safe" << endl;
				continue;
			} // end if

			bool found = true;
			for (i = 0; i < n; ++i ){
				double dis = distance_ls_p (taro[j], oni[j], c[i].p );
				if (!in_taro[i] && (is_point_on_line (taro[j], oni[j], c[i].p ) || dis <= c[i].r ) ) { 
					found = false;
					break;
				} // end if
			} // end for
			if (found ){
				cout << "Danger" << endl;
			}else{
				cout << "Safe" << endl;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0