akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int V;
vector<int> G[1100];
int match[1100];
bool used[1100];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i],w=match[u];
		if(w<0|| !used[w]&&dfs(w)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res=0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<V;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

int m,n;
int b[510],r[510];
int main(){
	while(1){
		cin>>m>>n;
		V=m+n;
		if(m==0&&n==0)break;
		REP(i,1100)G[i].clear();
		REP(i,m)
			cin>>b[i];
		REP(i,n)
			cin>>r[i];
		REP(i,m)
			REP(j,n){
				if(gcd(b[i],r[j])>1){
					add_edge(i,j+501);
				}
			}
		cout<<bipartite_matching()<<endl;
	}
	return 0;
}


Measured memory_bytes: 4948
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K; cin >> N >> K;
	int cnt[100010] = { 0 }, dp[100010];
	VI A(N);
	REP(i, N)cin >> A[i];
	REP(i, 100010)cnt[i] = 1;
	FOR(i,0, N) {
		
		eREP(j, K) {
		
			if (j - A[i] <= 0)dp[j] = cnt[j];
			else dp[j] = (cnt[j] - cnt[j - A[i] - 1] + mod) % mod;
		}
		REP(j, K)cnt[j + 1] = (cnt[j] + dp[j + 1]) % mod;
	}



	cout << dp[K] % mod << endl;

	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
  int a,b,c,i,cont=0;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    i=a;
    a=b;
    b=i;
  }
  for(i=a;i<=b;i++)
    if((c%i)==0)
      cont++;
  printf("%d\n",cont);
  return(0);
}

Measured memory_bytes: 596
#include <stdio.h>

int main() {

  int H ,W,i,j;

  while(1) {
    scanf("%d %d",&H, &W);
    if(H == 0 && W == 0) {
      break; 
    }

    for (j=1; j<=H; j++) {
      for(i=1; i<=W; i++) {
	if(j == 1 || j == H) {
	  printf("#");
	} else if (j !=1 && j !=H && i==1 || i==W) {
	  printf("#");
	} else {
	  printf(".");
	}
      }

      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<Int> D(K);
	for (Int i = 0; i < K; i++) {
		cin >> D[i];
	}
	
	Int flag = 1;
	Int temp;
	Int keta;
	while (flag) {
		temp = N;
		while (temp) {
			keta = temp % 10;
			auto itr = find(D.begin(), D.end(), keta);    //  最初の要素5へのイテレータを返す
			if (itr != D.end()) {     // 発見した場合
				N++;
				break;
			}
			temp /= 10;
		}
		if (temp == 0)flag = 0;
	}
	cout << N << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
//not so imp
#define fill0(ar) fill((ar), 0)
#define fillinf(ar) fill((ar), inf)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = (1<<17);
ll n;
ll a[maxn];
ll compat[20][20];

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        rep(i,n) rep(j,n) cin>>compat[i][j];
        rep(i,maxn) rep(j,16) fr(k,j+1,15) 
            if((i & (1<<j)) && (i & (1<<k))) a[i] += compat[k][j];
        rep(i,maxn) for(ll j=i;j>0;j=(j-1)&i){
            a[i] = max(a[i], a[j] + a[i-j]);
        }
        cout<<a[maxn-1];
    }
    end_routine();
}

Measured memory_bytes: 1280
Node = Struct.new(:p, :l, :r)
@tree = []
# @tree = Array.new(25, Node.new(-1, -1, -1))?????¨????????????Node???????????¢?????¬????????????????????????
# ????????????????????????

def preParse(u)
  return if u == -1
  print " " + u.to_s
  preParse(@tree[u].l)
  preParse(@tree[u].r)
end

def inParse(u)
  return if u == -1
  inParse(@tree[u].l)
  print " " + u.to_s
  inParse(@tree[u].r)
end

def postParse(u)
  return if u == -1
  postParse(@tree[u].l)
  postParse(@tree[u].r)
  print " " + u.to_s
end

n = gets.to_i

n.times do |i|
  @tree[i] = Node.new(-1, -1, -1)
end

n.times do
  v, l, r = gets.chomp.split(' ').map(&:to_i)
  @tree[v].l = l
  @tree[v].r = r
  @tree[l].p = v if l != -1
  @tree[r].p = v if r != -1
end

root = 0
n.times do |i|
  root = i if @tree[i].p == -1
end

puts 'Preorder'
preParse(root)
puts
puts 'Inorder'
inParse(root)
puts
puts 'Postorder'
postParse(root)
puts

Measured memory_bytes: 8716
import java.util.Scanner;

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

    //input
    int n = sc.nextInt();
    String[] result = new String[n];
    for(int i = 0; i < result.length; i++){
      result[i] = sc.next();
    }

    //output
    int acCount = 0;
    int tleCount = 0;
    int waCount = 0;
    int reCount = 0;
    for(int i = 0; i < result.length; i++){
      if( result[i].equals("AC") ){
        acCount++;
      }else if( result[i].equals("TLE") ){
        tleCount++;
      }else if( result[i].equals("WA") ){
        waCount++;
      }else if( result[i].equals("RE") ){
        reCount++;
      }
    }
    System.out.println("AC x "+acCount);
    System.out.println("WA x "+waCount);
    System.out.println("TLE x "+tleCount);
    System.out.println("RE x "+reCount);


  }
}


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

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        MaxUnionFind muf = new MaxUnionFind(nm[0], a);
        for (long i = 0; i < nm[1]; i++)
        {
            long[] xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
            muf.Union(xy[0],xy[1]);
        }
        long[] min = muf.Min;
        long res = 0;
        if (min.Length == 1)
        {
            res = 0;
        }
        else if (a.Length - min.Length < min.Length - 2)
        {
            res = -1;
        }
        else
        {
            long[] q = min.OrderBy(x => x).ToArray();
            long[] p = a.OrderBy(x => x).ToArray();
            long[] r = new long[p.Length - q.Length];

            int index = 0;
            for (int i = 0; i < min.Length - 2; i++)
            {
                while (index < q.Length && p[i + index] == q[index]) index++;
                r[i] = p[i + index];
            }
            res = r.Sum() + min.Sum();
        }
        Console.WriteLine(res != -1 ? $"{res}" : "Impossible");
    }
    static void e()
    {
        throw new ArgumentException();
    }
}
class MaxUnionFind
{
    ufData[] data;
    public long[] Min => data.Where((x, y) => x.Parent == y).Select(x => x.Data).ToArray();
    public MaxUnionFind(int count,long[] d)
    {
        data = Enumerable.Range(0, count).Select(x => new ufData(x, d[x])).ToArray();
    }
    public void Union(long x, long y)
    {
        long xp = Parent(x);
        long yp = Parent(y);
        long xd = data[xp].Data;
        long yd = data[yp].Data;
        if (xp != yp)
        {
            data[yp].Parent = xp;
            data[xp].Data = Math.Min(xd,yd);
        }
        data[yp].Parent = xp;
    }
    public bool IsSameGroup(long x, long y) => Parent(x) == Parent(y);
    public long Parent(long x)
    {
        form(x);
        return data[x].Parent;
    }
    public long Data(long x)
    {
        form(x);
        return data[data[x].Parent].Data;
    }
    private void form(long x)
    {
        while (data[data[x].Parent].Parent != data[x].Parent)
        {
            data[x].Parent = data[data[x].Parent].Parent;
        }
    }
    struct ufData
    {
        public long Parent { get; set; }
        public long Data { get; set; }
        public ufData(long parents, long data)
        {
            Parent = parents;
            Data = data;
        }
    }
}

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

int main(void)
{
	int n, m, a, b, c, t;
	int p, q, r;
	int cost[100][100], time[100][100];
	
	while (scanf("%d %d", &m, &n), n){
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++){
				if (i == j) cost[i][j] = time[i][j] = 0;
				else cost[i][j] = time[i][j] = 10000000;
			}
		}
		
		for (int i = 0; i < m; i++){
			cin >> a >> b >> c >> t;
			cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
			time[a - 1][b - 1] = time[b - 1][a - 1] = t;
		}
		
		for (int k = 0; k < n; k++){
			for (int i = 0; i < n; i++){
				for (int j = 0; j < n; j++){
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
					time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
				}
			}
		}
		
		int k;
		cin >> k;
		for (int i = 0; i < k; i++){
			cin >> p >> q >> r;
			if (r == 0) cout << cost[p - 1][q - 1] << endl;
			else cout << time[p - 1][q - 1] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 984
#include <iostream>
using namespace std;
int main(){
	int n,r;
	while(cin>>n>>r){
		if(n==0&&r==0)break;
		int card[51];
		int tmp1[51],tmp2[51];
		for(int i=0;i<n;++i)card[i]=(n-i);
		for(int i=0,p,c;i<r;++i){
			cin>>p>>c;
			for(int j=0;j<p-1;++j)tmp1[j]=card[j];
			for(int j=p-1;j<p+c-1;++j)tmp2[j-(p-1)]=card[j];
			for(int j=0;j<c;++j)card[j]=tmp2[j];
			for(int j=c;j<c+p-1;++j)card[j]=tmp1[j-c];
		}
		cout<<(card[0])<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{
	
	
	public static void main(String[] args) {
		new Main().Kei();
	}
	
	void Kei() {
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.next());
		String g="";
		
		for(int i=0;i<N;i++) {
			int t=Integer.parseInt(sc.next());
			int x=Integer.parseInt(sc.next());
			int y=Integer.parseInt(sc.next());
			g="No";
			if(t>=x+y) {
				if((t-(x+y)+2)%2==0)
					g="Yes";
			}
			if(g.equals("No"))
				break;
		}
		System.out.println(g);
		sc.close();
	}
	
}




Measured memory_bytes: 55508
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

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

int main(void){
    int H, W; cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++){
        cin >> S[i];
    }
    
    vector<vector<int>> dis(H,vector<int>(W,-1));
    dis[0][0] = 0;
    
    queue<pair<int,int>> q;
    pair<int, int> start;
    start.first = 0, start.second = 0;
    q.push(start);
    while(!q.empty()){
        pair<int,int> now = q.front(); q.pop();
        // cout << "test" << endl;
        int x = now.first, y = now.second;
        // cout << x << ' ' << y << "\n";
        for(int dir = 0; dir < 4; dir++){
            int nx = x + dx[dir], ny = y + dy[dir];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            
            if(S[nx][ny] == '#') continue;
            
            if(dis[nx][ny] != -1) continue;
            
            // cout << nx << " " << ny << endl;
            pair<int,int> next;
            next.first = nx, next.second = ny;
            q.push(next);
            dis[nx][ny] = dis[x][y] + 1;
        }
    }
    
    int dis_goal = dis[H-1][W-1];
    if(dis_goal == -1) cout << -1 << "\n";
    else{
        int black = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(S[i][j] == '#') black++;
            }
        }
        cout << ((H*W)-dis_goal-1) - black << "\n";
    }
}


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

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

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return -0;
	}
	if (s.size() < 26) {
		bool used[26];
		for (int i = 0;i < 26;i++) {
			used[i] = false;
		}
		for (int i = 0;i < s.size();i++) {
			used[s[i] - 'a'] = true;
		}
		for (int i = 0;i < 26;i++) {
			if (!used[i]) {
				cout << s << (char)('a' + i) << endl;
				return 0;
			}
		}
	}

	queue<char>q;
	int i = s.size() - 1;
	q.push(s[i]);
	while (s[i - 1] > s[i]) {
		i--;
		q.push(s[i]);
	}
	i--;
	while (!q.empty()) {
		char qf = q.front();q.pop();
		if (qf > s[i]) {
			cout << s.substr(0, i) << qf << endl;
			return 0;
		}
	}



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  vector<string>s(n);
  for(int i; i<n; i++)  cin >> s[i];
  sort(s.begin(), s.end());
  int cnt=1;
  for(int i=0; i<n-1; i++){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout << cnt << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

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

template<typename T>
struct FenwickTree{
    vector<T> fenwick;
    int  n;

    FenwickTree(int n):
        fenwick(vector<T>(n+1, 0)), n(n) {}

    T sum(int i) {
        if (!i) return 0;
        return fenwick[i] + sum(i-(i&-i));
    }

    T sum(int i, int j){
        // half-open Terval
        return sum(j-1) - sum(i-1);
    }

    void add(int i, T x) {
        if (i > n) return;
        fenwick[i] += x;
        add(i+(i&-i), x);
    }
};

//1-indexed
//  http://na-o-s.hateblo.jp/entry/2014/07/13/031143

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s;
    cin >> s;
    vector<FenwickTree<int32>> fts(26,FenwickTree<int32>(n));
    REP(i,n){
        fts[s[i]-'a'].add(i+1,1);
    }
    int32 q;
    cin >> q;
    REP(_,q){
        int32 v;
        cin >> v;
        if(v == 1){
            int32 i;
            char c;
            cin >> i >> c;
            fts[s[i-1]-'a'].add(i,-1);
            fts[c-'a'].add(i,1);
            s[i-1] = c;
        }else{
            int32 l,r;
            cin >> l >> r;
            int32 ans = 0;
            REP(i,26){
                if(fts[i].sum(l,r+1))ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 106396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i,n) cin >> x.at(i);
	ll ans=0;
	rep(i,n-1){
		ans+=min(b,(x.at(i+1)-x.at(i))*a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val graph: Array[List[Int]] = new Array[List[Int]](n + 1).map(a => Nil);
        for (i <- (1 to n)) {
            graph(i) = readLine.split(" ").map(_.toInt).drop(2).toList;
        }
        val ret = Main.dfs(n + 1, graph);
        for (i <- (1 to n)) {println("%d %d %d".format(i, ret(i)(0), ret(i)(1)))}
    }
    def dfs(size: Int, graph: Array[List[Int]]): Array[Array[Int]] = {
        val ret = Array.ofDim[Int](size, 2);
        def go(stack: List[Int], cost: Int): Int = {
            stack match {
                case Nil => cost;
                case curr :: rest => {
                    ret(curr)(0) = cost;
                    val nextCost = graph(curr).foldLeft(cost + 1) { (c, i) =>
                        if (ret(i)(0) == 0) go(i :: rest, c) else c;
                    }
                    ret(curr)(1) = nextCost;
                    nextCost + 1;
                }
            }
        }
        (1 until size).foldLeft(1) { (cost, i) => if (ret(i)(0) == 0) go(List(i), cost) else cost}
        ret;
    }
}



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

int main() {
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a != 1 && b != 1) {
		printf("1");
	}
	else {
		if (a != 2 && b != 2) {
			printf("2");
		}
		else {
			printf("3");
		}
	}
}

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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int32_t main()
{
  FIO
 
  
  int x1,x2,x3,x4,y1,y2,y3,y4,wx,wy;
  cin>>x1>>y1>>x2>>y2;
  wx=-(y2-y1);
  wy=x2-x1;
  x3=x2+wx;
  y3=y2+wy;
  x4=x1+wx;
  y4=y1+wy;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
  //timer();
  return 0;
}  

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

int main() {
    int a,b,c,d,e,f;
    cin >> a>>b>>c>>d>>e>>f;
    if (e-a>f){
        cout << ":(" << endl;
    } 
  else {
    cout << "Yay!" << endl;
  }
  }



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n),b(n);
  rep(i,n)cin>>a[i],b[i]=a[i];
  sort(all(b));
  rep(i,n)
    if(a[i]<=b[n/2-1]){
      cout<<b[n/2]<<endl;
    }else{
      cout<<b[n/2-1]<<endl;
    }

}


Measured memory_bytes: 3712
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 12/05/2018 12:33:43
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;
bool compare(pair<int, int> p1, pair<int, int> p2){
	 if(1) return true;
	 return false;
}

vector<int> g[100100];
vector<int> visited(100100, 0);

void dfs(int c, int color) {
	if(visited[c] == 0) {
		visited[c] = color;
	}
	
	
//	cout<<"we are in dfs and color "<<color<<endl;
	for(int nxt : g[c]){
		if(visited[nxt] == 0) dfs(nxt, color);
	}
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int n, m;
	cin>>n>>m;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 0; i < m; i++) {
		int x, y;
		cin>>x>>y;
		g[x].PB(y);
		g[y].PB(x);
	}
	int color = 1;
	for(int i = 0; i < n; i++) {
		if(visited[i+1] == 0) {
//			cout<<"dfs "<<a[i]<<"color "<<color<<endl;
			dfs(a[i], color);	
			color++;
		}
		
	}
	
//	for(int i = 0; i < n; i++) {
//		cout<<"g "<<i+1<<" "<<visited[i+1]<<endl;
//	}
	
	int res = 0;
	for(int i = 0; i < n; i++){
		if(visited[i+1] != 0 && visited[i+1] == visited[a[i]]) {
//			cout<<a[i]<<" - "<	<i+1<<endl;
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 7808
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    H = get_li()
    if n == 1:
        print('Yes')
        return
    m = H[0]
    for h in H[1:]:
        if h > m:
            m = h
        elif m - 1 > h:
            print('No')
            return
    print('Yes')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 84588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll x;
  cin>>x;
  ll ans=0;
  while(x>=500){
    x-=500;
    ans+=1000;
  }
  while(x>=5){
    x-=5;
    ans+=5;
  }
  cout<<ans<<endl;
  return(0);
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }

    int Amin = 0;
    int AtoB = 0;
    int Bmax = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= A) {
            Amin++;
        }
        else if (P[i] > B) {
            Bmax++;
        }
        else {
            AtoB++;
        }
    }
    cout << min(Amin, min(AtoB, Bmax)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>

struct Data
{
    int A;
    int B;
};


int main()
{
    int N;
    std::cin >> N;
    std::vector<Data> data(N);

    for (int i = 0; i < N; i++)
    {
        std::cin >> data[i].A >> data[i].B;
    }

    std:sort(data.begin(), data.end(), [](auto const& lhs, auto const& rhs) {
        return lhs.B > rhs.B; // 左の方が大きい...というイメージ。
    });

    int res = data[0].B;
    for (int i = 0; i < N; i++)
    {
        res = std::min(res, data[i].B);
        res = res - data[i].A;
        //printf("A=%d, B=%d, res=%d\n", data[i].A, data[i].B, res);

        if (res < 0)
        {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
 
    return 0;
}

Measured memory_bytes: 4848
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint qinv=111111112;
llint cul(int keta){
	llint ans=1;
	llint bgen=10;
	for(int h=0;h<30;h++){
		if(keta&(1<<h)){ans*=bgen;ans%=mod;}
		bgen*=bgen;bgen%=mod;
	}
	ans--;
	ans*=qinv;ans%=mod;
	return ans;
}
int main(void){
	int n,Q,i,j;cin>>n>>Q;
	vector<pair<int,int>>bas;
	for(i=0;i<Q;i++){
		int L,R;cin>>L>>R;
		bas.pub(mp(L-1,i));
		bas.pub(mp(R,i));
	}
	SO(bas);
	//区間 numberを求める
	vector<llint>kak(Q+Q-1);
	for(i=0;i<Q+Q-1;i++){kak[i]=cul(bas[i+1].fir-bas[i].fir);}
	static llint dp[32768][10]={0};
	dp[0][0]=1;
	
	for(int bi=0;bi<(1<<Q);bi++){
		//biにする
		int ko=1;//ko=0は遷移順を最後にする
		while(ko<(1<<Q)){
			if(ko-(bi&ko)!=0){ko+=ko-(bi&ko);continue;}
			//cerr<<"bi="<<bi<<"ko="<<ko<<endl;
			//bi-koにkoの内容を加える
			llint bai=1;
			for(i=0;i<Q+Q-1;i++){
				int aaa=0,bbb=0;
				if((ko&(1<<bas[i].sec))>0){aaa=2;}
				else if((bi&(1<<bas[i].sec))>0){aaa=1;}
				if((ko&(1<<bas[i+1].sec))>0){bbb=2;}
				else if((bi&(1<<bas[i+1].sec))>0){bbb=1;}
				if(aaa+bbb==4){bai*=kak[i]+1;bai%=mod;}
				else if(aaa+bbb==3){bai*=kak[i];bai%=mod;}
			}
			for(int su=0;su<9;su++){dp[bi][su+1]+=bai*dp[bi-ko][su];dp[bi][su+1]%=mod;}
			ko++;
		}
		for(int su=0;su<9;su++){dp[bi][su+1]+=dp[bi][su];dp[bi][su+1]%=mod;}
		//cerr<<"bi="<<bi<<endl;
		//for(int su=0;su<=9;su++){cerr<<"dp="<<dp[bi][su]<<endl;}
	}
	
	llint ans=dp[(1<<Q)-1][9]*qinv%mod;
	int nko=n-bas.back().fir+bas[0].fir;
	ans*=(cul(nko)*9+1)%mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2816
//#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
typedef pair < ld , int > pii ;
typedef pair < long long  , long long > pll ;
const int N = 2e5 + 123 ;
int n , a[N];

main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	pii best = mp(1e9 + 123 , -1);
	ld o = 1.0 * a[n] / 2.0;
	for(int i = 1 ; i < n ;i++){
		best = min(best , { abs(o - a[i]) , i} );
	}
	cout << a[n] << ' ' << a[best.se] ;
}

Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,d = inpl()
res = 0
for i in range(n):
    a,b = inpl()
    now = math.sqrt(a**2+b**2)
    if now <= d:
        res += 1
print(res)

Measured memory_bytes: 73640
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    ll sum=0;
    map<ll, ll> mp1;
    forr(i, n)
    {
        cin>>a[i];
        mp1[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll x, y;
        cin>>x>>y;
        sum-=mp1[x]*x;
        if(mp1.find(y)==mp1.end())
        {
            mp1[y]=mp1[x];
            sum+=mp1[y]*y;
            mp1.erase(x);
            cout<<sum<<endl;
            continue;
        }
        else
        {
            mp1[y]+=mp1[x];
            sum+=mp1[x]*y;
            mp1.erase(x);
            cout<<sum<<endl;
            continue;
        }
    }
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 8004
from collections import defaultdict

N, C = map(int, input().split())

D = defaultdict(list)
for _ in range(N):
    s, t, c = map(int, input().split())
    D[c-1].append((s, t))

IMOS = [0]*(10**5+2)
for c in range(C):
    D[c].sort(key=lambda x: x[0])

    pt = -1
    for i, (s, t) in enumerate(D[c]):
        if s == pt:
            IMOS[s+1] += 1
            IMOS[t] -= 1
        else:
            IMOS[s-1] += 1
            IMOS[t] -= 1
        pt = t

ans = 0
a = 0
for i in IMOS:
    a += i
    ans = max(ans, a)

print(ans)


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

namespace CSharpSample01
{


    class Program
    {

        static double Solve(int N, double[] p)
        {
            double[,] dp = new double[N + 1, N + 1];

            dp[0, 0] = 1;
            for (int j = 1; j <= N; j++) dp[0, j] = 0;

            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    dp[i + 1, j + 1] += dp[i, j] * p[i + 1];
                    dp[i + 1, j] += dp[i, j] * (1 - p[i + 1]);
                }
            }

            double ans = 0;
            for(int j = (N + 1) / 2; j <= N; j++)
            {
                ans += dp[N, j];
            }

            return ans;
        }
        

        

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

            double[] p = new double[N + 1];

            string[] input = Console.ReadLine().Split(' ');
            for(int i = 1; i <= N; i++)
            {
                p[i] = double.Parse(input[i - 1]);
            }

            Console.WriteLine(Solve(N, p));
        }
    }
}

Measured memory_bytes: 81376
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long ans = Long.MAX_VALUE / 16;
		ans = Math.min(ans, solve(H, W));
		ans = Math.min(ans, solve(W, H));
		System.out.println(ans);
	}

	long solve(long H, long W) {
		long ans = Long.MAX_VALUE / 16;
		if (W % 3 == 0) {
			ans = 0;
		} else {
			ans = W;
		}
		for (long i = 1; i < H; ++i) {
			ans = Math.min(ans, max(i * W, (H - i) * (W / 2), (H - i) * (W - W / 2))
					- min(i * W, (H - i) * (W / 2), (H - i) * (W - W / 2)));
			long w = i * W / (H - i);
			for (long j = w - 1; j <= w + 1; ++j) {
				if (j <= 0 || W - j <= 0)
					continue;
				ans = Math.min(ans,
						max(i * W, (H - i) * j, (H - i) * (W - j)) - min(i * W, (H - i) * j, (H - i) * (W - j)));
			}
		}
		return ans;
	}

	long max(long a, long b, long c) {
		long ret = a;
		ret = Math.max(ret, b);
		ret = Math.max(ret, c);
		return ret;
	}

	long min(long a, long b, long c) {
		return -max(-a, -b, -c);
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

N = int(input())

S = [input().rstrip() for i in range(N)]

ans = 0

for i in range(N):
    for j in range(len(S[i]) - 1):
        if S[i][j] == 'A' and S[i][j + 1] == 'B':
            ans += 1

a = 0
b = 0
ba = 0

for i in range(N):
    if S[i][0] == 'B' and S[i][-1] == 'A':
        ba += 1
    elif S[i][0] == 'B' and S[i][-1] != 'A':
        b += 1
    elif S[i][0] != 'B' and S[i][-1] == 'A':
        a += 1

exist = False

if a > 0 or ba > 0:
    exist = True
    if a > 0:
        a -= 1
    elif ba > 0:
        ba -= 1

if exist:
    ans += ba
    if b > 0:
        b -= 1
        ans += 1
    ans += min(a, b)

print(ans)


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

int main(){
  int N;
  cin >> N;
  int A[1000000];
  A[1] = N;
  if(N == 1) cout << 4 << endl;
  else if(N == 2) cout << 4 << endl;
  else {
    for(int i=2;i<1000000;i++){
      if(A[i-1] % 2 == 0){
        A[i] = A[i-1]/2;
      }
      else{
        A[i] = A[i-1]*3+1;
      }
      if(A[i] == 1){
        cout << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BAnOddProblem {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      int ret = 0;
      rep(i, n) {
        if (i%2 == 0 && a[i]%2 != 0) {
          ret++;
        }


      }
      cout << ret << endl;
    }
};

signed main() {
  BAnOddProblem solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            int n = int.Parse(Console.ReadLine());

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray();

            var count = 0;

            for(int i = 0; i< n; i++) {
                var al = a[a[i]];

                if(al == i) {
                    count++;
                }
            }

            Console.WriteLine(count / 2);
        }
    }
}


Measured memory_bytes: 35880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pb push_back
#define mp make_pair
typedef pair<int,int> ii;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	{
		cout<<k<<endl;
	}
	else if(k>a&&k<=a+b)
	{
		cout<<((k-a)*(0)+a)<<endl;
	}
	else
	{
		cout<<((k-(a+b))*(-1)+a)<<endl;
	}
}

Measured memory_bytes: 3636
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;

/*******************************************************************/

vector<int> a;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	a.clear(); a.resize(n);
	map<int, int> m;
	for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++;
	int lim = *max_element(a.begin(), a.end());
	sort(a.begin(), a.end());
	unordered_set<int> vis;
	for (int i = 0; i < n; i++) {
		if (vis.find(a[i]) != vis.end()) continue;
		for (int j = a[i]; j <= lim; j += a[i]) {
			if (j == a[i] && m[j] == 1) continue;
			if (m.find(j) != m.end()) vis.insert(j);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (vis.find(a[i]) == vis.end()) ans++;
	}
	cout << ans << endl;
}

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

string S;

int main() {
  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
    return 0;
  }
  cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            string s = Console.ReadLine();
            long ans = 0;
            for(var i = 0; i < s.Length; i++)
            {
                for (var j = 1; j <= s.Length - i; j++) 
                {
                    string sub = s.Substring(i, j);
                    bool ok = true;
                    for(var k = 0; k < sub.Length; k++)
                    {
                        ok &= (sub[k] == 'A' || sub[k] == 'C' || sub[k] == 'G' || sub[k] == 'T');
                    }
                    if (ok)
                    {
                        ans = Max(ans, sub.Length);
                    }
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        
        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}


Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
const int N=1e5+10;
int a[N],b[N],f[N];
map<int,int> mp;
int tot=0;
int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
}
void mg(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy) f[fy]=fx;
}
int c[N],d[N];
bool check(int n){
	memcpy(c,a,sizeof(c)),memcpy(d,b,sizeof(b));
	sort(c+1,c+n+1),sort(d+1,d+n+1);
	fo(i,1,n) if(c[i]!=d[i]) return false;
	return true;
}
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]),a[n+1]^=a[i];
	fo(i,1,n) scanf("%d",&b[i]),b[n+1]^=b[i];
	n++;
	fo(i,1,n)
	if(a[i]!=b[i] || i==n){
		ans+=i<n;
		if(!mp[a[i]]) mp[a[i]]=++tot;
		if(!mp[b[i]]) mp[b[i]]=++tot;
	}
	if(!check(n)) return printf("-1"),0;
	fo(i,1,tot) f[i]=i;
	fo(i,1,n) if(a[i]!=b[i]) mg(mp[a[i]],mp[b[i]]);
	fo(i,1,tot) if(f[i]==i) ans++;
	printf("%d",ans-1);
}


Measured memory_bytes: 6912
import           Data.Maybe
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> readParams >>= print

readParams :: IO [Int]
readParams = map readInt . B.words <$> B.getContents

readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt

solve :: [Int] -> Int
solve (n:as) = maybe (-1) (n -) $ count as

count :: [Int] -> Maybe Int
count = go 0
  where
    go acc []
      | acc == 0   = Nothing
      | otherwise  = Just acc
    go acc (x:xs)
      | acc+1 == x = go (acc+1) xs
      | otherwise  = go acc xs


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

typedef long long ll;
typedef long double ld;
const ll init = 1e9+7;

#define mkp make_pair
#define pb push_back
#define pq priority_queue
#define minpq priority_queue <int, vector<int>, greater<int> >
#define vi vector <int> 
#define vll vector <ll>
#define pii pair<int,int>

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b,c; cin>>a>>b>>c;
	if(c<=a+1){
		cout<<c+b<<endl;
	}
	else{
		int ans=a+1;
		c-=(a+1);
		ans += b;
		ans += min(b,c);
		cout<<ans<<endl;
	}
    return 0;
} 

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    cin>>n;
    long long int ans=100000;
    rep(i,n){
        ans+=ans*5/100;
        int temp=ans%1000;
        if(temp!=0){
            ans+=1000;
            ans-=temp;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3064