akhauriyash/Code-Regression huggingface dataset:
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cout<<n*n*n<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

long long counter=0;

void set(long long n,long long x){
    if(n==0){
if(x==0){
return;
}
else{
        counter+=1;
        return;
}
    }
    else if(x==1||x==0){
        return;
    }
    else if(x>=pow(2,n+1)-1){
        counter+=pow(2,n);
        set(n-1,x-pow(2,n+1)+1);
        return;
    }
    else{
        set(n-1,x-1);
        return;
    }
    
        }

int main(){
    long long N;
    long long X;
    cin>>N>>X;
    set(N,X);
    cout<<counter<<endl;
    
    
    
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K; cin >> N >> K;
  cout << (K==1 ? 0 : N-K) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

ll N,D,i=0;
ll x,y,d,count=0;

cin >> N >> D;

for(i=0;i<N;i++){
  cin >> x >> y;
  d=(x*x+y*y);

  if(D*D>=d){
    count++;
  }
}

cout << count << endl;

}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll k, a, b;
	cin >> k >> a >> b;

	ll ans;
	if (k <= a - 1) {
		ans = k + 1;
	}
	else {
		ll m = (k - a + 1) / 2;
		if (b - a > 2) {
			ans = a + (b - a) * m + (k - a + 1) % 2;
		}
		else {
			ans = k + 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, b; cin >> a >> b;
	if (a > b) {
		cout << a + a - 1 << endl;
	}
	else if (a == b) {
		cout << a + b << endl;
	}
	else {
		cout << b + b - 1 << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  int n, i, j, dx, dy, x, y, count;
  int map[1001][1001], dist, temp, ans[2];

  scanf("%d", &n);

  for(count=0;count<n;count++){
    x=y=0;
    for(i=0;i<1001;i++){
      for(j=0;j<1001;j++){
        map[i][j]=0;
      }
    }
    while(1){
      scanf("%d %d", &dx, &dy);
      if(dx==0 && dy==0) break;

      x+=dx;
      y+=dy;

      map[y][x]=1;
    }

    dist=-1;
    ans[0]=ans[1]=0;
    for(i=0;i<1001;i++){
      for(j=0;j<1001;j++){
        if(map[i][j]==1){
          temp=i*i+j*j;
          if(dist<temp){
	    dist=temp;
            ans[0]=j;
            ans[1]=i;
          }
          else if(dist==temp){
            if(ans[0]<j){
              dist=temp;
              ans[0]=j;
              ans[1]=i;
            }
          }
        }
      }
    }
    printf("%d %d\n", ans[0], ans[1]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int a,b,c;
    
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, cnt = 0, ans;
    string s;
    cin >> n >> s;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'E') cnt++;
    }
    ans = cnt;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'W') cnt++;
        if (s[i] == 'E') cnt--;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}
    
            

Measured memory_bytes: 900
// ########################################################
// ################ MaxBipartiteMatching ##################
// Hopcroft ( E * sqrt(V) )
#include <bits/stdc++.h>
using namespace std;
const int MAXN=50005,MAXM=150000;
int x,y,e,last[MAXN],prev[MAXM],head[MAXM];
int matching[MAXN],dist[MAXN],Q[MAXN];
bool used[MAXN],vis[MAXN];
void bfs()
{
  fill(dist,dist+x,-1);
  int Qs=0;
  for (int u=0;u<x;++u)
    if (!used[u])
      Q[Qs++] = u,dist[u]=0;
  for (int i=0;i<Qs;i++)
    {
      int u1=Q[i];
      for (int j=last[u1];j>=0;j=prev[j])
	{
	  int u2=matching[head[j]];
	  if (u2>=0 && dist[u2]<0)
	      dist[u2]=dist[u1]+1,Q[Qs++]=u2;
	}
    }
}
bool dfs(int u1)
{
  vis[u1]=true;
  for (int i=last[u1];i>=0;i=prev[i])
    {
      int v=head[i];
      int u2=matching[v];
      if (u2<0 || !vis[u2] && dist[u2]==dist[u1]+1 && dfs(u2))
	{
	  matching[v]=u1;
	  return used[u1]=true;
	}
    }
  return false;
}
int maxMatching()
{
  fill(matching,matching+y,-1);
  for (int res=0;;)
    {
      bfs();
      fill(vis,vis+x,false);
      int f=0;
      for (int u=0;u<x;++u)
	if (!used[u] && dfs(u))
	  ++f;
      if (!f)
	return res;
      res+=f;
    }
}
int main()
{
  cin>>x>>y>>e;
  fill(last,last+x,-1);
  for(int i=0;i<e;i++)
    {
      int u,v;
      cin>>u>>v;//0-based
      head[i]=v;
      prev[i]=last[u];
      last[u]=i;
    }
  cout<<maxMatching()<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Student[] ss = new Student[n];
        for (int i = 0; i < n; i++) {
            Student s = new Student();
            s.number = i + 1;
            s.order = in.nextInt();
            ss[i] = s;
        }

        Arrays.sort(ss);

        for (int i = 0; i < n; i++) {
            System.out.print(ss[i].number + " ");
        }
    }
}

class Student implements Comparable<Student> {
    int order;
    int number;

    @Override
    public int compareTo(Student o) {
        return this.order - o.order;
    }
}

Measured memory_bytes: 63908
mod mat {
    #[derive(Debug)]
    pub struct Matrix (pub Vec<Vec<isize>>);
    impl Matrix {
        pub fn new() -> Matrix {
            Matrix(Vec::new())
        }
    }
}
use std::io::BufRead;
fn main() {
    let handle = std::io::stdin(); 
    let mut row = String::new(); 
    handle.lock().read_line(&mut row).ok();
    let row: usize = row.trim()
        .split_whitespace().take(1).map(|a| a.parse()).next().unwrap().unwrap();
    let mut mat = mat::Matrix::new();
    let mut vec: Vec<isize> = Vec::new();
    for _ in 0..row {
        mat.0.push(Vec::new());
    }
    for (r, line) in handle.lock().lines().enumerate().take(row) {
        for num_str in line.ok().unwrap().trim().split_whitespace() {
            mat.0[r].push(num_str.trim().parse().ok().unwrap());
        }
    }
    for line in handle.lock().lines().take(mat.0[0].len()) {
        vec.push(line.unwrap().trim().parse().ok().unwrap());
    }
    let mut ans: Vec<isize> = Vec::new();
    for line in mat.0 {
        ans.push(line.iter()
        .zip(vec.iter()).map(|(a, b)| a * b).sum());
    }
    for i in ans {
        println!("{}", i);
    }
}


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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = (y); x <= (z); x++)
#define REPP(x, y, z) for(int x = (y); x >= (z); x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration
int n;
int c, r;
//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	cin >> c >> r >> n;

	int ans = 0;

	if(n % max(c, r) == 0)
		ans = n / max(c, r);
	else
	{
		ans = n / max(c, r)+1;
	}
	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
A = list(map(int, input().split()))
D = []
for i in range(n-1):
    D.append(A[i+1]-A[i])
else:
    D.append(k-(A[n-1]-A[0]))
D.sort(reverse=True)
print(k-D[0])


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

using namespace std;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

constexpr ll  k_max = 100000;

int main() {
    ll K;
    cin >> K;
    deque<ll> dq{};
    array<ll, k_max> costs{};
    costs.fill(numeric_limits<ll>::max());
    costs.at(1) = 1;
    constexpr ll initial_node = 1;

    dq.emplace_front(initial_node);
    while (!dq.empty()){
        ll node_from = dq.front();
        dq.pop_front();
        ll node_to;
        node_to = node_from * 10 % K;
        if (costs.at(node_to) > costs.at(node_from)){
            dq.push_front(node_to);
            costs.at(node_to) = costs.at(node_from);
        }
        node_to = (node_from+1) % K;
        if (costs.at(node_to) > costs.at(node_from)){
            dq.push_back(node_to);
            costs.at(node_to) = costs.at(node_from) + 1;
        }
    }
    cout << costs.at(0) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

int main(){
  int num[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k = in() - 1;
  cout << num[k] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x;
	for(int i=1;i<=10000;i++)
	{
		cin>>x;
		if(x==0)
		{
			break;
		}
		cout<<"Case "<<i<<": "<<x<<endl;
	}

	return 0;
}



		


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

string s;
int res = 700;

int main(){
  cin >> s;
  if(s.at(0) == 'o') res += 100;
  if(s.at(1) == 'o') res += 100;
  if(s.at(2) == 'o') res += 100;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  vector<vector<int>> ans(h, vector<int>(w));
  int num = 1, count = 0;
  bool mode = true;
  rep(i, h){
    rep(j, w){
        if(count == a.at(num-1)){
          num++;
          count = 0;
        }
      if(mode == true){
        ans.at(i).at(j) = num;
        if(j == w-1) mode = false;
      }else{
        ans.at(i).at(w-j-1) = num;
        if(j == w-1) mode = true;
      }
      count++;
    }
  }
  rep(i, h){
    rep(j, w){
      if(j != 0) cout << " ";
      cout << ans.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[7],c;
	while(scanf("%d",&n),n)
	{
		fill(a,a+7,0);
		while(n--)scanf("%d",&c),a[min(c/10,6)]++;
		for(c=0;c<7;++c)printf("%d\n",a[c]);
	}
	return 0;
}

Measured memory_bytes: 756
#include<bits/stdc++.h>
typedef long long i64;
const int N=3e5+7;
int n,m,v0[N],q[N];
i64 s[N],f0[N],f1[N],rs[N],tmp[N];
i64 max(i64 a,i64 b){return a>b?a:b;}
struct pos{
	i64 x,y;
	i64 operator*(const pos&w)const{return x*w.y-y*w.x;}
	pos operator-(const pos&w)const{return (pos){x-w.x,y-w.y};}
}ss[N],w;
int sp;
struct info{
	int v0[N];
	i64 s[N],f[N],mf[N],f1[N];
	pos ps[N];
	void push(int i){
		while(sp&&(ss[sp]-ss[sp-1])*(ps[i]-ss[sp-1])>=0)--sp;
		ss[++sp]=ps[i];
	}
	i64 val(int i){
		while(sp&&(ss[sp]-ss[sp-1])*w>=0)--sp;
		return w*ss[sp]+i64(i+1)*i/2-s[i];
	}
	void pre(){
		ss[sp=0]=(pos){0,0};
		for(int i=1;i<=n;++i){
			s[i]=s[i-1]+v0[i];
			w=(pos){1,i};
			mf[i]=max(f[i]=val(i),mf[i-1]);
			ps[i]=(pos){i,mf[i]+i64(i-1)*i/2+s[i]};
			push(i);
			f1[i]=-(1ll<<60);
		}
	}
	void dac(int L,int R){
		if(L==R)return;
		int M=(L+R)>>1;
		dac(L,M),dac(M+1,R);
		sp=0;
		for(int i=L;i<=M;++i)push(i);
		for(int i=M+1;i<=R;++i){
			w=(pos){1,i};
			tmp[i]=val(i)+rs[i+1];
		}
		for(int i=R-1;i>M;--i)tmp[i]=max(tmp[i],tmp[i+1]);
		for(int i=R;i>M;--i)f1[i]=max(f1[i],tmp[i]);
	}
}i0,i1;
int $(int x){return n+1-x;}
char buf[20000007],*ptr=buf,ob[10000007],*op=ob;
int _(){
	int x=0;
	while(*ptr<48)++ptr;
	while(*ptr>47)x=x*10+*ptr++-48;
	return x;
}
void pr(i64 x){
	int ss[25],sp=0;
	do ss[++sp]=x%10;while(x/=10);
	while(sp)*op++=ss[sp--]+48;
	*op++=10;
}
int main(){
	fread(buf,1,sizeof(buf),stdin);
	n=_();
	for(int i=1;i<=n;++i)v0[i]=_(),i0.v0[i]=i1.v0[n+1-i]=v0[i];
	i0.pre();
	i1.pre();
	for(int i=1;i<=n+1;++i)rs[i]=i1.mf[$(i)];
	i0.dac(0,n);
	for(int i=1;i<=n+1;++i)rs[i]=i0.mf[$(i)];
	i1.dac(0,n);
	for(int i=1;i<=n;++i){
		f0[i]=i0.mf[i-1]+i1.mf[$(i+1)];
		f1[i]=max(i0.f1[i],i1.f1[$(i)]);
	}
	for(m=_();m;--m){
		int x=_(),y=_();
		pr(max(f0[x],f1[x]-y+v0[x]));
	}
	fwrite(ob,1,op-ob,stdout);
	return 0;
}

Measured memory_bytes: 62720
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,teamnum,b;
	int m1,s1,m2,s2,m3,s3,m4,s4;
	while(1){
		cin >> n;
		if(n==0) break;
		int team[1000000]={0};
		int team2[1000000]={0};
		for(int i=0;i<n;i++){
			cin >> teamnum;
			cin >> m1 >> s1;
			cin >> m2 >> s2;
			cin >> m3 >> s3;
			cin >> m4 >> s4;
			team[teamnum] = m1*60+s1+m2*60+s2+m3*60+s3+m4*60+s4;
			team2[teamnum]=team[teamnum];
		}
		sort(team,team+1000000);
		int cnt=0;
		for(int i=0;i<1000000;i++){
			if(team[i]!=0 && cnt<2){
				for(int j=0;j<1000000;j++){
					if(team2[j]==team[i]){
						cout << j << endl;
						cnt++;
					}
					if(team[999998]==team2[j]){
						b=j;
					}
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}
		

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

const ll INF = (1ll << 31) - 1;

struct Segment {
    int n;
    vector<ll> node;

    Segment(int N) {
        n = 1;
        while (n < N) n *= 2;

        // ノード数は ceil(log2(N))^2 * 2 (葉数が2べきとなるよう調整)
        node.assign(2 * n - 1, INF);
    }

    void update(int k, ll a) {  // k番目の値をaに変更
        // k番目の葉 : k+n-1
        k += n - 1;
        node[k] = a;

        // 子 → 親 : (k-1)/2
        // 親 → 子(1,2) : 2*k + (1,2)
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    ll find_min(int a, int b, int k = 0, int l = 0, int r = -1) {  // [a,b)の最小値を返す
        if (r < 0) r = n;

        // 含まない
        if (r <= a || b <= l) return INF;
        // 完全に含む
        if (a <= l && r <= b)
            return node[k];
        else {
            ll vl = find_min(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = find_min(a, b, 2 * k + 2, (l + r) / 2, r);

            return min(vl, vr);
        }
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    Segment mtree(n), Mtree(n);
    ll pp = -1, cnt = 0;
    bool sorted[n] = {};
    for (int i = 0; i < n; i++) {
        ll p;
        cin >> p;
        if (pp < p)
            cnt++;
        else
            cnt = 1;
        if (cnt >= k) sorted[i - k + 1] = true;
        mtree.update(i, p);
        Mtree.update(i, -p);
        pp = p;
    }
    int ans = 1;
    for (int i = 0; i + k < n; i++) {
        if (-Mtree.find_min(i, i + k) < -Mtree.find_min(i + k, i + k + 1) && mtree.find_min(i, i + 1) < mtree.find_min(i + 1, i + 1 + k)) {
            sorted[i + 1] = false;
            continue;
        }
        ans++;
    }
    cnt = 0;
    for (int i = 0; i < n; i++) {
        if (sorted[i]) cnt++;
    }
    cout << (cnt ? ans - cnt + 1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
const ll mod = 1000000007;


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

vector<int> d(n);
r(i,n)cin>>d.at(i);
ll sum=0;
r(i,n){
  r(j,n){
    if(i==j)continue;
    sum+=d.at(i)*d.at(j);
  }
}
cout<<sum/2<<endl;





  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int n,i,j,a,b,c,d;
	char s[1000000];
	scanf("%d",&n);
	a=0;
	b=0;
	c=0;
	d=0;
	for(i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='A'){
			a+=1;
		}
		else if(s[0]=='W'){
			b+=1;
		}
		else if(s[0]=='T'){
			c+=1;
		}
		else{
			d+=1;
		}
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long dp[3100][3100]={0};
//const long long INF=1LL<<60;
//int h[100100][2];
//int N;
//long long W,weight[111],value[111];

string s,t;

int main() {
   cin >> s >>t;

rep(i,s.size()){
rep(j,t.size()){
if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
}
}
string res="";

int i=(int)s.size(), j=(int)t.size();

while(i>0 && j>0){
if(dp[i][j]==dp[i-1][j]){
--i;
}else if(dp[i][j]==dp[i][j-1]){
--j;
}else{
res=s[i-1]+res;
--i,--j;
}
}

cout << res;


return 0;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n,k; cin >> n >> k;
    int a[k];
    for(int i = 0;i < k;i++){
        cin >> a[i];
    }
    
    for(int i = n;i <= 100000;i++){
        string s = to_string(i);
        bool b = true;
        for(int j = 0;j < k;j++){
            if(s.find(to_string(a[j])) != string::npos){
                b = false;
                break;
            }
        }
        if(b){
            cout << s;
            break;
        }
    }
}



Measured memory_bytes: 256
// cleartime: 4時間くらい？
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <cmath>

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

using namespace std;

typedef vector< vector<int> > field;

int w, h;
field f, closed;
int mx[] = {0, 0, 1, -1},
    my[] = {1, -1, 0, 0};

int in_range(int x, int y, int w, int h) {
    return (int)(0 <= x && x < w && 0 <= y && y < h);
}

int bt(int x, int y, int step) {
    int res = INT_MAX, tmp;

    // 終了条件
    if ( step == 10 ) {
        return res;
    }

    // 上下左右に進めるなら進む
    REP(i, 4) {
        int nx = x, ny = y;

        while(1) {
            nx += mx[i];
            ny += my[i];

            if ( !in_range(nx, ny, w, h) ) {
                break;
            }

            if ( f[ny][nx] == 1 ) {
                break;
            } else if ( f[ny][nx] == 3 ) {
                return step + 1;
            }
        }

        if ( !in_range(nx, ny, w, h) || abs(x-nx) == 1 || abs(y-ny) == 1 ) continue;

        // 障害物を破壊
        f[ny][nx] = 0;
        tmp = bt(nx-mx[i], ny-my[i], step+1);
        f[ny][nx] = 1;

        // 最小手の更新
        if ( tmp < res )
            res = tmp;
    }

    return res;
}

int main() {
    int fx, fy, res;

    while( cin >> w >> h, w || h ) {
        f = field(h, vector<int>(w));

        // 入力
        REP(i, h) {
            REP(j, w) {
                cin >> f[i][j];
                if ( f[i][j] == 2 ) {
                    fx = j;
                    fy = i;
                }
            }
        }

        res = bt(fx, fy, 0);

        if ( res != INT_MAX )
            cout << res;
        else
            cout << -1;
        cout << endl;
    }

    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	int lp = n - 1;

	int c4 = 0, c2 = 0;
	rep(i, 0, n) {
		int t; cin >> t;
		if (t % 4 == 0) c4++;
		else if (t % 2 == 0) c2++;
	}
	while (lp > 0 && c4) {
		c4--;
		lp -= min(lp, 2);
	}
	if (!lp) {
		cout << "Yes" << endl;
		return 0;
	}
	lp++;
	while (lp > 0 && c2) {
		c2--;
		lp -= min(lp, 1);
	}
	if (lp) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool okX[4001][16002];
bool okY[4001][16002];

int main(){
	string s;
	int x, y;
	
	cin >> s >> x >> y;

	int dx[8001], dy[8001];
	bool direction = false;
	int cnt = 0;
	int xnum = 0, ynum = 0;
	for(int i = 0; i < s.length(); i++){
		if (s[i] == 'T'){
			if(!direction){
				dx[xnum++] = cnt;
			}
			else{
				dy[ynum++] = cnt;
			}
			cnt = 0;
			direction = !direction;
		}
		else{
			cnt++;
		}
	}
	if (!direction){
		dx[xnum++] = cnt;
	}
	else{
		dy[ynum++] = cnt;
	}

	okX[0][8000] = okY[0][8000] = true;
	okX[1][8000+dx[0]] = true;
	for (int i = 2; i <= xnum; i++){
		for (int j = 0; j < 16002; j++){
			if (j+dx[i-1] < 16002)
				okX[i][j] |= okX[i-1][j+dx[i-1]];
			if (j-dx[i-1] >= 0)
				okX[i][j] |= okX[i-1][j-dx[i-1]];
		}
	}
	for (int i = 1; i <= ynum; i++){
		for (int j = 0; j < 16002; j++){
			if (j+dy[i-1] < 16002)
				okY[i][j] |= okY[i-1][j+dy[i-1]];
			if (j-dy[i-1] >= 0)
				okY[i][j] |= okY[i-1][j-dy[i-1]];
		}
	}
	if (okX[xnum][8000+x] && okY[ynum][8000+y])
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 125184
import java.util.Scanner;

public class Main{
    private int cnt;

    public static void main(String[] args){
        new Main();
    }

    public Main(){
      Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int A[] = new int[1000000];

        for(int i=0;i<n;i++){
            A[i] = scan.nextInt();
        }
        shellSort(A, n);
        printArray(A, n);
    }

    public void isort(int A[], int n, int g){
        for(int i=g;i<n;i++){
            int v = A[i];
            int j = i - g;
            // 挿入先が見つかるまでループ
            // 挿入するため、見ていった要素を一個ずつ後方へズラす。
            while(j >=0 && A[j] > v){
                A[j+g] = A[j];
                j = j -g;
                cnt++;
            }
            // 見つけた挿入場所へ挿入。
            A[j+g] = v;
        }
    }

    public void shellSort(int A[], int n){
        cnt = 0;
        int i, j, m;
        int G[] = new int[100];
        if(n < 3){
            G[0] = n;
            G[1] = n-1;
            G[2] = 1;
            m = n;
        }else{
            j = 0;
            for(i=1;i<n;i=i*3+1){
                G[j++] = i;
            }
            m = j;
        }
        System.out.println(m);
        for(i=m-1;i>=1;i--){
            System.out.print(G[i] + " ");
        }
        System.out.println(G[i]);

        for(i=m-1;i>=0;i--){
            isort(A, n, G[i]);
        }
        System.out.println(cnt);
    }

    // 一列で表示
    public static void printArray(int A[], int n){
        int i;
        for(i=0;i<n;i++){
            System.out.println(A[i]);
        }
    }
}

Measured memory_bytes: 296892
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll T, N;

signed main(){
    cin >> T;
    ll K, L, R;
    REP(hoge, T){
        cin >> N;
        ll ans = 0;
        vector<pll> camel, camer;
        REP(i, N){
            cin >> K >> L >> R;
            ans += min(L, R);
            if(L >= R) camel.push_back(pll(K, L - R));
            else camer.push_back(pll(K, R - L));
        }
        sort(ALL(camel));
        sort(ALL(camer));
        priority_queue<ll, vector<ll>, greater<ll>> que;
        int j = 0;
        REP(i, N + 1){
            while(j < camel.size() && camel[j].first == i){
                que.push(camel[j].second);
                ans += camel[j].second;
                j++;
            }
            while(que.size() > i){
                ans -= que.top();
                que.pop();
            }
        }
        while(!que.empty()) que.pop();
        j = camer.size() - 1;
        for(int i = N; i > 0; i--){
            while(j >= 0 && camer[j].first == i){
                que.push(camer[j].second);
                ans += camer[j].second;
                j--;
            }
            while(que.size() > N - i){
                ans -= que.top();
                que.pop();
            }
        }
        while(!que.empty()) que.pop();
        PRINT(ans);
    }
}

Measured memory_bytes: 8336
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* we want to find the 
 * row+col with most targets in it
 * Somehow we need to 
 * recognize double count the crossing.
 */
void solve() {
    cini(h);
    cini(w);
    cini(m);

    vector<pii> hcnt(h);
    for(int i=0; i<h; i++) 
        hcnt[i].second=i;
    vector<pii> wcnt(w);
    for(int j=0; j<w; j++)
        wcnt[j].second=j;

    map<pii,int> s;
    for(int i=0; i<m; i++) {
        cini(th);
        cini(tw);
        th--;
        tw--;
        s[{th, tw}]++;
        hcnt[th].first++;
        wcnt[tw].first++;
    }
    sort(all(hcnt), greater<pii>());
    sort(all(wcnt), greater<pii>());

    int ans=0;
    for(int i=0; i<h; i++) {
        if(hcnt[i].first<hcnt[0].first)
            break;

        for(int j=0; j<w; j++) {
            if(wcnt[j].first<wcnt[0].first)
                break;

            int lans=hcnt[i].first+wcnt[j].first;
            int dec=s[{hcnt[i].second,wcnt[j].second}];
            ans=max(ans, lans-dec);
            if(dec==0)
                break;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 50108
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
 
using namespace std;
typedef long long ll;

int main()
{
	int k;
	scanf("%d", &k);
	
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	printf("%d\n", a[k-1]);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 200


//問題文のとおり
int s[2],t[2],d[2];

int main() {
	REP(i, 2)cin >> s[i];
	REP(i, 2)cin >> t[i];
	REP(i, 2)d[i] = t[i] - s[i];

	string ans = "";
	REP(i, d[1])ans += "U";
	REP(i, d[0]+1)ans += "R";
	REP(i, d[1]+1)ans += "D";
	REP(i, d[0]+1)ans += "L";
	REP(i, 1)ans += "U";


	REP(i, 1)ans += "L";
	REP(i, d[1] + 1)ans += "U";
	REP(i, d[0] + 1)ans += "R";
	REP(i, d[1] + 1)ans += "D";
	REP(i, d[0])ans += "L";
	cout << ans << endl;
	cin >> ans;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

double dp[3005][3005];
double dat[3005];
int main() 
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>dat[i];
	}
	dp[0][0]=1.0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp[i+1][j]+=dp[i][j]*(1.0-dat[i+1]);
			dp[i+1][j+1]+=dp[i][j]*(dat[i+1]);
		}
	}
	double sum=0.0;
	for(int i=(n+1)/2;i<=n;i++)
	{
		sum+=dp[n][i];
	}
	printf("%.9f",sum);
    return 0;
}

Measured memory_bytes: 69120
#include <stdio.h>

int main(){
    int N;
    int a,b,c,d;
    int i;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a<b){
            d = a;
            a = b;
            b = d;
        }
        if(a<c){
            d = a;
            a = c;
            c = d;
        }
        printf((a*a-b*b-c*c) ? "NO\n" : "YES\n");
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

bool h[26];

void solve() {
	string s; cin >> s;
	for (char c: s) {
		h[c-'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!h[i]) {
			putchar(i+'a');
			return;
		}
	}
	puts("None");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if (a==0) return 0; if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}





int main(void) {

    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    int ans = 0;
    bool flag[N];
    rep(i,N) flag[i] = true;
    rep(i,N) {
        if (i - K >= 0 && T[i - K] == T[i] && flag[i - K]) {
            flag[i] = false;
        }
        if (flag[i]) {
            if (T[i] == 'r') ans += P;
            else if (T[i] == 's') ans += R;
            else ans += S;
        }
    }
    out(ans);

    


    return 0;
}











Measured memory_bytes: 512
#include<stdio.h>
int main(void){
     int a,b,d,r;
     double f;
     scanf("%d %d",&a,&b);
     d = a / b;
     r = a % b;
     f = (double)a / b;
     printf("%d %d %lf\n",a/b,a%b,f);

    return 0;
}

Measured memory_bytes: 636
n = int( input() )
an = list( map(int, input().split()) )

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

for a in an:
    if a < len(bucket):
        bucket[a] += 1
    else:
        bucket[0] += 1

#print(bucket[:5])
ans = 0
for i in range(len(bucket)):
    if i == bucket[i]:
        continue

    ans += bucket[i] if i > bucket[i] else bucket[i] - i


print(ans)

Measured memory_bytes: 63984
package main

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

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

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func gcdMulti(xs []int) int {
	ans := xs[0]
	for i := 1; i < len(xs); i++ {
		ans = gcd(ans, xs[i])
	}
	return ans
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	ds := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range ds {
		sc.Scan()
		t, _ := strconv.Atoi(sc.Text())
		ds[i] = abs(X - t)
	}
	fmt.Println(gcdMulti(ds))
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
//int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,s[100010];
vector<int>primes;
map<int,int>mp;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    for(int i=2;i<=100000;i++){
        if(prime(i))primes.pb(i);
    }
    rep(i,n){
        int x;
        cin>>x;
        for(int p:primes){
            if(p*p*p>x)break;
            while(x%(p*p*p)==0){
                x/=p*p*p;
            }
        }
        mp[x]++;
    }
    int ans=0;
    for(P p:mp){
        //cout<<p.fi<<" "<<p.se<<endl;
        if(p.fi==1){
            ans+=(p.se?1:0);
        }
        else{
            int x=p.fi,pir=1;
            for(int i:primes){
                if(i*i>x)break;
                int cnt=0;
                while(x%i==0){
                    x/=i;
                    cnt++;
                }
                if(cnt==1)pir*=i*i;
                if(cnt==2)pir*=i;
            }
            pir*=x*x;
            if(mp.find(pir)==mp.end())ans+=p.se;
            else{
                if(pir<p.fi)ans+=max(p.se,mp[pir]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6656
#include <stdio.h>
 
int main()
{
  long i,a,b,k;
  
  scanf("%ld %ld %ld",&a,&b,&k);
  
  if(a>=k){
    a-=k;
  }else if(a+b>=k){
    b-=k-a;
    a=0;
  } else{
    a=0;
    b=0;
  }
  
  
  
  printf("%ld %ld\n",a,b);
  
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;

	long long L[100];
	L[0] = 2;
	L[1] = 1;
	for(int i = 2; i <= n; i++) L[i] = L[i-1] + L[i-2];

	cout << L[n];
}


Measured memory_bytes: 256
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=0





def solve():


    # for _ in range(ii()):
    
        

    n=ii()
    a=li()
    ans=0
    for i in range(1,n+1):
        if i&1 and a[i-1]&1:
            ans+=1
    print(ans)







        
if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()


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

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.size() / 2; i++) {
    if (s.at(i) != s.at(s.size()-1-i)) {
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    float a,n,t,b,l,m,k;
    int c;
    scanf("%f",&n);
    a=2*acos(0.0)*1;
    b=2*acos(0.0)*n*n;
    t=b/a;
    c=round(t);
    //c=(int)t;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
N, A, B, C, D = map(int, input().split())
S= input()

A -= 1
B -= 1
C -= 1
D -= 1

ok = []
ng = []

for i in range(1, N - 1):
    if S[i] == S[i + 1] and S[i] == "#":
        ng.append(i)
    elif S[i - 1] == S[i] and S[i] == S[i + 1] and S[i] == ".":
        ok.append(i)

for ngi in ng:
    if (A < ngi and ngi < C) or (B < ngi and ngi < D):
        print("No")
        exit()

if C < D:
    print("Yes")

else:
    for oki in ok:
        if B <= oki and oki <= D:
            print("Yes")
            exit()

    print("No")


Measured memory_bytes: 9328
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
typedef long long ll;
int a[100][2];
int N;
int main() {
	int Y;
	cin >> N >> Y;
	Y = Y / 1000;
	int x = -1, y = -1, z = -1;
	int i, j;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <=  N - i; j++) {
			int k = N - i - j;
			if (i * 10 + j * 5 + k == Y)x = i, y = j, z = k;
		}
	}
	cout << x << ' ' << y << ' ' << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	string s;cin>>s;
	int k;cin>>k;
	string sub;
	vector<string> ks(k);
	for(int i=0;i<k;i++){
		ks[i]="zzzzz";
	}
	for(int i=0;i<s.size();i++){
		for(int j=1;j<=k;j++){
			if(i+j>s.size())break;
			sub.clear();
			for(int l=0;l<j;l++){
				sub.push_back(s[i+l]);

			}
//			cout<<"sub"<<sub<<endl;
			for(int m=0;m<k;m++){
				if(ks[m]>sub){
					string temp=ks[m];
					ks[m]=sub;
					sub=temp;
				}else if(ks[m]==sub){
					break;
				}
			}
//			for(int l=0;l<k;l++){
//				cout<<ks[l]<<endl;
//			}
		}
	}
	cout<<ks[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }
        Scanner cin = new Scanner();

        int K, S;
        void solve() {
            K = cin.nextInt();
            S = cin.nextInt();

            int X, Y, Z,ans=0;
            for (X = K; X >= 0; X--) {
                for (Y = K; Y >= 0; Y--) {
                    Z = S - X - Y;
                    if (0 <= Z && Z <= K)
                        ans++;
                }
            }

            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public char nextChar() { return char.Parse(next()); }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
            public string[] array() { return Console.ReadLine().Split(' '); }
            public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); }
            public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); }
            public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); }
            public double[] arrayDouble() { return Array.ConvertAll(array(), double.Parse); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
char ch[210000];
int a[210000],b[210000],bin[30],i,j,ans[210000],minn[68000000],n;
int main()
{
	scanf("%s",ch);
	n=strlen(ch);
	for (i=1;i<=n;i++)
	{
		a[i]=ch[i-1]-'a'+1;
	}
	bin[1]=1;
	for (i=2;i<=26;i++)  bin[i]=bin[i-1]<<1;
	for (i=1;i<=n;i++) b[i]=b[i-1]^bin[a[i]];
	memset(minn,0x7f,sizeof(minn));
	memset(ans,0x7f,sizeof(ans));
	minn[0]=0;
	for (i=1;i<=n;i++)
	{
		ans[i]=min(ans[i],minn[b[i]]+1);
		for (j=1;j<=26;j++)
		{
			ans[i]=min(ans[i],minn[b[i]^bin[j]]+1);
		}
		minn[b[i]]=min(minn[b[i]],ans[i]);
	}
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 268544
#
# abc090 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """11009 11332"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """31415 92653"""
        output = """612"""
        self.assertIO(input, output)


def resolve():
    A, B = map(int, input().split())
    ans = 0
    for i in range(A, B+1):
        s = str(i)
        for j in range((len(s)+1)//2):
            if s[j] != s[-1-j]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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


int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if (A >= K) {
        printf("%ld %ld\n", A-K, B);
    }
    else {
        printf("%ld %ld\n", 0, max(0LL, A+B-K));
    }
}


Measured memory_bytes: 256