akhauriyash/Code-Regression huggingface dataset:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def f(r,c):
    d = c
    prod = 1
    div = 1
    divacc = 1
    for i in range(r-1):
        prod = (prod*d)%R
        divacc = (divacc*div)%R
        d += 1
        div += 1
    ret = (prod*modinv2(divacc,R))%R
    #ddprint("f r {} c {} ret {}".format(r,c,ret))
    return ret

r1,c1,r2,c2 = inm()
r1 += 1
c1 += 1
r2 += 1
c2 += 1
print((f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1))%R)


Measured memory_bytes: 39152
#include <stdio.h>
#include <string.h>
 
char s[101];
 
int main(void)
{
    
        scanf("%s", s); 
        int res =0; 
        int n = strlen(s);
  
  for(int i=0;i < n;i++){
        if(s[i] != s[n-1-i]){
                res++;
        }   
  }
  printf("%d\n", res/2);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
vector<long long> divisor(long long n)
{
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    vl a(n);
    rp(i, 0, n) cin >> a[i];
    sort(be(a));
    ll all[1111111];
    za(1111111, all);
    rp(i, 0, n - 1)
    {
        if (a[i] == a[i + 1])
            all[a[i]]++;
    }
    ll ans = 0;
    rp(i, 0, n)
    {
        bool sig = true;
        vl now = divisor(a[i]);
        rp(j, 0, now.size())
        {
            if (all[now[j]] > 0)
            {
                sig = false;
            }
        }
        all[a[i]]++;
        if (sig)
            ans++;
    }
    ce(ans);
}

Measured memory_bytes: 13544
from collections import deque

N,M = map(int,input().split())
E = [[] for _ in range(N)]

q = deque([0])
#辺の定義
#辺E(u,v)の重みがw
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  E[u].append(v)
  E[v].append(u)

#各頂点が白(0)か黒(1)か
color = [-1 for _ in range(N)]

#dfsで色を塗っていく
#頂点の数をN、辺の数をMとすると、O(N+M)で解ける

color[0] = 0
while q:
  u = q.popleft()
  for v in E[u]:
    if color[v] == -1:
      q.append(v)
      color[v] = u

#各頂点の色を出力
print('Yes')
for i in range(1,N):
  print(color[i]+1)



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

template<class T, class Upd>
struct SegmentTree {
    int n;
    Upd upd;
    vector<T> data;
    const T Lim;
    explicit SegmentTree(int n_, const T& Lim_)
        : upd(Upd()), Lim(Lim_) { init(n_);}
    void init(int n_) {
        for(n = 1; n < n_; n <<= 1);
        data.assign(2 * n - 1, Lim);
    }
    void update(int k, T a) {//0-indexed
        k += n - 1;
        data[k] = a;
        while(k > 0) {
            k = (k - 1) >> 1;
            data[k] = upd(data[k * 2 + 1], data[k * 2 + 2]); 
        }
    }
    T __query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return Lim;
        if(a <= l && r <= b) return data[k];
        else {
            T val_l = __query(a, b, k * 2 + 1, l, (l + r) >> 1);
            T val_r = __query(a, b, k * 2 + 2, (l + r) >> 1, r);
            return upd(val_l, val_r);
        }
    }
    T query(int a, int b) { //[a, b)
        return __query(a, b, 0, 0, n);
    }
};

template<class T>
struct updmin {
    T operator () (const T& l, const T& r) { return min(l, r);}
};

using i64 = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegmentTree<int, updmin<int>> seg(n, 2147483647);
    while(q--) {
        int k, u, v;
        cin >> k >> u >> v;
        if(k)
            cout << seg.query(u, v + 1) << endl;
        else
            seg.update(u, v);
    }
    return 0;
}

Measured memory_bytes: 3896
#include<iostream>
#include <algorithm>
using namespace std;
int dp[100001];

int main()
{
    int N;
	cin >> N;
    dp[0] = 0;
	for(int i = 1; i <= N; i++){
		int m = dp[i-1] + 1;
		for(int k = 6; k <= i;){
            m = min(m, 1 + dp[i-k]);
            k *= 6;
        }
		for(int k = 9; k <= i;){
            m = min(m, 1 + dp[i-k]);
            k *= 9;
        }
		dp[i] = m;
	}
	cout << dp[N] << "\n";
	return 0;
}


Measured memory_bytes: 640
import sys

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver(N,A):
    ans = 0

    for i,a in enumerate(A):
        #print(i,a)
        if (i+1) % 2 != 0 and a % 2 != 0:
            ans += 1

    print(ans)

def main():

    N = LI()
    A = LI()

    solver(N,A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000005];
int main() {
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	sort(a+1,a+1+n,greater<int>());
	long long ans=a[1] ;
	for(int i=2; i<=n/2; i++)
		ans+=2*a[i] ;
	if (n%2)
		ans+=a[(n+1)/2];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
{-# LANGUAGE BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = flip map [1..h] $ \i -> flip map [1..w] $ \j -> (j == 1 || odd i) && j /= w
    blue = map (map not) red
    po = zipWith (zipWith (||)) al
    printColor = putStrLn . unlines . map (map (\b -> if b then '#' else '.'))
  printColor (po red)
  printColor (po blue)


Measured memory_bytes: 41852
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long int
#define ld long double
#define FOR(i,a,b) for (auto i = (a); i != (b); i = (a)<(b)? i+1 : i-1)
#define pb push_back
#define mod 1000000007
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll su[n+1][3]={0};
    if(s[0]=='R')
            ++su[0][0];
        else if(s[0]=='B')
        ++su[0][1];
        else
            ++su[0][2];
    for(int x=1;x<n;x++)
    {    su[x][0]=su[x-1][0];
         su[x][1]=su[x-1][1];
         su[x][2]=su[x-1][2];
        if(s[x]=='R')
            ++su[x][0];
        else if(s[x]=='B')
        ++su[x][1];
        else
            ++su[x][2];
    }
    ll ans=su[n-1][1]*su[n-1][0]*su[n-1][2];
    for(int x=1;x<=n/2;x++)
    {
        for(int y=0;y<n;y++)
        {
            if(y+x<n && y+2*x<n)
            {
                if(s[y]!=s[x+y] && s[y]!=s[2*x+y] && s[y+x]!=s[y+2*x])
                    --ans;
            }
        }
    }
    cout<<ans;

}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,k;
int p[50];
signed main(){
	int i,j;
	cin>>k;
	for(i=0;i<50;i++)
		p[i]=k/50+49;
	for(i=0;i<k%50;i++)
		p[i]+=50-k%50+1;
	for(;i<50;i++)
		p[i]-=k%50;
	cout<<50<<endl;
	for(i=0;i<50;i++){
		if(i<49)
			cout<<p[i]<<" ";
		else
			cout<<p[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define LOCAL

#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 123456789LL;
const double PI = acos(-1);

int main() {
	IOS;
	llong n; cin >> n;
	llong a, b; cin >> a >> b;
	llong cyc = n / (a + b);
	llong left = min(a, n - cyc * (a + b));
	cout << cyc * a + left;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdint>

std::uint32_t some_of_integer(std::uint32_t n, std::uint32_t s, std::uint32_t sum = 0, std::uint32_t i = 0)
{
	std::uint32_t num_cmb = 0;
	if (n == 0) {
		if (sum + i <= s && s <= sum + 9) {
			++num_cmb;
		}
	}
	else {
		for (; i < 9; ++i) {
			num_cmb += some_of_integer(n - 1, s, sum + i, i + 1);
		}
	}
	return num_cmb;
}

int main()
{
	std::uint32_t n, s;
	for (std::cin >> n >> s; !(n == 0 && s == 0); std::cin >> n >> s) {
		std::cout << some_of_integer(n - 1, s) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1152
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
s=set()
for i in range(n-1):
    if a[n-1-i-1]>1+a[n-i-1]:
        print("No")
        exit()
    elif a[n-i-2]==a[n-i-1]+1:
        a[n-i-2]-=1
        s.add(i)
for i in range(n-1):
    if a[i]>a[i+1] and i in s:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 85228
using System;
using System.Linq;

namespace diverta2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] RGBN = CIN.IntArray();
            int R = RGBN[0];
            int G = RGBN[1];
            int B = RGBN[2];
            int N = RGBN[3];

            long ans = 0;
            for (int i = 0; i <= N; i++)
            {
                for (int j = 0; j <= N; j++)
                {
                    if (N < R * i + G * j)
                    {
                        continue;
                    }
                    if ((N - R * i - G * j) % B == 0)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

using namespace std;

stack <int> top_sort;

vector <int> adj[100001];

int dist[100001];

bool visit[100001];

void dfs(int u){
	
	int l = adj[u].size();
	
	for(int i=0; i<l; i+=1){
		
		int v = adj[u][i];
		
		if(visit[v] == 0){
			
			visit[v] = 1;
			
			dfs(v);
		}
	}
	
	top_sort.push(u);
	
	return;
}

int main(){
	
	ios_base::sync_with_stdio(0);
	
	cin.tie(0);
	
	cout.tie(0);
	
	int n,m;
	
	cin>>n>>m;
	
	for(int i=0; i<m; i+=1){
		
		int u,v;
		
		cin>>u>>v;
		
		adj[u].push_back(v);
	}
	
	for(int i=0; i<=n; i+=1){
		
		dist[i] = 0;
	}
	
	for(int i=1; i<=n; i+=1){
		
		if(visit[i] == 0){
			
			visit[i] = 1;
			
			dfs(i);
		}
	}
	
	while(!top_sort.empty()){
		
		int u = top_sort.top();
		
		top_sort.pop();
		
		int l = adj[u].size();
		
		for(int i=0; i<l; i+=1){
			
			int v = adj[u][i];
			
			dist[v] = max(dist[v],dist[u]+1);
		}
	}
	
	int ans = 0;
	
	for(int i=1; i<=n; i+=1){
		
		if(dist[i] >= ans){
			
			ans = dist[i];
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 8704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{    
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    int sum1 = A*10+B+C;
    int sum2 = A+B*10+C;
    int sum3 = A+B+C*10;

    if( sum1 >= sum2 && sum1 >= sum3 ){
        printf("%d\n",sum1);
        return 0;
    }
    if( sum2 >= sum3 && sum2 >= sum1 ){
        printf("%d\n",sum2);
        return 0;
    }
    if( sum3 >= sum2 && sum3 >= sum1 ){
        printf("%d\n",sum3);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

	int diff = b - a;

	int tower_a = 0;
	//int tower_b = 0;
	for (int i = 1; i <= diff; i++) {
		if (i < diff) {
			tower_a += i;
		}
		//tower_b += i;
	}

	//cout << tower_a << " " << tower_b << endl;
	cout << tower_a - a << endl;

}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll S;
    cin >> S;
    ll lm = 1e9;
    ll x = 0;
    if(S % lm != 0) x = (lm - S%lm);
    ll y = (S + x) / lm;
    cout << "0 0 " << lm << " 1 " << x << " " << y << endl; 
    return 0;
}

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

int64_t sum_b(int64_t b, vector<int64_t> vec)
{
  int64_t ret = 0;
  for (size_t i; i < vec.size(); ++i)
  {
    ret += abs(vec[i] - b);
  }
  return ret;
}

int main()
{
  int64_t n, ans = 10e9;
  cin >> n;
  vector<int64_t> A(n);
  for (int i = 0; i < n; ++i)
  {
    int64_t a;
    cin >> a;
    A[i] = a - (i + 1);
  }
  sort(A.begin(), A.end());
  int64_t mean = A[n / 2];
  ans = sum_b(mean, A);

  cout << ans << "\n";
}

Measured memory_bytes: 3456
//Md Fahad
// CSE 18

#include<bits/stdc++.h>


using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int fx[] = {+1,-1,+0,+0};                         // 4 X directions
const int fy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int fx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int fy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif


typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{
    //READ_IN;
    int a,b;
    cin >> a >> b;

    for(int i=1;i<=10000000;i++){

        int A = floor(double(i*0.08));
        int B = floor(double(i*0.1));

        if(A==a && B==b){
            int ans=i;
            cout << ans << endl;
            return 0;
        }


    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int A[10][10];
int N;
int b[100];

int main()
{
    rep(i, 0, 3)
    {
        rep(j, 0, 3)
        {
            cin >> A[i][j];
        }
    }
    cin >> N;
    rep(k, 0, N)
    {
        cin >> b[k];
        rep(i, 0, 3)
        {
            rep(j, 0, 3)
            {
                if (A[i][j] == b[k])
                {
                    A[i][j] = 0;
                }
            }
        }
    }
    rep(i, 0, 3)
    {
        if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

jdg = False
for i in a:
    if (i % 2 == 0 and (i % 5 != 0 and i % 3 != 0)):
        jdg = True
        break

print("DENIED" if jdg else "APPROVED")


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    bool hanntei=false;
    for(int i=0;i<N/2;++i)
    {
        if(S[i]!=S[i+N/2]) {
            hanntei=false;
            break;
        }
        else hanntei = true;
    }
    if(hanntei&&N%2==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int n, ans = 0; ld d;
	cin >> n >> d;
	while (n--) {
		ld x, y;
		cin >> x >> y;
		ld dis = (ld) sqrt(x*x+y*y);
		if (dis <= d) ++ans;
	}
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3684
from collections import defaultdict
n, k, *a = map(int, open(0).read().split())
d = defaultdict(int)

for b in a:
    d[b] += 1

k = len(d) - k
ans = 0
for v in sorted(d.values()):
    if k <= 0:
        break
    ans += v
    k -= 1
print(ans)


Measured memory_bytes: 37456
import sys
sys.setrecursionlimit(1000000)
n = int(input())
edges = []
nodes = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    edges.append({a: b, b: a, 'color': 0})
    nodes[a].append(i)
    nodes[b].append(i)
 
 
def paint_edge(edge, node, root=False):
    if not root:
        color = edges[edge]["color"]
        i = 1
        max_color = len(nodes[node])
        for n_edge in nodes[node]:
            if n_edge != edge:
                if i == color:
                    i += 1
                edges[n_edge]["color"] = i
                max_color = max(max_color, paint_edge(n_edge, edges[n_edge][node]))
                i += 1
        return max_color
 
    else:
        connect = len(nodes[node])
        max_color = connect
        for i in range(connect):
            n_edge = nodes[node][i]
            edges[n_edge]["color"] = i + 1
            max_color = max(max_color, paint_edge(n_edge, edges[n_edge][node]))
        return max_color
 
 
print(paint_edge(-1, 0, True))
for i in range(n - 1):
    print(edges[i]["color"])

Measured memory_bytes: 97476
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 128

static char ebuf[N];
static char *e;

static char obuf[N];
static char *o;

static
incl(ch)
{
  if (ch == '?') return ch;
  if (ch == 'Z') return 'A';
  return ch + 1;
}

static
decl(ch)
{
  if (ch == '?') return ch;
  if (ch == 'A') return 'Z';
  return ch - 1;
}

static void
concat3()
{
  if (*e == '+') {
    ++e; concat3();
    o[-1] = incl(o[-1]);
  } else if (*e == '-') {
    ++e; concat3();
    o[-1] = decl(o[-1]);
  } else {
    *(o++) = *(e++);
  }
}

static void
concat2()
{
  while (*e != '\0') {
    if (*e == '[') {
      char *p, *q;
      p = o;
      ++e; concat2();
      q = o - 1;
      for (; p < q; ++p, --q) {
        const char ch = *p;
        *p = *q;
        *q = ch;
      }
      continue ;
    } else if (*e == ']') {
      ++e;
      break ;
    }
    concat3();
  }
}

main()
{
  for (;;) {
    fgets(ebuf, N, stdin);
    *(strchr(ebuf, '\n')) = '\0';
    if (strcmp(ebuf, ".") == 0) break ;
    e = ebuf;
    o = obuf;
    concat2(); *o = '\0';
    for (o = obuf; *o != '\0'; ++o) {
      if (*o == '?') *o = 'A';
    }
    puts(obuf);
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 524
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

	vector<int> c(n - 1), s(n - 1), f(n - 1);
	for(int i = 0; i < n - 1; i++){
		cin >> c[i] >> s[i] >> f[i];
	}

	for(int i = 0; i < n; i++){
		if(i == n - 1){
			cout << 0 << endl;
			return 0;
		}
		int time = 0;
		time += s[i];
		time += c[i];
		for(int j = i + 1; j < n - 1; j++){
			if(time < s[j]){
				time = s[j];
			}
			if((time - s[j]) % f[j] != 0){
				time += f[j] - (time - s[j]) % f[j];
			}

			time += c[j];
		}

		cout << time << endl;
	}
}

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

struct bar{
  int a,b,c,d;

  void set1(int x, int y){
    a = x;b = y;
  }
  void set2(int z ,int w){
    c = z;d = w;
  }
};

bool than(const bar x,const bar y){
  return x.b < y.b;
}

int main(){
  int n,m,h,k;
  int s[1000],rs[1000],r[1000];
  int max,ans;
  int x,y;
  vector<bar> p;
  bar tmp;

  while(1){
    cin >> n >> m >> h >> k;
    if(!n && !m && !h && !k)break;

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

    p.clear();
    for(int i=0;i<m;i++){
      cin >> x >> y;
      tmp.set1(x,y);
      p.push_back(tmp);
    }

    sort(p.begin(),p.end(),than);

    for(int i=0;i<m;i++){
      p[i].set2(r[p[i].a-1],r[p[i].a]);
      swap(r[p[i].a-1],r[p[i].a]);
    }

    for(int i=0;i<n;i++)rs[r[i]] = s[i];


    ans = 0;
    for(int i=0;i<k;i++)ans += rs[i];

    max = 0;
    for(int i=0;i<m;i++){
      if(p[i].c<k && p[i].d>=k){
	if(rs[p[i].c] > rs[p[i].d]){
	  if(max < rs[p[i].c] - rs[p[i].d])max = rs[p[i].c] - rs[p[i].d];
	}
      }
      if(p[i].d<k && p[i].c>=k){
	if(rs[p[i].d] > rs[p[i].c]){
	  if(max < rs[p[i].d] - rs[p[i].c])max = rs[p[i].d] - rs[p[i].c];
	}
      }
    }

    cout << ans - max <<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
int a,b;
cin >> a >> b;
if(a < 10 && b < 10) cout << a*b << endl;
else cout << -1 << endl;

return 0;
}

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

#define MAX_SIZE 1500000

using namespace std;


int main(){
	int dansu,kansu,shelf[20],book[100],min_size,left,right,m,dansu_index;

	while(true){
		scanf("%d %d",&dansu,&kansu);
		if(dansu == 0 && kansu == 0)break;

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

		min_size = MAX_SIZE;
		left = 0,right = MAX_SIZE;
		m = (left+right)/2;

		while(left < right){

			shelf[0] = m;
			dansu_index = 0;
			for(int i = 0; i < kansu && dansu_index < dansu;){
				if(shelf[dansu_index] >= book[i]){
					shelf[dansu_index] -= book[i];
					i++;
				}else{
					dansu_index++;
					if(dansu_index < dansu)shelf[dansu_index] = m;
				}
			}

			if(dansu_index == dansu){
				left = m + 1;
				m = (left + right)/2;
			}else{
				right = right - 1;
				m = (left + right)/2;
			}
		}

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

	}

    return 0;
}

Measured memory_bytes: 2564
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct a list;

struct a{
  int key;
  list *next, *prev;
};

list *head, *tail;

void  insert(int key){
  list *new;
    new = (list*)malloc(sizeof(list));
    new->key = key;
    new->next = head->next;
    new->prev = head;
    head->next = new;
    new->next->prev = new;
}

void delete(int key){
  list *t = head->next, *prev = head;
    while(t != tail && t->key != key) {
        prev = t;
        t = t->next;
    }

    if (t != tail) {
        prev->next = t->next;
        t->next->prev = prev;
        free(t);
    }
}

void deleteFirst(){
  list *first = head->next;
    head->next = first->next;
    first->next->prev = head;
    free(first);
}

void deleteLast() {
    list *last = tail->prev;
    tail->prev = last->prev;
    last->prev->next = tail;
    free(last);
}

  int main(void){
    int m, i, n;
    char c[15];
    scanf("%d", &n);

    head = (list*)malloc(sizeof(list));
    tail = (list*)malloc(sizeof(list));
    head->key = tail->key = -1;
    head->next = tail;
    tail->prev = head;
    head->prev = tail->next = NULL;

    for(i = 0; i < n; i++){
      scanf("%s", c);
      if(strcmp(c, "insert") == 0){
        scanf("%d", &m);
        insert(m);
      }else if(strcmp(c, "delete") == 0){
        scanf("%d", &m);
        delete(m);
      }else if(strcmp(c, "deleteFirst") == 0){
        deleteFirst();
      }else if(strcmp(c, "deleteLast") == 0){
        deleteLast();
      }
    }

    list *t = head->next;
    while(t != tail) {
        printf("%d%c", t->key, ((t->next == tail) ? '\n' : ' '));
        t = t->next;
    }

    return 0;
}


Measured memory_bytes: 32980
include Math
a,b,theta = gets.chomp.split(" ").map{|x| x.to_f}
r = PI * theta / 180.0 
c = (a**2 + b**2 - 2*a*b*cos(r))**0.5
h = b*sin(r)
s = a*h/2
printf("%f\n",s)
printf("%f\n",a+b+c)
printf("%f\n",h)


Measured memory_bytes: 6952
import java.util.Scanner;

//Surf Smelt Fishing Contest
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ra = 101, rb = -1;
		while(n--!=0){
			int a = sc.nextInt(), b = sc.nextInt();
			if(rb < b || rb==b && a < ra){
				ra = a;
				rb = b;
			}
		}
		System.out.println(ra+" "+rb);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17300
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] num = new int[100002];
    String[] S = sc.nextLine().split(" ");
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(S[i]);
      num[n]++;
      num[n+1]++;
      num[n+2]++;
    }
    
    int ans = 0;
    for(int i = 0; i < 100002; i++){
      ans = num[i] > ans ? num[i] : ans;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 48732
import numpy as np

a,b,x=list(map(int,input().split()))
area=x/a

if area<=a*b/2.0:
    h=2*area/b
    print(90-np.degrees(np.arctan(h/b)))
else:
    h=2*b-2*area/a
    print(np.degrees(np.arctan(h/a)))

Measured memory_bytes: 14264
S = input()
if int(S[:2]) > 12:
    if 13 > int(S[2:]) > 0:
        print("YYMM")
    else:
        print("NA")
elif 0 < int(S[:2]) < 13:#12xx~01xx
    if int(S[2:]) > 12:
        print("MMYY")
    elif 0 < int(S[2:]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:#00xx
    if 0 < int(S[2:]) <13:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

vector<vector<int>> Edge(100005);
vector<bool> seen(100005,false);
vector<int> ans(100005);
/*
void bfs(int start,int parent){
    seen.at(start) = true;
    for(int V : Edge.at(start)){
        if(seen.at(V)) continue;
        ans.at(V) = parent;
    }
    bfs(V,start);
}*/

int main() {
    int N,M;cin >> N >> M;
    for(int i = 0;i<M;i++){
        int a,b;cin >> a >> b;
        Edge.at(a).push_back(b);
        Edge.at(b).push_back(a);
    }
    queue<P> Q;
    Q.push(make_pair(1,-1));
    seen.at(1) = true;
    while(!Q.empty()){
        P p = Q.front();Q.pop();
        int A = p.first;int root = p.second;
        
        for(int V : Edge.at(A)){
            if(seen.at(V)) continue;
            seen.at(V) = true;
            ans.at(V) = A;
            Q.push(make_pair(V,A));
        }
    }
    cout << "Yes" << endl;
    for(int i = 2;i<=N;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 10484
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    };
    println!("{}{}{}",s[0],s.len()-2,s[s.len()-1]);
}


Measured memory_bytes: 4352
s = gets.chomp.split("").map{|c|c=="R"}

ans = Array.new(s.size, 0)
prev = 0
ch = 1
(1...s.size).each{|i|
  if s[i]
    ch += 1
    prev = i
  else
    ans[i] += (ch)/2
    ans[i-1] += (ch+1)/2
    ch = 0
    bit = (prev-i)&1
    ans[prev+bit] += 1
  end
}

puts ans*" "


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

using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//const ll inf=(ll)1e16;
ll a[100],n,s;
vector <ll> v;

bool check(ll b)
{
	ll t=n;
	ll sz=0;
	while(t>0)
	{
		a[sz]=t%b;
		t/=b;
		sz++;
	}
	ll res=0;
	for(ll i=0;i<sz;i++)
		res+=a[i];
	return res==s;
}

int main()
{
	//ans=inf;
	cin >> n >> s;
	for(ll i=2;i<=330000;i++)
		if(check(i))
		{
			cout << i;
			return 0;
		}
	if(n==s)
	{
		cout << n+1;
		return 0;
	}
	//cout << check(n) << endl;
	for(ll i=1;i*i<=n-s;i++)
		if((n-s)%i==0)
		{
			v.pb(i);
			v.pb((n-s)/i);
		}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
		if(check(v[i]+1))
		{
			cout << v[i]+1;
			return 0;
		}
	cout << -1;
	return 0;
}

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

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

  int32_t a[n];
  int32_t b = 0;
  for (int32_t i = 0; i < n; i++) {
    cin >> a[i];
    b += a[i] % 2;
    b %= 2;
  }
  if (b) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>

#define MAX_N   100
#define MAX_W   10000

using namespace std;

int n, W;
int w[MAX_N], v[MAX_N];

int dp[MAX_N + 1][MAX_W + 1];

int rec(int i, int j)
{
  if (dp[i][j] >= 0) {
    // すでに調べたことがあるならばその結果を再利用
    return dp[i][j];
  }
  int res;
  if (i == n) {
    res = 0;
  } else if (j < w[i]) {
    res = rec(i + 1, j);
  } else {
    res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
  }
  // 結果をテーブルに記憶する
  return dp[i][j] = res;
}

void solve()
{
  // まだ調べられていないことを表す-1でメモ化テーブルを初期化
  memset(dp, -1, sizeof(dp));
  printf("%d\n", rec(0, W));
}

int main(void)
{
  int i;
  cin >> n >> W;

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

  solve();

  return 0;
}

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

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

int main()
{
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    cout << GCD(a, b) << " " << LCM(a, b) << endl;
  }
}



Measured memory_bytes: 3156
#include <iostream>
#include <string>

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
      if (S[i] == '+') ans++;
      else ans--;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n//2+2) for i in range(n)] #dp[i][j]=i番目までに裏がj枚出る確率
dp[0][0]=p[0]
dp[0][1]=1-p[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]*p[i]
    for j in range(1,n//2+1):
        dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i])
ans=0
for i in range(n//2+1):
    ans+=dp[-1][i]
print(ans)

Measured memory_bytes: 147080
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC105 B - Cakes and Donuts
// 2020.06.09

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  REP(i, 26){
    REP(j, 16){
      if(i*4 + j*7 == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

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

min_cost = 10**11
for i in range(2**n):
    height = 0
    k_count = 0
    cost = 0
    for j in range(n):
        if (i>>j) & 1:
            if an[j] <= height:
                cost += height - an[j] + 1
                height += 1
            else:
                height = an[j]
            k_count += 1
        height = max(height, an[j])
    if k_count >= k:
        min_cost = min(min_cost, cost)

print(min_cost)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using ll = long long;

int f(vector<bool> is, int i, vector<int>& time){
    if(i == 24){
        int last = -1;
        int res = 10000;
        for(int i = 0;i <= 23;i++){
            // cout<<is[i]<<" ";
            if(is[i] && last == -1){
                last = i;
            }else if(is[i]){
                res = min(res, i - last);
                // cout<<"!"<<i-last<<" ";
                last = i;
            }
        }
        if(last != -1)
        res = min(24 - last, res);
        // cout<<": "<<res<<endl;
        return res;
    }
    if(time[min(i,24-i)] == 0){
        is[i] = false;
        return f(is,i+1,time);
    }else if(time[min(i,24-i)] >= 2 || (i == 12 && time[i] == 1) || (i == 0 && time[i] == 1)){
        is[i] = true;
        return f(is,i+1,time);
    }else if(i > 12){
        is[i] = !is[24-i];
        return f(is,i+1,time);
    }else{
        is[i] = true;
        int x = f(is,i+1,time);
        is[i] = false;
        int y = f(is,i+1,time);
        return max(x,y);
    }

}

int main(){
    vector<int> time(13,0);
    int N;cin>>N;
    time[0]++;
    for(int i = 0;i < N;i++){
        int c;cin>>c;
        time[c]++;
        if(time[c]>=3){
            cout<<0<<endl;
            return 0;
        }
    }
    if(time[12] >= 2 || time[0]>=2){
        cout<<0<<endl;
        return 0;
    }
    int res = 0;
    
    vector<bool> is(24,false);
    cout<<f(is, 0, time)<<endl;
    

}

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


int main(){
  int N,M;
  std::cin>>N>>M;
  std::vector<int> A(M);
  for (int i = 0; i < N; i++){
    int K;
    std::cin>>K;
    for (int j = 0; j < K; j++){
      int temp;
      std::cin>>temp;
      A[temp-1] += 1;
    }
  }
  int sum = 0;
  for (int i = 0; i < M; i++){
    if(A[i] == N){
      sum += 1;
    }
  }
  std::cout<<sum<<std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
   int r,c;
   cin>>r>>c;
   vv(op,r+1,c+1);
   rep(i,r){
       rep(j,c){
           cin>>op.at(i).at(j);
       }
   }

 rep(i,r){
       rep(j,c){
           op.at(i).at(c)+=op.at(i).at(j);
       }
   }

rep(i,c+1){
       rep(j,r){
           op.at(r).at(i)+=op.at(j).at(i);
       }
   }


  rep(i,r+1){
       rep(j,c+1){
           cout<<op.at(i).at(j);
           if(j!=c)cout<<" ";
       }
   cout<<endl;
   }
}


Measured memory_bytes: 3172
s=input()
 
sl=len(s)+1
l=[0]*sl
 
for i in range(sl-1):
  if s[i]=="<":
    l[i+1]=l[i]+1
    
for i in range(sl-2,-1,-1):
  if s[i]==">":
    l[i]=max(l[i+1]+1, l[i])
    
print(sum(l))

Measured memory_bytes: 29024
S = input()

ans = 0

def dfs(s, sum_, n):
    if n == len(S)-1:
        return int(s) + sum_

    return dfs(s+S[n+1], sum_, n+1) + dfs(S[n+1], sum_+int(s), n+1)

print(dfs(S[0], 0, 0))

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int a,b,n,r;
	int cnt, i;
	while( scanf("%d %d %d", &a, &b, &n)!=EOF ){
		r = 0;
		for(i=0; i<=n; i++) {
			if (i>0) r += a/b;
			a = ( a - (a/b)*b )*10;
		}
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include<atcoder/all>

using namespace std;

using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }

using mint = modint998244353;
struct S {
	ll n0, n1, cnt;
};

using F = bool;

S op(S l, S r) { return S{l.n0+r.n0,l.n1+r.n1,l.cnt+r.cnt+l.n1*r.n0}; }
S e() { return S{ 0,0,0 }; }
S mapping(F l, S r) {
	if (l) {
		return { r.n1,r.n0,r.n1*r.n0 - r.cnt };
	}
	else {
		return r;
	}
}
F composition(F l, F r) {
	return l^r;
}
F id() {
	return 0;
}

void solve() {
	int n, q; cin >> n >> q;
	vector<S>a(n);
	REP(i, n) {
		int x; cin >> x;
		if (x == 0) {
			a[i] = { 1,0,0 };
		}
		else a[i] = { 0,1,0 };
	}
	lazy_segtree<S, op, e, F, mapping, composition, id>seg(a);
	REP(i, q) {
		int t; cin >> t;
		if (t == 1) {
			int l, r; cin >> l >> r;
			l--;
			seg.apply(l, r, 1);
		}
		else {
			int l, r; cin >> l >> r;
			l--;
			print(seg.prod(l, r).cnt);
		}
	}

}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



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

typedef long long ll;

int n;
int t[20];
vector<int> v[20];

void makePattern(int idx, int cnt, int bit){
  if(cnt > 6) return;
  if(idx == n){
    if(cnt == 6){
      v[n].push_back(bit);
    }
    return;
  }

  makePattern(idx + 1, cnt, bit);
  makePattern(idx + 1, cnt + 1, bit | (1 << idx));
}

bool check(ll x, ll y, ll z){
  return x + y > z && x + z > y && y + z > x;
}

void solve(){
  double ans = 0;

  for(int i = 0; i < v[n].size(); i++){
    vector<int> a;

    for(int j = 0; j < n; j++){
      if(v[n][i] & (1 << j)){
        a.push_back(t[j]);
      }
    }

    sort(a.begin(), a.end());

    do{
      ll A = a[0];
      ll B = a[1];
      ll C = a[2];
      ll X = a[3];
      ll Y = a[4];
      ll Z = a[5];

      if(!check(A, B, C) || !check(A, Y, Z) ||
         !check(B, X, Z) || !check(C, Y, Z)){
        continue;
      }

      A *= A;
      B *= B;
      C *= C;
      X *= X;
      Y *= Y;
      Z *= Z;

      ll V =
        A * X * (B + C - A + Y + Z - X) +
        B * Y * (C + A - B + Z + X - Y) +
        C * Z * (A + B - C + X + Y - Z) -
        A * Y * Z -
        B * Z * X -
        C * X * Y -
        A * B * C;

      ans = max(ans, sqrt((double)V / 144));
    }while(next_permutation(a.begin(), a.end()));
  }

  printf("%.6f\n", ans);
}

int main(){
  for(n = 6; n <= 15; n++){
    makePattern(0, 0, 0);
  }

  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    solve();
  }
}

Measured memory_bytes: 1052
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    turn = []
    east = 0
    total = S.count("E")

    for i in range(N):
        left = i - east
        s = S[i]
        if s == "E":
            east += 1
        right = total - east
        turn.append(left + right)

    print(min(turn))


if __name__ == "__main__":
    main()


Measured memory_bytes: 15520