akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_d>
問題文============================================================
 非負整数専門店「せいすうや」には、N 個の非負整数が売られています。
 i 個目の非負整数は Ai で、その価値は Bi です。 価値の異なる同じ非負整数が複数売られていることもあります。
 
 高橋君は、「せいすうや」でいくつかの整数を買うことにしました。
 高橋君は、買う整数たちの bitwise or が K 以下になるような 任意の組み合わせで、整数を買うことができます。
 高橋君は、買った整数たちの価値の総和をできるだけ大きくしたいです。
 
 高橋君が達成できる、価値の総和の最大値を求めてください。
 ただし、bitwise or とは、ビットごとの論理和を表します。
=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll ret = 0;
    ll N,K; cin >> N >> K;
    vector<ll> A(N),B(N);
    for(int i = 0; i < N;i++) cin >> A[i] >> B[i];
    for(int i = 0; i < N;i++) if(K == (K|A[i])) ret += B[i];
    for(ll i = 1; i <= K; i<<= 1){
        if(!(i&K)) continue;
        ll nK = (K^i) | (i-1);
        ll T = 0;
        for(int j = 0; j < N;j++){
            if(nK != (nK|A[j])) continue;
            T += B[j];
        }
        ret = max(ret,T);
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] roads = new int[N];
		for(int i=0; i<N; i++){
			roads[i] = 0;
		}
		
		for(int i=0; i<M; i++){
			roads[ sc.nextInt()-1 ]++;
			roads[ sc.nextInt()-1 ]++;
		}
		
		for(int i=0; i<N; i++){
			System.out.println(roads[i]);
		}
		return;
	}
}

Measured memory_bytes: 23764
n=int(input())
a=[int(input()) for _ in range(n-1)]
ki=[[] for _ in range(n)]
for i,x in enumerate(a):
  ki[x-1].append(i+1)

ans=0
import sys
sys.setrecursionlimit(10**7)
from collections import Counter
def marge(arg):
  ret=0
  arg.sort(reverse=True)
  for i,x in enumerate(arg):
    ret=max(ret,i+1+x)
  return ret


def dfs(v):
  ret=[]
  if len(ki[v])==0:return 0
  for nv in ki[v]:
    ret.append(dfs(nv))
  return marge(ret)
print(dfs(0))


Measured memory_bytes: 116236
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int t[110], v[110];
    rep(i, N) cin >> t[i];
    int sum = 0;
    rep(i, N) sum += t[i];
    rep(i, N) cin >> v[i];
    int s[40010];
    rep(i, 40010) {
        s[i] = INF;
    }
    s[0] = 0;
    int T = 0;
    rep(i, N) {
        for(int j = T; j < T + t[i] * 2; j += 2) {
            s[j + 1] = min({s[j + 1], v[i] * 2, s[j] + 1}); 
            s[j + 2] = min({s[j + 2], v[i] * 2, s[j] + 2}); 
        }
        T += t[i] * 2;
    }
    //rep(i, sum * 2 + 1) cout << fixed << setprecision(1) << i/2.0 << " " << s[i]/2.0 << endl;
    //cout << endl;
    T = sum * 2;
    s[sum * 2] = 0;
    RREP(i, N - 1, 0) {
        for(int j = T; j > T - t[i] * 2; j -= 2) {
            s[j - 1] = min({s[j - 1], v[i] * 2, s[j] + 1});
            s[j - 2] = min({s[j - 2], v[i] * 2, s[j] + 2}); 
        }
        T -= t[i] * 2;
    }
    int ans = 0;
    // rep(i, sum * 2 + 1) cout << fixed << setprecision(1) << i/2.0 << " " << s[i]/2.0 << endl;
    // cout << endl;
    rep(i, sum * 2 + 1) ans += s[i];
    cout << fixed << setprecision(12) << ans/4.0 << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
int digit(int a)
{
int r;
r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
return r + 1;
}
int main(){
    quickie;
   // txt;
    int a;
    string s;
    cin>>a>>s;
    int sum = 0;
    int m = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'D'){
            sum--;
        }else{
            sum++;
        }
        m = max(sum,m);
    }
    cout<<m;
    
    return 0;
}

Measured memory_bytes: 3636
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int a = -1, b = -1;
	for (int i = 1; i != s.length(); ++i) {
		if (s[i - 1] == s[i]) {
			a = i, b = i + 1;
			break;
		}
		if (i > 1 && s[i - 2] == s[i]) {
			a = i - 1, b = i + 1;
			break;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i,N) cin >> L[i];
    sort(L.begin(), L.end());
    ll Lnum[1001] = {};
    ll pos = 0;
    rep(i,N){
        Lnum[L[i]]++;
    }
    int S[1001] = {};
    REP(i,1,1001){
        S[i] = S[i-1] + Lnum[i];
    }
    ll ans = 0;
    REP(a,1,1001) {
        // 同じ長さのやつを２個使う
        if(Lnum[a] <= 1) continue;
        int aans = S[min(2*a-1,1000LL)] - S[a];
        aans *= (Lnum[a] * (Lnum[a]-1) / 2);
        ans += max(aans, 0);
        // 3つ同じ
        ans += (Lnum[a] * (Lnum[a]-1) * (Lnum[a]-2) / 6);
    }
    REP(a,1,1001){
        if(Lnum[a]==0) continue;
        int aans = 0;
        REP(b,a+1,1001){
            if(Lnum[b]==0) continue;
            int bans = S[min(a+b-1,1000LL)] - S[b];
            bans *= Lnum[b];
            aans += max(0, bans);
            aans += (Lnum[b] * (Lnum[b]-1) / 2);
        }
        aans *= Lnum[a];
        ans += aans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// O(qlogn)
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf prllf
using namespace std;
#define ll long long
const int N=2e6+9;

void slv()
{
    ll n;
    cin >> n;
    ll a[n+3];
    for(ll i=0;i<n;i++) cin >> a[i];
    ll mx=1LL;
    ll ans=0LL;
    for(ll i=0;i<n;i++) {
        mx=max(mx,a[i]);
        ans += (mx-a[i]);
    } cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
    for(int cs=1;cs<=t;cs++) {
        //prllf("Case %d:\n",cs);
        slv();
    }
    return 0;
}


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

int main(){
  long double n,k,ans = 0;
  cin >> n >> k;

  for ( long double i = 1; i <= n; i++ ) {
    long double temp = i,x = 0;
    while ( temp < k ){
      temp *= 2;
      ++x;
    }
    long double ttmp =  1 / ( pow( (long double)2, x ) * n );
    ans += ttmp;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using R=double;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(void){
	int H,W;
    cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }

    bool isOK = false;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j]=='#'){
                for(int k = 0; k < 4; k++){
                    if(i+dy[k] < 0 or i+dy[k] > H-1){
                        continue;
                    }
                    if(j+dx[k] < 0 or j+dx[k] > W-1){
                        continue;
                    }
                    if(s[i+dy[k]][j+dx[k]] == '#'){
                        isOK = true;
                        break;
                    }
                }
                if(isOK == false){
                    cout << "No" << endl;
                    return 0;
                }else{
                    isOK = false;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from pprint import pprint

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, CD):
    S = sum(map(lambda x: x[0] * x[1], CD))
    D = sum(map(lambda x: x[1], CD))
    return D - 1 + (S-1) // 9


def main():
    N = read_int()
    CD = [read_int_n() for _ in range(N)]
    print(slv(N, CD))

    # N = 100
    # CD = [[random.randint(0, 9), random.randint(1, 10000)] for _ in range(N)]
    # print(N)
    # print(CD)
    # print(slv(N, CD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 47744
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int D[100];
int main() {
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  int N = 1;
  for (int i=0; i<K; i++) {
    D[0]++;
    for (int j=0; j<N; j++) {
      if (D[j] > 9 || (j + 1 < N && D[j] > D[j+1] + 1)) {
        D[j+1]++;
        for (int k=j; k>=0; k--) {
          D[k] = max(D[k+1]-1, 0);
        }
      }
    }
    if (D[N]) N++;
  }
  for (int i=N-1; i>=0; i--) cout << D[i];
  cout << endl;
}

Measured memory_bytes: 256
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]
flag=False

for i in range(0,9):
  if int(a_list[i])==n:
    print(a_list[i])
    flag=True
    break
  elif n < 111:
    print("111")
    break
if flag==False:
  for i in range(0,8):
    if int(a_list[i])< n < int(a_list[i+1]):
      print(a_list[i+1])
      break

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

int main(){
    int n,sum=0;
    cin >> n;
    int x=n;
    
    while(x!=0){
        sum+=x%10;
        x/=10;
    }
    
    if(n%sum==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

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

const u64 mod = 1000000007;

u64 msb(u64 n) {
  u64 m = 0x1;
  while (n >= m) m <<= 1;
  return m >> 1;
}

const u64 arr[] = {0, 1, 3, 0};

u64 f(u64 n) {
  if (n <= 3) return arr[n];

  u64 m = msb(n);
  return (((n - m + 1) & 0x1) * m) ^ f(n % m);
}

int main() {
  RULL(A, B);
  
  PULL(f(B) ^ f(A) ^ A);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
int main()
{
  int n;
  std::cin>>n;
  int i;
  int sum=100;
  for(i=0;i<n;i++)
    {
      sum+=std::ceil(sum*0.05);
    }
  std::cout<<sum*1000<<std::endl;

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int n, m, q;
int res = 0;
vector<vector<int>> v;
vector<int> nums;

void f() {
    if (nums.size() == n + 1) {
        int r = 0;
        for (auto item : v) {
            if (nums[item[1]] - nums[item[0]] == item[2]) {
                r += item[3];
            }
        }
        res = max(res, r);
        return;
    }
    for (int i = nums.back(); i <= m; i++) {
        nums.push_back(i);
        f();
        nums.pop_back();
    }
}

int main() {        
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        v.push_back({a, b, c, d});
    }
    nums.push_back(1);
    for (int i = 1; i <= m; i++) {
        nums.push_back(i);
        f();
        nums.pop_back();
    }
    cout << res << endl;
}


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

int main() {
  int N;
  long long x;
  cin >> N >> x;
  
 vector<long long> a(N); 
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  int satisfied = 0;
  for(int i=0;i<N;i++){
    if(a.at(i) > x){
      break;
    }else if(i==N-1 && a.at(i) < x){
      break;
    }else{
      satisfied ++;
      x -= a.at(i);
    }
  }  
  cout << satisfied << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int[] a=new int[8];
            for(int i=0;i<8;i++){
            	a[i]=Integer.parseInt(sc.next(),2);
            }
            for(int i=0;i<8;i++){
                if(a[i]>0){
                    if(i==7){System.out.println("C");break;}
                    else if(a[i+1]==0){System.out.println("C"); break;}
                    else{
                    	if(a[i]==a[i+1]){
                            if(i+2==8){System.out.println("A");break;}
                            else{
                                if(a[i]==a[i+2]){System.out.println("B"); break; }
                                else{System.out.println("A");break;}
                            }
                        }else if(a[i+1]==a[i]+a[i]*2){System.out.println("D"); break;
                        }else if(a[i]==a[i+1]*2){System.out.println("E"); break;
                        }else if(a[i+1]==a[i]+a[i]/2){System.out.println("F"); break;
                        }else{System.out.println("G"); break; }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 20076
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// https://www.hamayanhamayan.com/entry/2018/11/24/223908

void solve(void)
{
  int n;cin>>n;
  string str;cin>>str;
  int q;cin>>q;
  for (int lc = 0; lc < q; lc++)
  {
    int res =0 ;
    int k = 0;
    cin>>k;
    int c = 0;
    int m_cnt = 0;
    int c_cnt = 0;
    int ttl = 0;
    for (int i = 0; i < n; i++)
    {
      if(str[i] =='D'){
        while(c < n and c - i < k)
        {
          if(str[c] =='M')m_cnt++;
          else if(str[c] =='C')
          {
            c_cnt++;
            ttl += m_cnt;
          }
          c++;
        }
        res += ttl;
      }
      else if(str[i] == 'M')
      {
        m_cnt --;
        ttl -= c_cnt;
      }
      else if(str[i] =='C')
      {
        c_cnt--;
      }
    }

    cout<<res<<endl;
  }
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4276
#include <stdio.h>
#define bit(n,m)(((n)>>(m))&1)

int main(){
	int n;
	scanf("%d",&n);
	for(int x=0;x<1<<n;x++){
		printf("%d:",x);
		for(int k=0;k<n;k++)if(bit(x,k))printf(" %d",k);
		puts("");
	}
}


Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int i;
    int j;
    int a[n];
    j=0;
    unsigned long sum=0;
    for(i=1;i<=n;++i){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    printf("%lu\n",sum);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#include<numeric>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    ll n;cin>>n;vl a(n);vl b(n);
    rep(i,n)cin>>a[i]>>b[i];
    ll ans=0;
    for(int i=(int)n-1;i>=0;i--)
        ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	char C;
	cin >> C;
	string x = "abcdefghijklmnopqrstuvwxyz";
	int y;
	for (int i = 0; i < 26; i++)
	{
		if (x[i] == C) y = i;
	}

	cout << x[y + 1] << endl;
		 
	return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<vector<int>> pos(200005);
	vector<ll> dp(n + 1);
	dp[0] = 1;
	int pre = 0;
	rep(i, n)
	{
		int a; cin >> a;
		dp[i + 1] = dp[i];
		if (pre != a && pos[a].size() != 0)
		{
			dp[i + 1] += dp[pos[a].back() + 1];
		}
		dp[i + 1] %= (ll)1e9 + 7;
		pos[a].push_back(i);
		pre = a;
	}
	cout << dp[n] << endl;
}

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

int main() {
  
  vector<int> vec(3);

  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
  }
    sort(vec.begin(), vec.end());
 if((vec.at(0)==5) && (vec.at(1)==5) && (vec.at(2)==7)){
  cout<< "YES" << endl;
  }    
    else{
      cout<<"NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(s[n-1]=='s') cout << s + "es" << endl;
  else cout << s + "s" << endl;
}

Measured memory_bytes: 3632
#include <cstdio>

int main(){
    int a,b,c,x,sum;
    int cnt = 0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &x);

    for(int i = 0; i<=a; i++){
        for(int n = 0; n<=b; n++){
            for(int m=0; m<=c; m++){
                sum = 500*i+100*n+50*m;
                if(sum==x){
                    cnt+=1;
                }
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

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

int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w);
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  
  if (n % 2 == 0) {
    cout << n / 2 << endl;
  } else {
    cout << (n / 2 + 1) << endl;
  }

  return 0;
}


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

signed main() {
 string num;
 cin >> num ;
 if( num[0] == '7' || num[1] == '7' || num[2] == '7' )
   cout << "Yes" << "\n";
 else
   cout << "No" << "\n";
  
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  YORN(s==t);
  return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	as := make([]int, N)
	for i, _ := range as {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)
	min := as[0]
	max := as[len(as)-1]

	costs := make([]int, max-min+1)
	for i := min; i <= max; i++ {
		index := i - min
		cost := 0
		base := i
		for _, v := range as {
			cost += (v - base) * (v - base)
		}
		costs[index] = cost
	}
	sort.Ints(costs)
	fmt.Println(costs[0])
}


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

int main(){
  
  int N;
  cin >> N;
    
  
  if (N/100 == 7){
    cout << "Yes" << endl;
  }
  
  else if ((N%100)/10 == 7){
    cout << "Yes" << endl;
  }
  
  else if ((N%10) == 7){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3544
#!/usr/bin/env/ python3
N = int(input())
A = [int(x) for x in input().split()]
mydict = {}
for i in range(len(A)):
    if A[i] in mydict: mydict[A[i]] += 1
    else: mydict[A[i]] = 1
#print(mydict)
ans = 0
for i in list(mydict.keys()):
    if mydict[i] > 1: ans += int(mydict[i] * (mydict[i] - 1) / 2)
for i in range(len(A)):
    print(ans - (mydict[A[i]] - 1))


Measured memory_bytes: 24748
n, m = map(int, input().split())
xlst = list(map(int, input().split()))
xlst.sort()
dlst = []
for i in range(m - 1):
    dlst.append(xlst[i + 1] - xlst[i])
dlst.sort(reverse = True)
ans = sum(dlst) - sum(dlst[:n - 1])
print(ans)

Measured memory_bytes: 20320
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
const int MOD = 1e9 + 7 ;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main(){
   IOS
   int n;
   cin>>n;

   int arr[n];
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }

    int dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1] - arr[0]);

    for (int j = 2; j < n; ++j) {
        dp[j] = min(dp[j-2]+ abs(arr[j]-arr[j-2]), dp[j-1]+abs(arr[j]-arr[j-1]));
    }

  cout<<dp[n-1];
    return 0;
}
// CHECK FOR CORNER CASES LIKE 0,1 etc.


Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct inn{
	int n,c,r;
	inn(int n,int c,int r):n(n),c(c),r(r){}
	bool operator<(const inn& other)const{
		return r<other.r;
	}
};
const int MAX=INT_MAX/10;
int main(){
	int n,m,l;
	while(cin>>n>>m>>l,n){
		vvi dist(n,vi(n,-1));
		vvi risk(n,vi(n,MAX));
		REP(i,m){
			int a,b,d,e;
			cin>>a>>b>>d>>e;
			dist[a-1][b-1]=d;
			dist[b-1][a-1]=d;
			risk[a-1][b-1]=e;
			risk[b-1][a-1]=e;
		}
		
		queue<inn> q;
		q.push(inn(0,0,0));
		vvi cost(n,vi(l+1,MAX));
		cost[0][0]=0;
		while(!q.empty()){
			inn in=q.front();q.pop();
			if(cost[in.n][in.c]<in.r){
				continue;
			}
			REP(i,n){
				if(i!=in.n&&dist[in.n][i]!=-1){
					REP(j,2){
						int nr=in.r+(j==1?0:risk[in.n][i]);
						int nc=in.c+(j==0?0:dist[in.n][i]);
						if(nc<=l&&cost[i][nc]>nr){
							cost[i][nc]=nr;
							q.push(inn(i,nc,nr));
						}
					}
				}
			}
		}
		int best=INT_MAX;
		REP(i,l+1){
			best=min(best,cost[n-1][i]);
		}
		cout<<best<<endl;
	}
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  char c;
  bool sflag = false;
  REP(i, n){
    cin >> c;
    if(c=='Y')
      sflag = true;
  }
  if(sflag)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
const int N = 3005;
int dp[N][N] = {{0}};
int n, s;
int a[N];
const int M = 998244353;
void solve() {  
    // not taken -> multiply by 2
    // taken -> multiply 
    cin >> n >> s;
    fr(i, 1, n) 
        cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j] = (2 * dp[i - 1][j]) % M;
        }
        for (int j = a[i]; j < N; ++j) {
            (dp[i][j] += (dp[i - 1][j - a[i]])) %= M;
        }
    }
    cout << dp[n][s];
}       
    

Measured memory_bytes: 74064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll sx,sy,tx,ty;
  cin >> sx>>sy>> tx>>ty;
  ll x=tx-sx;
  ll y=ty-sy;
  for(ll i=0;i<x;i++) cout <<"R";
  for(ll i=0;i<y;i++) cout <<"U";
  for(ll i=0;i<x;i++) cout <<"L";
  for(ll i=0;i<y+1;i++) cout <<"D";
  for(ll i=0;i<x+1;i++) cout <<"R";
  for(ll i=0;i<y+1;i++) cout <<"U";
  cout<<"LU";
  for(ll i=0;i<x+1;i++) cout <<"L";
  for(ll i=0;i<y+1;i++) cout <<"D";
  cout <<"R"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (){
	
	int a,b;
	char s [15],t[15],u[15];
	
	scanf("%s %s",&s,&t);
	scanf("%d %d",&a,&b);
	scanf("%s",&u);
	
	if(strcmp(s,u)==0){
		printf("%d %d\n",a-1,b);
	}else if (strcmp(t,u)==0){
		printf("%d %d\n",a,b-1);
	}
	

return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

// //最大公約数
// int gcd(int a,int b){
//     return b ? gcd(b,a%b):a;
// }

// //最小公倍数
// int lcm(int a,int b){
//     return a/gcd(a,b)*b;
// }

// //素数判定
// bool isPrime(int x){
//     int i;
//     if(x<2)return 0;
//     else if(x==2)return 1;
//     if(x%2==0)return 0;
//     for(int i=3;i*i<=x;i+=2){
//         if(x%i==0)return 0;
//     }
//     return 1;
// }

// //桁ごとの足し算
// int digsum(int n){
//     int res=0;
//     while(n>0){
//         res+=n%10;
//         n/=10;
//     }
//     return res;
// }

// //約数列挙
// vector<int> enum_div(int n){
//     vector<int> ret;
//     for(int i=1;i*i<=n;++i){
//         if(n%i==0){
//             ret.push_back(i);
//             if(i*i !=n){
//                 ret.push_back(n/i);
//             }
//         }
//     }
//     return ret;
// }

// //累乗の計算とあまり,0で累乗そのまま出力
// long long modpow(long long a,long long n,long long mod){
//     if(mod==0)mod=__LONG_LONG_MAX__;
//     long long res=1;
//     while(n>0){
//         if(n & 1)res=res*a%mod;
//         a=a*a%mod;
//         n>>=1;
//     }
//     return res;
// }

// //指定文字の文字数カウント
// int stringcount(string s,char c){
//     return count(s.cbegin(),s.cend(),c);
// }

char a;
int main(){
    cin>>a;
    if(islower(a)){
        cout<<"a"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys 
from heapq import heappop,heappush
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
# INF = 10**31
cost = [[0]*(N+1) for _ in range(N+1)] 
tmp = [[0]*(N+1) for _ in range(N+1)] 
for i in range(N):
    A = list(map(int,readline().split()))
    for j in range(N):
        cost[i+1][j+1] = A[j]
        tmp[i+1][j+1] = A[j]
        

for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            if cost[i][j] > cost[i][k] + cost[k][j]:
                print(-1)
                sys.exit()
            if cost[i][k] and cost[k][j] and cost[i][j] == cost[i][k] + cost[k][j]:
                tmp[i][j] = 0

ans = sum([sum([c for c in row]) for row in tmp])
print(ans//2)

Measured memory_bytes: 70580
@$_=$p[$_]=$_ for@N=1..<>;map{unshift@a,@N*$#N/2-$%;@$A>@$B&&($A^=$B^=$A^=$B),$%+=@$B*map$p[$$B[@$B]=$_]=$B,@$A if($B=$p[$'*/ /])-($A=$p[$`])}reverse<>;print"@a"

Measured memory_bytes: 112640
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lminps():
    return list(map(int,input().split()))

a,b,c = miinps()

if a == b and b == c:
  print("No")
elif a != b and a != c and b != c:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int N,X,T, cnt;
  unused = scanf("%d %d %d", &N, &X, &T);

  cnt = 1;
  while(cnt > 0){
    if(cnt*X >= N) break;
    else cnt++;
  }
  printf("%d", cnt*T);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

const int MAXN = 1e5 + 10;

int n, x[MAXN];
vector<int> adj[MAXN];

void dfs(int v, int p = -1){
	for (int u:adj[v])
		if (u^p){
			dfs(u, v);
			x[v] ^= x[u]+1;
		}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n-1; i++){
		int a, b;	cin >> a >> b, a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0);
	if (x[0])
		cout << "Alice\n";
	else
		cout << "Bob\n";
	return 0;
}


Measured memory_bytes: 12416
#include <iostream>
 
int main(){
  int n, q, t, cnt, u, l;
  int str[100000];
  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::cin >> str[i];
  }
  std::cin >> q;
  cnt = 0;
 
  for(int i = 0; i < q; i++){
    std::cin >> t;
    u = -1;
    l = n;
    while(l - u != 1){
      if(str[(u + l) / 2] > t) l = (u + l) / 2 + (u + l) % 2;
      else u = (u + l) / 2;
    }
    if(str[u] == t || str[l] == t) cnt++;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
int main()
{
		long long n;
		cin>>n;
		vector<long> a(n+1,0);
		vector<long> b(n+1,0);
		vector<long> c(n+1,0);
		for(long i=0;i<n;i++)
		{
			long long x,y,z;
			cin>>x>>y>>z;
			a[i]=x;
			b[i]=y;
			c[i]=z;
		}
		for(long i=1;i<n;i++)
		{
			a[i]=max(b[i-1]+a[i],c[i-1]+a[i]);
			b[i]=max(a[i-1]+b[i],c[i-1]+b[i]);
			c[i]=max(c[i]+a[i-1],c[i]+b[i-1]);
		}
		cout<<max(a[n-1],max(b[n-1],c[n-1]))<<"\n";
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long ans = INT64_MAX;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<pair<int, int> > XY(N);
    set<int> XS, YS;
    for (auto &xy : XY) {
        cin >> xy.first >> xy.second;
        XS.insert(xy.first);
        YS.insert(xy.second);
    }
    vector<int> X(XS.begin(), XS.end()), Y(YS.begin(), YS.end());
    int Xsize = X.size(), Ysize = Y.size();
    for (int i = 0; i < Xsize; i++) for (int j = i; j < Xsize; j++) for (int k = 0; k < Ysize; k++) for (int l = k; l < Ysize; l++) {
        int count = 0;
        for (auto &xy : XY) {
            if (X[i] <= xy.first && X[j] >= xy.first && Y[k] <= xy.second && Y[l] >= xy.second) count++;
        }

        if (count >= K) ans = min(ans, (long long)(X[j]-X[i])*(Y[l]-Y[k]));
    }
    printf("%lld\n", ans);
    return 0;
}

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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
		ll h, a;	cin >> h >> a;

		if( h % a == 0 )	cout << h / a << endl;
		else				cout << h / a + 1 << endl;

	return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

// ------------------------------------------------------------------------------------------

string s;
int N;

signed main() {
  cin >> s >> N;
  int end = 0;
  rep (i, s.size()) {
    if (s[i] == '1') {
    } else {
      end = i;
      break;
    } 
  }

  if (s[0] == '1') {
    if (N <= end) {
      cout << 1 << endl;
    } else {
      cout << s[end] << endl;
    }
  } else {
    cout << s[0] << endl;
  }

  return 0;
}

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

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

    ll ans = 0;

    if (k <= a + b) {
        if (a <= k) ans = a;
        else ans = k;
    } else {
        ans = a - (k-a-b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	InputUtil in = new InputUtil();
    	PrintWriter out = new PrintWriter(System.out);
    	int n = in.nextInt();
    	int m = in.nextInt();
    	int l = in.nextInt();
    	int[] A = in.nextInt(new int[n*m]);
    	int[] B = in.nextInt(new int[m*l]);
    	long[] C = new long[n*l];

    	for(int i=0; i<n; i++) {
        	for(int j=0; j<l; j++) {
        		for( int k=0; k<m; k++) {
        			C[i*l+j] += A[i*m+k] * B[k*l+j];
        		}
        	}
    	}
    	
    	StringBuilder sb = new StringBuilder();
    	for(int i=0; i<n; i++) {
        	for(int j=0; j<l; j++) {
        		if(j > 0)
        			sb.append(" ");
        		sb.append(C[i*l+j]);
        	}
        	sb.append(EOL);
    	}
        
    	out.print(sb.toString());
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}


/**
 * --------------------------------------------------
 * Input Utility
 * --------------------------------------------------
 */
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 28724
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
void solve()
{
  ll n,t; cin>>n>>t;
  ll ans=n-(2*t);
  if(ans<0) ans=0;
  cout<<ans<<endl;
}
signed main(){
        solve();

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;    
    }else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256