akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int H, W;
bool visited[1000][1000];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<string> m;

int main(void)
{
    int num = 0;
    cin >> H >> W;
    REP(i, H)
    {
        string st;
        cin >> st;
        m.push_back(st);
    }

    int maxdist = 0;
    REP(starth, H)
    {
        REP(startw, W)
        {
            if (m[starth][startw] == '#')
                continue;

            memset(visited, false, sizeof(visited));
            queue<int> queueX;
            queue<int> queueY;
            queue<int> dist;

            queueX.push(startw);
            queueY.push(starth);
            dist.push(0);
            visited[starth][startw] = true;

            while (!queueX.empty())
            {
                int x = queueX.front();
                int y = queueY.front();
                int distance = dist.front();
                if (distance > maxdist)
                    maxdist = distance;

                queueX.pop();
                queueY.pop();
                dist.pop();

                REP(i, 4)
                {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (nx < 0 || ny < 0 || nx >= W || ny >= H)
                        continue;
                    if (visited[ny][nx])
                        continue;
                    if (m[ny][nx] == '#')
                        continue;
                    visited[ny][nx] = true;
                    queueX.push(nx);
                    queueY.push(ny);
                    dist.push(distance + 1);
                }
            }
        }
    }
    cout << maxdist << endl;
}

Measured memory_bytes: 1280
n, m = gets.split.map(&:to_i)

a = n.times.map {gets.chomp}
b = m.times.map {gets.chomp}

0.upto(n - m) do |ai|
    0.upto(n - m) do |aj|
        catch do |tag|
            m.times do |bi|
                m.times do |bj|
                    throw(tag, false) if a[ai + bi][aj + bj] != b[bi][bj]
                end
            end
            true
        end or next
        puts "Yes"
        exit
    end
end

puts "No"

Measured memory_bytes: 1788
using System;

namespace N___Slimes
{
    class Program
    {
        static long[,] costs;
        static long[] sumSize;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var slimes = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            costs = new long[N, N];
            for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) costs[i, j] = -1;
            for (int i = 0; i < N; i++) costs[i, i] = 0;

            sumSize = new long[N + 1];
            sumSize[0] = 0;
            for (int i = 1; i < N + 1; i++) sumSize[i] = sumSize[i - 1] + slimes[i - 1];


            Console.WriteLine(calcCost(0, N - 1));
        }
        static long calcCost(int start, int end)
        {
            if (costs[start, end] != -1) return costs[start, end];

            var result = long.MaxValue;
            for (int i = start; i + 1 <= end; i++)
            {
                result = Math.Min(result, calcCost(start, i) + calcCost(i + 1, end) + sumSize[end + 1] - sumSize[start]);
            }
            return costs[start, end] = result;
        }
    }
}


Measured memory_bytes: 14524
#include <stdio.h>
#include <stdlib.h>
char number[1001];
int num,y,total;
int cnt=0;
long x;
main(void)
{
	
	while(1){
		
	
		scanf("%s",number);
		
		num = atoi(number);
		
		if(num==0){break;}
		
		for(y=0;;y++){
			
			x=number[y]-'0';
			
			if(x<0){
			
				printf("%d\n",total);	
				total=0;
				
				break;
				}
			
			total+=x;
			
		}
	}
	
	return 0;
}

Measured memory_bytes: 544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j, n, q, com, b, e;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				int min = 1000000000, max = -1000000000;
				com = sc.nextInt();
				b = sc.nextInt();
				e = sc.nextInt();
				for(j = b; j < e; j++) {
					if(com == 0) {
						if(min >= a[j]) {
							min = a[j];
						}
					}
					if(com == 1) {
						if(max <= a[j]) {
							max = a[j];
						}
					}
				}
				if(com == 0) {
					System.out.println(min);
				}
				if(com == 1) {
					System.out.println(max);
				}
			}
		}
	}
}


Measured memory_bytes: 35244
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl(), reverse=True)

AB = [-1] * K
for a in A[::-1]:
    if AB[0] >= B[-1] + a:
        break
    tmp = [a + b for b in B[bisect(B, AB[0]-a):]][-K:]
    AB = list(merge(tmp, AB))[-K:]

ans = [-1] * K

for c in C:
    if ans[0] >= AB[-1] + c:
        break
    tmp = [ab + c for ab in AB[bisect(AB, ans[0]-c):]][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")


Measured memory_bytes: 3936
#pragma comment (linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

//トポロジカルソート(1 orig)
vector<int> kahn(const Graph& g)
{
	const int V = g.size();
	vector<int> indeg(V, 0);	//indeg[i] : 頂点iに入ってくる辺の数
	stack<int> S;				//indeg[i] == 0 なるiの集合

	//隣接リストは辺の集合g[i]でノード一つを表す
	//各ノードについて入ってくる辺の数を計算
	for (Edges node : g) {
		for (Edge e : node) {
			indeg[e.dst]++;
		}
	}
	// 1 orig なのでVはノード数+1であることに注意
	for (int i = 1; i < V; i++) {
		if (indeg[i] == 0) S.push(i);
	}

	vector<int> ans;

	while (S.size() > 0) {
		int n = S.top();
		S.pop();
		
		ans.push_back(n);

		//入る辺のないノードを削除し、そのノードから出ているエッジのdstの参照カウンタを減らす
		for (Edge e : g[n]) {
			indeg[e.dst]--;
			if (indeg[e.dst] == 0) S.push(e.dst);
		}
	}
	return ans;
	
}

signed main() {

	int N, M;
	cin >> N >> M;
	Graph g(N + 1);
	Graph grev(N + 1);
	for (int i = 0; i < N - 1 + M; i++) {
		int a, b;
		cin >> a >> b;
		add_arc(g, a, b);
		add_arc(grev, b, a);
	}

	vector<int> v = kahn(g);
	int ans[100001];
	int rev[100001];

	rep(i, N) {
		rev[v[i]] = i;
	}

	ans[v[0]] = 0;
	for (int n : v) {
		//親候補のうち最大のノードの子になる
		int maxi = -1;
		int par;
		//grev:有向グラフの向きを逆にしたもの、自分が指しているすべてのノードが親候補
		for (Edge e : grev[n]) {
			if (maxi < rev[e.dst]) {
				maxi = rev[e.dst];
				par = e.dst;
			}
		}
		if (maxi == -1) continue;
		ans[n] = par;

	}

	REP(i, 1, N + 1) {
		cout << ans[i] << "\n";
	}



	return 0;
}

Measured memory_bytes: 19124
def max(a, b)
  return a>b ? a : b
end
s = gets.chomp()
n = s.length
ans = 0
i = 0; c = 0
while i<n do
  if s[i]=='J' then
    c += 1
  else
    if s[i]=='O' && c>0 then
      j = 1
      while i+j<n && s[i+j]=='O' do
        j += 1
      end
      if i+j<n && j<=c && s[i+j]=='I' then
        if s[i+j]=='I' then
          k = 1
          while i+j+k<n && s[i+j+k]=='I' do
            k += 1
          end
          if j<=k then
            ans = max(ans, j)
          end
          i = i+j+k-1
        end
      else
        i = i+j-1
      end
    end
    c = 0
  end
  i += 1
end
puts ans

Measured memory_bytes: 8228
#include<stdio.h>

int main(void){
    int i, K;
    scanf("%d", &K);
    char S[100];
    scanf("%s", S);
    for(i = 0; S[i]!='\0';i++);
    if(i > K) {
        for(int j = 0; j < K;j++){
            printf("%c", S[j]);
    }
        printf("...\n");
    }
    else printf("%s\n", S);
    return 0;

}

Measured memory_bytes: 1648
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<int> V;
typedef vector<V> VV;
namespace el {
	//s[ed]=bg;
	map<int, int> s;
	void init(int N) {
		for (int i : range(N)) {
			s[i] = i;
		}
	}
	int get(int a) {
		return s.lower_bound(a)->first;
	}
	//[s,t]
	void update(int a, int b) {
		auto it = s.lower_bound(a);
		int bg = it->second;
		vector<int> erase_list;
		erase_list.push_back(it->first);
		++it;
		while (it != s.end()&&it->second<=b) {
			erase_list.push_back(it->first);
			++it;
		}
		int sz = erase_list.size();
		for (int i : range(sz - 1)) {
			s.erase(erase_list[i]);
		}
		s[erase_list.back()] = bg;
	}
}

constexpr int INF = 1123456;
int main() {
	int N,M,Q;
	cin >> N >> M >> Q;
	VV query;
	el::init(N);
	vector<string> ret(Q);
	for (int i : range(M)) {
		int d, a, b;
		cin >> d >> a >> b;
		a--; b--;
		query.push_back({ d,INF,a,b });
	}
	for (int i : range(Q)) {
		int e, s, t;
		cin >> e >> s >> t;
		s--; t--;
		query.push_back({ e,i,s,t });
	}
	sort(ALL(query));
	for (auto q : query) {
		int type = q[1];
		if (type == INF) {
			int a = q[2];
			int b = q[3];
			el::update(a, b);
		}
		else {
			int a = q[2];
			int b = q[3];
			if (a < b) {
				if (el::get(a) >= b) {
					ret[type] = "Yes";
				}
				else {
					ret[type] = "No";
				}
			}
			else {
				ret[type] = "Yes";
			}
		}

	}

	for (int i : range(Q)) {
		cout << ret[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 19640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	K := next()
	K_int, _ := strconv.Atoi(K)
	S := next()

	S_rune := []rune(S)
	if len(S_rune) <= K_int {
		fmt.Println(string(S_rune))
	} else {
		fmt.Println(string(S_rune[:K_int]) + "...")
	}
}

Measured memory_bytes: 1764
program cube
 implicit none
 character(100000) :: s
 integer n, i, red, blue
 read *, s
 red = 0
 blue = 0
 n = len_trim(s)
 do i = 1,n
   if (s(i:i) == "0") then
     red = red + 1
  else
    blue = blue + 1
  end if
 end do
 print '(i0)', n-abs(red-blue)
 stop
end program cube

Measured memory_bytes: 700
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << (n*a < b ? n*a : b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;



int main(){
	int n;

	cin >> n;
	while(n--){
		int a;
		bool f = true;
		vector<int> b, c; 
		for(int i = 0; i < 10; i++){
			cin >> a;
			if(f || b[b.size()-1] < a){
				b.push_back(a);
				f = false;
			}else{
				c.push_back(a);
			}
		}
		bool check = true;
		for(int i = 1; i < b.size() && check; i++){
			if(b[i] < b[i-1]){
				check = false;
			}
		}
		for(int i = 1; i < c.size() && check; i++){
			if(c[i] < c[i-1]){
				check = false;
			}
		}
		
		if(check){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1204
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n = 0;

  cin >> n;

  map<pair<int, int>, int> am;

  for(int i = 0; i < n; i++) {
    double x;
    cin >> x;
    ll cur = llround(x * 1e9);
    int f = 0, t = 0;
    while(cur % 2 == 0) {
      cur /= 2; t++;
    }
    while(cur % 5 == 0) {
      cur /= 5; f++;
    }
    am[mp(f, t)]++;
  }

  ll ans = 0;

  for(auto& i : am)
    for(auto& j : am) {
      if(i.fi.fi + j.fi.fi >= 18 && i.fi.se + j.fi.se >= 18) {
        if(i < j) ans += 1ll * i.se * j.se;
        else if(i == j) ans += 1ll * i.se * (j.se - 1) / 2;
      }
    }

  cout << ans;

  return 0;
}
/*

*/


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

int main(){
    int n; cin >> n;
    int ans=0;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    for(int i=1; i<n-1; i++){
        ans+=min(b[i-1],b[i]);
    }
    cout << ans+b[0]+b[n-2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

vector<P> query;

int main() {
	int N, M; cin >> N >> M;
	query.assign(M, P(0, 0));
	for (int i = 0; i < M; i++) {
		cin >> query[i].second >> query[i].first;
	}
	sort(query.begin(), query.end());
	int ans = 0; int t = 0;
	for (int i = 0; i < query.size(); i++) {
		if (query[i].second >= t) {
			ans++;
			t = query[i].first;
		}
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

ll n, x, m, a[200100], l, r, sum, ans;
signed main() {
    cin >> n >> x >> m; set<ll> st; a[1] = x;
    for(r = 1; st.find(a[r]) == st.end(); r++)
        a[r + 1] = a[r] * a[r] % m, st.insert(a[r]);
    for(l = 1; a[l] != a[r]; l++);
    if(n <= r) {
        for(int i = 1; i <= n; i++)
            ans += a[i];
        cout << ans << endl;
        return 0;
    }
    for(int i = 1; i < l; i++) ans += a[i];
    for(int i = l; i < r; i++) sum += a[i];
    ll len = r - l; n -= l - 1, ans += n / len * sum, n %= len;
    for(int i = 0; i < n; i++) ans += a[l + i];
    cout << ans << endl;
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 6492
import java.io.*
import java.util.*

fun solve(A: Long, B: Long, C: Long, D: Long){
    val ans = Math.min(A, B) + Math.min(C, D)
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    val C = sc.next().toLong()
    val D = sc.next().toLong()
    solve(A, B, C, D)
}



Measured memory_bytes: 29596
package main                                              

import "fmt"                                              
import "math"                                             
                                                          
func min(nums ...int) int {                                                                                          
        if len(nums) == 0 {
                panic("")
        }               
        res := nums[0]
                                                          
        for i := 0; i < len(nums); i++ {
                res = int(math.Min(float64(res), float64(nums[i])))
        }                                                 
        return res                                        
}  
func main() {
        var D, G int
        var points [][]int

        minC := 100000000

        fmt.Scanf("%d %d", &D, &G)

        for i := 0; i < D; i++ {
                var num, extra int
                fmt.Scanf("%d %d", &num, &extra)
                points = append(points, []int{num, extra})
        }

        n := len(points)

        for bit := 0; bit < (1 << n); bit++ {
                sum := 0
                count := 0
                for i := 0; i < n; i++ {
                        if bit&(1<<i) >= 1 {
                                sum += (i+1)*100*points[i][0] + points[i][1]
                                count += points[i][0]
                        }
                }

                if sum >= G {
                        minC = min(minC, count)
                } else {
                        for i := n - 1; i >= 0; i-- {
                                if bit&(1<<i) >= 1 {
                                        continue
                                }
                                for k := 0; k < points[i][0]; k++ {
                                        if sum >= G {
                                                minC = min(minC, count)
                                        }
                                        sum += (i + 1) * 100
                                        count++
                                }
                        }
                }
        }

        fmt.Printf("%v", minC)
}

Measured memory_bytes: 1840
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sort(A.begin(), A.end());
	ll ans = 0;
	int mns = 0;
	for (int i = 0; i < N; i++) {
		if ((i == 0 || A[i] < 0) && i < N - 1) {
			mns++;
			ans -= A[i];
		}
		else
		ans += A[i];
	}
	cout << ans << endl;

	ll temp1 = A[N - 1];
	for (int i = 1; i < mns; i++) {
		cout << temp1 << " " << A[i] << endl;
		temp1 -= A[i];
	}

	ll temp2 = A[0];
	for (int i = mns; i < N - 1; i++) {
		cout << temp2 << " " << A[i] << endl;
		temp2 -= A[i];
	}

	cout << temp1 << " " << temp2 << endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>

using namespace std;

int N;

long long int calc(vector<int> &joi, vector<vector<int>>& O, vector<vector<long long int>>& P){
  int tmp = 0;
  for(int i = 0; i < 10; i++) tmp += joi[i];
  if(tmp == 0) return -1000000000LL;
  int cnt;
  long long int ans = 0;
  for(int i = 0; i < N; i++){
    cnt = 0;
    for(int j = 0; j < 10; j++){
      if(joi[j] && O[i][j]) cnt++;
    }
    ans += P[i][cnt];
  }
  return ans;
}

int dfs(int depth, vector<int> &j, vector<vector<int>> &O, vector<vector<long long int>> &P){
  if(depth == 10){
    return calc(j, O, P);
  }else{
    j[depth] = 0;
    long long int a = dfs(depth + 1, j, O, P);
    j[depth] = 1;
    long long int b = dfs(depth + 1, j, O, P);
    return max(a , b);
  }
}

int main(){
  cin >> N;
  
  vector<vector<int>> O(N, vector<int>(10,0));
  vector<vector<long long int>> P(N, vector<long long int>(11,0LL));
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 10; j++){
      cin >> O[i][j];
    }
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 11; j++){
      cin >> P[i][j];
    }
  }
  
  vector<int> joisino(10,0);
  
  long long int ans = 0LL;
  ans = dfs(0,joisino,O,P);
  cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int a, b;
    std::cin >> a >> b;

    std::cout << std::max(a + b, std::max(a - b, a * b)) << std::endl;
}

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


struct Node {
    int id;
    int parentId;
    int leftId;
    int rightId;
};


class BinaryTree {

public:
    static const int NIL_ID = -1;
    Node *nodes;

    BinaryTree(int cnt) {
        nodes = (Node *)malloc(sizeof(Node) * cnt);
        for (int i = 0; i < cnt; i++)
        {
            nodes[i] = Node{i, NIL_ID, NIL_ID, NIL_ID};
        }
    }

    ~BinaryTree() {
        delete nodes;
    }

    void push_values(int id, int leftId, int rightId) {
        nodes[id].leftId = leftId;
        nodes[id].rightId = rightId;

        if (leftId != NIL_ID)
            nodes[leftId].parentId = id;
        if (rightId != NIL_ID)
            nodes[rightId].parentId = id;
    }

    void printPreorder(int id) {
        if (id == NIL_ID)
            return;
        cout << " " << id;
        printPreorder(nodes[id].leftId);
        printPreorder(nodes[id].rightId);
    }

    void printInorder(int id) {
        if (id == NIL_ID)
            return;
        printInorder(nodes[id].leftId);
        cout << " " << id;
        printInorder(nodes[id].rightId);
    }

    void printPostorder(int id) {
        if (id == NIL_ID)
            return;
        printPostorder(nodes[id].leftId);
        printPostorder(nodes[id].rightId);
        cout << " " << id;
    }

    int findRootId() {
        Node node = nodes[0];
        int parentId = node.parentId;
        while (parentId != NIL_ID) {
            node = nodes[parentId];
            parentId = node.parentId;
        }
        return node.id;
    }
};


int main() {
    int N;
    int i, id, leftId, rightId;

    cin >> N;

    unique_ptr<BinaryTree> tree(new BinaryTree(N));

    for (i = 0; i < N; i++) {
        cin >> id >> leftId >> rightId;
        tree->push_values(id, leftId, rightId);
    }

    int rootId = tree->findRootId();

    cout << "Preorder" << endl;
    tree->printPreorder(rootId);
    cout << endl;
    cout << "Inorder" << endl;
    tree->printInorder(rootId);
    cout << endl;
    cout << "Postorder" << endl;
    tree->printPostorder(rootId);
    cout << endl;
}



Measured memory_bytes: 3084
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
int main(void){

	int a, b;
	double x = 0, y = 0, r = 0;
	for( ; ; ){
		scanf("%d,%d", &a, &b);
		if(!a && !b)
			break;
		x += sin(r) * a;
		y += cos(r) * a;
		r += b/180.0*M_PI;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	
		public static void main(String[] args) {
			long a=scan.nextLong();
			long max=0;
			for(int i=0;i<5;i++) {
				long b=lupper_division(a,scan.nextLong());
				max=lmax(b,max);
			}
			System.out.println(max+4);
		}
}


Measured memory_bytes: 21844
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;

  int res = 0;

  map<string, int> mp;
  while (n--) {
    string s;
    cin >> s;
    for (int i = 0; i + 1 < s.size(); ++i) {
      res += (s[i] == 'A' && s[i + 1] == 'B');
    }

    s = s.substr(0 , 1) + s.back();

    if (s[0] != 'B') {
      s[0] = 'C';
    }
    if (s[1] != 'A') {
      s[1] = 'C';
    }
    if (s[0] == 'B' || s[1] == 'A') {
      ++mp[s];
    }

  }


  res += max(0, mp["BA"] - 1);

  if (mp["BA"] != 0 && mp["CA"] != 0) {
    --mp["CA"];
    ++res;
  }

  if (mp["BA"] != 0 && mp["BC"] != 0) {
    --mp["BC"];
    ++res;
  }

  res += min(mp["CA"] , mp["BC"]);

  cout << res;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
   int x,a,b;
   scanf("%d %d %d",&x,&a,&b);
   if(a>=b){
      printf("delicious\n");
   }else if((b-a)<=x){
       printf("safe\n");
   }else{
       printf("dangerous\n");
   }
   return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  cout << (n % 2 == 0 ? n : n * 2);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector <long long> A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	
	long long res = 0;
	for (int i = 0; i < N; i++) {
		res += A[i] / 2;
		if (i < N - 1) {
			if (A[i] % 2 == 1) {
				if (A[i + 1]>0) {
					res += 1;
					A[i + 1]--;
				}
			}

		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()

{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))
    cout<<"2"<<endl;
else if(a!=b && a!=c && b!=c)
    cout<<"3"<<endl;
else
    cout<<"1"<<endl;



 return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		while(true) {
			char[][] area = new char[9][9];
			String s = sc.next();
			if(s.equals("#")) {break;}
			int i=0;
			try {
			for(int h=0;h<9;h++) {
				for(int w=0;w<10;w++) {
					if(s.charAt(i) == '/') {
						i++;
						break;
					}else if(s.charAt(i) == 'b') {
						i++;
						area[h][w] = 'b';
					}else {
						int blank = Character.getNumericValue(s.charAt(i));
						i++;
						for(int a=0;a<blank;a++) {
							area[h][w] = 'a';
							w++;
						}
						w--;
					}
				}
			}
			}
			catch(IndexOutOfBoundsException e) {
				
			}
			area[sc.nextInt()-1][sc.nextInt()-1] = 'a';
			area[sc.nextInt()-1][sc.nextInt()-1] = 'b';
			
			s = "";
			int p=0;
			
			try {
				for(int h=0;h<9;h++) {
					p=0;
					for(int w=0;w<9;w++) {
						if(area[h][w] == 'b') {
							if(p>0) {
								s += p;
							}
							s += "b";
							p=0;
						}else if(area[h][w] == 'a'){
							p++;
						}
					}
					if(p>0) {
						s += p;
					}
					
					s+="/";
				}
			}catch(IndexOutOfBoundsException e) {
				
			}

			s=s.replace("//", "/");
			s=s.replace("//", "/");
			s=s.replace("//", "/");
			s=s.replace("//", "/");
			s=s.replace("//", "/");
			
			System.out.println(s.substring(0, s.length()-1));
			
		}
	sc.close();
	}

}



Measured memory_bytes: 27960
from collections import deque

def nqueen(queen_rcs, n, k):
    def rc2idx(r, c):  # 7,7->88となる
        return (n + 2) * (r + 1) + c + 1

    queens = deque([])
    table = [None] * (n + 2) + ([None] + [-1] * n + [None]) * n + [None] * (n + 2)
    directions = [-(n + 3), -(n + 2), -(n + 1), -1, 1, n + 1, n + 2, n + 3]

    # queen_rcsに基づきqueenを入れ、おけない場所をマーク
    for queen_r, queen_c in queen_rcs:
        idx = rc2idx(queen_r, queen_c)
        table[idx] = idx
        for direction in directions:
            search_idx = idx
            while table[search_idx] is not None:
                if table[search_idx] == -1:
                    table[search_idx] = idx
                search_idx += direction

    idx = rc2idx(0, 0)
    max_idx = rc2idx(n - 1, n - 1)
    while len(queens) < n - k:
        # 配置できる場所を探す
        while idx <= max_idx and (table[idx] is None or table[idx] > -1):
            idx += 1
        if idx > max_idx:
            # 配置できる場所がなかった場合はバックトラック
            idx = queens.pop()
            for i in range((n + 2) * (n + 2)):
                if table[i] is not None and table[i] == idx:
                    table[i] = -1
            idx += 1
            continue
        # 配置できる場所があった場合は置く
        table[idx] = idx
        queens.append(idx)
        for direction in directions:
            search_idx = idx
            while table[search_idx] is not None:
                if table[search_idx] == -1:
                    table[search_idx] = idx
                search_idx += direction
        idx += 1
    return table


def print_table(table, n):
    def rc2idx(r, c):  # 7,7->88となる
        return (n + 2) * (r + 1) + c + 1
    for r in range(n):
        for c in range(n):
            idx = rc2idx(r, c)
            if table[idx] == idx:
                print("Q", end="")
            else:
                print(".", end="")
        print("\n", end="")

def main():
    queen_rcs = []
    k = int(input())
    for _ in range(k):
        line = input().split()
        r, c = list(map(int, line))
        queen_rcs.append((r, c))
    table = nqueen(queen_rcs, 8, k)
    print_table(table, 8)


if __name__ == "__main__":
    main()



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

#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vull vector<ull>
#define all(v) v.begin(),v.end()
#define mp make_pair
#define bitcount(x) __builtin_popcountll(x)
#define charcount(s,c) count(s.begin(), s.end(), c)
#define each(a,b) memset(a,b,sizeof a) //for b=0/-1, all pos,s for multidim arr too;
#define tofsi(s,c,t) memset(s,c,t) // for char s[n],first t;
#define tofs(s,pos,c,t) fill_n(s.begin()+pos, t, c);
#define fi first
#define se second


ll e_bit=0xAAAAAAAA;
ll o_bit=0x55555555;
lld pi = acos(-1.0);
ll gprime=402653189;
ll pprime=1610612741;
ll dulo=1000000007;

bool is_power2(ll n){
	return (n&&!(n&(n-1)));
}
ll power(ll x, ll y){
    ll temp;
    if( y == 0)
       return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp);
    else
    {
        if(y > 0)
            return (((x*temp))*temp);
        else
            return (temp*temp)/x;
    }
}

long long int mul_inv(long long int n,long long int p,long long int m){
	if(p==1){
		return n%m;
	}
	else if(p%2==0){
		long long int t= mul_inv(n,p/2,m);
		return ((t)*(t))%m;
	}
	else{
		long long int t= mul_inv(n,p/2,m);
		return ((((n%m)*t)%m)*t)%m;
	}
}

bool isprime(ll n){
	if(n==1){
		return false;
	}
	if(n==2){
		return true;
	}
	if(n%2==0){
		return false;
	}
	for(ll i=3;i<=sqrt(n);i+=2){
		if(n%i==0){
			return false;
		}
	}
	return true;
}


// getline(cin,s), cin.ignore() if cin>>p b4;


/*
struct compare {
    bool operator() (pair<int,int> a,pair<int,int> b) const{
        return a.se<b.se;
    }
};
*/


/*
---------------------Priority Queue Compare Operator------------------------

priority_queue<int, std::vector<int>, compare> pq;

*/
int n,m;
int am[55][55];
vector<pair<int,int>>e;
int ans[3600];
int vis[3600];
void br(){
	for(int i=0;i<m;i++){
        am[e[i].fi][e[i].se]=0;
		am[e[i].se][e[i].fi]=0;
        for(int j=0;j<n;j++)vis[j]=0;
        queue<int>q;
        q.push(e[i].fi);
        vis[e[i].fi] = 1;
        int check = false;
        while(!q.empty()){
            int x=q.front();
            if(x==e[i].se){
                check=1;
                break;
            }
            q.pop();
            for(int j=0;j<n;j++){
                if(am[x][j]==1 && vis[j] == 0){
                    q.push(j);
                    vis[j]=1;
                }
            }
        }
        am[e[i].fi][e[i].se]=1;
		am[e[i].se][e[i].fi]=1;
        if(check==0)ans[i] = 1;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	/*freopen("fbh.in","r",stdin);
    freopen("B-large.out","w",stdout);*/
	/*float ans;
	std::cout << std::fixed;
    std::cout << std::setprecision(9);
    std::cout << ans;
	*/
	
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		am[x-1][y-1]=1;
		am[y-1][x-1]=1;
		e.pb(mp(x-1,y-1));
	}
	br();
	int an=0;
	for(int i=0;i<m;i++){
		an+=ans[i];
	}
	cout<<an;
	return 0;
}

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

#define ll long long

const int INF = 1000000;

void chmin(ll& a, ll b){ 
  if (a > b) a = b;
}

int main() {
  int H, W;
  cin >> H >> W;
  
  ll cost[10][10];
  
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> cost[i][j];
    }
  }
  
  ll dp[11][10][10];
  
  
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  
  for (int j = 0; j < 10; j++) {
    for (int k = 0; k < 10; k++) {
      dp[1][j][k] = cost[j][k];
    }
  }
  
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
          chmin(dp[i+1][j][k], dp[i][j][l] + cost[l][k]);
          chmin(dp[i+1][j][k], dp[i][j][k]);
        }
      }
    }
  }
  
  
  
  vector<ll> numcount(10, 0);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int x;
      cin >> x;      
      if (x != -1) numcount[x]++;
    }
  }
  
  
  ll ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += numcount[i] * dp[10][i][1];
  }
  
  cout << ans << endl;
  
  
  
}

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

int main() {
	char s[200],p[200];
	int judge = 0;
	cin >> s;
	int len = strlen(s);
	for(int i = 0; i < len ; i++){
		s[len + i] = s[i];
	}
	cin >> p;
	for(int j = 0; j <strlen(p) ; j++){
		for(int i = 0; i < 2*len ; i++){
			if(p[j] == s[i]){
				for(int k = 0; k < strlen(p) ;k++){
					if(p[j+k] == s[i+k]){
						judge = 1;
					}
					else{
						judge = 0;
						break;
					}
				}
			}
			if(judge == 1){
				cout << "Yes" << endl;
				goto END;
			}
		}
	}
	cout << "No" << endl;
END:
	return 0;
}

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

int n;
int L[64];
std::string str;

int main() {  
  for(;;) {
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      std::cin >> str;
      L[i] = str.size();
    }
    for(int i = 0; i < n; ++i) {
      int state = 0;
      int x = 0;
      int dx[5] = {5, 7, 5, 7, 7};
      for(int j = i; j < n; ++j) {
        x += L[j];
        if( x > dx[state] ) break;
        if( x == dx[state] ) {
          x = 0;
          state += 1;
          if( state == 5 ) {
            break;
          }            
        }
      }
      if( state == 5 ) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
            

  return 0;
}

Measured memory_bytes: 3308
from operator import mul
from functools import reduce

n, m = [int(i) for i in input().split()]
arr = [int(input()) for i in range(m)]
arr.append(n+1)
arr.insert(0, -1)
div_arr = [arr[i+1]-arr[i]-1 for i in range(len(arr)-1)]


def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

if 0 in div_arr:
  print(0)
else:
  print(reduce(mul, [Fib(i+1) for i in div_arr])%1000000007)

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


int n,a[101];

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ans = INT_MAX;
	for(int i = 1; i <= 100; i++) {
		int sum = 0;
		for(int j = 0; j < n; j++) {
			sum += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans,sum);
	}
	cout << ans << endl;
	return 0;
}

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

int main ( ) 
{
string x ; 
cin >> x ; 
int start = 0 ;
int end = 0 ;
int len = x.size();
	for (int i = 0 ; i<len ; i++)
	{
		if (x[i] == 'A')
		{start = i ; 
		break ;
		}
		
	}
	for (int i=0; i<len;i++)
	{
		if (x[i]== 'Z')
		end = i ;
	}
	cout << end - start +1 ; 
		return 0 ; 
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;

int n;
int a[MAXN];
vector <int> pos[30];
long long ans = 0;

int main() {

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 20; j++) {
      if ((a[i] & (1 << j))) {
        pos[j].push_back(i);
      }
    }
    int l = 0;
    for (int j = 0; j < 20; j++) {
      if (sz(pos[j]) >= 2) {
        int prev = pos[j][sz(pos[j]) - 2];
        l = max(l, prev + 1);
      }
    }
    ans += (i - l + 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9028
#include <stdio.h>
#include <stdlib.h>



int main()
{
	int i,p,b,count=0,j;
	
	scanf("%d", &p);
	int *binary = (int*)malloc(sizeof(int)*p);

	for (i = 0; i < p; i++)
	{
		scanf("%d", &binary[i]);
	}

    scanf("%d", &b);
	int *binary2 = (int*)malloc(sizeof(int)*b);

	for (i = 0; i < b; i++)
	{
		scanf("%d", &binary2[i]);
	}

	


	for (i = 0; i < b; i++)
	{
		int left = 0, right = p;
		
				while(left < right){
					j = (left + right) / 2;
					if(binary2[i] == binary[j])
					{
						count++;
					    break;
						
					}
					else if(binary2[i] > binary[j])
					left = j + 1;
					else if(binary2[i] < binary[j])
					right = j ;
				}
	
	}

	
		
	
	printf("%d\n", count);


	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(){
int i,h,w,j;
scanf("%d%d",&h,&w);
char f[h][w+1];
for(i=0;i<h;i++)scanf("%s",f[i]);
for(i=0;i<h;i++){
for(j=0;j<w;j++){
if(f[i][j]=='#')printf("#");
else {
int tmp=0;
if(i!=0&&f[i-1][j]=='#')tmp++;
if(i!=h-1&&f[i+1][j]=='#')tmp++;
if(j!=0&&f[i][j-1]=='#')tmp++;
if(j!=w-1&&f[i][j+1]=='#')tmp++;
if(i!=0&&j!=0&&f[i-1][j-1]=='#')tmp++;
if(i!=0&&j!=w-1&&f[i-1][j+1]=='#')tmp++;
if(i!=h-1&&j!=0&&f[i+1][j-1]=='#')tmp++;
if(i!=h-1&&j!=w-1&&f[i+1][j+1]=='#')tmp++;
printf("%d",tmp);
}
}
puts("");
}
return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
A = [[-1] * N for _ in range(N)]
for i in range(N) :
    An = int(input())
    for _ in range(An) :
        x, y = map(int, input().split())
        A[i][x-1] = y

def check(honest) :
    for i in range(N) :
        for j in range(N) :
            if honest[i] and ((honest[j] == 0 and A[i][j] == 1) or (honest[j] == 1 and A[i][j] == 0)) :
                return False
                
    return True

ret = 0
for i in range(2 ** N) :
    honest = [0] * N
    for j in range(N) :
        if i & 1 :
            honest[j] = 1
        i //= 2
    
    if check(honest) :
        ret = max(ret, sum(honest))
    
print(ret)

Measured memory_bytes: 44892
def bit_count(i, b)
  ret = 0
  until(i == 0) do
    ret += 1 if i[0] == b
    i >>= 1
  end
  ret
end

N = gets.to_i
H = []
U = []
N.times{|i|
  n = gets.to_i
  h = 0
  u = 0
  n.times{
    x, y = gets.chomp.split(" ").map(&:to_i)
    y == 1 ? (h |= 1 << (x - 1)) : (u |= 1 << (x - 1))
  }
  H << h; U << u
}

ans = 0
(1...2**N).each{|i|
  next if bit_count(i, 1) <= ans
  h, u = [0, 0]
  (1..N).each{|n|
    (h |= H[n - 1]; u |= U[n - 1]) if i[n - 1] == 1
  }
  ans = bit_count(i, 1) if (h & ~i == 0)  && (u & i == 0)
}

puts ans


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i <= M; ++i){
        int sum = i*N;
        for(int j = 0; j <= N; ++j){
            sum = i*N - i*j + j*(M-i);
            if(sum == K){
                cout << "Yes" << '\n';
                return 0;
            }
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3644
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
using namespace std;

int main()
{
    fast; 
    ll n,mx,i,j;
    cin>>n>>mx;
    ll dp[n+1][mx+1];
    ll w[n+1],v[n+1];
    f(i,1,n+1)
    	cin>>w[i]>>v[i];
    
    f(i,0,n+1)
    	dp[i][0]=0;
    f(j,0,mx+1)
    	dp[0][j]=0;

    f(i,1,n+1)
    {
    	f(j,1,mx+1)
    	{
    		if(j>=w[i])
    			dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
    		else dp[i][j]=dp[i-1][j];
    	}
    }
    cout<<dp[n][mx];
}


Measured memory_bytes: 79232
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    ll n, p;
    cin >> n >> p;
    map<ll, ll> mp;
    for(ll i = 2; i * i <= p; i++){
        while(p % i == 0){
            mp[i]++;
            p /= i;
        }
    }
    if(p != 1)mp[p]++;
    ll res = 1, r = 1;
    for(auto m : mp){
        res = res * pow(m.first, (m.second / n));
    }
    cout << res << endl;
}



Measured memory_bytes: 3984
#include <stdio.h>

int main(void){
	char str[10001];
	int J, I, n, i;
	while (scanf("%s", &str) != EOF){
		J=0,I=0;
		n = strlen(str);
		for (i = 0; i < n - 2; i++){
			if (str[i]=='J' && str[i+1]=='O' && str[i+2]=='I') J++;
			if (str[i]=='I' && str[i+1]=='O' && str[i+2]=='I') I++;
		}
		printf("%d\n%d\n",J,I);
	}
	return 0;
}

Measured memory_bytes: 552
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k = gi()*500;
    printf(k >= gi() ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256