akhauriyash/Code-Regression huggingface dataset:
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;


int solve(int i, int k)
{
	int cnt = 0;
	while (i < k){
		i = i * 2;
		cnt++;
	}
	return cnt ;
}

LL pows(LL a, LL b)
{
	if (b == 0)
		return 1;
	LL temp = pows(a, b / 2);
	temp = temp * temp;
	if (b % 2 == 1)
		temp = temp * a;
	return temp;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    LL n, k; cin >> n >> k;

    LD ans = 0;
    LD temp = (long double)1/(long double)n;
    for (int i = 1; i <= n; i++){
    	if (i >= k){
    		ans += (long double)1/(long double)n;
    		continue;
    	}
    	int check = solve(i,k);
    //	cout << i << " " << check << endl;
    	ans  += temp * (long double)1 / (long double)pows(2, check);
    }

    cout << fixed << setprecision(15) << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define F first
#define S second

#define YES "YES"
#define NO "NO"

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

int r, c, n;
pii p[200000], q[200000];
int v[100000];

bool bd(int a, int b) {
	return a == 0 || a == r || b == 0 || b == c;
}

int main(int argc, char **argv) {
	cin >> r >> c >> n;
	int m = 0;
	REP(i, n) {
		p[m].S = p[m + 1].S = i;
		cin >> p[m].F.F >> p[m].F.S >> p[m + 1].F.F >> p[m + 1].F.S;
		if (bd(p[m].F.F, p[m].F.S) && bd(p[m + 1].F.F, p[m + 1].F.S)) m += 2;
	}
	sort(p, p + m);

	int k = 0;
	REP(i, m) if (p[i].F.F == 0 && p[i].F.S != 0) v[k++] = p[i].S;
	REP(i, m) if (p[i].F.S == c && p[i].F.F != 0) v[k++] = p[i].S;
	REP(i, m) if (p[m - 1 - i].F.F == r && p[m - 1 - i].F.S != c) v[k++] = p[m - 1 - i].S;
	REP(i, m) if (p[m - 1 - i].F.S == 0 && p[m - 1 - i].F.F != r) v[k++] = p[m - 1 - i].S;

	stack<int> sk;
	set<int> st;
	REP(i, m) {
		if (st.count(v[i]) == 0) {
			sk.push(v[i]);
			st.insert(v[i]);
		}
		else {
			if (sk.top() != v[i]) {
				cout << NO << endl;
				return 0;
			}
			sk.pop();
		}
	}

	cout << YES << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int X, A, B; cin >> X >> A >> B;

	cout << (X-A)%B << endl;	

	return 0;

}


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

using namespace std;
using ll = long long;

#define MAX(a,b) (((a)>(b))?(a):(b))

int main()
{
  ll N, c1=0, c2=0, c4=0;
  cin >> N;
  for(ll i=0; i<N; ++i){
    ll a;
    cin >> a;
    if(a%2==1) ++c1;
    if(a%2==0&&a%4!=0) ++c2;
    if(a%4==0) ++c4;
  }
  if(c1<=c4||(c1==c4+1&&c2==0)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3608
import numpy as np,math,itertools
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(n)]
p=[]
for i in range(n):
    if ct[i][1]<=t:
        p+=[ct[i][0]]
if p!=[]:print(min(p))
else:print("TLE")

Measured memory_bytes: 21268
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n,m;
int a[N];
int fa[N];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
vector <int> v[N];
vector <int> va,vb;
int main(){
	n=read(),m=read();
	For(i,1,n)
		a[i]=read();
	if (m==n-1)
		return puts("0"),0;
	For(i,1,n)
		fa[i]=i;
	For(i,1,m){
		int x=read()+1,y=read()+1;
		x=getf(x),y=getf(y);
		fa[x]=y;
	}
	For(i,1,n)
		v[getf(i)].pb(a[i]);
	For(i,1,n){
		if (v[i].empty())
			continue;
		sort(v[i].begin(),v[i].end());
		reverse(v[i].begin(),v[i].end());
		vb.pb(v[i].back());
		v[i].pop_back();
		while (!v[i].empty())
			va.pb(v[i].back()),v[i].pop_back();
	}
	sort(va.begin(),va.end());
	int cnt=(int)vb.size()-2;
	if (va.size()<cnt)
		return puts("Impossible"),0;
	LL ans=0;
	For(i,0,(int)vb.size()-1)
		ans+=vb[i];
	For(i,0,cnt-1)
		ans+=va[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7168
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner io = new Scanner(System.in);
        long a = io.nextInt(), b = io.nextInt();
        System.out.println((a * b) / gcd(a, b));
    }
    public static long gcd(long a, long b) {
        return a == 0 ? b : gcd(b % a, a);
    }
}


Measured memory_bytes: 23380
#include<stdio.h>
int main()
{
  int n, rt[200000], i, j, ri = 0, sum = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &rt[i]);
    }
  ri = rt[0];
  sum = rt[1] - ri;
  for(i = 1; i < n; i++)
    {
      if(sum < rt[i] - ri) sum = rt[i] -ri;
      if(ri > rt[i]) ri = rt[i];
    }
  printf("%d\n", sum);
}



Measured memory_bytes: 2576
#include <stdio.h>

int min(int a, int b)
{
    return (b > a ? a : b);
}

int main(void)
{
    int i, j, k;
    int n;
    int dist[101][101];
    int t, from, to;
    
    scanf("%d", &n);
    
        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                dist[i][j] = 1000000;
            }
            dist[i][i] = 0;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &from);
            scanf("%d", &k);
            
            for (j = 0; j < k; j++){
                scanf("%d", &to);
                dist[from][to] = 1;
            }
        }
        
        for (k = 1; k <= n; k++){
            for (i = 1; i <= n; i++){
                for (j = 1; j <= n; j++){
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        
        scanf("%d", &n);
        
        for (i = 0; i < n; i++){
            scanf("%d%d%d", &from, &to, &j);
            
            if (dist[from][to] < j){
                printf("%d\n", dist[from][to] + 1);
            }
            else {
                printf("NA\n");
            }
        }
        
        return (0);
}

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

int main()
{
    int n, tmp, a1, a2, a3, a4;
    cin >> n;
    a4 = n / 1000;
    tmp = n - a4 * 1000;
    a3 = tmp / 100;
    tmp = tmp - a3 * 100;
    a2 = tmp / 10;
    a1 = tmp - a2 * 10;
    if (a4 == a3 && a3 == a2)
    {
        cout << "Yes" << endl;
    }
    else if (a3 == a2 && a2 == a1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int h, w, n, sr, sc;
string s, t;

// L, R, U, D
int moves[2][4], threshold[4], lim[4];
map<char, int> m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    
    m['L'] = 0;
    m['R'] = 1;
    m['U'] = 2;
    m['D'] = 3;
    
    threshold[0] = sc;
    threshold[1] = w - sc + 1;
    threshold[2] = sr;
    threshold[3] = h - sr + 1;

    for (int i = 0; i < 4; ++i) lim[i] = threshold[i];
    // cout << '\n';
    for (int i = 0; i < n; ++i) {
        int dir = m[s[i]];
        ++moves[0][dir];
        if (dir == 0) ++lim[1];
        if (dir == 1) ++lim[0];
        if (dir == 2) ++lim[3];
        if (dir == 3) ++lim[2];

        // for (int j = 0; j < 2; ++j) {
            // for (int k = 0; k < 4; ++k) {
                // cout << moves[j][k] << ' ';
            // }
            // cout << '\n';
        // }
        bool out = false;
        if (moves[0][0] - moves[1][1] >= threshold[0]) out = true;
        if (moves[0][1] - moves[1][0] >= threshold[1]) out = true;
        if (moves[0][2] - moves[1][3] >= threshold[2]) out = true;
        if (moves[0][3] - moves[1][2] >= threshold[3]) out = true;

        if (out) {
            cout << "NO";
            return 0;
        }
        dir = m[t[i]];
        if (moves[1][dir] + 1 < lim[dir])
            ++moves[1][dir];
    }
    cout << "YES";
}


Measured memory_bytes: 3996
N, M = map(int, input().split())

ks = []
for m in range(M):
    ks.append(list(map(int, input().split())))

p = list(map(int, input().split()))

def calc(n,aaa):
    if n == N:
        abc = 0
        for i in range(M):
            ans = 0
            for j in range(1,ks[i][0]+1):
                ans += int(aaa[ks[i][j]-1])
            if p[i] == ans % 2:
                abc += 1

        if abc == M:
            return 1
        else:
            return 0

    ans1 = calc(n+1,aaa + '0')
    ans2 = calc(n+1,aaa + '1')

    return ans1 + ans2

print(calc(0,''))

Measured memory_bytes: 42224
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <complex>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define rtr(c, i) for (typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); --i)
#define contains(c, x) ((c).find(x) != (c).end())
#define Contains(c, x) (find(all(c), x) != (c).end())
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, (n))
#define To_String to_string< char,std::char_traits<char>,std::allocator<char> >

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	while (cin >> n, n) {
		map<int, int> a;
		rep(i, n) { int k; cin >> k; a[k]++; }
		int res = -1;
		tr(a, i) { if (2 * i->second > n) res = i->first; }
		if (res >= 0)
			cout << res << endl;
		else
			cout << "NO COLOR" << endl;
	}
	return 0;
}

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

const int N = 2e5 + 7;
int arr[N], pref[N];
map<int, int> lol;
int n, k;

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

  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    arr[i] %= k;
    if (arr[i] == 0) {
      arr[i] = k - 1;
    } else {
      arr[i]--;
    }
  }
  for (int i = 1; i <= n; ++i) {
    pref[i] = pref[i - 1] + arr[i - 1];
    if (pref[i] >= k) {
      pref[i] -= k;
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (i >= k - 1) {
      lol[pref[i - k + 1]]--;
    }
    lol[pref[i]]++;
    res += lol[pref[i + 1]];
  }
  cout << res << "\n";

  return 0;
}



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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K-1)=='A') S.at(K-1)='a';
  else if (S.at(K-1)=='B') S.at(K-1)='b';
  else S.at(K-1)='c';
  cout <<S << endl;
  return 0;
}


Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    string str;
    int n;
    n = 0;
    char c;
    while(std::cin >> str){
        if(n != 0){
            std::cout << " ";
        }
        n = str.length();
        for(int i=0; i<n; ++i){
            c = str[i];
            if (c - 'a' >= 0 && c - 'z' <= 0){
                c = 'A' + (c - 'a');
                std::cout << c;
            }
            else if (c - 'A' >= 0 && c - 'Z' <= 0){
                c = 'a' + (c - 'A');
                std::cout << c;
            }
            else {
                std::cout << c;
            }
        }
    }
    std::cout << endl;
    return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e17
#define mx 998244353
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll int n,m,k,i,j,cnt,ans,sum;
    cin>>n>>m>>k;
    ll int A[n+1],B[m+1];
    vector<ll int> a,b;
    vector<ll int>::iterator it;
    a.push_back(0);
    b.push_back(0);
    for(i=1;i<=n;i++){
        cin>>A[i];
        a.push_back(a[i-1]+A[i]);
    }
    for(i=1;i<=m;i++){
        cin>>B[i];
        b.push_back(b[i-1]+B[i]);
    }
    ans=-1;
    for(i=0;i<=n;i++){
        //cout<<"i="<<i<<" "<<"a[i]="<<a[i]<<endl;
        //cout<<"k-a[i]="<<k-a[i]<<endl;
        it=lower_bound(b.begin(),b.end(),k-a[i]);
        if(binary_search(b.begin(),b.end(),k-a[i]))
        j=it-b.begin();
        else j=it-b.begin()-1;
        //cout<<"*it="<<*it<<endl;
        //cout<<"j="<<j<<endl;
        //cout<<"i+j="<<i+j<<endl;
        if(a[i]+b[j]<=k)
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10548
N = int(input())
l = []
edge = [[] for i in range(N)]
idx = {}
for i in range(N-1):
	a,b = map(int,input().split())
	a -= 1
	b -= 1
	edge[a].append([b,None])
	edge[b].append([a,None])
	l.append((a,b))
	idx[(a,b)] = len(edge[a]) - 1

search = [(0,0)]
searched = [False for i in range(N)]
col_max = 1
while len(search) > 0:
	s = search.pop()
	n = s[0]
	c = s[1]
	searched[n] = True
	color = 1
	for e in edge[n]:
		if not searched[e[0]]:
			if color == c:
				color += 1
			e[1] = color
			col_max = max(col_max, color)
			search.append((e[0], color))
			color += 1
print(col_max)
for e in l:
	a,b = e[0], e[1]
	print(edge[a][idx[(a,b)]][1])

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

typedef long long lint;

lint s[200010],ans=0;
int x[200010],n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		s[i]=s[i-1]+a;
		x[i]=x[i-1]^a;
	}
	int end=1;
	for(int start=1;start<=n;start++){
		for(;(s[start]-s[end-1])!=(x[start]^x[end-1]);end++);
		ans+=start-end+1;
	}
	printf("%lld",ans);
	return 0;
}

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

void binarySearch( int, int*, int );

int C = 0;

int main()
{
  int i, j, n, q, *S, *T;


  scanf("%d", &n);
  S = malloc( n * sizeof(int));
  for( i=0; i<n; i++ ) scanf("%d", &S[i]);

  scanf("%d", &q);
  T = malloc( q * sizeof(int));
  for( i=0; i<q; i++ )
    {
      scanf("%d", &T[i]);

      binarySearch( n, S, T[i]);
    }

  printf("%d\n", C);
  
  return 0;
}


void binarySearch( int n, int *S, int key)
{
  int left, right, mid;
  left = 0;
  right = n;

  while( left < right )
    {
      mid = (left + right)/2;
      if( key == S[mid] )
	{
	  C++;
	  return;
	}
      if( key > S[mid] )
	left = mid + 1;
      else if( key < S[mid] )
	right = mid;
    }
}
  

  

  



Measured memory_bytes: 2372
import math
lst=[s for s in input()]
lst.append('R')
n=len(lst)
p=[0]*n
now='R'
count=0
for i in range(n):
    if now == lst[i]:
        count+=1
    else:
        
        if now=='R':
            p[i-1]=count
            count=1
        elif now=='L':
            p[i-count]=count
            count=1
        now=lst[i]
p.pop()
newp=[0]*(n-1)
flag=[0]*(n-1)
for j in range(len(p)):

    if (flag[j]==0) and (p[j]!=0): 
        newp[j]=math.ceil(p[j]/2)+p[j+1]//2
        newp[j+1]=math.ceil(p[j+1]/2)+p[j]//2
        flag[j]=1
        flag[j+1]=1
print(*newp)





Measured memory_bytes: 61012
#include<stdio.h>
int parent(int);
int left(int);
int right(int);


int main(){
  int n, i, x;
  int a[250];
  scanf("%d", &n);

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

  /*if(n==1)printf("node 1: key = %d, \n",a[1]);
  else  if(n==2)printf("node 1: key = %d, left key = %d, \n",a[1],a[2]);
 else{
 printf("node 1: key = %d, left key = %d, right key = %d, \n",a[1],a[2],a[3]);*/
    
 for ( i = 1; i <= n; i++ ){
   printf("node %d: key = %d, ",i,a[i]);
   if(i!=1) printf("parent key = %d, ",a[parent(i)]);
   if(n>=2*i){
     printf("left key = %d, ",a[left(i)]);
   }
   if(n>=2*i+1){
     printf("right key = %d, ",a[right(i)]);
   }
   printf("\n");
   
 }
 return 0;
}

int parent(a){
  return a/2;
}
int left(a){
  return 2*a;
}
int right(a){
  return 2*a+1;
}


Measured memory_bytes: 2044
#include <cstdio>
#include <numeric>
#include <iostream>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  while(true){
    vector<int> n(6);
    REP(i,6) cin >> n[i];

    if(accumulate(n.begin(), n.end(), 0) == 0) break;

    int num = 100000001;
    REP(i,3) num = min(num, n[i]+n[3+i]);

    int ans = 0;

    REP(i,min(num+1, 3)){
      int tmp = i;
      REP(j,3){
	int a = n[j];
	int b = n[3+j];
	tmp += (a + b - i) / 3;
      }
      //printf("%d: %d\n", i, tmp);
      ans = max(ans, tmp);
    }

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

Measured memory_bytes: 908
/*ex9_1 hightierra*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 1000

// スタックの定義
typedef struct{
    int size;
    int count;
    char data[SIZE];
    char *top;
}stack;

// 初期化
void initialize(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[0]);
}

// pushとpopの定義
void push(stack *stk, char pushdata){
    if(stk->count >= stk->size){
        printf("Error: Stack overflow.");
        exit(1);
    }else{
        *(stk->top) = pushdata;
        stk->top++;
        stk->count++;
    }
}

char pop(stack *stk){
    char popdata;
    if(stk->count <= 0){
        printf("Error: Stack underflow.");
        exit(1);
    }else{
        popdata = *(stk->top);
        stk->top--;
        stk->count--;
        return popdata;
    }
}


int main(void){
    stack input;
    char key[SIZE],popdata;
    int i;
    
    initialize(&input);

    // 入力データをkeyにいれる
    scanf("%s",key);
    
    // 入力データ分ループし、popかpush
    for(i=0; i<strlen(key); i++){
        if(key[i] != 'B'){
            push(&input,key[i]);
        }else if(key[i] == 'B' && (input.count)>0){
            popdata = pop(&input);
        }
    }
    for(i=0; i<input.count; i++){
        printf("%c",input.data[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define PLI pair<ll,int>
#define PII pair<int, int>
#define X first
#define Y second
#define MP make_pair
#define PLL pair<ll, ll>
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const double eps = 1e-6;
using namespace std;

int Read()
{
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll ReadL()
{
    ll x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
char s[100];
char t[20][20]=
{
    "KIHBR",
    "AKIHBR",
    "KIHABR",
    "KIHBAR",
    "KIHBRA",
    "AKIHABR",
    "AKIHBAR",
    "AKIHBRA",
    "KIHABAR",
    "KIHABRA",
    "KIHBARA",
    "AKIHABAR",
    "AKIHABRA",
    "AKIHBARA",
    "KIHABARA",
    "AKIHABARA"
};

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    while(scanf("%s", s) != EOF)
    {
        bool f = 0;
        for(int i = 0; i < 16; i ++)
        if(strcmp(s, t[i]) == 0) {f = 1; break; }
        printf("%s\n", f ? "YES" : "NO");
    }
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    double a, b;
    cin >> a >> b;
    FOR(i, 1, 2000)
    {
        if(floor(i * 0.08) == a && floor(i * 0.1) == b)
        {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
s = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):  # all comb
    for j in range(M):  # k loop
        c = 0
        for k in range(N):  # s loop
            if ((i >> k) & 1) and (k + 1) in s[j][1:]:
                c += 1
        if c % 2 != p[j]:
            break
        elif j == M - 1:
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct{ll a,b;} P;
ll f(P p,P q){return p.a>q.a;}
ll n,m,i,s=0;
P x[100007];
main(){
	ios::sync_with_stdio(0); cin.tie(0);
	for(cin>>n>>m;i<n;) cin>>x[i].a>>x[i++].b;
	sort(x,x+n,f);
	for(;m*i--;) s+=min(x[i].b,m)*x[i].a, m-=min(m,x[i].b);
	cout<<s;
}


Measured memory_bytes: 5208
s = list(input())
count_abc = 0
a_count = 0
i = 0
while(i < len(s) - 1):
    if s[i] == "A":
        a_count += 1
    elif s[i] == "B" and s[i+1] == "C":
        if(i < len(s)-2):
            i += 1
        count_abc += a_count
    else:
        a_count = 0
    i += 1
print(count_abc)

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

#define BUF 1024

int main(void) {
  int k;
  char str[BUF];
  memset(str, '\0', BUF);
  scanf("%d %s", &k, str);
  if (strlen(str) <= k) printf("%s\n", str);
  else {
    char print_str[BUF];
    memset(print_str, '\0', BUF);
    strncpy(print_str, str, k);
    printf("%s...\n", print_str);
  }

  return 0;
}


Measured memory_bytes: 1684
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;


int main(){
    int n,m,pi;
    cin >> n >> m;
    int correct = 0, penalty = 0;
    int done[n] = {};
    string si;
    for (int i=0; i<m;i++){
        cin >> pi >> si;
        if ((si == "AC") && (done[pi-1] != -1)) {
            penalty += done[pi-1];
            done[pi-1] = -1;
            correct++;
        } else if ((si == "WA") && done[pi-1] != -1) {
            done[pi-1]++;
        } 
    }
    cout << correct << " " << penalty << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    vector<vector<int>> A;
    int H, W;
    cin>>H>>W;
    
    rep(i, H){
        string a;
        cin>>a;
        vector<int> A_;
        rep(j, W){
            if(a[j]=='.'){
                A_.push_back(10000);
            }
            else
            {
                A_.push_back(0);
            }
        }
        A.push_back(A_);
    }

    REP(i, 1, H){
        REP(j, 0, W){
            A[i][j] = min(A[i][j], A[i-1][j] + 1);
        }
    }

    for(int i = H-2; i >= 0; --i){
        REP(j, 0, W){
            A[i][j] = min(A[i][j], A[i+1][j] + 1);
        }
    }

    REP(i, 0, H){
        REP(j, 1, W){
            A[i][j] = min(A[i][j], A[i][j-1] + 1);
        }
    }

    REP(i, 0, H){
        for(int j = W-2; j >= 0; --j){
            A[i][j] = min(A[i][j], A[i][j+1] + 1);
        }
    }

    int x=0;

    REP(i, 0, H){
        REP(j, 0, W){
            x = max(A[i][j], x);
        }
    }

    cout<<x<<endl;
    return 0;
    
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if(A.back() == B.front() && B.back() == C.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

// Pair ...
type Pair struct {
	first  int
	second int
}

func min(x, y Pair) Pair {
	if x.first < y.first {
		return x
	}
	if x.first == y.first && x.second < y.second {
		return x
	}
	return y
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	x := readInt()
	n := readInt()

	p := make([]int, 102)
	for i := 0; i < n; i++ {
		j := readInt()
		p[j] = 1
	}

	ans := Pair{999999, -1}
	for i := 0; i <= 101; i++ {
		if p[i] == 1 {
			continue
		}
		dif := abs(x - i)
		ans = min(ans, Pair{dif, i})
	}
	fmt.Println(ans.second)
	return
}


Measured memory_bytes: 1772
nmc = input().split()
n, m, c = int(nmc[0]), int(nmc[1]), int(nmc[2])
ba_li = []
for i in range(n + 1):
    ba_add = input().split()
    ba_li.append(ba_add)
b_li = ba_li[0]
count = 0
for i in range(n):
    sum = 0
    for j in range(m):
        sum += int(ba_li[i + 1][j]) * int(b_li[j])
    if sum > -c:
        count += 1
print(count)


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

main(){
  int N;
  cin >> N;
  char A[N],B[N],C[N];
  cin >> A >> B >> C;
  int ans=0;
  for(int ii=0;ii<N;ii++){
    if(A[ii]==B[ii] && C[ii]!=A[ii])ans++;//1
    else if(A[ii]==C[ii] && B[ii]!=A[ii])ans++;//1
    else if(B[ii]==C[ii] && A[ii]!=B[ii])ans++;//1
    else if(A[ii]!=B[ii] && C[ii]!=A[ii] && B[ii]!=C[ii])ans+=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
class DICE {
private:
	int label[6];
public:
	//?????????????????????
	DICE();
	void RotateLabel(char DIRECTION);
	void SpinLabel(void);
	int ReturnTopLabel(void);
	int ReturnRightLabel(int Top, int Front);
};
DICE::DICE() {
	for (unsigned int i = 0; i < 6; ++i) {
		std::cin >> label[i];
	}
}
void DICE::RotateLabel(char DIRECTION) {
	if (DIRECTION == 'N') {
		std::swap(label[5], label[4]);
		std::swap(label[4], label[0]);
		std::swap(label[1], label[0]);
	}
	if (DIRECTION == 'S') {
		std::swap(label[1], label[0]);
		std::swap(label[4], label[0]);
		std::swap(label[5], label[4]);


	}
	if (DIRECTION == 'E') {
		std::swap(label[5], label[2]);
		std::swap(label[2], label[0]);
		std::swap(label[0], label[3]);


	}
	if (DIRECTION == 'W') {
		std::swap(label[0], label[3]);
		std::swap(label[2], label[0]);
		std::swap(label[5], label[2]);
	}
}
void DICE::SpinLabel(void) {
	std::swap(label[1], label[2]);
	std::swap(label[1], label[3]);
	std::swap(label[3], label[4]);
}
int DICE::ReturnTopLabel(void) {
	return label[0];
}
int DICE::ReturnRightLabel(int Top, int Front) {
	if (label[2] == Top || label[3] == Top) {
		RotateLabel('E');
	}
	while (label[0] != Top) {
		RotateLabel('N');
	}
	while (label[1] != Front) {
		SpinLabel();
	}
	return label[2];
}
int main(void) {
	DICE dice1 = DICE();
	int NumberQuestion;
	std::cin >> NumberQuestion;
	for (int i = 0; i < NumberQuestion; ++i) {
		int LabelTop, LabelFront;
		std::cin >> LabelTop >> LabelFront;
		std::cout << dice1.ReturnRightLabel(LabelTop, LabelFront) << std::endl;
	}
//system("pause");
	return 0;
}

Measured memory_bytes: 3092
s = gets.chomp

if s.length % 2 == 1
  puts 'No'
else
  n = s.length / 2
  flag = true
  s.length.times do |i|
    next if i.odd?

    next if s[i] + s[i+1] == 'hi'
    flag = false

  end

  if flag
    puts 'Yes'
  else
    puts 'No'
  end
end


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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;

template<typename T>
class dsu
{
	public:
		vector<T> par,sz;
		ll n;
		dsu(ll n_)
		{
			n=n_;
			par.resize(n+1);
			sz.resize(n+1);
			for(int i=0;i<=n;i++)
			{
				par[i]=i;
				sz[i]=1;
			}
		}
		T getp(T x)
		{
			while(par[x]!=x)
			{
				par[x]=par[par[x]];
				x=par[x];
			}
			return x;
		}
		void merge(T a,T b)
		{
			T p1=getp(a),p2=getp(b);
			if(p1==p2)
			{
				return;
			}
			if(sz[p2]>sz[p1])
			{
				swap(p1,p2);
			}
			par[p2]=p1;
			sz[p1]+=sz[p2];
			sz[p2]=0;
		}
};


signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        int n,m;
        cin>>n>>m;
        dsu<int> obj(n);
        f(i,1,m)
        {
            int u,v;
            cin>>u>>v;
            obj.merge(u,v);
        }
        set<int> ms;
        f(i,1,n)
        {
            ms.insert(obj.getp(i));
        }
        cout<<sz(ms)-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 8324
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
a.sort(reverse=True)
ans = a[0]
if (n-1)%2 == 1:
    for i in range(n//2-1):
        ans += a[i+1]*2
else:
    for i in range(n//2-1):
        ans += a[i+1]*2
    ans += a[n//2]
print(ans)

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

int main(){
    int a=0,b=0,i;
    string s;
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s.at(i) == '0'){a++;}
        if(s.at(i) == '1'){b++;}
    }
    cout << s.size()-max(a,b) + min(a,b) << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename TYPE> TYPE gcd(TYPE a, TYPE b){return (a % b)? gcd(b, a % b) : b;}
template<typename TYPE> TYPE lcm(TYPE a, TYPE b){return a * b / gcd(a, b);}

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

    pair<int, int> p[n]; //(b, a)
    REP(i,n){
        int a, b;
        cin >> a >> b;
        p[i].second = a;
        p[i].first = b;
    }

    sort(p, p+n);

    ll sum = 0;
    bool ok = true;
    REP(i,n){
        sum += p[i].second;

        if(sum > p[i].first){
            ok = false;
            break;
        }
    }

    cout << (ok? "Yes" : "No") << endl;


}

int main(void){
    solve_131D();
    //cout << solve_145D() << endl;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &a : A) {
    cin >> a;
  }
  int64_t res = A[0] - 1, cur = 2;
  for (int i = 1; i < N; i++) {
    if (cur == A[i]) cur++;
    if (cur < A[i]) {
      res += (A[i] - 1) / cur;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3732
#include <cstdlib>
#include <iostream>
#include <stack>
 
using namespace std;
 
char expr[10000];
 
int main() {
    stack<long> S;
    cin.getline(expr, 10000);
    char* s = expr;
    for (;;) {
        if (*s == '\0') { break; }
        if ('0' <= *s && *s <= '9') {
            S.push(strtol(s, &s, 10));
            if (*s == ' ') { ++s; }
        } else {
            long b = S.top(); S.pop();
            long a = S.top(); S.pop();
            long r = 0;
            switch (*s) {
                case '+':
                    r = a + b;
                    break;
                case '-':
                    r = a - b;
                    break;
                case '*':
                    r = a * b;
                    break;
            }
            ++s;
            if (*s == ' ') { ++s; }
            S.push(r);
        }
    }
    cout << S.top() << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  vector<int> imos(100009, 0); // 難易度i未満の問題数
  rep(i, n) imos[d[i] + 1]++;
  for (int i = 1; i < 100009; ++i) imos[i] += imos[i-1];

  int ans = 0;
  for (int k = 0; k < 100009; ++k) if (imos[k] == n / 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define ll long long
//#define pw (ll)pow 
#define MAX 1000005
#define MOD (ll)1e9+7
using namespace std;

int main()	
{
	int n;
	cin >> n;
	ll x,p=1;
	ll a[n];
	for(int i=0; i<n; i++)	cin >> a[i];
	sort(a,a+n);
	for(int i=0; i<n; i++)	{
		x=a[i];
		if(x==0) {cout << 0 << endl; return 0;}
		if(log10(x)+log10(p)<=18.0 && p*x<=(ll)1e18)	p*=x;

		else {
			cout << -1 << endl;
			return 0;
		}
	}
	if(log10(p)>18 || p>(ll)1e18)	cout << -1 << endl;
	else cout << p << endl;
	return 0;
}

Measured memory_bytes: 4568
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010
ll p;
ll f(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)ans=(ans*a)%p;
		a=(a*a)%p;b/=2;
	}
	return ans;
}
int main(){
	IOS;
	tihs;
	
	ll n;
	cin>>n>>p;
	string s;cin>>s;
	ll cnt[10010]={0};
	ll ans = 0;
	if(p==2 or p==5){
		rep(i,0,n){
			ll t = s[i]-'0';
			if(t%p==0) ans += (i+1);
		}
		cout<<ans;
		return 0;
	}
	ll b[n];
	ll val = 0,ct = 0;
	for(ll i=n-1;i>=0;--i){
		ll t = s[i]-'0';
		val = 0;
		val += (f(10,ct)*t)%p;
		val %= p;
		if(i+1<n)(val += b[i+1])%=p;
		b[i]=val;
		ct++;
		cnt[b[i]%p]++;
	}
	cnt[0]++;
	rep(i,0,p){
		ans += (cnt[i]*(cnt[i]-1))/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2196
<?php

fscanf(STDIN, "%d %d", $switch,$lamp);


for($i=0;$i<$lamp;++$i){
    $str_lamp = trim(fgets(STDIN));
    $lamp_map[$i] = explode(" ",$str_lamp);

}

$str_binary = trim(fgets(STDIN));
$binary = explode(" ",$str_binary);
$ans =[];
for($i=0;$i<$lamp;++$i){
    $checker = [];
    for($k=1;$k<=$lamp_map[$i][0];$k++){
        $checker[$lamp_map[$i][$k]] = 1;
    }
    for($j=0;$j<(pow(2,$switch));++$j){
        $hoge =0;
        foreach($checker as $number => $one){

            if($j & ((pow(2,$number-1)) )){
                $hoge++;
            }
        }
        if($hoge % 2 == $binary[$i]){
            @$ans[$j]++;
        }
    }
}
$count = 0;
foreach($ans as $value){
    if($value == $lamp){
        $count++;
    }
}
echo $count;

Measured memory_bytes: 4728
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	boolean[] p = new boolean[50100];
	void run(){
		p[0]=p[1]=true;
		for(int i=2;i<50100;i++){
			if(p[i]) continue;
			for(int j=i*2;j<50100;j += i){
				p[j] = true;
			}
		}
		for(;sc.hasNextInt();){
			int n=sc.nextInt();
			int i,j; 
			for(i = n-1;p[i];i--);
			for(j = n+1;p[j];j++);
			System.out.println(i+" "+j);
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();	
	}
}

Measured memory_bytes: 11000
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int a[n+1];a[0]=0;
	int b[n+1];b[0]=0;
	int i;
	for(i=1;i<n+1;i++){
		scanf("%d",&a[i]);
		b[i] = 0;
	}
	//iについて何個同じ数字が連結しているかを保存する。
	int j = 1;
	int connect = 1;
	for(i=1;i<n+1;i++){
		while( a[i] ==a[i+1]){
			i++;
			connect ++;
		}
		b[j] = connect;
		j++;
		connect = 1;
	}
	int ans =0;
	for(i=0;i<n+1;i++){
		if(b[i] >=2){
			ans += b[i]/2;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main (){
  int n;
  int num;
  int i;
  int min = 1000001;
  int max = -1000001;
  long long sum = 0;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d",&num);
    sum += num;
    if(min > num){
      min = num;
    }
    if(max < num){
      max = num;
    }
  }
  printf("%d %d %lld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2140
S = input().strip()
T = input().strip()

def count(i):
	c = 0
	for j in range(len(T)):
		if i + j >= len(S):
			return len(T)
		if T[j] != S[i + j]:
			c += 1
	return c

topvalue = len(T)
for i in range(len(S)):
	c = count(i)
	if topvalue > c:
		topvalue = c
print(topvalue)


Measured memory_bytes: 9052
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N;
vector<pair<pii, int>> data;

signed main()
{
	cin >> N;
	data.resize(N);

	rep(i, N) {
		int x,y,h;cin>>x>>y>>h;
		data[i]=make_pair(pii(x,y),h);
	}

	rep(x, 101) rep(y, 101) {
		int H = -1;
		rep(i, N) {
			// h_i = H - |x - x_i| - |y - y_i|
			if (data[i].scd > 0) {
				H = data[i].scd + abs(data[i].fst.fst - x) + abs(data[i].fst.scd - y);
			}
		}

		bool ok = true;

		rep(i, N) {
			if (data[i].scd != max(H - abs(data[i].fst.fst - x) - abs(data[i].fst.scd - y), 0ll)) {
				ok = false;
			}
		}

		if (ok) {
			printf("%lld %lld %lld\n", x, y, H);
			return 0;
		}
	}
}



Measured memory_bytes: 256
# coding: utf-8
import sys
     
n = int(raw_input())

list_num = [int(num) for num in raw_input().split(' ')]

cost = 0
for num in list_num:
    cost += (100-num)**2
 
for ans in range(-100, 100):
    cost_tmp = 0
    for num in list_num:
        cost_tmp += (ans-num)**2
    if cost > cost_tmp:
        cost = cost_tmp

print cost

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, l;
    cin >> n >> l;
    vector<int> t(n + 1);
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        t[i] = l + i - 1;
        sum += t[i];
    }
    int ret = INF, mi = INF;
    for (int i = 1; i <= n; i++)
    {
        int s = 0;
        for (int j = 1; j <= n; j++)
        {
            if (i == j)
                continue;
            s += t[j];
        }
        if (abs(sum - s) <= mi)
        {
            mi = min(mi, abs(sum - s));
            ret = s;
        }
    }
    cout << ret << endl;
}


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

using namespace std;

string ans = "0n0n0n0=7";
int in[4];

int f(int d, int now){
	if(d == 3){
		if(now == 7)return 1;
		return 0;
	}

	ans[d*2 + 1] = '+';
	int res = f(d + 1, now + in[d + 1]);
	if(res == 1)return 1;

	ans[d*2 + 1] = '-';
	res = f(d + 1, now - in[d + 1]);
	if(res == 1)return 1;

	return 0;
}

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

	for(int i = 0; i < 4; i++){
		in[i] = str[i] - '0';
		ans[i*2] = str[i];
	}

	f(0, in[0]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }


int main(){
    int n,p;
    in(n,p);
    vector<int> vec(n);
    ll odd=0,even=0;
    rep(i,n){
        cin>>vec[i];
        if(vec[i]%2==0)even++;
        else odd++;
    }
    ll ans=(ll)intpow((ll)2,even);
    if(odd>=1){
        ans*=(ll)intpow((ll)2,odd-1);
    }
    if(odd==0&&p==1){
        ans=0;
    }
    out(ans);
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  bool can = false;
  vector<int> ans(N);
  for(int n = 0; n < 4; n++){
    bitset<2> bit(n);
    ans[0]=bit[0];
    ans[1]=bit[1];
    for(int i = 1; i < N-1; i++){
      if(ans[i]==0){
        if(S[i]=='o') ans[i+1]=ans[i-1];
        if(S[i]=='x') ans[i+1]=1-ans[i-1];
      }
      if(ans[i]==1){
        if(S[i]=='o') ans[i+1]=1-ans[i-1];
        if(S[i]=='x') ans[i+1]=ans[i-1];
      }
    }
    int t,s;
    if(ans[0]==0){
      if(S[0]=='o') t=ans[1];
      else t=1-ans[1];
    }
    if(ans[0]==1){
      if(S[0]=='o') t=1-ans[1];
      else t=ans[1];
    }
    if(ans[N-1]==0) {
      if(S[N-1]=='o') s=ans[N-2];
      if(S[N-1]=='x') s=1-ans[N-2];
    }
    if(ans[N-1]==1) {
      if(S[N-1]=='o') s=1-ans[N-2];
      if(S[N-1]=='x') s=ans[N-2];
    }
    if(t==ans[N-1]&&s==ans[0]) {
      can=true;
      break;
    }
  }
  if(can) {
    for(auto x:ans) {
      if(x==0) cout<<'S';
      else cout<<'W';
    }
  }
  else cout<<-1;
  cout<<endl;
}

Measured memory_bytes: 1024
X = input().split()
N = int(X[0])
A = int(X[1])
B = int(X[2])

if (B - A) % 2 == 0:
    print((B - A) // 2)
elif 2*B < N:
    print( A + ((B-A-1)//2) )
elif 2*A > N:
    print( N - B + 1 + ((B-A-1)//2) )
else:
    if (N-A <= B-1):
        print( N - B + 1 + ((B-A-1)//2) )
    else:
        print( A + ((B-A-1)//2) )

Measured memory_bytes: 3064