akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int64_t gcd(int64_t a, int64_t b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int64_t lcm(int64_t a, int64_t b){
	return a / gcd(a, b) * b;
}

int main(void) {
    int N;
    cin >> N;
    int64_t ans = 1;
    while(N--) {
        int64_t T;
        cin >> T;
        ans = lcm(T, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n*3];
      for(int i = 0; i < n * 3; i++)
        arr[i] = sc.nextInt();

      Arrays.sort(arr);
      long sum = 0;
      for(int i = n * 3 - 2, t = 0; i >= 0 && t < n; i-=2, t++)
        sum = sum + arr[i];
      System.out.println(sum);
  }
}

Measured memory_bytes: 91952
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()){
            int x = s.nextInt();
            int y = s.nextInt();
            if(x == 0 && y == 0) break;
            String result;
            if( x > y ){
                result = y + " " + x;
            } else {
                result = x + " " + y;
            }
            System.out.println(result);
        }
    }

}

Measured memory_bytes: 26392
from collections import defaultdict
n = int(input())
al = list(map(int, input().split()))
ia = [(i+1) - a for i, a in enumerate(al)]
jb = [(i+1) + a for i, a in enumerate(al)]
# print(ia)
# print(jb)
d_ia = defaultdict(lambda: 0)
d_jb = defaultdict(lambda: 0)
for t in ia:
    d_ia[t] += 1
for t in jb:
    d_jb[t] += 1

ans = 0

for k, v in d_ia.items():
    ans += (d_jb[k]*v)
print(ans)


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

using namespace std;

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

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

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

	int ret[4] = {};

	REP(i, N)
	{
		string s;
		cin >> s;
		if(s == "AC") ret[0]++;
		else if(s == "WA") ret[1]++;
		else if(s == "TLE") ret[2]++;
		else if(s == "RE") ret[3]++;
	}

	cout << "AC x " << ret[0] << endl;
	cout << "WA x " << ret[1] << endl;
	cout << "TLE x " << ret[2] << endl;
	cout << "RE x " << ret[3] << endl;

	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);

    int A, B;
    cin >> A >> B;
    if (max (A, B) >= 10)
        cout << "-1\n";
    else
        cout << A * B << "\n";
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

string s;
int n;
int main(int argc,char* argv[]){
	cin>>s>>n;
	for(int i=0;i<s.size();i+=n){
		cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;



unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}


int MAXN = 1100;
bool **m;
vector<Pi> *g;

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

  m = new bool *[MAXN];
  g = new vector<Pi> [MAXN * MAXN];
  for (int i = 0; i < MAXN; i++)
    m[i] = new bool[MAXN];
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++)
      m[i][j] = 0;

  int h, w;
  cin >> h >> w;
  char c;
  int cx, cy, dx, dy;
  cin >> cx >> cy >> dx >> dy;
  cx--, cy--, dx--, dy--;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++){
      cin >> c;
      if (c == '.')
	m[i][j] = 1;
    }

  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++){
      int cur = MAXN * i + j;
      if (m[i][j])
	for (int ii = i - 2; ii <= i + 2; ii++)
	  for (int jj = j - 2; jj <= j + 2; jj++){
	    int can  = MAXN * ii + jj;
	    if (ii < h and ii >= 0 and jj < w and jj >= 0 and (not (ii == i and jj == j)) and m[ii][jj]){
	      if (abs(ii - i) + abs(jj - j) == 1)
		g[cur].pb(MP(can, 0));
	      else
		g[cur].pb(MP(can, 1));
	    }
	  }
    }

  
  deque<int> q;
  int *dist = new int[MAXN * MAXN];
  for (int i = 0; i < MAXN * MAXN; i++)
    dist[i] = INF;
  dist[cx * MAXN + cy] = 0;
  q.push_back(cx * MAXN + cy);

  while (!q.empty()){
    int v = q.front();
    q.pop_front();
    if (v == dx * MAXN + dy){
      cout << dist[v] << endl;
      exit(0);
    }
    for (auto item: g[v]){
      if (dist[item.fi] > dist[v] + item.se){
	dist[item.fi] = dist[v] + item.se; 
	if (item.se == 0)
	  q.push_front(item.fi);
	else
	  q.push_back(item.fi);
      }
    }
    
  }

  cout << -1 << endl;
  
  
}


Measured memory_bytes: 174348
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

typedef long long LL;

LL n, m;

int main()
{	
 	//freopen("in.txt","r",stdin);
 	//freopen("out.txt","w",stdout);
    cin >> n >> m;
    LL sum = 0;
    if (n * 2 <= m)
    {
        sum += n;
        m -= n * 2;
    }
    else
    {
        sum += m / 2;
        m = 0;
    }
    sum += m / 4;
    cout << sum << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#include <complex>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	long long ans = 0;
	int now = 0;
	bool state = 0;
	for(int i = 0; i < s.size(); i ++)
	{
		if(state == 0)
		{
			if(s[i] == 'A')
				now ++;
			else if(s[i] == 'B')
				state = 1;
			else
				now = 0;
		}
		else
		{
			if(s[i] == 'A')
			{
				now = 1;
				state = 0;
			}
			else if(s[i] == 'B')
			{
				now = 0;
				state = 0;
			}
			else
			{
				ans += now;
				state = 0;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

using Node = vector<int>; // 隣接リスト
using NodeList = vector<Node>;

int main() {
    int n, m;
    cin >> n >> m;
    NodeList nodes(n, Node(vector<int>(0)));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    int ans = 0;
    function<void(int, vector<int>)> dfs = [&ans, &nodes, &n, &dfs](int index, vector<int> visited) {
        visited.push_back(index);
        auto children = nodes[index];
        auto result = remove_if(children.begin(), children.end(), [&visited](auto x) {
            return std::find(visited.begin(), visited.end(), x) != visited.end();
        });
        children.erase(result, children.end());
        if (children.size() == 0) {
            if (visited.size() == n) ans++;
        } else {
            for (auto nextNode : children) {
                dfs(nextNode, visited);
            }
        }
    };

    dfs(0, vector<int>(0));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
  int n; cin >> n;
  int p[n];
  int minnum = 1001001001;
  int ans = 0;
  FOR(i,0,n-1) {
    cin >> p[i];
    if(p[i]<=minnum) {
      chmin(minnum,p[i]);
      ++ans;
    }
  }
  cout << ans << endl;

  

  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;


int main() {
  int n,k;cin >> n >> k;
  int ans=0;
  rep(i,n){
    int h;cin >> h;
    if(h>=k)ans ++;
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        int[] inputs = input();
//        int[] inputs = mockup();

        int swapCount = sort(inputs);

        // output
        StringBuilder output = new StringBuilder();
        for (int i : inputs) {
            output.append(i + " ");
        }
        String outputString = output.toString();
        System.out.println(outputString.substring(0,outputString.length() - 1));
        System.out.println(swapCount);
    }

    /**
     * selection sort
     * @param inputs
     * @return
     */
    private static int sort(int[] inputs) {
        int swapCount = 0;
        int min = 0;

        for (int i = 0; i < inputs.length; i++) {
            min = i;
            for (int j = i; j < inputs.length; j++) {
                if (inputs[j] < inputs[min]) {
                    min = j;
                }
            }
            if (i != min) {
                swap(inputs, i, min);
                swapCount++;
            }
        }
        return swapCount;
    }

    private static int[] mockup() {
        int a[] = {5,6,4,2,1,3};
        return a;
    }

    private static void swap(int[] inputs, int j, int i) {
        int a = inputs[j];
        int b = inputs[i];
        inputs[i] = a;
        inputs[j] = b;
    }

    public static int[] input() {
        Scanner in = new Scanner(System.in);
        int count = in.nextInt();
        int[] inputs = new int[count];
        for (int i = 0; i < count; i++) {
            inputs[i] = in.nextInt();
        }
        in.close();
        return inputs;
    }

}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {// ここにプログラムを追記
    int x , y;
    cin >> x >> y;
    sum += y - x + 1;
  }
  cout << sum << endl;
}

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

using namespace std;

typedef long long ll;

  int main() {
  ll n, sum = 0;
  cin >> n;
  for (int i = 1; i < n+1; i++) {
    if (i % 15 != 0) {
      if (i % 3 != 0) {
        if (i % 5 != 0) {
          sum += i;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

class Hill:
  def __init__(self, H):
    self.observatories = [Observatory(i, self) for i in H]
    self.count = 0

  def read_pathway(self, A, B):
    self.observatories[A-1].add_neighbor(B-1)
    self.observatories[B-1].add_neighbor(A-1)
    
  def count_good_observatory(self):
    for observatory in self.observatories:
      observatory.judge()
    print(self.count)

class Observatory:
  def __init__(self,height, Hill):
    self.height = height
    self.neighbors = []
    self.Hill = Hill
    
  def add_neighbor(self, x):
    self.neighbors.append(self.Hill.observatories[x])
    
  def judge(self):
    flag = True
    for neighbor in self.neighbors:
      if self.height <= neighbor.height:
        flag = False
        break      
    if flag:
      self.Hill.count += 1
    
AtCoderHill = Hill(H)
for i in range(M):
  A, B = [int(i) for i in input().split()]
  AtCoderHill.read_pathway(A, B)
AtCoderHill.count_good_observatory()

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

int main(){

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

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

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

//int main()
//{
//	fastIOS();
//
//	int n; cin >> n;
//    vector<int> v;
//    
//    REP(i,n)
//    {
//        int temp;
//        cin >> temp;
//        v.push_back(temp);
//    }
//    
//    int min[n];
//    min[0] = INT_MAX;
//    int cnt = 0;
//    
//    REP(i,n)
//    {
//        if(min[cnt] >= v[i])
//        {
//            cnt++;
//            min[cnt] = v[i];
//        }
//    }
//    
//    cout << cnt << endl;
//    
//    return 0;
//}


int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 

int main()
{
    fastIOS();
    
    int n; cin >> n;
    int arr[n];
    
    REP(i,n)
    {
        cin>> arr[i];
    }
    
    cout << MinimumNumIncreasingSubsequences(arr,n) << endl;
    
    return 0;
}

Measured memory_bytes: 5376
//G.cpp
#include<bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;

void visit_bfs(vector< vector<int> > &adj_mat, vector<int> &dist, int node){
	queue<int> vque;
	vque.push(node);
	dist[node] = 0;
	while(!vque.empty()){
		node = vque.front();
		vque.pop();
		for(int nn: adj_mat[node]){
			dist[nn] = max(dist[nn], dist[node] + 1);
			vque.push(nn);
		}
	}

}

int dfs(vector< vector<int> > &adj_mat, vector<int> &dist, int node){

		if(dist[node])
			return dist[node];
		for(int nn: adj_mat[node]){
			dist[node] = max(dist[node], dfs(adj_mat, dist, nn) + 1);
		}
		return dist[node];
}

int main(){
	int n, m;
	cin >> n >> m;
	unordered_set<int> non_leafs;
	vector< vector<int> >adj_mat(n, vector<int>(0, 0)); 
	int x, y;
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		non_leafs.insert(y-1);
		adj_mat[x-1].push_back(y-1);
	}

	vector<int> dist(n, 0);

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(non_leafs.find(i) == non_leafs.end()){
			ans = max(ans, dfs(adj_mat, dist, i));
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const ll INF = (1LL<<60);
/*RMQ & RUQ*/
template <typename T> struct LazySegmentTree {
  
  int n;
  vector<T> node, lazy;

  LazySegmentTree (int sz, T init = 0) {
    n = 1; while (n < sz) n <<= 1;
    node.assign(2*n, init);
    lazy.assign(2*n,-1); 
  }

  void eval (int k) {
    if (lazy[k] == -1) return ;
    node[k] = lazy[k];
    if (k < n) {
      lazy[2*k+1] = lazy[k];
      lazy[2*k+2] = lazy[k];
    }
    lazy[k] = -1;
  }

  void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
    eval(k);
    if (r < 0) r = n;
    if (b <= l || r <= a) return ;
    if (a <= l && r <= b) {
      lazy[k] = x;
      eval(k);
    } else {
      update(a,b,x,2*k+1,l,(r+l)/2);
      update(a,b,x,2*k+2,(r+l)/2,r);
      node[k] = min(node[2*k+1], node[2*k+2]);
    }
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    eval(k);
    if (r < 0) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2*k+1, l, (l+r)/2);
    T vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }

};

int main(){ 
  int n, q;
  cin >> n >> q;
  LazySegmentTree<ll> sg(n, (1LL<<31)-1);
  while (q--) {
    int c, a, b;
    ll x;
    cin >> c >> a >> b;
    if (c) {
      cout << sg.query(a,b+1) << endl;
    } else {
      cin >> x;
      sg.update(a,b+1,x);
    }
  }
  return 0;
} 


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

flag = 0

for i in A:
  if i%2 == 0:
    if (i%3 == 0) |(i%5 == 0):
      pass
    else:
      flag+=1
  else:
    pass
if flag ==0:
  ans ="APPROVED"
else:
  ans ="DENIED"
print(ans)

Measured memory_bytes: 3060
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 15;
int n , x[N] , y[N] , a[N] , fa[N];
db f[1 << N] , dis[N][N];
inline int F(int x) {return fa[x] == x ? x : fa[x] = F(fa[x]);}

int main(){
  cin >> n;
  rep(i,0,n) cin >> x[i] >> y[i] >> a[i];
  rep(i,0,n) rep(j,0,n) {
    db dx = x[i] - x[j];
    db dy = y[i] - y[j];
    dis[i][j] = sqrt(dx*dx+dy*dy);
  }
  rep(i,0,1<<n) {
    if(i == 0) continue;
    vi pts;
    rep(j,0,n) if(i >> j & 1) pts.pb(j);
    vector<pair<db,pii> > edges;
    rep(i,0,sz(pts)) rep(j,0,i) {
      edges.pb(mp(dis[pts[i]][pts[j]] , mp(pts[i] , pts[j])));
    }
    sort(all(edges));
    for(int p : pts) fa[p] = p;
    db cost = 0.;
    for(auto e : edges) {
      int u = F(e.se.fi);
      int v = F(e.se.se);
      if(u != v) {
        fa[v] = u;
        cost += e.fi;
      }
    }
    db sum = 0;
    for(int p : pts) sum += a[p];
    f[i] = (sum - cost) / sz(pts);
  }
  rep(i,1,1<<n) {
    for(int j=i;j;j=(j-1)&i) {
      f[i] = max(f[i] , min(f[j] , f[i ^ j]));
    }
  }
  printf("%.12f\n",f[(1<<n)-1]);
  return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if(x==0 && y==0) {
				break;
			}

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
}


Measured memory_bytes: 26720
#include <iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main() {
	int n;cin>>n;
	vector<long long> a(n+1),r(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
		r[a[i]]=i;
	}
//	priority_queue<long long,vector<long long>,greater<long long>>  q;
//	vector<long long> v;
	map<long long,int> m;
	m[r[1]]=0;
//	q.push(r[1]);
//	v.push_back(r[1]);
	long long ans=(n-r[1]+1)*r[1];
	for(int i=2;i<=n;i++){
//		int num=lower_bound(v.begin(),v.end(),r[i])-v.begin();
		auto itr=m.lower_bound(r[i]);
		long long left,right;
//		if(num==0){
//			left=0;
//		}else{
//			left=v[num-1];
//		}
		if(itr==m.begin()){
			left=0;
		}else{
			itr--;
			left=itr->first;
			itr++;
		}
		if(itr==m.end()){
			right=n+1;
		}else{
			right=itr->first;
		}
//		if(num==v.size()){
//			right=n+1;
//		}else{
//			right=v[num];
//		}
		ans+=i*(right-r[i])*(r[i]-left);
		m[r[i]]=0;
//		v.insert(v.begin()+num,r[i]);
//		cout<<ans<<' '<<i<<' '<<left<<' '<<right<<endl;
//		for(int j=0;j<v.size();j++){
//			cout<<v[j]<<' ';
//		}
//		cout<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

#define readv(v) for(auto& a : v) cin >> a;

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;

int H, W;
vvi G;
vvvvi dist;

bool valid(int i, int j, int i2, int j2){
    if (not G[i][j] or not G[i2][j2]) return false;
    if (i < i2) return true;
    if (i == i2) return j < j2;
    return false;
}

bool ins(int i, int j){
    return i >= 0 and j >= 0 and i < H and j < W and G[i][j];
}

int bfs(int i, int j, int i2, int j2){
    if (dist[i][j][i2][j2] != -1) return dist[i][j][i2][j2];
    vvi vis(H, vi(W, 0));
    queue<vi> q;
    q.push({i,j,0});
    while (not q.empty()) {
        vi u = q.front(); q.pop();
        dist[i][j][u[0]][u[1]] = dist[u[0]][u[1]][i][j] = u[2];
        if (u[0] == i2 and u[1] == j2) return u[2];
        if (not vis[u[0]][u[1]]) {
            vis[u[0]][u[1]] = 1;
            if (ins(u[0]+1, u[1])) q.push({u[0]+1, u[1], u[2]+1});
            if (ins(u[0], u[1]-1)) q.push({u[0], u[1]-1, u[2]+1});
            if (ins(u[0]-1, u[1])) q.push({u[0]-1, u[1], u[2]+1});
            if (ins(u[0], u[1]+1)) q.push({u[0], u[1]+1, u[2]+1});
        }
    }
    return -1;
}

int main(){
    cin >> H >> W;
    G = vvi(H, vi(W, 0));
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            char c; cin >> c;
            if (c == '.') G[i][j] = 1;
        }
    
    dist = vvvvi(H, vvvi(W, vvi(H, vi(W, -1))));
    int maxim = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int i2 = 0; i2 < H; i2++) {
                for (int j2 = 0; j2 < W; j2++) {
                    if (valid(i, j, i2, j2)) {
                        int d = bfs(i, j, i2, j2);
                        if (d > maxim) maxim = d;
                    }
                }
            }
        }
    }
    cout << maxim << endl;
}


Measured memory_bytes: 1920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vint d(100);
	rep(i, n){
		int a;cin>>a;
		d[a-1]++;
	}
	int ans = 0;
	rep(i, 100){
		if(d[i] > 0)ans++;
	}
	cout << ans << endl;
	return 0;
}


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


class Program
{
	//mod（10^9 + 7）
	static readonly long mod = 1000000007;

	//Main
	static void Main(string[] args)
	{
		int S = int.Parse(Console.ReadLine());

		//累積和
		long[] accum = new long[S+1];
		if(S >= 3){
			accum[3] = 1;
		}

		for(int i=4; i<S+1; i++){
			//まず、i単体で1通りある
			long temp = 1;

			//単体ではない場合、今までのケツに玉を加えるイメージ
			//対象は、3 <= j <= i-3までの和
			/*
			3つ前の並びのケツに3つ玉を加え、
			4つ前のケツに4個加え etc...
			*/
			if(3 <= i-3){
				long sum = accum[i-3] - accum[2];
				temp += sum;
				temp %= mod;
			}

			//累積和に反映
			accum[i] = accum[i-1] + temp;
			accum[i] %= mod;
		}

		long ans = accum[S] - accum[S-1];

		if(ans < 0){
			ans += mod;
		}
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 17552
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    int N,M,i,error=0;
    cin>>N>>M;
    vector<int> ans(N,0),count(N,0);
    vector<vector<int> > data(M,vector<int>(2));
    rep(i,0,M)cin>>data.at(i).at(0)>>data.at(i).at(1);
    rep(i,0,M){
        if(data.at(i).at(0)==1 && data.at(i).at(1)==0 && N!=1)error++;
        if(count.at(data.at(i).at(0)-1)==0){
            ans.at(data.at(i).at(0)-1)=data.at(i).at(1);
            count.at(data.at(i).at(0)-1)++;
        }else{
            if(ans.at(data.at(i).at(0)-1)!=data.at(i).at(1)){
                error++;
            }
        }
    }
    if(N!=1 && ans.at(0)==0)ans.at(0)++;
    if(error!=0)cout<<-1;
    else rep(i,0,N)cout<<ans.at(i);
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define l_ength size
#define MOD (ll)(1e9+7)

int main(void){
int n,i,j;
ll dp[3][123456],t=1ll;;
fill(dp[0],dp[3],0ll);
string s;
cin>>s;
n=s.l_ength();
for(i=0;i<n;++i){
for(j=0;j<3;++j){
dp[j][i+1] = dp[j][i];
if(s[i]=='?'){
dp[j][i+1]*=3;
dp[j][i+1]%=MOD;
}
if(s[i]=='A'+j||s[i]=='?'){
dp[j][i+1]+=((j)?dp[j-1][i]:t);
dp[j][i+1]%=MOD;
}
}
if(s[i]=='?'){
t*=3;
t%=MOD;
}
}
cout<<dp[2][n]<<endl;
return 0;
}


Measured memory_bytes: 3328
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, M) = reads()

# 2 <= N
# 1 <= M

appears = [0] * (10**5 + 1)

card = [0] * M
pair = [0] * M

for x in reads():
  if appears[x]:
    pair[x%M] += 1
  appears[x] ^= True
  card[x%M] += 1

result = 0

result += card[0] // 2

if M % 2 == 0:
  result += card[M//2] // 2


# print(card)
# print(pair)

for i in range(1, (M-1)//2+1):
  use = min(card[i], card[M-i])
  card[i] -= use; card[M-i] -= use
  result += use
  # if use > 0:
  #   print("i = " + str(i))
  #   print("use = " + str(use))
  #   print(card)
  #   print(pair)
  for j in (i, M-i):
    if card[j] > 0:
      result += min(card[j] // 2, pair[j])

print(result)


Measured memory_bytes: 16740
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  ll ans = k;
  for(int i=0;i<n-1;i++)ans *= k-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long W, H, x, y;

void solve();

int main() {
  cin >> W >> H >> x >> y;
  solve();
}

void solve() {
  // 任意の点と中心を通る直線で必ず2等分できるため
  double area = double(W) / 2 * H;
  // x, y が中心を通る場合は直線は一意に決まらない
  bool is_center = (x * 2 == W) && (y * 2 == H);

  cout << area << " " << (is_center ? 1 : 0) << endl;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    ll n,k,i,j,m;

    cin>>n>>k;
    j=0;
    rep(i,n){
        cin>>m;
        if(m>=k)j++;
    }
	cout<<j<<endl;
    
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.empty((N, M),dtype=int)
for n in range(N):
    A[n, :] = list(map(int, input().split()))
X = np.dot(A, B) + C
print(len(X[X>0]))

Measured memory_bytes: 12472
m = 1000000000+7
from scipy.special import comb

n = int(input())

if n == 1:
    print(0)
    exit()
if n == 2:
    print(2)
    exit()

ans = pow(10,n) - (2 * pow(9,n) - pow(8,n))
ans %= m

print(ans)

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

namespace ABC042_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = scan();
            var b = scan();
            var k = new int[10-a[1]];
            int r = 0;
            int p = 0;
            for (int i = 0; i < 10; i++)
            {
                r = 0;
                foreach (var item in b)
                {
                    if (item==i)
                    {
                        r++;
                        break;
                    }
                }
                if (r==0)
                {
                    k[p] = i;
                    p++;
                }
            }
            //二部探索
            
            Console.WriteLine(BinarySearch(k,a[0]));
        }
        static bool check(int[] a,int mid)
        {
            int count = -1;
            string k = mid.ToString();
            int r =k.Length;
            for (int i = 0; i < r; i++)
            {
                int n = int.Parse(k[i].ToString());
                foreach (var t in a)
                {
                    if (n==t)
                    {
                        count++;
                        break;
                    }
                }
                if (count!=i)
                {
                    return false;

                }
            }
            return true;
        }
        static int BinarySearch(int[] a, int left1)
        {
            int mid = left1;
            bool n = true;

            while  (n)
            {
                
                if (check(a,mid))
                {
                    return mid;
                }
                else
                {
                    mid++;
                }
            }
            
            return mid;
        }
        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static int[] scan()
        {
            return Array.ConvertAll
                (Console.ReadLine().Split(' '), int.Parse);
        }
    }
}


Measured memory_bytes: 6744
n, m, d = map(int,input().split())

if d == 0:
    ans = n *  (m - 1) / n / n
    print("{:.10f}".format(ans))
else:
    ans = 2 * (n-d) * (m - 1) / n / n
    print("{:.10f}".format(ans))


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

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> s(H);
    for(int i=0;i<H;i++){
      cin>>s[i];
    }

    vector<pair<int,int>> v;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(s[i][j]=='B'){
          v.push_back(make_pair(i,j));
          break;
        }
      }
      for(int j=W-1;j>=0;j--){
        if(s[i][j]=='B'){
          v.push_back(make_pair(i,j));
          break;
        }
      }
    }

    int ans=0;
    for(auto p:v){
      for(auto q:v){
        ans=max(ans,abs(p.first-q.first)+abs(p.second-q.second));
      }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3968
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力
static double sdRate;											// 近づく確率

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 期待値 - 取得
double
fGetVal(
	int piPos					// <I> 位置
)
{
	// 偶数
	if (piPos % 2 == 0) {
		return (double)(piPos / 2) / sdRate;
	}

	// 奇数
	double ldVal = 1.0;
	ldVal += fGetVal(piPos - 1) * sdRate;
	ldVal += fGetVal(piPos + 1) * (1.0 - sdRate);

	return ldVal;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// 座標 - 取得
	int liPos;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liPos);

	// 近づく確率 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lf", &sdRate);
	sdRate /= 100.0;

	// 期待値 - 取得
	double ldVal = fGetVal(liPos);

	// 出力
	sprintf(lc1Buf, "%.7lf\n", ldVal);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    int k = x / (y+z);
    int n = x % (y+z);
    if(n==z) {
        cout << k << endl;
    } else {
        cout << k-1 << endl;
    }
}

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

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

	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

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

	cout << A.back() - A.front() << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main() {
ll x,y,z;
cin>>x>>y>>z;

swap(x,y);
swap(x,z);
cout<<x<<" "<<y<<" "<<z<<endl;
return 0;

}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<time.h>
#include<limits.h>
#include<unordered_map>
#include<set>
#include<queue>
#include<stack>
#include <iomanip>
using namespace std;
#define inf LLONG_MAX
const int N = 1e7 + 1;
#define int long long

void solve() {
    int n;cin>>n;
    int c = 0;
    for (int i = 0; i < n; i ++) {
        int x; cin >> x;
        if (i%2==0 && x %2==1) c++;
    }
    cout << c;
}

int32_t main() {
        solve();
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();
    int n = s.length();
    StringBuffer sb = new StringBuffer(s);
    String reverse = sb.reverse().toString();

    int digit = 1; // mod2019
    int sum = 0; // mod2019
    int mod = 2019;
    int remains[] = new int[mod];
    Arrays.fill(remains, 0);
    int res = 0;
    for (int i = 0; i < n; i++) {
      remains[sum]++;
      int a = Character.getNumericValue(reverse.charAt(i));
      sum = (sum + a*digit) % mod;
      digit = digit*10 % mod;
      res += remains[sum]; // 自分より小さくmod2019が等しい数(すなわちremains[sum])がペアになる
    }
    System.out.println(res);
  }
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  int index = 1;
  int count = 0;

  while (index != 2) {
    if (count == n) {
      p(-1);
      return 0;
    }
    index = a[index];
    count++;
  }

  p(count);
}

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

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
using ll = long long;
using ld = long double;

int const nmax = 200000;
vector<int> g[1 + nmax];

pair<int,int> dfs(int node, int parent){
  pair<int,int> sol(0, node);
  for(int h = 0; h < g[node].size(); h++){
    int to = g[node][h];
    if(to != parent)
      sol = max(sol, dfs(to, node));
  }
  sol.first++;
  return sol;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i < n; i++){
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  pair<int,int> sol = dfs(dfs(1, 0).second, 0);

  if(sol.first % 3 == 2)
    cout << "Second";
  else
    cout << "First";
  return 0;
}


Measured memory_bytes: 29952
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
        k: usize,
    }
    let v = vec![a, b, c, d, e];
    let n = v.len();

    for i in 0..n {
        for j in 0..i {
            if v[i] - v[j] > k {
                println!(":(");
                return;
            }
        }
    }
    println!("Yay!");
}


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

int main(int argc, char const *argv[]) {
  int sum = 0, n, k;
  cin >> n >> k;
  vector <int> l(n);
  for(int i = 0; i < n;i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<int>());
  for(int i = 0;i < k;i++) {
    sum += l.at(i);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
def upper_bound(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s+t)//2
        if A[m] > x:
            t = m
        else:
            s = m
    
    return t

def lower_bound(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s+t)//2
        if A[m] >= x:
            t = m
        else:
            s = m
    
    return t


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += lower_bound(A, b) * (N - upper_bound(C, b))

print(ans)

Measured memory_bytes: 102016
#include<stdio.h>

#define MAX 101
#define INFTY -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int G[MAX][MAX],d[MAX],color[MAX],n,Q[MAX],head,tail;

void enqueue(int x){
  Q[tail++]=x;
}

int  dequeue(){
  return Q[head++];
}


void bfs(int s){
  int i;
  for(i=1;i<=n;i++){
    d[i]=INFTY;
  }
  d[s]=0;
  color[s]=GRAY;
  enqueue(s);

  while(head!=tail){
    int u=dequeue(),v;
    for(v=1;v<=n;v++){
      if(G[u][v]==1){
      if(color[v]==WHITE){
        color[v]=GRAY;
        d[v]=d[u]+1;
        enqueue(v);
      }
    }
  }
      color[u]=BLACK;
  }
}


int main(){
  int i,j,k,u;
  scanf("%d",&n);

  for(i=0;i<n;i++){
	scanf("%d %d",&u,&k);
	for(j=0;j<k;j++){
  	int v;
  	scanf("%d",&v);
  	G[u][v]=1;
	}
  }
  bfs(1);
  for(i=1;i<=n;i++){
	printf("%d %d\n",i,d[i]);
  }
  return 0;
}




Measured memory_bytes: 2036
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", (a - 1) * (b - 1));
	return 0;
}


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



int main(){

  int a;
  cin>>a;
  if(a%7 == 1)cout<<"fri"<<endl;
  if(a%7 == 2)cout<<"sat"<<endl;
  if(a%7 == 3)cout<<"sun"<<endl;
  if(a%7 == 4)cout<<"mon"<<endl;
  if(a%7 == 5)cout<<"tue"<<endl;
  if(a%7 == 6)cout<<"wed"<<endl;
  if(a%7 == 0)cout<<"thu"<<endl;
  return 0;
}



Measured memory_bytes: 3100