akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

class RollingHash(object):
    def __init__(self, S: str, MOD: int = 10 ** 9 + 7, BASE: int = 10 ** 5 + 7):
        self.S = S
        self.N = N = len(S)
        self.MOD = MOD
        self.BASE = BASE
        self.S_arr = [ord(x) for x in S]

        self.POWER = [1] * (N + 1)
        self.HASH  = [0] * (N + 1)
        p, h = 1, 0
        for i in range(N):
            self.POWER[i + 1] = p = (p * BASE) % MOD
            self.HASH[i + 1] = h = (h * BASE + self.S_arr[i]) % MOD

    def hash(self, l: int, r: int):
        # get hash for S[l:r]
        _hash = self.HASH[r] - (self.HASH[l] * self.POWER[r - l] % self.MOD)
        if _hash < 0:
            _hash += self.MOD
        return _hash

# 汎用的な二分探索のテンプレ
# check_func(x) = true となるxの最小値を探索する
# left : check_func(x) = falseとなるx
# right: check_func(x) = true となるx
# search_max: check_func(x) = true となるxの"最大値"を探索する場合はTrue
# check_func: answer <= x であればcheck_func(x) = true となるような関数
def binary_search(left: int, right: int, check_func, search_max:bool=False):
    # ok と ng のどちらが大きいかわからないことを考慮
    while abs(right - left) > 1:
        mid = (left + right) // 2
    
        if check_func(mid) ^ search_max:
            right = mid
            # print(left, right, mid, 't')
        else:
            left = mid
            # print(left, right, mid, 'f')

    return left if search_max else right

def main():
    N = int(input())
    S = input()

    rs = RollingHash(S)

    # 長さLの部分文字列同士が、範囲を重ねず同じ文字列となる場合はTrue,
    # そうでない場合はFalseを返す関数
    def isOK(L):
        if L == 0:
            return True
        hash_to_left = defaultdict(list)
        for i in range(N - L + 1):
            _hash = rs.hash(i, i + L)
            # hashが衝突しても文字列が完全に一致するか分からないので、
            # 衝突した場合は文字列が完全に一致するか調べ、かつ
            # 文字列同士がSの中で重なるような範囲にない場合はOKとする
            for j in hash_to_left[_hash]:
                if j+L <= i and S[i:i+L] == S[j:j+L]:
                    return True
            hash_to_left[_hash].append(i)

        return False
    # 範囲が重ならないことが条件にあるので、答えは最大でもN // 2（文字列の長さの半分）となる。
    # ただし、二分探索する上で絶対に答えとならない範囲を含めたいので、
    # 探索範囲としてはN // 2 + 1 と、+1しておく。
    ans = binary_search(0, N // 2 + 1, isOK, search_max=True)
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
	long long n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0 ; i < n; i++){
		cin >> a[i] >> b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	long long low, high;
	long long mid1, mid2;
	if(n % 2 == 0){
		mid1 = (n-1)/2;
		mid2 = n/2;
		low = min(a[mid1],b[mid1])+min(a[mid2],b[mid2]);
		high = max(a[mid1],b[mid1]) + max(a[mid2],b[mid2]);
	}else{
		mid1 = n / 2;
		low = min(a[mid1],b[mid1]);
		high = max(a[mid1],b[mid1]);
	}
	cout << high - low + 1 << "\n";
	return 0;
}

Measured memory_bytes: 4856
use std::io::stdin;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut n_m_x: Vec<i32> = Vec::with_capacity(3);
    for iter in buf.split_whitespace(){
        n_m_x.push(iter.parse::<i32>().unwrap());
    }

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let mut cost_array: Vec<i32> = Vec::new();
    for iter in buf.split_whitespace(){
        cost_array.push(iter.parse::<i32>().unwrap());
    }

    println!("{}", solve(n_m_x, cost_array));
}

fn solve(n_m_x: Vec<i32>, cost_array: Vec<i32>) -> i32 {
    let n = n_m_x[0];
    let x = n_m_x[2] as usize;

    let mut cost = vec![0; n as usize];
    for index in cost_array {
        cost[index as usize] = 1;
    }
    cost[x] = 0;

    let (left, right) = cost.split_at(x);
    min(left.iter().sum(), right.iter().sum())
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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


int dp[1<<26], INF;

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

    memset(dp, 0x7f, sizeof dp);
    INF = dp[0];

    int mask = 0;
    dp[0] = 0;
    string s; cin >> s;

    int ans;
    for (char c : s) {
        int d = c-'a';
        mask ^= 1<<d;

        ans = INF;
        ans = min(ans, 1 + dp[mask]);
        forn(e,26) ans = min(ans, 1 + dp[mask ^ (1<<e)]);
        dp[mask] = min(dp[mask], ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 262992
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    s = S()
    ols = len(s)
    ls = ols // 2
    ans = 0
    for i in range(ls):
        # print(s[i], s[ols-1-i])
        if s[i] != s[ols-1-i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.List

main = do
  getLine
  ass <- map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
  print (sports maxBound ass)

sports :: Int -> [[Int]] -> Int
sports r ass
  | any null ass' = min r nx
  | otherwise = sports (min r nx) ass'
  where
    ass' = map (\yys@(y:ys) -> if y==x then ys else delete x yys) ass
    (nx,x) = last . sort . map (\xs -> (length xs, head xs)) . group . sort . map head $ ass

Measured memory_bytes: 11644
int main() {
	long long int n, m, sosu[200005] = {}, count[200005] = {}, L[200005],R[200005];
	scanf("%lld", &n);

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

	for (int i = 2; i <= 100000; i++) {
		if (sosu[i] == 0) {
			for (int j = 2 * i; j <= 100000; j += i) {
				sosu[j] = -1;
			}
		}
	}

	for (int i = 2; i <= 100000; i++) {
		if (sosu[i] == 0&&sosu[(i+1)/2]==0&&i%2==1) {
			count[i] = count[i - 1] + 1;
         
		}else{
		count[i] = count[i - 1];
        }
	}
	for (int i = 0; i < n; i++) {
		printf("%lld\n",count[R[i]]-count[L[i]-1]);
	}
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,m;cin>>n>>m;
  string a[n+10],b[m+10];
  rep(i,0,n)cin>>a[i];
  rep(i,0,m)cin>>b[i];

  rep(i,0,n-m+(n==1||m==1)){
    rep(j,0,n-m+(n==1||m==1)){

      bool e=true;
      rep(k,0,m){
        rep(l,0,m){
          if(a[k+i][l+j]!=b[k][l]){e=false;break;}
        }
        if(!e)break;
      }
      if(e){out("Yes");return 0;}
    }
  }

  out("No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

int main() {
    int N;
    int a;
    double ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        ans += 1.0 / a;
    }

    ans = 1 / ans;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


signed main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    int N;
    cin >> N;

    vii a(N);
    rep(i, N){
        cin >> a[i].first;
        a[i].second = i + 1;
    } 

    vector<vli> dp(N + 5, vli(N + 5, 0));

    //dp[curr_index][how_many_in_left];

    sort(all(a), greater<pii>());

    repA(i, 1, N){
        repA(j, 0, i - 1){
            int L = j;
            int R = i - 1 - j;
            smax(dp[L + 1][R], dp[L][R] + abs(L + 1 - a[i - 1].second)*a[i - 1].first);
            R = j;
            L = i - 1 - j;
            smax(dp[L][R + 1], dp[L][R] + abs(N - R - a[i - 1].second)*a[i - 1].first);
        }
    }

    lli ans = 0;
    rep(i, N + 1){
        smax(ans, dp[i][N - i]);
    }

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

Measured memory_bytes: 34820
N = int(input())
T = [[0, 0]]
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append((t, x + y))

for i in range(N):
    dt = T[i+1][0] - T[i][0]
    dxy = abs(T[i+1][1] - T[i][1])

    if dt < dxy or dt % 2 != dxy % 2:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 22624
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
    cin >>n>>m;
    if(n%2==1){
    for(int i=1;i<=m;i++){
    cout<<i<<" "<<n+1-i<<endl;
    }
    }
    else{
    for(int i=1;i<=m&&i<=n/4;i++){
    cout<<i<<" "<<n+1-i<<endl;
    }
    if(m>n/4) {
        for(int i=n/4+1;i<=m;i++){
            cout<<i<<" "<<n-i<<endl;
        }
    }
    }



}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

ll Defent(vector<ll> &a, vector<ll> &b, int i, int j)
{
	ll res = 0;
	if (b[i] >= a[j])
	{
		b[i] = b[i] - a[j];
		res += a[j];
		a[j] = 0;
	}
	else
	{
		res += b[i];
		a[j] = a[j] - b[i];
		b[i] = 0;
	}

	return res;
}

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

	vector<ll> a(n + 1);
	vector<ll> b(n);

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

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

	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		res += Defent(a, b, i, i);

		if (b[i] > 0)
		{
			res += Defent(a, b, i, i + 1);
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
from collections import deque

move = [(1, 0), (-1, 0), (0, 1), (0, -1)]     # 動ける場所の候補

def debug(p, t):
    player = p
    debug_grid = list(list(grid[h]) for h in range(H))
    debug_grid[start[0]][start[1]] = "S"
    debug_grid[goal[0]][goal[1]] = "G"
    debug_grid[player[0]][player[1]] = "P"
    print("~~~~~~~~~ t = " + str(t+1) + "  ~~~~~~~~")
    for debug_h in range(H):
        print("".join(debug_grid[debug_h][debug_w] for debug_w in range(W)))

def search(start=(0,0), goal=(None,None), visit=set()):
    visit.add(start)                            # スタート地点はすでに訪れている
    next_set = deque([(start, 0)])              # 次に進む候補を列挙する。スタック（右から取り出す = pop）だと深さ優先になり、キュー（左から取り出す = popleft）だと幅優先になる
                                                # 第一成分はスタート地点、第二成分は時刻を表す。
    while next_set:                             # p = [] になったら止める
        p, t = next_set.popleft()               # 要素を消去して、消去した要素を出力
        h, w = p
        for dh, dw in move:                     # 頂点 p から進める経路の候補から一つ選ぶ
            q = (h + dh, w + dw)
            if q[0] < 0 or q[0] >= H or q[1] < 0 or q[1] >= W:
                continue
            if grid[q[0]][q[1]] == "#":         # 壁があったら進まない
                continue
            if q in visit:                      # 一度訪れていた場合は進まない
                continue
            #### (debug code) ######
            # debug(q, t)
            ########################
            if q == goal:                       # ゴールがあるならば、ここで判定
                return t + 1                    # 経路の長さは t + 1 で与えられる
            visit.add(q)                        # 頂点 q に一度訪れた事をメモ (for の前に書くと、ここで選ばれた q が最短であるはずなのに、違う経路でvisit = Trueを踏んでしまう可能性がある)
            next_set.append((q, t + 1))         # p から q へと移動。時刻を 1 進める
    return -1


H,W = map(int,input().split())                # 左上は(h,w)=(0,0)、右下は(h,w)=(H-1,W-1)

grid = []
cnt = 0

for h in range(H):
    grid.append(input())
    cnt += grid[-1].count(".")
start = (0,0)
goal = (H-1, W-1)
res = search(start,goal)
if res == -1:
    print(-1)
else:
    print(cnt - res - 1)

Measured memory_bytes: 9628
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

int card[5];
map<int, int> table;

int main() {
  while (1) {
    table.clear();
    if (scanf("%d", &card[0]) != 1) break;
    for (int i=1; i<5; i++) {
      getchar();
      scanf("%d", &card[i]);
    }

    sort(card, card+5);
    for (int i=0; i<5; i++) {
      table[card[i]]++;
    }
  
    int num_straight = 0;
    for (int i=0; i<4; i++) {
      num_straight += (card[i+1] == card[i] + 1);
    }
  
    if (table[card[0]] == 4 || table[card[4]] == 4) puts("four card");
    else if (table.size() == 2) puts("full house");
    else if (num_straight + (card[0] == 1 && card[4] == 13 && card[1] != 2) >= 4) puts("straight");
    else if (table[card[1]] == 3 || table[card[3]] == 3) puts("three card");
    else if (table[card[1]] + table[card[3]] == 4) puts("two pair");
    else if (table.size() < 5) puts("one pair");
    else puts("null");
  }
}

Measured memory_bytes: 2636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

char s[200];
int main(){
    FILE *fp=stdin;//fopen("input.txt","r");
    fscanf(fp,"%s",&s);
    int n = strlen(s);
    int x=-1,y=-1;
    rep(i,0,n) if(s[i]=='C') {x=i; break;}
    per(i,0,n) if(s[i]=='F') {y=i; break;}
    if((x==-1)||(y==-1)||(x>y)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.split.map(&:to_i).unshift("")

def max_heapify(arr, i)
    l = i * 2
    r = l + 1

    if (l < arr.size) && (arr[i] < arr[l])
        m = l
    else
        m = i
    end

    if (r < arr.size) && (arr[m] < arr[r])
        m = r
    end

    if m != i
        tmp = arr[i]; arr[i] = arr[m]; arr[m] = tmp
        max_heapify(arr, m)
    end

    arr
end

(n/2).downto(1) do |i|
    arr = max_heapify(arr, i)
end

puts arr.join(" ")



Measured memory_bytes: 51256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    ll ans=2*n;
    for (ll i=0;i<n;i++){
        ans=2*n;
        for (ll j=i;j<n;j++){
            if (s[j]==t[j-i]){
                ans--;
            }else{
                break;
            }
            if(j==n-1){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long a,b;
  char op;
  cin >> a >> op >> b;
  
  long long ans;
  if (op=='+'){
    ans = a+b;
  }
  else {
    ans =a-b;
  }
  
  cout << ans << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

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

  int s = n.size();
  if(n[s-1] == '2' || n[s-1] == '4' || n[s-1] == '5' || n[s-1] == '7' || n[s-1] == '9') cout << "hon" << endl;
  else if(n[s-1] == '0' || n[s-1] == '1' || n[s-1] == '6' || n[s-1] == '8') cout << "pon" << endl;
  else cout << "bon" << endl;

  return 0;
}

Measured memory_bytes: 3620
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    n, m, *hab = map(int, open(0).read().split())
    h = hab[:n]
    ab = hab[n:]
    ab = [[ab[2 * i] - 1, ab[2 * i + 1] - 1] for i in range(m)]

    ans_set = set(range(n))
    not_ans_set = set()
    # print(h)
    for a, b in ab:
        if h[a] >= h[b]:
            ans_set.discard(b)
            not_ans_set.add(b)
        if h[a] <= h[b]:
            ans_set.discard(a)
            not_ans_set.add(a)
        # print(a, b, ans_set, not_ans_set)

    ans = len(ans_set)
    print(ans)
    return(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46848
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 11 12:47:17 2019

@author: YudNK
"""

N, K = map(int,input().split())
D = [int(i) for i in input().split()]
M = min(N, K)
max = 0
for a in range(M + 1):
    l = (M+1)//2 - a
    if l < 0:
        l = 0
    for b in range(l,M - a + 1):
        C = []
        t = K - (a + b)
        C.extend(D[:a])
        C.extend(D[N - b:])
        C2 = [i for i in C if i >= 0]
        if len(C) - len(C2) < t:
            C = C2
        else:
            C.sort()
            C = C[t:]
        if sum(C) > max:
            max = sum(C)
print(max)

Measured memory_bytes: 3064
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int sum=0;
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                if(s.charAt(i)==s.charAt(j)){
                    sum++;
                }
            }
        }
        if(sum==8){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll n, d;



int main() {
	cin >> n >> d;
	if (n % (d * 2 + 1) == 0) cout << n / (d * 2 + 1) << endl;
	else cout << n / (d * 2 + 1) + 1 << endl; 






	return 0;
}



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

int main() {
  int w, h, n; cin >> w >> h >> n;
  int xl=0, xu=w, yl=0, yu=h;
  rep(i,n) {
    int x, y, a; cin >> x >> y >> a;
    if (a == 1) xl = max(xl,x);
    if (a == 2) xu = min(xu,x);
    if (a == 3) yl = max(yl,y);
    if (a == 4) yu = min(yu,y);
  }
  w = xu - xl;
  h = yu - yl;
  int ans = 0;
  if (w < 0 || h < 0) ans = 0;
  else ans = w * h;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
S = input()
ans  = "Yes"
l = len(S)
if l % 2 == 1:
    ans = "No"
for i in range(l):
    if i % 2 == 0:
        if S[i] !="h":
            ans ="No"
    else:
        if S[i] !="i":
            ans ="No"
print(ans)


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

int main()
{
  int S;
  cin >> S;
  int A=S/1000;
  int B=S/100%10;
  int C=S/10%10;
  int D=S%10;
  if(A+B+C+D==7) cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  else if(A+B+C-D==7) cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  else if(A+B-C+D==7) cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  else if(A-B+C+D==7) cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  else if(A+B-C-D==7) cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  else if(A-B-C+D==7) cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  else if(A-B+C-D==7) cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  else if(A-B-C-D==7) cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int max = 0;
    for(int i = 1; i < n; i++){
      int count = 0;
      boolean[] a = new boolean[26];
      for(int j = 0; j < i; j++){
        if(a[s.charAt(j) - 'a']){
          continue;
        }
        for(int k = i; k < n; k++){
          if(s.charAt(j) == s.charAt(k)){
            a[s.charAt(j) - 'a'] = true;
            count++;
            break;
          }
        }
      }
      max = Math.max(max, count);
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int n,k,ls;LL ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		while(ls<i*2)ls+=k;
		int val=ls-i,tot;tot=(n-val)/k+1;
		if(val*2%k)continue;if(n-val<0)continue;
		if(val!=i)ans+=1ll*tot*3+1ll*(tot-1)*tot/2*6;
		else ans+=1ll+1ll*(tot-1)*2*3+1ll*(tot-1)*(tot-2)/2*6;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Connection and Disconnection
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;

/* typedef */

typedef long long ll;
typedef ll mat[2][2];

/* global variables */

char s[MAX_N + 4];
mat as, bs, cs;

/* subroutines */

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

void addmat(const mat a, const mat b, mat c, bool eq) {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) c[i][j] = LINF;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
	if (! eq || j != k)
	  for (int l = 0; l < 2; l++)
	    setmin(c[i][l], a[i][j] + b[k][l]);
}

void printmat(mat a) {
  printf("%lld %lld\n", a[0][0], a[0][1]);
  printf("%lld %lld\n", a[1][0], a[1][1]);
}

/* main */

int main() {
  int k;
  scanf("%s%d", s, &k);
  int n = strlen(s);

  for (int st = 0; st < 2; st++) {
    int cdp[2], ndp[2];
    if (st == 0) cdp[0] = 0, cdp[1] = INF;
    else cdp[0] = INF, cdp[1] = 1;

    for (int i = 1; i < n; i++) {
      if (s[i - 1] == s[i]) ndp[0] = cdp[1];
      else ndp[0] = min(cdp[0], cdp[1]);
      ndp[1] = min(cdp[0], cdp[1]) + 1;
      cdp[0] = ndp[0], cdp[1] = ndp[1];
    }

    as[st][0] = cdp[0], as[st][1] = cdp[1];
  }
  //printmat(as);

  bool eq = (s[0] == s[n - 1]);
  memset(cs, 0, sizeof(mat));

  while (k > 0) {
    if (k & 1) {
      addmat(cs, as, bs, eq);
      memcpy(cs, bs, sizeof(mat));
    }
    addmat(as, as, bs, eq);
    memcpy(as, bs, sizeof(mat));
    k >>= 1;
  }
  //printmat(cs);

  printf("%lld\n", min(min(cs[0][0], cs[0][1]), min(cs[1][0], cs[1][1])));
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;

int main() {
    fastio();

    cin >> n;
    cout << "ABC" << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std;
vector<int>bin[20];
const int maxn=1000000;
int n,d[maxn+4]={0},v[20]={0},f[(1<<20)+4];
int main()
{
	int x,y,z;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d%d",&x,&y,&z);
		d[x]^=z,d[y]^=z;
	} 
	int s=0,res=0,t=0;
	for(int i=0;i<n;i++)v[d[i]]++;
	for(int i=1;i<=15;i++){
		res+=v[i]/2,v[i]%=2;
		if(v[i]){
			s|=(1<<(i-1));
			t++;
		}
	}
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=0;i<=(1<<15)-1;i++){
		int cnt=0;
		for(int j=0;j<=14;j++)
			if(i&(1<<j))cnt++;
		bin[cnt].push_back(i);
	}
	for(int p=2;p<=t;p++)
		for(int k=0;k<bin[p].size();k++){
			int i=bin[p][k];
			for(int u=0;u<=14;u++)
			if(i&(1<<u))
			for(int v=0;v<=14;v++)
				if(i&(1<<v)&&(u!=v)){
					int w=(u+1)^(v+1)-1; 
					if(u==w||v==w)continue;
					if(i&(1<<w))f[i]=min(f[i],f[i-(1<<w)-(1<<u)-(1<<v)]+2);
					else f[i]=min(f[i],f[i-(1<<u)-(1<<v)+(1<<w)]+1);
				}
		}
	printf("%d",f[s]+res);
	return 0;
}


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

int main(){
    int N;

    map < int, int> it;

    cin >> N;
    for(int i = 0; i < N; i++){
        int n;
        cin >> n;

        it[n] += 1;
    }

    string s = "YES";
    for(auto itt = it.begin(); itt != it.end(); itt++){
        if(itt->second >= 2){
            s = "NO";
        }
    }

    cout << s << endl;
    




}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


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

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,count=0,count2=0;
    cin>>n;
    vector<ll>p(n);
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    for(ll i=0;i<n;i++){
        if(i+1==p[i]){
            if(i!=n-1){
                swap(p[i],p[i+1]);
            }
            else{
                swap(p[i],p[i-1]);
            }
            count++;
        }
        
    }
    
    cout<<count<<endl;

    

}

Measured memory_bytes: 1024
n = input()
a = int(n[:2])
b = int(n[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
	print('AMBIGUOUS')
elif 1 <= a <= 12:
	print('MMYY')
elif 1 <= b <= 12:
	print('YYMM')
else:
	print('NA')

Measured memory_bytes: 3060
#include <stdio.h>
#include <memory.h>

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

typedef long double ld;

//FILE *in = freopen("input.txt", "r", stdin);

int n, m;
int data[100];
int maxl, maxd;

void input() {
	maxl = -1;
	maxd = -1;
	memset(data, 0, sizeof(data));
	rep(i, n) {
		int x;
		scanf("%d", &x);
		data[x / m]++;
		if (maxl < x/m) maxl = x/m;
		if (maxd < data[x/m]) maxd = data[x/m];
	}
	maxl++;
}

void process() {
	ld sum = 0.01;

	rep(i, maxl) {
		sum += ((ld)(maxl-i-1)/(maxl-1)) * ( (ld)data[i]/(ld)maxd );
	}

	printf("%Lf\n", sum);
}

int main() {
	while(true) {
		scanf("%d%d", &n, &m);
		if (!n) break;
		input();
		process();
	}
	return 0;
}

Measured memory_bytes: 1048
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int x,y;
            double z;
            String[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            double c = double.Parse(s[0]);
            double d = double.Parse(s[1]);

            x = a / b;
            y = a % b;
            z = c / d;
            Console.WriteLine(x+" "+y+" "+"{0:F5}", z);
        }
    }
}

Measured memory_bytes: 9316
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int l, r, d;
	cin >> l >> r >> d;
	cout << (r / d - (l - 1) / d) << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,W;
    cin>>n>>W;
     long long wt[n];
    long long val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    vector<vector<long long>> K(n+1,vector<long long>(W+1,0));
      for (int i = 0; i <= n; i++) { 
        for (int w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
              {
                    K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
              }
            else
                K[i][w] = K[i - 1][w]; 
        }
      }
   // cout<<maxval[n][w];
  cout<<K[n][W];
    return 0;
}

Measured memory_bytes: 83152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;

ll N,ans;
vector<ll> A;

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

	cin >> N;


	ll now = 11;
	while (A.size() < N) {
		bool flag = true;
		for (ll i = 2; i*i <= now; i++) {
			if (now%i == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			A.push_back(now);
		}
		now += 10;
	}
	FOR(i, 0, N)cout << A[i] << " ";
	cout << endl;



}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n;
	cin >> n;
	--n;
	vector<pair<pii,int>> edges;
	int mult = 1;
	fu(i,1,19){
		if(n && (n&1) == 0){edges.pb({{i,20},n*mult});--n;}
		if(n)edges.pb({{i,i+1},mult});
		edges.pb({{i,i+1},0});
		mult*=2;
		n/=2;
	}
	cout << "20 " << edges.size() << '\n';
	for(pair<pii,int> e: edges){
		cout << e.F.F << " " << e.F.S << " " << e.S << '\n';
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int r,c,a,tmp,tmp2,sum;
    tmp=0;
    tmp2=0;
    sum=0;
    cin>>r>>c;
    std::vector<vector<int>> vec(r+1,vector<int>(c+1));
    for (int i=0;i<r;i++) {
        for (int j=0;j<c;j++) {
            cin>>a;
            cout<<a<<" ";
            vec[i][j]=a;
            tmp=tmp+a;
        }
        cout<<tmp<<endl;
        tmp=0;
    }
    for (int k=0;k<c;k++) {
        for (int l=0;l<r;l++) {
            tmp2=tmp2+vec[l][k];
        }
        cout<<tmp2<<" ";
        sum=sum+tmp2;
        tmp2=0;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3172
# N = gets.chomp.to_i
N, M = gets.chomp.split.map(&:to_i)
# A = Array.new(N + 1, 0)  # 0 means no trap, 1 means existence of trap. 1-indexed

lights = []
M.times do |i|
  ks = gets.chomp.split.map(&:to_i)
  k = ks[0]
  s = ks[1..-1]
  light = 0
  s.each do |ss|
    ss -= 1 # 0-indexed
    light += 1 << ss
  end
  lights << light
end

# p lights

p = gets.chomp.split.map(&:to_i)

ans = 0
0.upto((1<<N)-1).each do |pattern|  # pattern is the bit representation of switch. 00..0 to 11..1
  # p "pattern: #{pattern}"
  
  ok = true
  0.upto(M-1).each do |i|
    # p "lights[#{i}]: #{lights[i]}"
    cnt = 0
    0.upto(N-1).each do |j|
      if ((lights[i] & (1 << j)) & (pattern & (1 << j))) > 0
        cnt += 1
      end
    end
    # p "cnt: #{cnt}"
    # p "p[#{i}]: #{p[i]}"
    if (cnt % 2) != p[i]
      ok = false
    end
  end
  if ok
    ans += 1
  end
end

p ans

Measured memory_bytes: 2044
#include <iostream>
#define maxn 100001
using namespace std;
int n,a[maxn],num[maxn]={0},m=-100000,m1,x=10000000,x1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		m=max(m,a[i]);
		x=min(x,a[i]);
	}
	x1=x;
	m1=m;
	for(int i=1;i<=n;i++)
	{
		num[a[i]+1]++;
		num[a[i]-1]++;
		num[a[i]]++;
	}
	m=-1;
	for(int i=x1-1;i<=m1-1;i++)
	{
		if(m<num[i+1]) m=num[i+1];
	}
	cout<<m;
	return 0;
}

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

int main() {
	int N;
	string S;
	cin>>N;
	cin>>S;
	int count=0;
	for(int i=0; i<=N-3; i++){
		if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')count++;
	}
	cout<<count++;
}

Measured memory_bytes: 256
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem: abc102A

#include <bits/stdc++.h>

using namespace std;

int A[101]={};

int main(){
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>A[i];
	}
	sort(A+1, A+N+1);
	cout<<A[N]-A[1]<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a;
  scanf("%d",&a);
  if(a==1)
  {
    printf("Hello World");
    return 0;
  }
  else
  {
    int b,c;
    scanf("%d %d",&b,&c);
    printf("%d\n",b+c);
    return 0;
  }
}


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

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, k = map(int, input().split())

d=[]
a=[]
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

nn=[i for i in range(1,n+1)]
for i in range(k):
    for j in range(d[i]):
        #print(a[i][j])
        if a[i][j] in nn:
            nn[a[i][j]-1]=0

#print(nn)
cnt=0
for i in range(len(nn)):
    if nn[i]!=0:
        cnt+=1
print(cnt)

Measured memory_bytes: 9244
import sys

input = sys.stdin.readline


def main():
    H, W, A, B = map(int, input().split())

    line = [0] * A + [1] * (W - A)
    X = "".join(map(str, line))
    ans = [""] * H
    for i in range(H):
        if i == B:
            X = "".join(map(lambda x: str(x ^ 1), line))
        ans[i] = X

    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 4084
# coding: utf-8
# コッホ曲線
import math
import decimal


def koch(depth, p1, p2):
    if depth == 0:
        return

    s = (decimal.Decimal((2 * p1[0] + 1 * p2[0])) / 3,
         decimal.Decimal((2 * p1[1] + 1 * p2[1])) / 3)
    t = (decimal.Decimal((1 * p1[0] + 2 * p2[0])) / 3,
         decimal.Decimal(((1 * p1[1] + 2 * p2[1]))) / 3)
    u = (
        (t[0] - s[0]) * decimal.Decimal(math.cos(math.radians(60))) -
        (t[1] - s[1]) * decimal.Decimal(math.sin(math.radians(60))) + s[0],
        (t[0] - s[0]) * decimal.Decimal(math.sin(math.radians(60))) +
        (t[1] - s[1]) * decimal.Decimal(math.cos(math.radians(60))) + s[1],
    )

    koch(depth - 1, p1, s)
    print(' '.join(map(lambda x: '{:.8f}'.format(x), s)))
    koch(depth - 1, s, u)
    print(' '.join(map(lambda x: '{:.8f}'.format(x), u)))
    koch(depth - 1, u, t)
    print(' '.join(map(lambda x: '{:.8f}'.format(x), t)))
    koch(depth - 1, t, p2)


if __name__ == "__main__":
    depth = int(input())
    p1 = (decimal.Decimal(0), decimal.Decimal(0))
    p2 = (decimal.Decimal(100), decimal.Decimal(0))
    print(' '.join(map(lambda x: '{:.8f}'.format(x), p1)))
    koch(depth, p1, p2)
    print(' '.join(map(lambda x: '{:.8f}'.format(x), p2)))



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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) {
        cin >> p[i];
        p[i]--;
    }
    int counter = 0;
    REP(i, N - 1) {
        if(p[i] == i) {
            swap(p[i], p[i + 1]);
            counter++;
        }
    }
    if(p[N - 1] == N - 1) {
        swap(p[N - 2], p[N - 1]);
        counter++;
    }
    cout << counter << endl;
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  string t;
  cin >> t;
  bool f = true;
  rep(i,s.length()) {
    if(s[i] != t[i]) f = false;
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc126/tasks/abc126_d

#include "algorithm"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

// f: node, s: length
V<VPL> edges;
VL colors;

void rec(ll u, ll p, ll c) {
  colors[u] = c;

  for (auto edge : edges[u]) {
    ll v = edge.first;
    ll l = edge.second;
    if (v == p) continue;

    ll nc = l % 2 == 0 ? c : 1 - c;
    rec(v, u, nc);
  }
}

void solve() {
  ll N;
  cin >> N;

  edges = V<VPL>(N, VPL());

  rep(i, N - 1) {
    ll u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    edges[u].emplace_back(v, w);
    edges[v].emplace_back(u, w);
  }

  // 一つの色を決め、再帰的に見て変が偶数であれば同じ色、奇数であれば違う色、としていくと、「任意の
  // 2 点間の距離が偶数 ⇒ 同じ色」「任意の 2 点間の距離が奇数 ⇒
  // 違う色」が実現され、後者の対偶より 「任意の 2 点が同じ色 ⇒
  // 距離が偶数」が実現されることとなる

  colors = VL(N, -1);

  rec(0, -1, 1);

  rep(i, N) { cout << colors[i] << endl; }
}

VL dists;
void rec_to_fill_dist(ll u, ll p, ll d) {
  dists[u] = d;

  for (auto edge : edges[u]) {
    ll v = edge.first;
    ll l = edge.second;

    if (v == p) continue;

    rec_to_fill_dist(v, u, d + l);
  }
}

void solve2() {
  ll N;
  cin >> N;

  edges = V<VPL>(N, VPL());

  rep(i, N - 1) {
    ll u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    edges[u].emplace_back(v, w);
    edges[v].emplace_back(u, w);
  }

  // 適当に根を決め、根からの距離を d[i] とすると、 2 点間の距離は d[i] + d[j] -
  // 2*d[LCA] よってこの偶奇は d[i] と d[j] の偶奇で決定される
  // ここで、 d[i]
  // が偶数なら根と同じ色、奇数なら根と違う色を埋めるとすると、「任意の 2
  // 点について同じ色」 ⇔ 「2 点の d の偶奇が等しい」 ⇔ 「2 点の距離が偶数」
  // となる

  colors = VL(N);
  colors[0] = 1;

  dists = VL(N);
  rec_to_fill_dist(0, -1, 0);

  repf(u, 1, N + 1) {
    colors[u] = dists[u] % 2 == 0 ? colors[0] : 1 - colors[0];
  }

  rep(u, N) { cout << colors[u] << endl; }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll x;
    cin>>x;
    double p;
    cin>>p;
    if(abs(p-100)<0.01){
        x++;
        cout << x/2 << endl;
        return 0;
    }
    p/=100.0;
    if(x%2==0){
        cout << (double)x/2.0/p << "\n";
    }
    else{
        x++;
        cout << (double)x/2.0/p << "\n";
    } 

    
}

Measured memory_bytes: 256