akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, long long K, std::vector<long long> a) {
  vl num;
  for (ll i = 0; i < N; i++) {
    ll sum = a[i];
    num.push_back(sum);
    for (ll j = i + 1; j < N; j++) {
      sum += a[j];
      num.push_back(sum);
    }
  }
  sort(all(num));

  ll r = 50; // 1125899906842624
  ll ans = 0;
  while (r >= 0) {
    auto iter = lower_bound(all(num), pow(2, r));
    ll k = num.end() - iter;

    ll p = pow(2, r);
    vl tmpNum;
    if (k >= K) {
      ans += p;
      for (auto it = iter; it != num.end(); it++) {
        tmpNum.push_back(*it - p);
      }
    } else {
      for (auto it = num.begin(); it != iter; it++) {
        tmpNum.push_back(*it);
      }
      for (auto it = iter; it != num.end(); it++) {
        tmpNum.push_back(*it - p);
      }
    }
    num = tmpNum;
    sort(all(num));

    r--;
  }
  print(ans);
}

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


Measured memory_bytes: 12528
#include<stdio.h>
int l;
int ans=0;

int main()
{
    while(scanf("%d",&l)!=-1)
    {
        ans=0;
        for(int i=0;i*l<600;i++)
        {
            ans=ans+i*l*i*l*l;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = Integer.parseInt(scan.nextLine());
    int[] cost = new int[n];
    String[] hiki = scan.nextLine().split(" ");
    for(int i = 0;i < n;i++){
      cost[i] = Integer.parseInt(hiki[i]);
    }
    int[] dp = new int[n];
    dp[0]=0;
    dp[1]=Math.abs(cost[1]-cost[0]);
    for(int i = 2;i < n;i++){
      dp[i]=
      Math.min(dp[i-2]+Math.abs(cost[i]-cost[i-2]),
      dp[i-1]+Math.abs(cost[i]-cost[i-1]));
    }
    System.out.println(dp[n-1]);
  }
  
}


Measured memory_bytes: 35624
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe (fromJust)

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [[Int]] -> [String]
solve (dice:qCnt:qs) =
    map solve' $ take (head qCnt) qs
    where
    solve' [upSide,foreSide] =
        let cmdSet = [(upSide, ["", "N", "W", "E", "S", "NN"]),
                        (foreSide, ["S", "", "NWS", "NES", "NEES", "N"])] in
        let d = foldl' f dice cmdSet in
        show $ d!!2
    f :: Dice -> (Int,[String]) -> Dice
    f dice (side,cmds) =
        let cmd = fromJust . lookup side $ zip dice cmds in
        foldl' rot dice cmd 

main =
    mapM_ putStrLn =<< solve . map (map read . words) . lines <$> getContents

Measured memory_bytes: 4000
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Brave Princess Revisited
public class Main{

	int[][] dist;
	void run(){
		Scanner sc =new Scanner(System.in);
		int INF = 1<<29;
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), L = sc.nextInt();
			if((n|m|L)==0)break;
			int[][] d = new int[n][n], e = new int[n][n];
			for(int[]a:d)Arrays.fill(a, INF);
			for(int[]a:e)Arrays.fill(a, INF);
			while(m--!=0){
				int s = sc.nextInt()-1, t = sc.nextInt()-1, D = sc.nextInt(), E = sc.nextInt();
				d[s][t] = d[t][s] = D; e[s][t] = e[t][s] = E;
			}
			dist = new int[n][L+1];
			for(int[]a:dist)Arrays.fill(a, INF);
			dist[0][L] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(n, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return dist[o1[0]][o1[1]]-dist[o2[0]][o2[1]];
				}
			});
			q.add(new int[]{0, L});
			int res = INF;
			while(!q.isEmpty()){
				int[] a = q.poll();
				int v = a[0], c = a[1];
				if(v==n-1){
					res = Math.min(res, dist[v][c]); continue;
				}
				for(int i=0;i<n;i++){
					if(d[v][i]==INF)continue;
					int w = dist[v][c] + e[v][i];
					if(w<dist[i][c]){
						dist[i][c] = w; q.add(new int[]{i, c});
					}
					if(d[v][i]<=c&&dist[v][c]<dist[i][c-d[v][i]]){
						dist[i][c-d[v][i]] = dist[v][c]; q.add(new int[]{i, c-d[v][i]});
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

// dp[i] := 足場iにたどり着くまでに支払うコストの最小値

// 足場Nにたどり着くまでに支払うコストの最小値
// dp[N] = min dp[N-1] + abs(h[N] - h[N-1]),
//             dp[N-2] + abs(h[N] - h[N-2])

using namespace std;
// 足場iにたどり着くまでに支払うコストの最小値
#define MAX_N 100001
int memo[MAX_N];
int h[MAX_N];
int solve(int i) {
  int ret = -1;
  if (memo[i] != -1) return memo[i];
  if (i <= 1) return 0; // 足場1にたどり着く最小値
  if (i >= 3) ret = min(solve(i-1) + abs(h[i] - h[i-1]), solve(i-2) + abs(h[i] - h[i-2]));
  else ret = solve(i-1) + abs(h[i] - h[i-1]);
  return memo[i] = ret;
}
int main() {
  int n;
  cin >> n;
  memset(memo, -1, sizeof(memo));
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  cout << solve(n) << endl;
  return 0;
}


Measured memory_bytes: 6672
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2 2
2 0
0 0
-1 0
1 0"# => r#"2
1"#,

r#"3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5"# => r#"3
1
2"#,

r#"5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000"# => r#"5
4
3
2
1"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, m: usize,
        ab: [(i64, i64); n],
        cd: [(i64, i64); m],
    }
    let mut ans = "".to_string();

    for i in 0..n {
        let mut near = (m, i64::abs(ab[i].0 - cd[m-1].0) + i64::abs(ab[i].1 - cd[m-1].1));
        for j in (0..m-1).rev() {
            let xy = i64::abs(ab[i].0 - cd[j].0) + i64::abs(ab[i].1 - cd[j].1);
            if xy <= near.1 {
                near = (j + 1, xy);
            }
        }
        ans.push_str(&near.0.to_string());
        if i != n - 1 {
            ans.push_str(&"\n");
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
n = int(input())
h = list(map(int,input().split()))


dp = [99999999]*n

dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
  
print(dp[n-1])

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

int main() {
    int x, y; cin >> x >> y;
    int sum = 0;
    if(x == 1){
        sum+= 300000;
    }
    if(x == 2){
        sum+= 200000;
    }
    if(x == 3){
        sum+= 100000;
    }
    if(y == 1){
        sum+= 300000;
    }
    if(y == 2){
        sum+= 200000;
    }
    if(y == 3){
        sum+= 100000;
    }
    if(x == 1 && y ==1) sum += 400000;
    
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "AC";
		if(s.charAt(0) != 'A') result = "WA";
		boolean flg = false;
		for(int i = 1; i < s.length(); i++){
		    if(Character.isUpperCase(s.charAt(i))){
		        if(i >= 2 && s.length()-2 >= i && s.charAt(i) == 'C' && !flg){
		            flg = true;
		        }else{
		            result = "WA";
		        }
		    }
		}
		if(!flg) result = "WA";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
        BidirectionalIterator last1 ,
        BidirectionalIterator first2 ,
        BidirectionalIterator last2 ){
    if (( first1 == last1 ) || ( first2 == last2 )) {
        return false ;
    }
    BidirectionalIterator m1 = last1 ;
    BidirectionalIterator m2 = last2 ; --m2;
    while (--m1 != first1 && !(* m1 < *m2 )){
    }
    bool result = (m1 == first1 ) && !(* first1 < *m2 );
    if (! result ) {
        while ( first2 != m2 && !(* m1 < * first2 )) {
            ++ first2 ;
        }
        first1 = m1;
        std :: iter_swap (first1 , first2 );
        ++ first1 ;
        ++ first2 ;
    }
    if (( first1 != last1 ) && ( first2 != last2 )) {
        m1 = last1 ; m2 = first2 ;
        while (( m1 != first1 ) && (m2 != last2 )) {
            std :: iter_swap (--m1 , m2 );
            ++ m2;
        }
        std :: reverse (first1 , m1 );
        std :: reverse (first1 , last1 );
        std :: reverse (m2 , last2 );
        std :: reverse (first2 , last2 );
    }
    return ! result ;
}

template < class BidirectionalIterator > bool next_combination ( BidirectionalIterator first , BidirectionalIterator middle , BidirectionalIterator last )
{
    return next_combination (first , middle , middle , last );
}


double d[22][3];

//ティツヲツ?ァツエツ?テ」ツ?凝」ツつ詠テ・ツ?凝・ツ渉姪」ツつ甘・ツ?コテ」ツ?凖ァツオツ?」ツ?ソテ・ツ青暗」ツつ湘」ツ??
double func(vector<int> v, int r){
    double ret = 0;
    do{
        double sum = 0;
        rep(i,r){
            rep(j,r){
                rep(k,3) sum += (d[v[i]][k] - d[v[j]][k]) * (d[v[i]][k] - d[v[j]][k]);
            }
        }
        ret = max(ret, sum / 2);
    }while(next_combination(v.begin(), v.begin() + r, v.end()));
    return ret;
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i,n) rep(j,3) cin >> d[i][j];

    vector<int> v;
    rep(i,n) v.emplace_back(i);
    cout <<fixed << setprecision(6)<< func(v,m) << endl;

}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

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

    vector<int> d(n), c(m);
    for(int i=0; i<n; i++) cin >> d[i];
    for(int i=0; i<m; i++) cin >> c[i];
    
    vector<vector<int> > dp(n+1, vector<int>(m+1, inf));
    dp[0][0] = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            dp[j][i+1] = min(dp[j][i+1], dp[j][i]);
        }
        for(int j=0; j<n; j++){
            dp[j+1][i+1] = min(dp[j+1][i+1], dp[j][i]+c[i]*d[j]);
        }
    }

    int ans=inf;
    for(int i=0; i<=m; i++){
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    char dif = 'A' - 'a';
    printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] +dif);

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b;
  cin>>a>>b;
 int ans=a-2*b;
  if(ans<0) ans=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

確率漸化式
確率DP 期待値DP
小数 近似値 絶対誤差 format

i個目のコイン(i = 0 , 1, ...)まで投げて表がちょうどj枚であった確率 xs[i][j]

xs[i][j] = p[i] * xs[i - 1][j - 1] + (1 - p[i]) * xs[i - 1][j]

これは、jが大きい方から見ていく前提で

xs[j] = p[i] * xs[j - 1] + (1 - p[i]) * xs[j]

とかける

求めるものは

sum(j > n - j) xs[j]

*/

void main(){
	int n = read.to!int;
	
	real[] ps = readln.chomp.split.map!(to!real).array;
	
	real[] xs = [1.0];
	foreach(i; 0 .. n){
		xs ~= 0.0;
		foreach_reverse(j; 0 .. i + 2){
			xs[j] *= 1.0 - ps[i];
			if(j > 0) xs[j] += ps[i] * xs[j - 1];
		}
		debug writeln("xs:", xs);
	}
	
	
	real ans = 0.0;
	foreach(j; n / 2 + 1 .. n + 1){
		ans += xs[j];
	}
	
	format("%0.12f", ans).writeln;
	
}


Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
}


Measured memory_bytes: 256
n,k,s=map(int,input().split())
if s >= 10**5+1:
  ans=[str(s)]*k
  ans.extend(["1"]*(n-k))
  print(" ".join(ans))
else:
  ans=[str(s)]*k
  ans.extend([str(10**9)]*(n-k))
  print(" ".join(ans))

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

static const int MAX = 100;
static const long long INFTY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            if(d[i][k] == INFTY) continue;
            for(int j=0; j<n; j++){
                if(d[k][j] == INFTY) continue;
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int e, u, v, c;
    cin >> n >> e;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            d[i][j] = ((i==j) ? 0 : INFTY);
        }
    }

    for(int i=0; i<e; i++){
        cin >> u >> v >> c;
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for(int i =0; i<n; i++) if(d[i][i] < 0) negative = true;

    if(negative){
        cout << "NEGATIVE CYCLE" << endl;
    }
    else{
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(j) cout << " ";
                if(d[i][j] == INFTY) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

using P = pair<ll, ll>;

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    vector<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());

    queue<P> q;
    ll total_damage = 0;
    ll ans = 0;
    rep(i, N) {
        ll x = p[i].first;
        ll h = p[i].second;
        while (q.size() && q.front().first < x) {
            total_damage -= q.front().second;
            q.pop();
        }

        h -= total_damage;
        if (h > 0) {
            ll cnt = (h + A - 1) / A;
            ans += cnt;
            ll damage = cnt * A;
            total_damage += damage;
            q.emplace(x + 2 * D, damage);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(void)
{
	int n,h[100000],i,max=0,cnt=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>h[i];
	for(i=n-2;i>=0;i--){
		if(h[i]>=h[i+1]) cnt++;
		else cnt=0;
		if(max<cnt) max=cnt;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 640
/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
*/
function Main(input) {
input = input.split("\n");
input = input[1].split(" ");
input = input.sort(num);
  var flag = false;
  for(var i=1;i<input.length;i++){
  if(input[i-1]==input[i]){
  flag = true;
  }
  }
  if(flag)console.log("NO");
  else console.log("YES")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}

Measured memory_bytes: 34088
def main():
  num, money  = map(int, input().split())
  
  array = [-1,-1,-1]
  for i in range(num+1):
    for j in range(num+1):
      if i + j > num:
        continue
      sum = i*10000 + j*5000 + (num-i-j)*1000
      if sum == money:
        array[0]=i
        array[1]=j
        array[2]=num-i-j
        break
  print("{0[0]} {0[1]} {0[2]}".format(array))
  
main()

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

int isprime(int X, int cx)
{
    int flag;
    int i;
    
    if (X == 2)
        return (1);
    if (X == 3)
        return (1);
    if (X == 5)
        return (1);
    if (X == 7)
        return (1);
        
    if (X < 100)
    {
        flag = 0;
        for (i=2; i<X; i++)
        {
            if (X % i == 0)
                return (0);
            else
                flag = 1;
        }
        if (flag == 1)
            return (1);
    }
    else
    {
        flag = 0;
        for (i=2; i<cx; i++)
        {
            if (X % i == 0)
                return (0);
            else
                flag = 1;
        }
        if (flag == 1)
            return (1);
    }
    return (0);
}

int    main(void)
{
      int    X;
      int num;
      int    cx;
      double rx;
    int tmp;
  
      num = scanf("%d", &X);
      if (num != 1)
          return (0);
  
      rx = sqrt(X);
      cx = ceil(rx);
  
      tmp = X;
      while (tmp <= 100100)
    {
        if (isprime(tmp, cx) == 1)
        {
              printf("%d", tmp);
              return (0);
        }
        else
        {
              tmp++;
        }
    }
      return (0);
}


Measured memory_bytes: 128
alp = ('A'..'Z').to_a

n = gets.to_i
s = gets.chomp

(0..(s.length - 1)).each do |i|
  if alp.index(s[i]) + n <= 25
    s[i] = alp[alp.index(s[i]) + n]
  else
    s[i] = alp[alp.index(s[i]) + n - 26]
  end
end

puts s

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

int Max(int &a,int b){return a=max(a,b);}

int dp[20010];

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

  int v[N],w[N];
  for(int i=0;i<n;i++)cin>>v[i]>>w[i];
  
  for(int i=0;i<n;i++) 
    for(int j=0;j<=W;j++)Max(dp[j+w[i]],dp[j]+v[i]);

  int ans = 0;
  for(int i=0;i<=W;i++)Max(ans,dp[i]);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int k, s;
    cin >> k >> s;
    ll sum = 0;
    rep(x, k + 1){
        rep(y, k + 1){
            int z = s - x - y;
            if(0 <= z && z <= k)
                ++sum;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
S = gets.chomp

ar = S.split("")
num1 = ar[0].to_i * 10 + ar[1].to_i
num2 = ar[2].to_i * 10 + ar[3].to_i

if num1 == 0 then
  if 1 <= num2 && num2 <= 12 then
    puts "YYMM"
  else
    puts "NA"
  end
elsif 1 <= num1 && num1 <= 12 then
  if 1 <= num2 && num2 <= 12 then
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if 1 <= num2 && num2 <= 12 then
    puts "YYMM"
  else
    puts "NA"
  end
end


Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int solve(int n) {
    int p = int(pow(n, 2));
    p /= 100;
    int res = 0, t = 1;
    for (int i = 0; i < 4; i++) {
        res += t * (p % 10);
        p /= 10;
        t*=10;
    }
    return res;
}

int main()
{
    int T, n;
    scanf("%d", &T);
    for (int t = 1; t <= T; t++) {
        scanf("%d", &n);
        printf("Case %d:\n", t);
        for (int i = 0; i < 10; i++) {
            n = solve(n);
            printf("%d\n", n);
        }
    }
}


Measured memory_bytes: 2708
H, W, K = gets.split.map(&:to_i)
map = []
1.upto(H) do |i|
  map << gets.chomp.split(//).map {|c| c == '#' ? 1 : 0 }
end

h = (0...H).to_a
w = (0...W).to_a

hc = (0..H).map {|i| h.combination(i).to_a }.flatten(1)
wc = (0..W).map {|i| w.combination(i).to_a }.flatten(1)

ans = 0
hc.each do |hci|
  wc.each do |wci|
    total = 0
    hci.each do |i|
      wci.each do |j|
        total += map[i][j]
      end
    end
    ans += 1 if total == K
  end
end
puts ans


Measured memory_bytes: 14332
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] startNum = new long['Z' - 'A' + 1];
        for (int i = 0; i < N; i++) {
            String str = sc.next();
            startNum[str.charAt(0) - 'A']++;
        }

        long comb = 0;
        char[] march = new char[]{'M', 'A', 'R', 'C', 'H' };

        for (int i = 0; i < march.length; i++) {
            for (int j = i + 1; j < march.length; j++) {
                for (int k = j + 1; k < march.length; k++) {
                    comb += startNum[march[i] - 'A'] * startNum[march[j] - 'A'] * startNum[march[k] - 'A'];
                }
            }
        }
        out.println(comb);
    }
}

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

w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

white = [0, w, 0, h]
for x, y, a in xya:
    if a == 1:
        white[0] = max(white[0], x)
    elif a == 2:
        white[1] = min(white[1], x)
    elif a == 3:
        white[2] = max(white[2], y)
    else:  # a == 4
        white[3] = min(white[3], y)

width = max(white[1] - white[0], 0)
height = max(white[3] - white[2], 0)

ans = width * height
print(ans)


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

bool check(const std::string& w)
{
  int chrs[26] = {0};

  for (auto it = std::begin(w); it != std::end(w); it++)
    chrs[(*it-'a')]++;

  bool flag = true;
  for (int ii=0; ii<26; ii++)
    if (chrs[ii]%2)
      return false;

  return true;
}

int main()
{
  std::string w;
  std::cin >> w;

  std::cout <<  (check(w) ? "Yes" : "No") << std::endl;
  
  return 0;
}


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

typedef long long ll;
// #define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);




	int n,k,d;
	cin>>n>>k;
	vector<int> cnt(n+1,0);
	for(int i=0;i<k;i++){
		int d; cin>>d;
		for(int j=0;j<d;j++){
			int x; cin>>x;
			cnt[x]++;
		}
	}

	int ans = 0;
	for(int i=1;i<=n;i++){
		if (cnt[i] == 0)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    System.out.println(a<=x &&(a+b>=x || a==x) ?"YES":"NO");
  }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;

bool isVowel(char c){
	char vowel[5]={'a','e','i','o','u'};
	rep(i,5)if(c==vowel[i])return 1;
	return 0;
}

int main(){
	char c;
	cin>>c;
	cout<<(isVowel(c)?"vowel":"consonant")<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

namespace ITP1_6_C
{
    class Program
    {
        static Building[] Buildings;
        static void Main(string[] args)
        {
            Buildings = new Building[4];
            for (int i = 0; i < Buildings.Length; i++) Buildings[i] = new Building();

            int count = Convert.ToInt32(Console.ReadLine());

            for(int i = 0; i < count; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int buildingNum = Convert.ToInt32(input[0]) - 1;
                int floorNum = Convert.ToInt32(input[1]) - 1;
                int roomNum = Convert.ToInt32(input[2]) - 1;
                int peopleNum = Convert.ToInt32(input[3]);

                Buildings[buildingNum][floorNum][roomNum] += peopleNum;
            }

            for(int i = 0; i < Buildings.Length; i++)
            {
                Console.WriteLine(Buildings[i].ToString());

                if(i < Buildings.Length - 1)
                {
                    Console.WriteLine("####################");
                }
            }
        }
    }

    public class Building
    {
        public int FloorCount { get; protected set; }

        public Floor this[int index]
        {
            get
            {
                return Floors[index];
            }
            set
            {
                Floors[index] = value;
            }
        }
        protected Floor[] Floors { get; set; }

        public Building(int floorCount = 3)
        {
            FloorCount = floorCount;
            Floors = new Floor[FloorCount];
            for (int i = 0; i < FloorCount; i++) Floors[i] = new Floor();
        }

        public override string ToString()
        {
            var builder = new StringBuilder();

            for (int i = 0; i < FloorCount; i++)
            {
                builder.AppendLine(Floors[i].ToString());
            }

            return builder.ToString().TrimEnd('\r', '\n');
        }
    }

    public class Floor
    {
        public int RoomCount { get; protected set; } 

        public int this[int index]
        {
            get
            {
                return Rooms[index];
            }
            set
            {
                Rooms[index] = value;
            }
        }
        protected int[] Rooms { get; set; }

        public Floor(int roomCount = 10)
        {
            RoomCount = roomCount;
            Rooms = new int[RoomCount];
        }

        public override string ToString()
        {
            return " " + string.Join(" ", Rooms.Select(e => e.ToString()).ToArray());
        }
    }
}

Measured memory_bytes: 9632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main (){
    int n;
    cin >> n;
    vector<int>v(n);
    int maxi = 20001;
    rep(i, n) {
        int p;
        cin >> p;
        v[--p] = i + 1;
    }
    vector<int> a(n), b(n);
    rep(i, n) {
        a[i] = maxi* (i + 1);
        b[i] = maxi* (n - 1 - i) + v[i];
    }
    join(a); cout << endl;
    join(b); cout << endl;
}




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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int dp[100005],h[100005];
int solve(){
    cin>>n;
    rep(i,1,n) cin>>h[i];
    dp[2]=abs(h[1]-h[2]);
    rep(i,3,n){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define For(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

int N;

int main() {
    double M;
    cin >> N >> M;
    vector<double> a(N);
    rep(i,N) cin >> a.at(i);
    double sum=0;
    rep(i,N) sum+=a.at(i);
    int count=0;
    rep(i,N) {
        if(sum/(4*M)<=a.at(i)) count++;
    }
    if(count<M) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

p,q,r = na()

print(p+q+r-max(p,q,r))

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

int main()
{
  int x;
  cin>>x;
  int n1000,n5;
  
  n1000=(x/500)*1000;
    
  x=x-(x/500)*500;
  n5=(x/5)*5;
  
  cout<<n1000+n5<<endl;
  
}

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

using namespace std;

int N;
int a[(int)1e5+10][3];
int dp[(int)1e5+10][3];

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> a[i][0] >> a[i][1] >> a[i][2];

	for(int j = 0; j < 3; ++j) dp[0][j] = a[0][j];
	for(int i = 1; i < N; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 3; ++k){
				if(j == k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]);
			}
			dp[i][j] += a[i][j];
		}
	}
	int ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
	cout << ans << endl;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    vector<vector<bool>> vis(N, vector<bool>(N));
    int ma = 2;
    rep(i, N) for (int j = i + 1; j < N; j++) if (!vis[i][j]) {
        int d = a[j] - a[i];
        int prev = i, t = 2;
        for (ll x = a[j]; ; x += d, t++) {
            int k = lower_bound(all(a), x) - a.begin();
            if (i < k && k < N && a[k] == x) {
                vis[prev][k] = true;
                prev = k;
                ma = max(ma, t);
            }
            else break;
        }
    }
    cout << ma << endl;
}



Measured memory_bytes: 6316
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for __ in range(M):
    B.append(input())

for i in range(N-M+1):
    if B[0] in A[i]:
        for j in range(N-M+1):
            flag = True
            for k in range(M):
                if B[k] != A[i+k][j:j+M]:
                    flag = False
                    break
            if flag:
                print('Yes')
                exit()
print('No')
exit()

Measured memory_bytes: 38384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		long K = 1000000007;
		long ans = 1;
		
		for(int n=1; n<=N; n++) {
			ans = ans*n%K; 
		}	
		
		System.out.print(ans);
		keyboard.close();
	}
}

Measured memory_bytes: 35560
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int k){
 
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int num, i, x;
  char s[20];
  scanf("%d", &num);

  for ( i = 0; i < num; i++ ){
    scanf("%s", s);
    if ( strcmp(s, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(s, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
# frozen_string_literal: true

N = gets.to_i

WORDS = N.times.map { Kernel.gets }.map(&:chomp)

if WORDS.size != WORDS.uniq.size
  puts "No"
  exit 0
end

unless WORDS.each_cons(2).all? {|pair| pair[0][-1] == pair[1][0] }
  puts "No"
  exit 0
end

puts "Yes"


Measured memory_bytes: 1788
K, N = map(int, input().split())
AList = list(map(int, input().split()))

if N == 2:
    ans = AList[1] - AList[0]
else:
    lengths = [AList[-1] - AList[0]]
    for i in range(1, N):
        lengths.append(K - AList[i] + AList[i-1])
    ans = min(lengths)
print(ans)


Measured memory_bytes: 26444
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=132005;
int n,fa[N],fd[N],ch[N][2],dd[N][2];
ll l,r,mid,ans,minn[N];
vector<pair<ll,ll> > vec[N];
char c[10000005],*p=c;
inline int rd(){
	register int res=0;
	while(*p<'0'||*p>'9'){
		p++;
	}
	while(*p>='0'&&*p<='9'){
		res=res*10+*p-'0';
		p++;
	}
	return res;
}
bool cmp1(pair<ll,ll> a,pair<ll,ll> b){
	return a.first<b.first;
}
bool cmp2(pair<ll,ll> a,pair<ll,ll> b){
	return a.second<b.second;
}
void merge(vector<pair<ll,ll> > &a,vector<pair<ll,ll> > &b,vector<pair<ll,ll> > &c){
	if(a.size()>b.size()){
		swap(a,b);
	}
	sort(a.begin(),a.end(),cmp2);
	sort(b.begin(),b.end(),cmp1);
	minn[0]=b[0].second;
	for(int i=1;i<b.size();i++){
		minn[i]=min(minn[i-1],b[i].second);
	}
	for(int i=0,j=b.size()-1;i<a.size();i++){
		while(j>=0&&a[i].second+b[j].first>mid){
			j--;
		}
		if(j>=0&&(!c.size()||(minn[j]!=c.back().second||a[i].first<c.back().first))){
			c.push_back(make_pair(a[i].first,minn[j]));
		}
	}
	sort(a.begin(),a.end(),cmp1);
	sort(b.begin(),b.end(),cmp2);
	minn[0]=b[0].first;
	for(int i=1;i<b.size();i++){
		minn[i]=min(minn[i-1],b[i].first);
	}
	for(int i=0,j=b.size()-1;i<a.size();i++){
		while(j>=0&&a[i].first+b[j].second>mid){
			j--;
		}
		if(j>=0&&(!c.size()||(minn[j]!=c.back().first||a[i].second<c.back().second))){
			c.push_back(make_pair(minn[j],a[i].second));
		}
	}
}
void dfs(int u){
	if(!ch[u][0]){
		vec[u].clear();
		vec[u].push_back(make_pair(0LL,0LL));
		return;
	}
	dfs(ch[u][0]);
	dfs(ch[u][1]);
	vec[u].clear();
	for(int i=0;i<vec[ch[u][0]].size();i++){
		vec[ch[u][0]][i].first+=dd[u][0];
		vec[ch[u][0]][i].second+=dd[u][0];
	}
	for(int i=0;i<vec[ch[u][1]].size();i++){
		vec[ch[u][1]][i].first+=dd[u][1];
		vec[ch[u][1]][i].second+=dd[u][1];
	}
	merge(vec[ch[u][0]],vec[ch[u][1]],vec[u]);
}
int main(){
	fread(c,1,10000000,stdin);
	n=rd();
	for(int i=2;i<=n;i++){
		fa[i]=rd(),fd[i]=rd();
		if(!ch[fa[i]][0]){
			ch[fa[i]][0]=i;
			dd[fa[i]][0]=fd[i];
		}else{
			ch[fa[i]][1]=i;
			dd[fa[i]][1]=fd[i];
		}
		r+=2*fd[i];
	}
	while(l<=r){
		mid=(l+r)/2;
		dfs(1);
		if(vec[1].size()){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec a(N);
    rep(i, N) cin >> a[i];
    int res = 0;
    rep(i, N){
        if(i%2==0 && a[i]%2 == 1) res++;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7660
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{   
    ll n;
    fin(n);
    ll ar[n];
    for(ll i = 0; i < n; i++)
        fin(ar[i]);
    ll perm[n];
    for(ll i = 0; i < n; i++)
        perm[i] = i + 1;
    ll idx = 0;
    ll now = perm[idx];
    ll i = 0;
    while(i < n)
    {
        if(ar[i] != now)
            i++;
        else
        {
            idx++;
            now = perm[idx];
        }
    }
    ll present = idx;
    ll Break = n - present;
    if(Break > (n - 1))
    {
        puts("-1");
    }
    else
    {
        fout(Break);
    }
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

int main()
{
  int k, a, b;
  std::cin >> k >> a >> b;
  int sub = b - a;
  if (a % k == 0)
  {
    std::cout << "OK" << std::endl;
    return 0;
  }
  if ((a % k) + sub >= k)
  {
    std::cout << "OK" << std::endl;
  }
  else
  {
    std::cout << "NG" << std::endl;
  }
  
  return 0;
}

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

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,n,a[100000],ans=0,t,p;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for (i=0;i<n;i++){
		if (i==0){
			p=1;
			t=a[i];
		}
		else {
			if (t!=a[i]){
				ans+=(p%2);
				p=1;
				t=a[i];
			}
			else {
				p++;
			}
		}
	}
	cout<<ans+p%2;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

class BipartiteMatching {
    vector<vector<ll> > G;
    vll match;
    vector<bool> vis;
    ll N;
    BipartiteMatching(){}
    bool dfs(ll v) {
        vis[v] = true;
        for(auto &u:G[v]) {
            ll w = match[u];
            if(w < 0 || !vis[w] && dfs(w)) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
public:
    BipartiteMatching(ll size) {
        G.resize(size);
        N = size;
    }
    void initialize(ll size) {
        G.clear();
        G.resize(size);
        N = size;
    }
    void unite(ll u, ll v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ll search() {
        ll res = 0;
        match.assign(N, -1);
        for(int v = 0; v < N; v++) {
            if(match[v] < 0) {
                vis.assign(N, false);
                if(dfs(v)) res++;
            }
        }
        return res;
    }
};

void solve() {
    ll N, K, M;
    cin >> N >> K >> M;
    ll s = N + K, t = K + N + 1;
    BipartiteMatching g(N+K);
    REP(i, M) {
        ll c, p;
        cin >> c >> p;
        g.unite(c, N + p);
    }
    out(g.search());
}

int main() {
    fast_io;
    solve();
    return 0;
}



Measured memory_bytes: 3348