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

using namespace std;

typedef long long int ll;

const int N = (int) 3e2 + 10;

int n;
int f[4];

double memo[N][N][N];

//(1-a)f(x)=1+b*f(y)+c*f(z)
double dp(int _0, int _1, int _2, int _3) {
    if(_0 < 0 || _1 < 0 || _2 < 0 || _3 < 0) return 0;
    if(_0 == n) return 0;
    double &ans = memo[_1][_2][_3];
    if(ans != -1) return ans;
    ans = 1;
    double p0 = (double) _0 / n;
    double p_tot = 1 - p0;
    double p1 = (double) _1 / n;
    double p2 = (double) _2 / n;
    double p3 = (double) _3 / n;
    ans += p1*dp(_0 + 1, _1 - 1, _2, _3);
    ans += p2*dp(_0, _1 + 1, _2 - 1, _3);
    ans += p3*dp(_0, _1, _2 + 1, _3 - 1);
    ans /= p_tot;
    return ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int x; cin >> x;
        f[x]++;
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = 0; k < N; ++k) {
                memo[i][j][k] = -1;
            }
        }
    }
    cout << dp(f[0], f[1], f[2], f[3]) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 233088
fun main(arr:Array<String>) {
    val num = readLine()!!.toInt()
    val p = readLine()!!.replace(" ", "")
    val q = readLine()!!.replace(" ", "")

    val list = getJunretsu(0, num)
    val ans = Math.abs(list.indexOf(p) - list.indexOf(q))
    println(ans)
}

fun getJunretsu(flag:Int, total:Int):MutableList<String> {
    if(flag == (1 shl total) - 1) {
        return mutableListOf("")
    }
    val ans = mutableListOf<String>()
    for(i in (0 until total)) {
        val key = 1 shl i
        if(flag.and(key) > 0) {
            continue
        }
        val ret = getJunretsu(flag + key, total)
        ans.addAll(ret.map { (i+1).toString() + it })
    }
    return ans
}




Measured memory_bytes: 55356
n  = int(input())
x = list(map(int, input().split(" ")))

min_x = min(x)
max_x = max(x)

power = []
for i in range(100):
    power.append(i*i)

result = 999999
for i in range(min_x, max_x+1):
    count = 0
    for j in range(n):
        count = count + power[abs(i - x[j])]
    if(result > count):
        result = count

print(result)

Measured memory_bytes: 3064
require 'set'

s = gets.chomp
k = gets.to_i

set = Set.new
len = s.length

0.upto(len - 1) do |i|
  1.upto(len - i) do |j|
    break if j > k
    set.add s[i, j]
  end
end

puts set.to_a.sort[k-1]


Measured memory_bytes: 5500
package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	s, c, r := "Sunny", "Cloudy", "Rainy"
	in := nextWord()
	res := s
	if in == s {
		res = c
	} else if in == c {
		res = r
	}
	fmt.Fprint(writer, res)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

typedef long long ll;

int main() {
	int n,m;
	cin >> n >> m;
	
	vector<int> nums(n);
	for(int i=0; i < n; i++) {
		cin >> nums[i];
	}
	
	sort(nums.begin(), nums.end());
	vector<pair<int,int>> ops;
	
	for(int i=0; i < m; i++) {
		int b,c;
		cin >> b >> c;
		
		ops.push_back(make_pair(c,b));
	}
	
	sort(ops.begin(), ops.end(), greater<pair<int,int>>());
	
	ll sum = 0;
	int ind = 0;
	int op_ind = 0;
	while(op_ind < m && ind < n) {
		bool flag = false;
		int val = ops[op_ind].first;
		for(int i=0; i < ops[op_ind].second; i++) {
			if(ind == n || nums[ind] >= val) {
				flag = true;
				break;
			}
			
			sum += val;
			ind++;
		}
		
		if(flag) break;
		op_ind++;
	}
	
	
	for(int i = ind; i < n; i++) {
		sum += nums[i];
	}
	
	cout << sum;
	return 0;
}

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

const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    
    long long ans = 1;
    for (int i = 1; i <= n; i++) ans = (ans * i) % MOD;
    
    cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(1)==s.at(2))cout << "Yes" << endl;
    else if(s.at(1)==s.at(2) && s.at(2)==s.at(3))puts("Yes");
    else puts("No");
}

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

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	ans = 0
	if len(v) % 2 == 0:
		t = sorted(v)
		ans = t[n//2] - t[n//2 - 1]
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 52680
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
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;}

int main(){
    string s; cin >> s;
    deque<char> ans;
    rep(i, s.size()) {
        ans.push_back(s[i]);
    }
    int q; cin >> q;
    int cond = 1;
    rep(i, q) {
        int t; cin >> t;
        if(t==1) {
            cond *= -1;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if((f==1 && cond == -1) || (f==2 && cond == 1)) {
                ans.push_back(c);
            } else {
                ans.push_front(c);
            }
        }
    }
    string ansstr = "";
    while(ans.size() != 0) {
        ansstr += ans.front(); ans.pop_front();
    }
    if(cond == -1) reverse(ansstr.begin(), ansstr.end());
    cout << ansstr << endl;
}


Measured memory_bytes: 1412
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll sum = B - A + 1;
    ll tc = B / C - A / C;
    if (A % C == 0) tc++;
    ll td = B / D - A / D;
    if (A % D == 0) td++;
    ll g = lcm(C,D);
    ll tcd = B / g - A / g;
    if (A % g == 0) tcd++;
    print(sum - (tc + td - tcd));
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args){
		int hour=0;
		int min=0;
		int sec=0;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();
			int lineNum = Integer.parseInt(line);
			hour = lineNum / 3600;
			min = (lineNum % 3600) / 60;
			sec = lineNum % 60;
			String watch = hour +":"+ min +":"+sec;
			System.out.println(watch);
		}
		catch(IOException e){
		}
	}
}

Measured memory_bytes: 24304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

typedef pair<char, int> P;

void myprint(vector<P> &a) {
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != a.begin()) {
      cout << " ";
    }
    cout << it->first << it->second;
  }
  cout << endl;
}

void check_stable(vector<P> &a, vector<P> &b) {
  map<P, int> m;
  for (int i = 0; i < a.size(); ++i) {
    m[a[i]] = i;
  }

  int p = -1;
  int q = -1;
  bool stable = true;
  for (int i = 0; i < b.size(); ++i) {
    if (p != b[i].second) {
      p = b[i].second;
      q = m[b[i]];
      continue;
    }
    if (m[b[i]] < q) {
      stable = false;
      break;
    }
    q = m[b[i]];
  }

  if (stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}

void bubble_sort(vector<P> &a) {
  vector<P> c;

  int N = a.size();
  c.resize(N);
  copy(a.begin(), a.end(), c.begin());

  for (int i = 0; i < N; ++i) {
    for (int j = N - 1; j >= i + 1; --j){
      if(c[j].second < c[j - 1].second) {
        P t = c[j];
        c[j] = c[j - 1];
        c[j - 1] = t;
      }
    }
  }

  myprint(c);
  check_stable(a, c);
}

bool selection_sort(vector<P> &a) {
  vector<P> c;

  int N = a.size();
  c.resize(N);
  copy(a.begin(), a.end(), c.begin());

  for (int i = 0; i < N; ++i) {
    int m = i;
    for (int j = i; j < N; ++j) {
      if(c[j].second < c[m].second) {
        m = j;
      }
    }
    if (m != i) {
      P t = c[i];
      c[i] = c[m];
      c[m] = t;
    }
  }

  myprint(c);
  check_stable(a, c);
}

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

  vector<P> a;
  for (int i = 0; i < N; ++i) {
    string t;
    cin >> t;
    a.push_back(P(t[0], t[1] - '0'));
  }

  bubble_sort(a);
  selection_sort(a);

  return 0;
}

Measured memory_bytes: 3160
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, a, b = MAP()
s = STR()
c = 0
d = 0
for i in range(n):
    if s[i] == 'a' and c < a + b:
        print('Yes')
        c += 1
    elif s[i] == 'b' and c < a + b and d < b:
        print('Yes')
        c += 1
        d += 1
    else:
        print('No')

Measured memory_bytes: 76244
N, A = map(int, raw_input().split())
a = sorted(map(lambda x:int(x)-A, raw_input().split()))
mem = {}

def rec(p, acm):
    if (p, acm) in mem:
        return mem[(p, acm)]
    if p >= N:
        return 0
    if a[p] > 0 and acm > 0:
        return 0
    mem[(p, acm)] = rec(p+1, acm+a[p]) + rec(p+1, acm)
    if acm+a[p] == 0:
        mem[(p, acm)] += 1
    return mem[(p, acm)]

print rec(0, 0)


Measured memory_bytes: 26652
s = str(input())
k = 0
p = 0
for i in range(len(s)):
  if k > 0:
    if s[i] == 'g':
      k -= 1
      p += 1
    else:
      k -= 1
  else:
    if s[i] == 'g':
      k += 1
    else:
      k += 1
      p -= 1
print(p)
      
    
     
  
  
  

Measured memory_bytes: 9232
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    
    left = [i for i in range(M)]
    right = [2 * M - 1 - v for v in left]
    
    for i in range(M // 2):
        right[i] -= 2 * M + 1
    
    for i in range(M):
        left[i] %= N
        left[i] += 1
        right[i] %= N
        right[i] += 1
    
    for a, b in zip(left, right):
        print(a, b)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 85052
fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val cnt = LongArray(100000 + 1)

    var sum = 0L

    readInputLine().split(" ").forEach {
        cnt[it.toInt()]++
        sum += it.toLong()
    }

    repeat(readInputLine().toInt()) {
        val (b, c) = readInputLine().split(" ").map { it.toInt() }
        if (cnt[b] != 0L) {
            sum -= cnt[b] * b.toLong()
        }
        sum += cnt[b] * c.toLong()
        cnt[c] += cnt[b]
        cnt[b] = 0L

        builder.appendln(sum)
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 63280
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
a,b,c,d = map(int,input().split())

print("Yes" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else "No")

Measured memory_bytes: 2940
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 42;

int n;
int a[N][N];

ull dp[N][N][N][N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
    cin >> n;
    n *= 2;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            char c;
            cin >> c;
            if (c == '1') {
                a[i][j] = 1;
            }
        }
    }
    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            dp[i][i - 1][j][j - 1] = 1;
        }
    }
    for (int i = n - 1; i > 0; --i) {
        for (int j = i; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                for (int l = k; l < n; ++l) {
                    for (int x = i; x <= j; ++x) {
                        for (int y = k; y <= l; ++y) {
                            if (!a[x][y]) {
                                continue;
                            }
                            for (int lf = i; lf <= x; ++lf) {
                                for (int rg = y; rg <= l; ++rg) {
                                    dp[i][j][k][l] = dp[i][j][k][l] + dp[i][lf - 1][rg + 1][l] * dp[lf][x - 1][x + 1][j] * dp[k][y - 1][y + 1][rg];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    ull ans = 0;
    for (int i = 1; i < n; ++i) {
        if (a[0][i]) {
            ans += dp[1][i - 1][i + 1][n - 1];
        }
    }
    cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 21888
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e3,p=1e9+7;
struct Matrix{
	int v[2][2];
	Matrix(){memset(v,0,sizeof(v));}
	void init(){for (int i=0;i<2;i++)	v[i][i]=1;}
}Ans;
Matrix operator *(const Matrix &x,const Matrix &y){
	Matrix z;
	for (int i=0;i<2;i++)
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				z.v[i][k]=(z.v[i][k]+1ll*x.v[i][j]*y.v[j][k])%p;
	return z;
}
Matrix mlt(Matrix a,ll b){
	Matrix res; res.init();
	for (;b;b>>=1,a=a*a)	if (b&1)	res=res*a;
	return res;
}
int mlt(int a,ll b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p)	if (b&1)	res=1ll*res*a%p;
	return res;
}
char s[N+10][N+10];
int main(){
	int n=read(),m=read(); ll k; scanf("%lld",&k);
	for (int i=1;i<=n;i++)	scanf("%s",s[i]+1);
	int cnt=0,s1=0,s2=0,h1=0,h2=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (s[i][j]=='#'){
				cnt++;
				if (s[i][j+1]=='#')	s1++;
				if (s[i+1][j]=='#')	s2++;
			}
		}
		if (s[i][1]=='#'&&s[i][m]=='#')	h1++;
	}
	for (int i=1;i<=m;i++)	if (s[1][i]=='#'&&s[n][i]=='#')	h2++;
	if (h1&&h2){
		printf("1\n");
		return 0;
	}
	if (!h1&&!h2){
		printf("%d\n",mlt(cnt,k-1));
		return 0;
	}
	if (!h1)	swap(s1,s2),swap(h1,h2);
	Ans.v[0][0]=cnt,Ans.v[0][1]=s1,Ans.v[1][1]=h1;
	Ans=mlt(Ans,k-1);
	printf("%d\n",(Ans.v[0][0]-Ans.v[0][1]+p)%p);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<pair<ll,int>>> wgraph;
typedef pair<ll,int> pli;

vector<ll> bfs(wgraph v,int x){
  priority_queue<pli,vector<pli>,greater<pli>> q;
  vector<ll> dist(v.size(),longinf);
  dist[x]=0;
  q.push({0LL,x});
  
  while(q.size()){
    pli p=q.top(); q.pop();
    ll d=p.F, now=p.S;
    if(dist[now]<d){ continue; }
    for(auto to:v[now]){
      if(dist[to.S]>d+to.F){
        dist[to.S] = d+to.F;
        q.push({dist[to.S], to.S});
      }
    }
  }
  return dist;
}

int main(){
  int n;
  cin >> n;
  wgraph v(n);
  rep(i,n-1){
    int x,y,c;
    cin >> x >> y >> c; x--; y--;
    v[x].push_back({c,y});
    v[y].push_back({c,x});
  }
  int q,k; cin >> q >> k; k--;
  vector<ll> data=bfs(v,k);
  rep(i,q){
    int x,y;
    cin >> x >> y; x--; y--;
    cout << data[x]+data[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 18160
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int Y;
int main(){
  rd(X);
  rd(Y);
  wt_L(X+Y/2);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int X, Y;
// {
//   rd(X,Y);
//   wt(X+Y/2);
// }


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    lst = [s[0]]

    for char in s[1:]:
        if lst[-1] != char:
            lst.append(char)

    ans = len(lst)-1
    print(ans)
main()


Measured memory_bytes: 80428
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	s = chomp(s);
	int[10] r;
	for(int i=0;i<s.length;i++){
	    int n = to!int(s[i] - '0');
	    r[n]++;
	}
	string s1 = "";
	for(int i=1;i<=9;i++){
	    for(int j=0;j<r[i];j++)
		s1 ~= to!string(i);
	}
	bool[10] used = false;
	string[] ss = ["111","222","333","444","555","666","777","888","999","123","234","345","456","567","678","789"];
	string[] atm = ["11","22","33","44","55","66","77","88","99"];
	int[] anslist;
	for(int i=0;i<16;i++){
	    for(int j=i;j<16;j++){
		for(int k=j;k<16;k++){
		    for(int l=k;l<16;l++){
			for(int m=0;m<9;m++){
			    string temp = ss[i] ~ ss[j] ~ ss[k] ~ ss[l] ~ atm[m];
			    int[10] r1;
			    for(int i1=0;i1<temp.length;i1++){
				int n = to!int(temp[i1] - '0');
				r1[n]++;
			    }
			    int count = 0;
			    for(int i2=1;i2<=9;i2++){
				if(r1[i2] != r[i2]) count += abs(r1[i2] - r[i2]);
			    }
			    int ans = 0;
			    if(count == 1){
				for(int i2=1;i2<=9;i2++){
				    if(r1[i2] != r[i2] && r1[i2] <= 4) ans = i2;
				}
			    }

			    if(ans!=0 && !used[ans]){
				//writef("%d ",ans);
				used[ans] = true;
				anslist ~= ans;
			    }
			}
		    }
		}
	    }
	}
	sort(anslist);
	if(anslist.length > 0)
	    writef("%d",anslist[0]);
	else writef("%d",0);
	for(int i=1;i<anslist.length;i++)
	    writef(" %d",anslist[i]);
	writeln();
    }
}

Measured memory_bytes: 3188
package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	fmt.Scan(&n)
	// x * 1.08 = n
	// x = n / 1.08
	x := n / 1.08
	if math.Floor(math.Ceil(x) * 1.08) == n {
		fmt.Println(math.Ceil(x))
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    string s;
    cin >> s;
    int st, ed;
    st = s.find('A');
    reverse(s.begin(), s.end());
    ed = s.length() - s.find('Z');

    cout << ed - st;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
        


   
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>

using namespace std;


int n, a[15], ar[15], ans = 0;

int dfs(int d)
{
    for (int i = -1; i <= 1; i++) {
        ar[d] = a[d] + i;

        if (d == n - 1) {

            int pro = 1;
            for (int i = 0; i < n; i++)
                pro *= ar[i];

            if (pro % 2 == 0) ans++;
        }else
            dfs(d + 1);
    }

    return 0;
}


int main()
{
    

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    dfs(0);
    printf("%d", ans);
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split()
            .Select(x => int.Parse(x))
            .ToArray();
        var n = nm[0];
        var m = nm[1];
        var adlQuery =
            from i in Enumerable.Range(1, m)
            let vu = Console.ReadLine().Split()
                .Select(x => int.Parse(x) - 1)
                .OrderBy(x => x)
                .ToArray()
            select vu into es
            from e in new[] { es, es.Reverse() }
            let v = e.First()
            let u = e.Last()
            orderby u ascending
            group u by v into g
            select g;
        var adl = Enumerable.Range(0, n)
            .GroupJoin(adlQuery, i => i, adj => adj.Key, (_, inner) => inner.SelectMany(adj => adj))
            .DefaultIfEmpty()
            .Select(x => x.ToArray())
            .ToArray();
        var q = int.Parse(Console.ReadLine());
        var queriesQuery =
            from i in Enumerable.Range(1, q)
            let x = Console.ReadLine().Split()
                .Select(x => int.Parse(x))
                .ToArray()
            select new { i, v = x[0] - 1, d = x[1], c = x[2] };
        var queries = queriesQuery.ToArray();

        var dp = Enumerable.Range(1, 3).Select(_ => new int[n]).ToArray();
        foreach (var query in queries.Reverse())
        {
            var vs = new[] { query.v };
            for (int d = query.d; d > -1; --d)
            {
                var bfs = new List<int[]>();
                foreach (var v in vs)
                {
                    if (dp[0][v] <= query.i)
                    {
                        dp[0][v] = query.i;
                        dp[2][v] = query.c;
                    }

                    if (dp[1][v] < d)
                    {
                        dp[1][v] = d;
                        bfs.Add(adl[v]);
                    }
                }
                vs = bfs.SelectMany(x => x).Distinct().ToArray();
            }
        }

        foreach (var v in dp[2])
        {
            Console.WriteLine(v);
        }
    }
}


Measured memory_bytes: 72680
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, X;
int A[30];
bool dp[1000001];

bool is_prime(int x) {
  int d = sqrt(x);
  for (int i=2; i<=d; i++) {
    if (x % i == 0) return false;
  }
  return true;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> N >> X) {
    if (N == 0 && X == 0) break;
    rep(i, N) cin >> A[i];
    rep(i, X+1) dp[i] = 0;

    dp[0] = 1;
    for (int i=0; i<N; i++) {
      int a = A[i];
      for (int j=0; j<=X-a; j++) dp[j+a] |= dp[j];
    }
    int m = 0;
    for (int i=X; i>=2; i--) {
      if (dp[i] && is_prime(i)) {
        m = i;
        break;
      }
    }
    if (m == 0) cout << "NA\n";
    else cout << m << "\n";
  }
  return 0;
}

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

void solve(ll N, ll K, vector<ll> d, vector<vector<ll>> A)
{
    // rep(i, K) {
    //     rep(j, N)
    //         cout << A[i][j] << " ";
    //     cout << endl;
    // }

    vector<ll> mp(N+1);
    rep(i, K) 
        rep(j, N)
            mp[A[i][j]]++;

    ll ans=0;
    for(ll i = 1;i<=N;i++)
        if(mp[i] == 0)
            ans++;
    cout << ans << endl;

    
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    ll N, K;
    cin >> N;
    cin >> K;
    vector<ll> d(K);
    vector<vector<ll>> A(K, vector<ll>(N));
    rep(i, K) {
        cin >> d[i];
        rep(j, d[i]) {
            cin >> A[i][j];
        }
    }
            
    solve(N, K, d, A);
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,tmp,flag=0;
  vector<vector<int> > hole(3,vector<int>(3));
  map<int,pair<int,int> > mp;
  rep(i,3)rep(j,3){
	cin >> tmp;
    mp[tmp]=make_pair(i,j);
  }
  cin >> n;
  rep(i,n){
    cin >> tmp;
    if(mp.count(tmp))hole.at(mp[tmp].first).at(mp[tmp].second)=1;
  }
  rep(i,3){
    tmp=1;
	rep(j,3)tmp*=hole.at(i).at(j);
    if(tmp)flag=1;
  }
  rep(i,3){
    tmp=1;
	rep(j,3)tmp*=hole.at(j).at(i);
    if(tmp)flag=1;
  }
  tmp=1;
  rep(i,3){
    tmp*=hole.at(i).at(i);
  }
  if(tmp)flag=1;
  tmp=1;
  rep(i,3){
    tmp*=hole.at(i).at(2-i);
  }
  if(tmp)flag=1;
  cout << ((flag)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
s=input()
k=int(input())
l=list(s)
r=list(s*2)
z=set(l)
x=0
y=0
if len(z)==1 :
    print(int((len(l)*k)/2))
else:
    for i in range(1,len(l)):
      if l[i-1]==l[i]:
        l[i]=0
        x+=1
    for i in range(1,len(r)):
       if r[i-1]==r[i]:
        r[i]=0
        y+=1
    if 2*x==y:
         print(k*x)
    else:
         print(k*x+k-1)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strings = new String[n];
        for(int i = 0; i < n; i++) {
            strings[i] = sc.next();
        }
        int[] count = new int[26];
        String str = strings[0];
        for(int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            count[c - 'a']++;
        }
        int[] tempCount = new int[26];
        for(int i = 1; i < n; i++) {
            str = strings[i];
            for(int j = 0; j < str.length(); j++) {
                char c = str.charAt(j);
                tempCount[c - 'a']++;
            }
            for(int k = 0; k < 26; k++) {
                int minCount = Math.min(count[k], tempCount[k]);
                count[k] = minCount;
            }
            Arrays.fill(tempCount, 0);
        }
        for(int i = 0; i < 26; i++) {
            int num = count[i];
            while(num != 0) {
                System.out.print(Character.toChars('a' + i));
                num--;
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 21844
// #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<bitset>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    ll m,k; cin >> m >> k;
    if(m == 1 && k == 1){cout << -1 << endl;return 0;}
    if((1LL << m) <=  k){cout << -1 << endl;return 0;}
    vector<ll> ret((1LL << (m+1)),0);
    if(k == 0){
        ll cnt = 0;
        for(ll i = (1 << m)-1; 0 <= i; i--){
            ret[cnt] = i;
            cnt++;
        }
        rep(i,(1LL << m)){
            ret[cnt] = i;
            cnt++;
        }
    }
    else{
        vector<Pll> pairs;
        bitset<10000000> bs(0);
        rep(i,(1LL << m)){
            if(bs[i] == 0){
                pairs.emplace_back(Pll(i,i^k));
            }
            bs[i] = 1;bs[i^k] = 1;
        }
        ll cnt = 0, cnt_p = 0;
        while(cnt < (1LL << (m+1))){
            ll a = pairs[cnt_p].first, b = pairs[cnt_p].second;
            ll c = pairs[cnt_p+1].first, d = pairs[cnt_p+1].second;
            cnt_p +=2;
            ret[cnt] = ret[cnt+5] = b;
            ret[cnt+1] = ret[cnt+4] = a;
            ret[cnt+2] = ret[cnt+7] = c;
            ret[cnt+3] = ret[cnt+6] = d;
            cnt += 8;
        }
    }

    print(ret);
}

Measured memory_bytes: 5232
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;
 
int main() {
    int n;
    ll d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    ll d2 = d*d;
    ll count = 0;
    rep(i,n) {
        if (x[i] * x[i] + y[i] * y[i] <= d2 ) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, q, a1, a2, v;
string s;
vector<pair<ll, ll>> p;
bool ok[210000];

bool ss(ll a){
	ll now = a;
	REP(i, q) {
		if (p[i].first == s[now] - 'A') {
			if (p[i].second == 0)now--;
			else now++;
			if (now == n or now < 0)return false;
		}
	}
	return true;
}


// index が条件を満たすかどうか
bool isOK(int index, int key) {
	if (key == 0) {
		if (ss(index)) return true;
		else return false;
	}
	else {
		if (ss(index)) return false;
		if (ok[index]) return false;
		return true;
	}
}

// 汎用的な二分探索のテンプレ
int bs(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)s.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

int main() {
	cin >> n >> q;
	cin >> s;
	REP(i, q) {
		char a, b;
		cin >> a >> b;
		ll c = 0;
		if (b == 'R') c++;
		p.push_back(make_pair(a - 'A', c));
	}
	a1 = bs(0);
	REP(i, a1)ok[i] = true;
	a2 = bs(1);
	cout << a2 - a1 << endl;
}


Measured memory_bytes: 6644
def get_answer(ki):
    """
    めも
    配列コピーはしない
    入力テキスト配列から数値配列の変換は行わない（配列サイズが大きくなる）
    for,if,dictは使わない
    """
    k0 = ki[0].split(" ")
    n = int(k0[0])
    q = int(k0[1])
    q_index = [0] * n
    for k in ki[-q:]:
        k = k.split(" ")
        q0 = int(k[0])
        q1 = int(k[1])
        q_index[q0 - 1] += q1

    score = [0] * n

    t_index = []
    for i in range(0, n + 1):
        t_index.append([])
    for ki_n in ki[1:-q]:
        k = ki_n.split(" ")
        n0 = int(k[0])
        n1 = int(k[1])
        t_index[n0].append(n1)
        t_index[n1].append(n0)

    t_stack = [1]
    s_stack = [0]
    r_flag = [0] * n
    while len(t_stack) > 0:
        i = t_stack.pop()
        s = s_stack.pop()
        if r_flag[i - 1]:
            continue
        r_flag[i - 1] = 1
        s += q_index[i - 1]
        score[i - 1] += s
        t_stack += t_index[i]
        s_stack += [s] * len(t_index[i])

    ss = [str(s) for s in score]
    return " ".join(ss)


if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = input()
            if (not input1) or (len(input1) == 0):
                break
            input_ki.append(input1)
        except EOFError:
            break
    print(get_answer(input_ki))


Measured memory_bytes: 107544
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define pb push_back
#define rep(i,n) for(ll i=0;i < n;i++)
#define sz(x) x.size()

ll n,temp,ans;
vector<ll> a,b,c;
vector<ll>::iterator it1,it2,it3;

int main() {
	cin >> n;
	fr(i,1,n) {
		cin >> temp;
		a.pb(temp);
	}
	fr(i,1,n) {
		cin >> temp;
		b.pb(temp);
	}
	fr(i,1,n) {
		cin >> temp;
		c.pb(temp);
	}
	sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(c.begin(),c.end());
	rep(i,sz(b)) {
		it3 = upper_bound(c.begin(),c.end(),b[i]);
		ll cc = (sz(c) - (it3 - c.begin()));
		ll aa = 0;
		it1 = upper_bound(a.begin(),a.end(),b[i]-1);
		if(it1 != a.begin()) {
			it1--;
			aa = (it1-a.begin()) + 1;
		}
		ans += (cc * aa);
	}
	cout << ans << "\n";
}

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

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  if (N % 2 == 0) {
    int n = N/2;
    std::string s(S.begin(), S.begin() + n);
    std::string S_check = s+s;
    if (S==S_check) {
      std::cout << "Yes\n";
    } else {
      std::cout << "No\n";
    }
  } else {
    std::cout << "No\n";
  }
}


Measured memory_bytes: 504
#include<stdio.h>
int main(void){
  int r,c,i,j;
  scanf("%d %d",&r,&c);
  int a[r+1][c+1];

  for(i=1;i<=r+1;i++){ //?????????????????????0??§?????????????????????
    for(j=1;j<=c+1;j++){
      a[i-1][j-1]=0;
    }
  }
  for(i=1;i<=r;i++){ //???????????????????????????????????????
    for(j=1;j<=c;j++){
      scanf("%d",&a[i-1][j-1]);
    }
  }
  for(i=1;i<=r;i++){ //c+1???????????????r????????§?????????????±???????
    for(j=1;j<=c;j++){
      a[i-1][c]+=a[i-1][j-1];
    }
  }
  for(j=1;j<=c;j++){ //r+1???????????????c????????§?????????????±???????
    for(i=1;i<=r;i++){
      a[r][j-1]+=a[i-1][j-1];
    }
  }
  for(i=1;i<=r;i++){ //c+1?????????r????????§??????????±???????
    a[r][c]+=a[i-1][c];
  }
  for(i=1;i<=r+1;i++){
    printf("%d",a[i-1][0]); //1???????????\?????????????????????????????????
    for(j=2;j<=c+1;j++){
      printf(" %d",a[i-1][j-1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 644
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	a, b, c := make([]int, M), make([]int, M), make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&a[i], &b[i], &c[i])
		a[i]--
		b[i]--
	}

	dist := make([][]int, N)
	for i := 0; i < N; i++ {
		dist[i] = make([]int, N)
	}

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}

			dist[i][j] = 1e9
		}
	}

	for i := 0; i < M; i++ {
		dist[a[i]][b[i]] = c[i]
		dist[b[i]][a[i]] = c[i]
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if dist[i][k] + dist[k][j] < dist[i][j] {
					dist[i][j] = dist[i][k] + dist[k][j]
				}
			}
		}
	}

	count := 0
	for k := 0; k < M; k++ {
		flag := true
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if i == j {
					continue
				}

				if dist[i][a[k]] + c[k] + dist[b[k]][j] == dist[i][j] {
					flag = false
				}
			}
		}

		if flag {
			count++
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 640
use std::io;

fn main() {
	let mut str_n : String = String::new();
	let mut n : i32 = 0;
	let mut sum_digit : i32 = 0;

	io::stdin().read_line(&mut str_n).unwrap();

	str_n = str_n.trim().to_string();

	n = str_n.trim().parse().unwrap();

	for digit in str_n.chars() {
		sum_digit += digit as i32 - 48;
	}

	if n % sum_digit == 0 {
		println!("Yes");
	} else {
		println!("No");
	}
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(){
  double x1,y1,x2,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  printf("%f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
  

Measured memory_bytes: 1080
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){
    int cnt = 0;
    for(int i = 0; i < n; i += 2)
        cnt += (a[i] % 2 == 1);
    cout << cnt << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll X_1[100],X_2[100],Y_1[100],Y_2[100],D_1[100],D_2[100];
ll table[110][110][110];
map<ll,int> index_X,index_Y,index_D;
vector<ll> X,Y,D;

int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	X.push_back(-10);
	X.push_back(BIG_NUM);

	Y.push_back(-10);
	Y.push_back(BIG_NUM);

	D.push_back(-10);
	D.push_back(BIG_NUM);

	for(int i = 0; i < N; i++){
		scanf("%lld %lld %lld %lld %lld %lld",&X_1[i],&Y_1[i],&D_1[i],&X_2[i],&Y_2[i],&D_2[i]);
		X.push_back(X_1[i]);
		X.push_back(X_2[i]);
		Y.push_back(Y_1[i]);
		Y.push_back(Y_2[i]);
		D.push_back(D_1[i]);
		D.push_back(D_2[i]);
	}

	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	sort(D.begin(),D.end());

	X.erase(unique(X.begin(),X.end()),X.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	D.erase(unique(D.begin(),D.end()),D.end());

	ll size_X = X.size(),size_Y = Y.size(),size_D = D.size();

	for(int i = 0; i < size_X; i++){
		index_X[X[i]] = i;
	}
	for(int i = 0; i < size_Y; i++){
		index_Y[Y[i]] = i;
	}
	for(int i = 0; i < size_D; i++){
		index_D[D[i]] = i;
	}

	for(int x = 0; x <= size_X; x++){
		for(int y = 0; y <= size_Y; y++){
			for(int d = 0; d <= size_D; d++)table[x][y][d] = 0;
		}
	}

	for(int i = 0; i < N; i++){
		for(int x = index_X[X_1[i]]; x < index_X[X_2[i]]; x++){
			for(int y = index_Y[Y_1[i]]; y < index_Y[Y_2[i]]; y++){
				for(int d = index_D[D_1[i]]; d < index_D[D_2[i]]; d++)table[x][y][d]++;
			}
		}
	}

	ll ans = 0;

	for(int x = 0; x < size_X; x++){
		for(int y = 0; y < size_Y; y++){
			for(int d = 0; d < size_D; d++){
				if(table[x][y][d] >= K){
					ans += (X[x+1]-X[x])*(Y[y+1]-Y[y])*(D[d+1]-D[d]);
				}
			}
		}
	}

	printf("%lld\n",ans);


	return 0;
}



Measured memory_bytes: 12748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

#define  setbits(n) __builtin_popcount(n)
#define mp(a,b)  make_pair(a,b)
#define maxn 100003
int a[maxn], b[maxn], c[maxn];
int max(int a, int b)
{
	if (a > b)
		return a;
	else
		return b;
}
int max(int a, int b, int c)
{
	return max(a, max(b, c));
}
int dp[maxn + 1][4];
int maxpoints(int n, int  last)
{
	if (n == 0)
	{
		return 0;
	}
	if (dp[n][last] != -1)
		return dp[n][last];
	if (last == 0)
	{
		return dp[n][last] = max(a[n] + maxpoints(n - 1, 1), b[n] + maxpoints(n - 1, 2), c[n] + maxpoints(n - 1, 3));
	}
	else if (last == 1)
	{
		return dp[n][last] = max(b[n] + maxpoints(n - 1, 2), c[n] + maxpoints(n - 1, 3));
	}
	else if (last == 2)
	{
		return dp[n][last] = max(a[n] + maxpoints(n - 1, 1), c[n] + maxpoints(n - 1, 3));
	}
	else
	{
		return dp[n][last] = max(a[n] + maxpoints(n - 1, 1), b[n] + maxpoints(n - 1, 2));
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i, j, k, n, l, m;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for (i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	cout << maxpoints(n, 0);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,t;	cin>>s>>t;
	int count=0,k=s.size();
	FOR(i,0,k){
		if(s[i]!=t[i])	count++;
	}
	cout<<count<<endl;

    return 0;
}



Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
#define pop pop_back

const int N = 1e5 + 7;
const ll INF = 1e17;

int mod = 1000000007;

void solve()
{   
    ll a; ld b; cin >> a >> b;
    ll ans = a*b; cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t; 
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3748
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  int a,b;
  cin >> a >>b;
  kin(k);
  if(2*k>b-a){
    for(int i=a;i<=b;i++){
      cout << i << endl;
    }
  }
  else{
    for(int i=a;i<a+k;i++){
      cout << i << endl;
    }
    for(int i=b-k+1;i<=b;i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> nCr(long long n, long long r){
    const long long _MOD = 1000000007;
    vector<vector<long long>> _vec(n + 1, vector<long long>(n + 1, 0));
    for(long long i = 0; i < _vec.size(); i++){
        _vec[i][0] = 1;
        _vec[i][i] = 1;
    }
    for(long long i = 1; i < _vec.size(); i++){
        for(long long j = 1; j < i; j++){
            _vec[i][j] = _vec[i - 1][j] + _vec[i - 1][j - 1];
            if(_vec[i][j] > _MOD)_vec[i][j] %= _MOD;
        }
    }
    return _vec;
}

int main(){
    const long long MOD = 1e9 + 7;
    long long A, B;
    cin >> A >> B;
    long long R = A - B;
    vector<vector<long long>> C(2019, vector<long long>(2019));
    C = nCr(2019, 2019);
    
    for(long long i = 1; i <= B; i++){
        long long ans = C[R + 1][i] * C[B - 1][i - 1];
        if(ans > MOD)ans %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 64128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			int[] intArray = {x,y};
			if(intArray[0] == 0 & intArray[1] == 0){
				break;
			}else{
				if(intArray[0] > intArray[1]){
					int num = intArray[0];
					intArray[0] = intArray[1];
					intArray[1] = num;
				}
				
			}
			System.out.println(intArray[0] + " " + intArray[1]);

		}
		
	}
}


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

int main() {
  string A,B;
  cin >> A;
  cin >> B;
  if(A.size()>B.size()) cout << "GREATER" << endl;
  else if(A.size()<B.size()) cout << "LESS" << endl;
  else{
    int L=A.size();
    for(int i=0;i<L;i++){
      if(A.at(i)>B.at(i)){
        cout << "GREATER" << endl;
        return 0;
      }
      if(A.at(i)<B.at(i)){
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#define PI 3.141592653589

int main()
{
  int h,w,i,j;
  while(1)
    {
      scanf("%d %d",&h,&w);
      if(h == 0 && w == 0) break;
      for(i=0;i<h;i++)
	{
	  for(j=0;j<w;j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572