akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vvl num(10,vl(10));
    for(int i = 1;i<=n;i++){
        vl d;
        int x = i;
        while(x>0){
           d.push_back(x%10);
           x/=10; 
        }
        int a = d[d.size()-1];
        int b = d[0];
        if(!a||!b)continue;
        num[a][b]++;
    }
    ll res = 0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            res += num[i][j]*num[j][i];
        }
    }
    out(res);
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri(), m = ri();
	int k = ri();
	int64_t sum0[n + 1];
	sum0[0] = 0;
	for (int i = 0; i < n; i++) sum0[i + 1] = sum0[i] + ri();
	
	int64_t sum1[m + 1];
	sum1[0] = 0;
	for (int i = 0; i < m; i++) sum1[i + 1] = sum1[i] + ri();
	
	int res = 0;
	for (int i = 0; i <= m; i++) {
		auto itr = std::upper_bound(sum0, sum0 + n + 1, k - sum1[i]) - sum0 - 1;
		if (itr != -1) res = std::max<int>(res, i + itr);
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 6944
n = int(input())
a = list(map(int,input().split()))
odd = 0
even4 = 0
for num in a:
  if num%2 == 1:
    odd += 1
  elif num%4 == 0:
    even4 += 1
if odd + even4 == n and even4 >= odd-1:
  print('Yes')
elif even4 >= odd:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]


def solve(N, A):
    counter = Counter(A)
    if N % 2 == 1:
        for a, n in counter.items():
            if a == 0 and n == 1:
                continue
            if a % 2 != 0 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007
    else:
        for a, n in counter.items():
            if a % 2 != 1 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007

print(solve(N, A))
    

    


Measured memory_bytes: 14820
def abc140c():
    n = int(input())
    b = list(map(int, input().split()))
    ans = 0
    for i in range(len(b)):
        if i == 0:
            ans += b[i]

        if i == n-2:
            ans += b[i]

        if 0 < i :
            ans += min(b[i-1], b[i])
    print(ans)
abc140c()

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

int md = 1e9 + 7, pr[100001], an[100001][2];
ll x[100001];

bool ok(int l, int r) { return pr[r] - pr[l - 1] == 0; }

int main(){
	int n;
	ll a, b;
	scanf("%d%lld%lld", &n, &a, &b);
	if (a > b)swap(a, b);
	f(i, 1, n + 1)scanf("%lld", x + i);
	f(i, 3, n + 1)if (x[i] - x[i - 2] < a)printf("0\n"), exit(0);
	f(i, 2, n + 1)pr[i] += pr[i - 1] + (x[i] - x[i - 1] < a);
	an[1][0] = an[1][1] = 1;
	f(i, 2, n + 1){
		int j = upper_bound(x + 1, x + i + 1, x[i] - b) - x;
		if ((an[i][1] += an[i - 1][0]) >= md)an[i][1] -= md;
		if (ok(i, i) && (an[i][1] += an[i - 1][1]) >= md)an[i][1] -= md;
		if (j == i){
			if ((an[i][0] += an[i - 1][0]) >= md)an[i][0] -= md;
			if ((an[i][0] += an[i - 1][1]) >= md)an[i][0] -= md;
		}
		else if (ok(j + 1, i - 1) && (an[i][0] += an[j][1]) >= md)an[i][0] -= md;
	}
	int o = an[n][0] + an[n][1];
	printf("%d\n", o >= md ? o - md : o);
}


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

int main ()
{
int A,B;
cin>>A>>B;
if(A!=0&&B!=0&&A<=100&&B<=100){
if(A>=(2*B)){
    cout<<A-(2*B);
}
else{
    cout<<"0";
}
}
return 0;
}

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

int main() {
  uint64_t N,K;
  cin>>N>>K;
  if(K%2!=0){
    //Kが奇数の時、a,b,cはKの倍数であればよい。N以下のKの倍数の数Aを算出し、Aの3乗が答え。
    uint64_t A = N/K;
    cout<<A*A*A<<endl;
  }
  else{
    //Kが偶数の時、a,b,cはK/2の倍数で、かつ2つ足したときにKの倍数になればよい。
    //つまり、(a,b,c)=（奇、奇、奇）or（偶、偶、偶）＊偶奇が混ざると、2つ足したときKの倍数にならない組が出てきてしまう
    uint64_t B = N/(K/2);
    uint64_t BO = (B+1)/2;
    uint64_t BE = B/2;
    cout<<BO*BO*BO + BE*BE*BE<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > s(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char ch;
            cin >> ch;
            if (ch == '#') {
                s[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == 1) {
                if (i >= 1 && s[i - 1][j] == 1) {
                    continue;
                }
                if (i < H - 1 && s[i + 1][j] == 1) {
                    continue;
                }
                if (j >= 1 && s[i][j - 1] == 1) {
                    continue;
                }
                if (j < W - 1 && s[i][j + 1] == 1) {
                    continue;
                }
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL a[N];
int main() {
    LL k;
    scanf("%lld",&k);
    if(k==0){
        printf("2\n");
        printf("1 1\n");
    }
    else{
        for(int i=1;i<=50;i++)
            a[i]=i-1;

        LL temp=(k-1)/50+1;
        for(int i=1;i<=50;i++)
            a[i]+=(temp-1);

        int times=k%50;
        if(times==0)
            for(int i=1;i<=50;i++)
                a[i]++;

        for(int i=1;i<=times;i++){
            for(int j=1;j<=50;j++){
                if(i==j)
                    a[i]+=50;
                else
                    a[j]--;
            }
        }

        printf("%d\n",50);
        for(int i = 1;i<=50;i++)
            printf("%lld ",a[i]);
        printf("\n");
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	if(b-a == c-b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

int main() {

	char a, b; cin >> a >> b;
	char ans;
	if (a == 'H' && b == 'H') ans = 'H';
	if (a == 'H' && b == 'D') ans = 'D';
	if (a == 'D' && b == 'H') ans = 'D';
	if (a == 'D' && b == 'D') ans = 'H';
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
    elif h[pairs[i][0] - 1] == h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 0 
    else:
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Measured memory_bytes: 31812
#include <stdio.h>

int main(void) {
	
	while(1){
		
		int k=0, b[55]={}, hito, tama, naka;
		
		scanf("%d %d", &hito, &tama);
		
		if(!hito && !tama)
		break;
		
		naka=tama;
		
		while(1){
			
			if(naka){
				if(b[k]==tama-1){
					printf("%d\n", k);
					break;
				}
				b[k]++;
				naka--;
				k=++k%hito;
			}
			else{
				naka=b[k];
				b[k]=0;
				k=++k%hito;
			}
		}
	}
	
	return 0;
}

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

/* constant */

const int MAX_W = 16;
const int MAX_H = 16;
const int MAX_V = 50;
const int INF = 1 << 30;

/* typedef */

struct Stat {
  int vi, rs[3];
  Stat(int _vi, int _rs[]) {
    vi = _vi; rs[0] = _rs[0]; rs[1] = _rs[1]; rs[2] = _rs[2];
  }
};

typedef vector<int> vi;
typedef long long ll;

/* global variables */

int w, h;
string flds[MAX_H];
int vn, vs[MAX_V], nbrs[MAX_V][4];
int sv, rvs[3], mvs[3], ri, mi;

int dpos[] = {1, 0, -1, 0};
int dists[MAX_V][MAX_V][MAX_V][MAX_V];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> w >> h;
    if (w == 0) break;

    for (int i = 0; i < h; i++) cin >> flds[i];

    vn = ri = mi = 0;
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) {
	char ch = flds[y][x];
	if (ch == '#') continue;

	switch (ch) {
	case '*': rvs[ri++] = vn; break;
	case '_': mvs[mi++] = vn; break;
	case '@': sv = vn; break;
	}

      	int pos = y * w + x;
	vs[vn++] = pos;
      }

    dpos[1] = -w, dpos[3] = w;

    for (int vi = 0; vi < vn; vi++)
      for (int di = 0; di < 4; di++) {
	int pos = vs[vi] + dpos[di];
	int nvi = lower_bound(vs, vs + vn, pos) - vs;
	nbrs[vi][di] = (nvi < vn && vs[nvi] == pos) ? nvi : -1;
      }

    for (int vi = 0; vi < vn; vi++)
      for (int r0 = 0; r0 < vn; r0++)
	for (int r1 = 0; r1 < vn; r1++)
	  for (int r2 = 0; r2 < vn; r2++) dists[vi][r0][r1][r2] = INF;
    dists[sv][rvs[0]][rvs[1]][rvs[2]] = 0;
    
    queue<Stat> q;
    q.push(Stat(sv, rvs));

    int min_dist = INF;
    ll gbits = (1LL << mvs[0]) | (1LL << mvs[1]) | (1LL << mvs[2]);
    
    while (! q.empty()) {
      Stat u = q.front(); q.pop();
      int ud = dists[u.vi][u.rs[0]][u.rs[1]][u.rs[2]];
      ll ubits = (1LL << u.rs[0]) | (1LL << u.rs[1]) | (1LL << u.rs[2]);
      
      if (ubits == gbits) {
	min_dist = ud;
	break;
      }
      
      for (int di = 0; di < 4; di++) {
	int vvi = nbrs[u.vi][di];
	if (vvi < 0) continue;

	Stat v(vvi, u.rs);
	bool ok = true;

	if (ubits & (1LL << vvi))
	  for (int ri = 0; ri < 3; ri++)
	    if (vvi == v.rs[ri]) {
	      int nrvi = nbrs[v.rs[ri]][di];
	      if (nrvi < 0 || (ubits & (1LL << nrvi))) ok = false;
	      v.rs[ri] = nrvi;
	      break;
	    }

	if (ok && dists[vvi][v.rs[0]][v.rs[1]][v.rs[2]] >= INF) {
	  dists[vvi][v.rs[0]][v.rs[1]][v.rs[2]] = ud + 1;
	  q.push(v);
	}
      }
    }

    cout << min_dist << endl;
  }

  return 0;
}

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


int main() {
    long n, m;
    cin >> n >> m;
    vector<bool> possible (n+1, false);
    vector<long> numBalls (n+1, 1);
    possible[1] = true;
    for (long i = 0; i < m; i++) {
        long x, y;
        cin >> x >> y;
        numBalls[x]--;
        numBalls[y]++;
        if (possible[x]) {
            possible[y] = true;
            if (numBalls[x] == 0) {
                possible[x] = false;
            } 
        }
    }
    long counter = 0;
    for (long i = 1; i <= n; i++) {
        if (possible[i]) counter++;
    }
    cout << counter << endl;
    return 0;
}

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

#define int long long

#define _   int v, int tl, int tr, int l, int r
#define tm  (tl + tr >> 1)
#define sol v+v, tl, tm, l, r
#define sag v+v+1, tm+1, tr, l, r
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

int F[N+N], A[N], n;

void up(int x, int t){
    for(; x < N+N; x += x&-x)
        F[x] += t;           
}
int qry(int x){
    int t = 0;
    for(; x ; x -= x&-x)
		t += F[x];
    return t;
}

signed main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        scanf("%lld",&A[i]);
    }
        
    int l = 1;
    int r = mod;
    for(; l<r ;){
        int m = (l+r) >> 1;
		memset(F , 0 , sizeof F);
        up(0+N, 1);
        int p = 0;
        int asd = 0;
        for(int i=1; i<=n; i++){
            if(A[i] <= m) p++;
            else p--;
			asd += qry(p-1+N);
            up(p+N,1);
        }
        
        if(asd >= n*(n+1)/4 + 1) r = m;
        else l = m+1;
    }
    
    cout << l;
    return 0;
}

Measured memory_bytes: 2560
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n; 
    map<ll,ll> f,g;
    for(int i = 1;i <= n; i++){
        ll k; cin>>k;
        f[k+i]++;
        g[i-k]++;
    }
    ll ans = 0;
    for(auto pp : f){
        if(g.count(pp.ff)){
            ans += pp.ss*(g[pp.ff]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26656
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
aaa = list(enumerate(get_nums_l()))

aaa.sort(key=lambda a:a[1])

aaa = map(lambda a: a[0]+1, aaa)
print(" ".join(map(str,aaa)))

Measured memory_bytes: 70380
#include<stdio.h>
#define N 250
 


int parent(int);
int left(int);
int right(int);


int main(){
  int n;
  int i;
  int a[N];

  scanf("%d",&n);

  for( i = 1 ; i < n+1 ; i++ ){
    scanf("%d",&a[i]);
  }
  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(2*i<=n){
      printf("left key = %d, ",a[left(i)]);
    }
 
    if(2*i+1<=n){
      printf("right key = %d, ",a[right(i)]);
    }
   
 
    printf("\n");

  }

return 0;
 
}
int parent(int i){
  
   return i / 2;

}
 
int left(int i){
  
    return 2*i;

}
 
int right(int i){
  
   return 2*i + 1;

}

Measured memory_bytes: 600
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// テーブルを作る前処理
const int MAX = 2 * 1000 * 1000;
long long fac[MAX], finv[MAX], inv[MAX];
void CombInit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算(nCk)
long long CombExec(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	sort(ALL(A));
	CombInit();

	ll r = K - 1;
	ll nokori = N - K + 1;
	ll ans1 = 0;
	REP(i, nokori) {
		ll n = N - i - 1;
		ans1 += (A[i] * CombExec(n, r)) % MOD;
		ans1 %= MOD;
	}

	ll ans2 = 0;
	reverse(ALL(A));
	REP(i, nokori) {
		ll n = N - i - 1;
		ans2 += (A[i] * CombExec(n, r)) % MOD;
		ans2 %= MOD;
	}

	ans2 += MOD;
	ans2 += MOD;
	ans2 -= ans1;
	ans2 %= MOD;
	cout << ans2 << endl;
	return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string a, b; cin >> a >> b;
    if(a[0] <= b[0]){ rep(i, b[0]-'0') cout << a; cout << endl;}
    else {rep(i, a[0]-'0') cout << b; cout << endl;}
}

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

using namespace std;

using int64 = long long;

int main()
{
  int N, K, X[50], Y[50];

  cin >> N >> K;
  vector< int > aa, bb;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    aa.push_back(X[i]);
    bb.push_back(Y[i]);
  }

  int64 ret = numeric_limits< int64 >::max();
  for(int i : aa) {
    for(int j : aa) {
      for(int k : bb) {
        for(int l : bb) {

          int beet = 0;
          for(int m = 0; m < N; m++) {
            beet += i <= X[m] && X[m] <= j && k <= Y[m] && Y[m] <= l;
          }
          if(beet >= K) {
            ret = min(ret, 1LL * (j - i) * (l - k));
          }
        }
      }
    }
  }

  cout << ret << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a_list = list(map(int, input().split()))

    result = 0
    for i, a in enumerate(a_list):
        if i % 2 == 0:
            if  not a % 2 == 0:
                result += 1
        else:
            continue

    print(result)

    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    ll acc = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (s.substr(N - 1 - i, i + 1) == t.substr(0, i + 1)) {
            acc = i + 1;
            break;
        }
    }
    cout << 2 * N - acc << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

vector<vector<int>> sumb(4002, vector<int>(4002, 0));

int get(int y, int x, int k){
    return sumb[y+k-1][x+k-1] + sumb[y-1][x-1] - sumb[y+k-1][x-1] - sumb[y-1][x+k-1];
}

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

    int n, k; cin>>n>>k;
    vector<vector<int>> black(2*k, vector<int>(2*k, 0));
    for(int i=0; i<n; i++){
        int x, y; char c; cin>>x>>y>>c;
        if(c == 'W') y += k;

        black[y%(2*k)][x%(2*k)]++;
    }

    for(int i=0; i<4*k; i++){
        for(int j=0; j<4*k; j++){
            sumb[i+1][j+1] = sumb[i+1][j] + black[i%(2*k)][j%(2*k)];
        }
    }

    for(int i=0; i<4*k; i++){
        for(int j=0; j<4*k; j++){
            sumb[j+1][i+1] += sumb[j][i+1];
        }
    }

    int ans = 0;
    for(int i=1; i<=2*k; i++){
        for(int j=1; j<=2*k; j++){
            int val = get(i, j, k) + get(i + k, j + k, k);
            chmax(ans, val);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cnt = 0;
	for(char c : s) cnt += (c == 'x');
	if(cnt < 8) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007

int N, K;
vector<bool> D(10);

bool check(int i){
    while(i){
        if(D[i%10]) return false;
        i /= 10;
    }
    return true;
}

int main() {
    cin >> N >> K;
    for(int i=0; i<K; i++){
        int d; cin >> d;
        D[d] = true;
    }

    while(!check(N)) N++;

    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    while True:
        n,r = LI()
        if n == 0:
            break
        a = list(range(n))
        for _ in range(r):
            p,c = LI()
            a = a[p-1:p-1+c] + a[:p-1] + a[p-1+c:]
        rr.append(n - a[0])

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
typedef long long ll;
int main() {
	int a = 0, b = 0, c = 0;
	int n = 0;
	int suma[10000] = {}, sumb[10000] = {}, sumc[10000] = {};
	char aa[3] = {};
	std::cin >> aa[0] >> aa[1] >> aa[2];
	if (aa[0] == 'o') { a++; }
	if (aa[1] == 'o') { a++; }
	if (aa[2] == 'o') { a++; }
	std::cout << 700+a*100 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef pair<int, vector<string> > P;

int t;
string s;

P f(string s, vector<bool> cut) {
	P ret;
	string a;
	a += s[0];
	for(int i = 0; i < cut.size(); i++) {
		if(cut[i]) {
			ret.second.push_back(a);
			a = s[i + 1];
		}
		else {
			a += s[i + 1];
		}
	}
	ret.second.push_back(a);
	for(int i = 0; i < ret.second.size(); i++) {
		a = ret.second[i];
		while(a.size() > 1 && a.front() == '0') a = a.substr(1, a.size() - 1);
		ret.first += atoi(a.c_str());
	}
	return ret;
}

vector<vector<string> > ans[1000000];

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


	while(cin >> t >> s, t && s != "0") {
		for(int i = 0; i < 1000000; i++) {
			ans[i].clear();
		}
		int n = s.size();
		int m = -1;
		for(int bit = 0; bit < 1 << (n - 1); bit++) {
			vector<bool> cut(n - 1);
			for(int i = 0; i < n - 1; i++) {
				if(bit >> i & 1) cut[i] = true;
			}
			P p = f(s, cut);
			if(p.first > t) continue;
			m = max(m, p.first);
			ans[p.first].push_back(p.second);
		}
		if(m == -1) {
			cout << "error" << endl;
		}
		else if(ans[m].size() >= 2) {
			cout << "rejected" << endl;
		}
		else {
			cout << m;
			for(string v : ans[m][0]) {
				cout << " " << v;
			}
			cout << endl;
		}
	}
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

static const ll INF = 1e9;

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

class Node
{
    public:
    int X,Y;
    vector<pair<int,int>> next;
    bool camable = false;
    int depth = 0;
    bool seen = false;
};

int BFS(vector<vector<Node>> nodes, int st_x, int st_y)
{
    int max_depth = 0;
    queue<Node> bfs;
    nodes[st_y][st_x].seen = true;
    bfs.push(nodes[st_y][st_x]);
    if(bfs.front().camable)
    while(!bfs.empty())
    {
        max_depth = max(max_depth,bfs.front().depth);
        for(auto x : bfs.front().next)
        {
            if(!nodes[x.first][x.second].seen){
                nodes[x.first][x.second].depth = bfs.front().depth +1;
                nodes[x.first][x.second].seen = true;
                bfs.push(nodes[x.first][x.second]);
            }
        }
        bfs.pop();
    }
    return max_depth;
}

int Ans(int H, int W, vector<vector<Node>> nodes)
{
    int ans = 0;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            ans = max(ans, BFS(nodes,j,i));
        }
    }
    return ans;
}

int main()
{
    int H,W;
    cin >> H >> W;

    vector<vector<Node>> nodes(H+2,vector<Node>(W+2));

    for(int i=0;i<H+2;i++)
    {
        for(int j=0;j<W+2;j++)
        {
            nodes[i][j].X = j;
            nodes[i][j].Y = i;
        }
    }

    for(int i=0;i<H;i++)
    {
        string s;
        cin >> s;
        for(int j=0;j<W;j++)
        {
            if(s[j]=='.')
            {
                nodes[i+1][j+1].camable = true;
            }
        }
    }

    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(nodes[i-1][j].camable) nodes[i][j].next.push_back(make_pair(i-1,j));
            if(nodes[i+1][j].camable) nodes[i][j].next.push_back(make_pair(i+1,j));
            if(nodes[i][j-1].camable) nodes[i][j].next.push_back(make_pair(i,j-1));
            if(nodes[i][j+1].camable) nodes[i][j].next.push_back(make_pair(i,j+1));
        }
    }

    int ans = Ans(H,W,nodes);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
h,w,n = map(int,input().split())
r,c =  map(int,input().split())
s = input()
t = input()

def check(m,p,l):
    left = 0
    right = l
    for si,ti in zip(s[::-1],t[::-1]):
        if(ti==m):
            right = min(right+1,l)
        elif(ti==p):
            left = max(left-1,0)

        if(si==m):
            left = left+1
        elif(si==p):
            right = right-1

        if(left==right):
            return (-1,-1)

    return (left+1,right+1)

left,right = check('L','R',w)
if(not left<=c<right):
    print('NO')
    exit()

left,right = check('U','D',h)
if(not left<=r<right):
    print('NO')
    exit()

print('YES')

Measured memory_bytes: 52940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

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

int main() {
    int N;
    cin >> N;
    ll num[5];
    char march[5] = {'M', 'A', 'R', 'C', 'H'};
    fill(num, num + 5, 0);
    for (int i = 0; i < N; ++i) {
        string str;
        cin >> str;
        for (int j = 0; j < 5; ++j) {
            if (str[0] == march[j]) {
                num[j] += 1;
            }
        }
    }
    
    ll ans = 0;
    for (int a = 0; a < 3; ++a) {
        for (int b = a + 1; b < 4; ++b) {
            for (int c = b + 1; c < 5; ++c) {
                ans += num[a] * num[b] * num[c];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int c=1e7;
const ll mod=1e9+7;
ll m,ans=1,cnt=0;
map<ll,ll>p;
map<ll,ll>::iterator it;
void fac(ll x){
    //m=x;
while(x%2==0){
    cnt++;
    x/=2;
}
if(cnt>p[2]){
    p[2]=cnt;
}
cnt=0;
for(int i=3;i<=sqrt(x);i+=2){
   while(x%i==0){
    cnt++;
    x/=i;
   }
   if(cnt>p[i]){
    p[i]=cnt;
}
//cout<<"i"<<" "<<i<<endl;
cnt=0;
}
if(x>2){
    if(p[x]==0){
        p[x]=1;
    }
}
//cout<<"x"<<" "<<x<<" "<<m<<endl;
}
ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void lcm(){
    for(it=p.begin();it!=p.end();it++){
        ans=((ans%mod)*fp(it->first,it->second))%mod;
        //cout<<it->first<<" "<<it->second<<endl;
    }

//cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll cntr=0;
    ll arr[n+5];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        fac(arr[i]);
    }
    lcm();
    for(int i=0;i<n;i++){
      cntr=(cntr+(ans*fp(arr[i],mod-2))%mod)%mod;
    }
    cout<<cntr%mod;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int n;
    cin>>n;
    vector<tuple<string,int,int>> temp;
    rep(i,n){
        string s;
        int p;
        cin>>s>>p;
        //tupleのソートでstringとintを降順に並び替えるので点数にマイナスをかけ高い順に取り出す
        temp.push_back(make_tuple(s,-1*p,i+1));
    }
    sort(temp.begin(),temp.end());
    rep(i,n) cout<<get<2>(temp[i])<<endl;
    return 0;
}

Measured memory_bytes: 3624
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
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 (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 200000+7;
int a[MX];
int b[1000000+5];
int n;

const int A_MAX = 1000000;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    FOR(i,0,n-1) {
        cin >> a[i];
    }

    FOR(i,0,n-1) {
        if(b[a[i]] >= 1){
            b[a[i]] = 2;
            continue;
        }
        for(int j = a[i]; j <= A_MAX; j+=a[i]) {
            b[j]++;
        }
    }

    int ans = 0;
    FOR(i,0,n-1) {
        if(b[a[i]] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8344
#include<stdio.h>
int main(void)
{
	int x,n;
	scanf("%d",&x);
	n=x%7;
	if(x==3 || x==10 || x==17 || x==24)	{
		printf("sun\n");
	}
	if(x==4 || x==11 || x==18 || x==25) {
		printf("mon\n");
	}
	if(x==5 || x==12 || x==19 || x==26) {
		printf("tue\n");
	}
	if(x==6 || x==13 || x==20 || x==27) {
		printf("wed\n");
	}
	if(x==7 || x==14 || x==21 || x==28) {
		printf("thu\n");
	}
	if(x==1 || x==8 || x==15 || x==22 || x==29) {
		printf("fri\n");
	}
	if(x==2 || x==9 || x==16 || x==23 || x==30) {
		printf("sat\n");
	}
}


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

using namespace std;

typedef long long ll;

ll res = 0;

int N, K;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> N >> K;
	for (int b = K + 1; b <= N; b++) // 0 - b
	{
		int x = (N / b);
		res += x * (b - K);
		if (N % b >= K)
			res += (N % b - K + 1);
		if (K == 0)
			--res;
//		cout << "res: " << res << endl;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import numpy as np
from itertools import product

n, m, x = map(int, readline().split())
ca = np.array(read().split(), np.int64).reshape((n, m + 1))
INF = 10 ** 9

c = ca[:, 0]
a = ca[:, 1:]

p = np.array([e for e in product([1, 0], repeat=n)], np.int64)
rikai = np.dot(p, a)
cost = np.dot(p, c)
idx = rikai.min(axis=1) >= x
if idx.any():
    ans = cost[idx].min()
else:
    ans = -1

print(ans)


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n)
	{
		cin >> a[i];
	}
	
	vector<int> ans(n);
	rep(i,n){
		ans[a[i]-1] = i+1;
	}
	rep(i,n) cout << ans[i] << ' ';
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> G[5001];
int A[5001],B[5001];

void dfs(int pos){
  A[pos]=B[pos]=0;
  int maxm=-1e9, sum=0;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    dfs(to);
    B[pos]+=A[to];
    sum+=A[to];
    maxm=max(maxm,-A[to]+B[to]);
  }
  A[pos]=max(sum,sum+maxm+1);
}

int solve(){
  dfs(0);
  return A[0];
}

int main(){
  cin>>N;
  for(int i=1;i<=N;i++){
    int id;
    cin>>id;
    G[id].push_back(i);
    printf("%d\n",solve());
  }
  return 0;
}

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

int main(){
  long long r,D,x,ans;
  cin >> r >> D >> x;
  for(int i=0;i<10;i++){
    ans=r*x-D;
    cout << ans << endl;
    x=ans;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    vector<pair<int,int>>k;
    vector<pair<int,int>>g;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i%2){
            if(a[i]>k.size())k.resize(a[i]);
            k[a[i]-1]={k[a[i]-1].first+1,a[i]};
        }
        else{
            if(a[i]>g.size())g.resize(a[i]);
            g[a[i]-1]={g[a[i]-1].first+1,a[i]};
        }
    }
    if(k.size()==1 && g.size()==1){
        if(k[0].second!=g[0].second)cout<<"0"<<endl;
        else cout<<n/2<<endl;
        return 0;
    }
    sort(k.begin(),k.end(),greater<pair<int,int>>());
    sort(g.begin(),g.end(),greater<pair<int,int>>());
    if(k[0].second!=g[0].second)cout<<n-k[0].first-g[0].first<<endl;
    else cout<<n-max(k[1].first+g[0].first,k[0].first+g[1].first)<<endl;
    return 0;
}

Measured memory_bytes: 2912
#include <stdio.h>
int main()
{
int p, a, b, x;
char op;


	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if( op == '+'){
			x = a + b;
			printf("%d\n", x);
		}else if( op == '-'){
			x = a - b;
			printf("%d\n", x);
		}else if(op == '/'){
			x = a / b;
			printf("%d\n", x);
		}else if(op == '*'){
			x = a * b;
			printf("%d\n", x);
		}else if(op == '?'){
		     break;
			
		}
	}
	
	

	scanf("%d", &p);
	return 0;

}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline
f = lambda : map(int,input().split())

n, q = f()
s = input()

cnt = 0
ln = [0]*n
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    cnt += 1
  ln[i] = cnt
for _ in range(q):
  l, r = f()
  print(ln[r-1]-ln[l-1])

Measured memory_bytes: 52952
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

safeHead [] = Nothing
safeHead (x:_) = Just x

-- 
--
--

main = do 
    [a,b,x] <- getInts
    putStrLn . show $ div b x - div (a-1) x


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n; double m;
    cin >> n >> m;
    vector<double> a(n);
    double sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    rep(i, 0, n) {
        if (a[i] / sum >= 1.0 / (4.0 * m)) cnt++;
    }

    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

N,K=(int(x) for x in input().rstrip('\n').split())
snuke=set()
for i in range(K):
  d = int(input().rstrip('\n'))
  snuke = snuke | set((int(x) for x in input().rstrip('\n').split()))
print(N-len(snuke))

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#include <climits>
#define ll long long
#define INF 1000000000
using namespace std;
struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx==ry;
    }
    int parent(int x){
        return root(x);
    }
};

int main(){
    int ans=0;
    int N,M;
    cin >> N >> M;
    int a[M+5],b[M+5];
    vector<vector<int> > graph(N,vector<int> (N,INF));
    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    for(int i=0;i<M;i++){
        UnionFind tree(N+5);
        graph[a[i]][b[i]] = INF;
        graph[b[i]][a[i]] = INF;
        for(int j=0;j<M;j++){
            if(graph[a[j]][b[j]]==1){
                tree.unite(a[j],b[j]);
            }
        }
        bool check = true;
        for(int j=0;j<N;j++){
            if(!tree.same(0,j)){
                check = false;
            }
        }
        if(!check) ans++;
        check = true;
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ilway_Lines
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] temp = input.Split(',');
                double[] nums = new double[12];
                double s=0;
                for (int i = 0; i < 12; ++i)
                {
                    nums[i] = double.Parse(temp[i]);
                    if (i < 10) s += nums[i];
                }
                double t = s / (nums[10]+nums[11]);
                double s1 = nums[10] * t;
                for (int i = 0; i < 10; ++i)
                {
                    s1 -= nums[i];
                    if (s1 <= 0)
                    {
                        Console.WriteLine(i+1);
                        break;
                    }
                    
                }
                

            }
        }
    }
}



Measured memory_bytes: 15688
#abc136d
s=raw_input()
n=len(s)
c=[1]*n
for i in range(n):
 if s[i]=='R' and s[i+1]=='R':
  c[i+2]+=c[i]
  c[i]=0
for i in range(n-1,-1,-1):
 if s[i]=='L' and s[i-1]=='L':
  c[i-2]+=c[i]
  c[i]=0
print ' '.join(map(str,c))


Measured memory_bytes: 7156
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(a);
		int l = 0;
		for(int i = 1; i < N; i++) {
			l += a[i] - a[i - 1];
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 22868
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	var arr []int

	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		arr = append(arr, x)
	}
	sort.Ints(arr)

	var ans float64 = float64(arr[0])
	for i := 1; i < n ; i++ {
		ans = (ans + float64(arr[i])) / 2
	}

	fmt.Println(ans)

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int MOD = 1e9+7;

ostringstream sout;
string zero_padding(int num){
  sout << setfill('0') << setw(6) << num;
  string ret = sout.str();
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  map<int, vector<ipair> > mp;

  rep(i, M){
    int p, y;
    cin >> p >> y;
    mp[p].push_back(make_pair(y, i));
  }

  vector<ipair> ans(M);

  for(pair<int, vector<ipair>> p: mp){
    int pref = p.first;
    vector<ipair> cities = p.second;
    sort(cities.begin(), cities.end());
    rep(city_order, cities.size()){
      // cout << "===" << endl;
      // cout << "city_order:" << city_order << endl;
      // cout << "pref:" << pref << endl;
      int original_idx = cities[city_order].second;
      // cout << "original_idx:" << original_idx << endl;
      ans[original_idx] = make_pair(pref, city_order+1);
    }
  }

  rep(i, M){
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }

  return 0;
}


Measured memory_bytes: 13184
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::unordered_map<int, int> type_occurences;
typedef std::set<int> type_set_int;
using t_map_rate_n = std::map<int, int>;
using vint = std::vector<int>;


struct abc_178_a {
	int run(int i) {
		if(i == 0) {
			return 1;
		}
		return 0;
	}
};

int main(void) {
	abc_178_a solver;
	int input;
	std::cin >> input;

	std::cout << solver.run(input) << std::endl;

	return 0;
}


Measured memory_bytes: 3624