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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int W, H, N;
    cin >> W >> H >> N;
    Vi xs(N), ys(N), as(N);
    for (int i = 0; i < N; i++) {
        cin >> xs[i] >> ys[i] >> as[i];
    }

    int u = H, d = 0, l = 0, r = W;
    for (int i = 0; i < N; i++) {
        if (as[i] == 1) {
            l = max(l, xs[i]);
        }
        else if (as[i] == 2) {
            r = min(r, xs[i]);
        }
        else if (as[i] == 3) {
            d = max(d, ys[i]);
        }
        else {
            u = min(u, ys[i]);
        }
    }

    cout << max(r - l, 0) * max(u - d, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	ll ans=0;
	FOR(b,1,x+1){
		ll now=b;
		FOR(p,2,10){
			if(now*b<=x){
				chmax(ans,now*b);
				now*=b;
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
    

int a,b,c,k,ans=0;
cin>>a>>b>>c>>k;

if(a<b && b<c){
    cout<<"Yes"<<endl;
    ans=1;
}
else{

    for(int i=0;i<k;i++){

if(a>=b){
  b*=2;
}
else if(b>=c){
    c*=2;
}

if(a<b && b<c){
    cout<<"Yes"<<endl;
    ans=1;
    break;
}

    }
}
if(ans==0){
    cout<<"No"<<endl;
}

}
 

Measured memory_bytes: 3616
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[] x = new int[a];
        for (int i = 0; i < a; i++) {
            x[i] = scanner.nextInt();
        }
        int[] y = new int[a];
        for (int i = 0; i < a; i++) {
            y[i] = scanner.nextInt();
        }
        double[] p = new double[4];
        for (int i = 0; i < a; i++) {
            double p0 = Math.abs(x[i] - y[i]);
            p[1] += Math.pow(p0, 2);
            p[2] += Math.pow(p0, 3);
            p[3] = Math.max(p[3], p0);
            p[0] += p0;
        }
        p[1] = Math.sqrt(p[1]);
        p[2] = Math.cbrt(p[2]);
        for (double aa : p)
            System.out.println(aa);
    }
}


Measured memory_bytes: 26648
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

using namespace std;

bool dfs(const vector<vector<int>>& Edges_,vector<int>& IsVisit_,int root_){
	if(Edges_.empty() || IsVisit_.empty() || Edges_.size()!=IsVisit_.size() || root_<0 || IsVisit_.size()-1<root_)return false;

	IsVisit_[root_]=1;
	bool ans=false;
	for(const auto& val:Edges_[root_]){
		if(IsVisit_[val]==1)return true;
		if(IsVisit_[val]==0){
			ans=dfs(Edges_,IsVisit_,val);
			if(ans)return true;
		}
	}

	IsVisit_[root_]=2;
	return false;
}

int main() {
	int N,M;
	cin>>N>>M;
	vector<vector<int>> Edges(N);
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;
		Edges[u].push_back(v);
	}

	vector<int> IsVisit(N);
	bool ans=false;
	for(int i=0;i<N;++i){
		for(auto& val:IsVisit)val=0;
		IsVisit[i]=1;
		ans=dfs(Edges,IsVisit,i);
		if(ans)break;
	}

	if(ans)cout<<1<<endl;
	else cout<<0<<endl;
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;
    cin>>s;
    int N=s.length();
    ll ans=0;
    for(int bit=0;bit<(1<<(N-1));bit++){ //bit全探索
        ll tmp=0;
        rep(i,N-1){
            tmp*=10;
            tmp+=s[i]-'0';
            if(bit & (1<<i)){
                ans+=tmp;
                tmp=0;
            }
        }
        tmp*=10;
        tmp+=s.back()-'0';
        ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);

		while(true){
			int n = scan.nextInt();
			double m ,a;
			if(n == 0){
				break;
			}

			int[] s = new int[n];
			m = 0;
			for(int i = 0; i < n;i++){
				s[i] = scan.nextInt();
				m += s[i];
			}
			m = m/n;

			a = 0;
			for(int i = 0;i < n;i++){
				a += (s[i] - m)*(s[i] - m) ;
			}
			a = Math.sqrt(a/n);
			System.out.println(a);
		}
	}

}

Measured memory_bytes: 31136
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a,k;
    vector<long long int>v;
    
    cin>>n>>k;
    vector<long long int>cost(n,INT_MAX);
    for(long long int i=0;i<n;i++)
        {
            cin>>a;
            v.push_back(a);
        }
    cost[0]=0;
    cost[1]=abs(v[1]-v[0]);
    for(long long int i=2;i<n;i++)
        {
            if(i-k<0)
                {for(long long int j=0;j<i;j++)
                        cost[i]=min(cost[i],(cost[j]+abs(v[i]-v[j])));       
                }
            else if((i-k)>=0)
               {//cout<<"hoho";
                   for(long long int l=i-k;l<i;l++)
                        cost[i]=min(cost[i],(cost[l]+abs(v[i]-v[l])));       
                }          
        }
    cout<<cost[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

ll N, K;

bool chk(vector<int> vec)
{
    for(int i = 0; i < N; i++)
        if(vec[i] != i + 1)
            return false;
    return true;
}
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N;
    vector<int> vec(N, 0); for(int i = 0; i < N; i++) cin >> vec[i];
    bool check = false;
    if(chk(vec))
    {
        cout << "YES"; return 0;
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            swap(vec[i], vec[j]);
            if(chk(vec))
            {
                cout << "YES"; return 0;
            }
            swap(vec[i], vec[j]);
        }
    }
    
    
    
    if(check)
        cout << "YES";
    else
        cout << "NO";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<n;i++)
#define r (i*10+q[j])
typedef long long ll;

ll gcd(ll x,ll y)
{
    while(x!=y)
    {
        if(x>y)
            x=x-y;
        else
            y=y-x;
    }
    return x;
}

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y;
    a=a-1;
    ll l=c/gcd(c,d)*d;
    x=b/c+b/d-b/l;
    y=a/c+a/d-a/l;
    cout<<b-a-x+y<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll dp[102][100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    ll n,maxc;
    cin>>n>>maxc;
    pair<ll,ll>* arr=new pair<ll,ll>[n+1];
    arr[0]=make_pair(-1,-1);
    for(ll i=1;i<=n;++i)
    {
        ll a,b;
        cin>>a>>b;
        arr[i]=make_pair(a,b);
    }
    for(ll i=0;i<=n;++i)
    {
        dp[i][0]=0;
    }
    for(ll i=1;i<=n;++i)
    {
        ll value=arr[i].second;
        ll weight=arr[i].first;
        for(ll j=1;j<=maxc;++j)
        {
            dp[i][j]=dp[i-1][j];
            if(j-weight>=0 && dp[i-1][j-weight]!=-1)
            {
                ll newval=dp[i-1][j-weight]+value;
                if(dp[i][j]==-1)
                {
                    dp[i][j]=newval;
                }
                else
                {
                    dp[i][j]=max(newval,dp[i][j]);
                }
            }
        }
    }
    ll ans=-1;
    for(ll i=0;i<=maxc;++i)
    {
        ans=max(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}






































Measured memory_bytes: 83352
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n) rep(j,n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }
    rep(i,n) reverse(a[i].begin(), a[i].end());

    typedef pair<int, int> P;
    vector<P> que;
    auto set = [&](int i) -> void {
        if (a[i].size()==0) return;
        int j = a[i].back();
        if (a[j].back() == i) {
            if (i > j) swap(i,j);
            que.emplace_back(i,j);
        }
    };

    rep(i,n) set(i);

    int ans = 0;
    while (!que.empty()) {
        ans++;
        sort(que.begin(), que.end());
        que.erase(unique(que.begin(), que.end()), que.end());
        vector<P> tmp;
        swap(tmp, que);
        for (auto v : tmp) {
            a[v.first].pop_back();
            a[v.second].pop_back();
        }
        for (auto v : tmp) {
            set(v.first);
            set(v.second);
        }
    }

    rep(i,n) {
        if (a[i].size()) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.io.*;
public class Main {
    public static void main(String[] args){
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String line = reader.readLine();
            double r=Double.parseDouble(line);
            System.out.printf("%.6f %.6f\n",Math.PI*r*r, 2*Math.PI*r);
        }
        catch(IOException e){
        }
    }
}


Measured memory_bytes: 24816
import cmath
EPS = 1e-5

while True:
	n = int(input())
	if n == 0:
		break
	d = []
	for _ in range(n):
		x, y = list(map(float, input().split()))
		d.append(complex(x, y))

	res = 1
	for i in range(n):
		o1 = d[i]
		cnt0 = 1
		for j in range(n):
			if j == i:
				continue
			o2 = d[j]
			if abs(o1 - o2) + EPS <= 1:
				cnt0 += 1

		res = max(res, cnt0)
		for j in range(i+1, n):
			o2 = d[j]
			if abs(o1 - o2) - EPS >= 2:
				continue
			else:
				co = (abs(o1 - o2)**2) / (2 * abs(o1 - o2))
				si = cmath.sqrt(1 - co**2)
				p1 = o1 + (o2 - o1) * (co + 1j * si) / abs(o1 - o2)
				p2 = o1 + (o2 - o1) * (co - 1j * si) / abs(o1 - o2)

			cnt1, cnt2 = 2, 2
			for l in range(n):
				if l == i or l == j:
					continue
				else:
					o3 = d[l]
					if abs(p1 - o3) + EPS <= 1:
						cnt1 += 1
					if abs(p2 - o3) + EPS <= 1:
						cnt2 += 1
			res = max(res, cnt1, cnt2)
	print(res)


Measured memory_bytes: 5720
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
from fractions import gcd
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

left = [0]
right = [0]
for i in range(n):
    left.append(gcd(left[i], a[i]))
    right.append(gcd(right[i], a[-i-1]))
right = right[::-1]

ans = []

print(max([gcd(left[i], right[i+1]) for i in range(n)]))

Measured memory_bytes: 16144
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#define ll long long int

using namespace std;

ll p = 0;
int cnt = 0;
ll solve (ll x, ll rest ){
  if(x==0) return rest;
  return solve(rest%x,x);
}
ll n , x;
int main(){
  cin>>n>>x;
  ll rest = n - x;
  if(x < rest)
    swap(x,rest);
  cout<<n*3 - 3*solve(x,rest)<<endl;
  return 0;
}


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

int n, k, l, a, b, ans[200005], p[200005], cnt[200005];
vector<int> path;
set<int> par;
vector<vector<int>> adjList;
bitset<200005> visited;

int findSet(int i) {
	return (p[i] == i ? i : p[i] = findSet(p[i]));
}

void unionSet(int i, int j) {
	int x = findSet(i), y = findSet(j);
	if (x != y) {
		p[x] = y;
	}
}

void dfs(int u) {
	path.push_back(u);
	par.insert(findSet(u));
	cnt[findSet(u)]++;
	visited[u] = 1;
	for (int i = 0; i < adjList[u].size(); i++) {
		int v = adjList[u][i];
		if (!visited[v]) {
			dfs(v);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	cin >> n >> k >> l;
	adjList.resize(n+5);

	for (int i = 1; i <= n; i++) {
		p[i] = i;
	}

	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		unionSet(a, b);
	}

	for (int i = 0; i < l; i++) {
		cin >> a >> b;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			for (auto it = par.begin(); it != par.end(); it++) {
				cnt[*it] = 0;
			}
			path.clear();
			par.clear();
			dfs(i);

			for (int j = 0; j < path.size(); j++) {
				int u = path[j];
				ans[u] = cnt[findSet(u)];
			}
		}
	}

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

Measured memory_bytes: 13176
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = input().split()
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll LINF = 1e18;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}


int main()
{
  int Q,t,a,b;
  ll min=0,minx=0;
  cin >> Q;
  priority_queue<int> L;
  priority_queue<int, vector<int>, greater<int>> R;
  cin >> t >> a >> b;
  L.push(a);
  R.push(a);
  minx = a;
  min = b;

  for(int i=0; i<Q-1; i++){
    cin >> t;
    if(t == 1){
      int x,y;
      x = L.top();
      y = R.top();
      cin >> a >> b;
      min += b+abs(minx-a);
      if(a < x){
        L.pop();
        R.push(x);
        L.push(a);
        L.push(a);
        int k = L.top();
        minx = k;
      }else if (a > y){
        R.pop();
        L.push(y);
        R.push(a);
        R.push(a);
        int newx = L.top();
        min -= (newx-minx);
        minx = newx;
      }else{
        L.push(a);
        R.push(a);
        int newx = L.top();
        min -= (newx-minx);
        minx = newx;
      }
      //cout << "L:" << L.top() << ", R:" << R.top() << endl;
      //cout << "minx:" << minx << ", min:" << min << endl;
    }else{
      cout << minx << " " << min << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3828
def main():
	n = int(input())
	xx = list(map(int, input().split()))

	pp = [(xx[i], i + 1) for i in range(n)]
	pp.sort(key=lambda x: x[0])
	# print(xx)
	# print(pp)

	left = [0, 0] + [i + 1 for i in range(n)]
	right = [i + 1 for i in range(n)] + [n + 1, n + 1]
	ans = 0
	for i in range(n):

		ori_num, ori_ind = pp[i]
		l1 = left[ori_ind]
		l2 = left[l1]
		r1 = right[ori_ind]
		r2 = right[r1]

		# print("ori_num, ori_ind, l1, l2, r1, r2")
		# print(ori_num, ori_ind, l1, l2, r1, r2)
		# print(left)
		# print(right)

		ans += ((l1 - l2) * (r1 - ori_ind) + (ori_ind - l1) * (r2 - r1)) * ori_num

		right[l1] = r1
		left[r1] = l1

	print(ans)

main()

Measured memory_bytes: 66540
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>

int main(){
	char a[4];
	scanf("%s",a);
	if(a[0]==a[1]&&a[0]==a[2]) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int[] counter = new int[26];
		while ((str = br.readLine()) != null) {
			if (str.equals(""))
				break;
			str = str.toLowerCase();
			char[] ch = str.toCharArray();
			for (char c : ch) {
				if ('a' <= c && c <= 'z') {
					counter[c - 'a']++;
				}
			}
		}

		for (int i = 0; i < counter.length; i++) {
			System.out.println((char) ('a' + i) + " : " + counter[i]);
		}

	}
}

Measured memory_bytes: 24376
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#define ii pair < int , int >
#define mp make_pair
using namespace std;
int main()
{
 int x,y;
 cin>>x>>y;
 if(x == y)
 {
     cout<<0;
 }
 else if(x == -y)
 {
     cout<<1;
 }
 else if(x == 0 || y == 0)
 {
     if(x == 0)
     {
         int sum = abs(y);
         if(y  < 0)
            sum++;
         cout<<sum;
     }
     else
     {
         int sum = abs(x);
         if(x > 0)
            sum++;
         cout<<sum;
     }
 }
 else
 {
     if(x < 0 && y < 0)
     {
         if(x < y)
         {
             cout<<(abs(y-x));
         }
         else
         {
             cout<<abs(x-y)+2;
         }
     }
     else if(x > 0 && y > 0)
     {
         if(x > y)
         {
             cout<<x-y+2;
         }
         else
         {
             cout<<y-x;
         }
     }
     else
     {
         cout<<abs(x+y)+1;
     }
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0; 
    for(ll i=1;i*i<=m;i++){
        //cout<<i<<endl;
        if(m%i==0){
            //cout<< "Yes" << endl;
            ll now1 = i, now2 = m/i;
            if(now1*n<=m) ans = max(ans,now1);
            if(now2*n<=m) ans = max(ans,now2);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

   char tmp = s[0];   
   for (int i = 1; i <= s.length(); i++) {
       if (tmp == s[i]) {
           cout << "Bad" << endl;
           return 0;
       }
       tmp = s[i];
   }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=3e3+5,Mod=1e9+7,Inv2=Mod+1>>1;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,q,a[MAXN],F[MAXN][MAXN],ans,t;
inline void Add(int&x,int y){x+=y,x>=Mod?x-=Mod:0;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),q=read();
	Rep(i,1,n)a[i]=read();
	Rep(i,1,n)Rep(j,1,n)F[i][j]=a[i]>a[j];
	for(t=1;q--;){
		int x=read(),y=read();t=t*2%Mod;
		F[x][y]=F[y][x]=1ll*(F[x][y]+F[y][x])*Inv2%Mod;
		Rep(i,1,n)if(i!=x&&i!=y)F[i][x]=F[i][y]=1ll*(F[i][x]+F[i][y])*Inv2%Mod,F[x][i]=F[y][i]=1ll*(F[x][i]+F[y][i])*Inv2%Mod;
	}Rep(i,1,n)Rep(j,i+1,n)ans=(ans+F[i][j])%Mod;cout<<1ll*ans*t%Mod<<'\n';
	return 0;
}




Measured memory_bytes: 38864
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, minValue, result, r;

	cin >> n;
	cin >> minValue;
	result = -2e9;
	for (int j = 1; j < n; j ++) {
		cin >> r;
		result = max(r - minValue, result);
		minValue = min(minValue, r);
	}
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pi;
 
int N, M, Q, K, A, B, C, X, Y, Z;
string s, t;
 
int early[500005], late[500005], pt[500005];
int pref[500005], suff[500005];
int useful[500005], usable[500005];
deque<int> prefstuff;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K >> C;
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] == 'o'){
			if (i >= C) early[i+1] = pref[i-C]+1;
			else early[i+1] = 1;
		}
		pref[i+1] = max(pref[i],early[i+1]);
	}
	Z = 0;
	for (int i = s.size(); i >= 0; --i){
		 if (s[i] == 'o'){
			late[i+1] = suff[i+C+2]+1;
		}
		suff[i+1] = max(suff[i+2],late[i+1]);
	}
	/*
	for (int i = 1; i <= N; ++i){
		cout << early[i] << ' ' << late[i] << '\n';
	}
	cout << '\n';

	for (int i = 1; i <= N; ++i){
		cout << pref[i] << ' ' << suff[i] << '\n';
	}
	*/
	for (int i = 1; i <= N; ++i){
		if (suff[i+C+1] + early[i] >= K) useful[i] = 1;
	}
	for (int i = C+2; i < N+C+2; ++i){
		if (s[i-C-2] == 'o' && useful[i-C-1]) prefstuff.push_back(i-C-1);
		while (!prefstuff.empty() && early[prefstuff.front()] < K - suff[i]){
			prefstuff.pop_front();
		}
		if (prefstuff.size() > 1){
			for (auto it : prefstuff){
				useful[it] = -1;
			}
			while (prefstuff.size() > 1) prefstuff.pop_front();
		}
		
	}
	for (int i = 1; i <= N; ++i){
		if (early[i] == 0) continue;
		if (useful[i] == 1) cout << i << '\n';
	}
}

Measured memory_bytes: 12436
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        Array.Sort(ary, (x,y)=>y-x);
        
        long sum = ary.Sum(x => (long)x);
        long count = 1;
        sum -= ary.First();

        for(int i=1; i<n; i++) {
            if(sum * 2 >= ary[i - 1]) {
                count++;
            } else {
                break;
            }

            sum -= ary[i];
        }

        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 23132
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    size_t H, W, M;
    cin >> H >> W >> M;

    vector<size_t> h(M, 0), w(M, 0);
    for (size_t i = 0; i < M; ++i) { cin >> h[i] >> w[i];}

    vector<size_t> count_H(H, 0), count_W(W, 0);

    for (size_t i = 0; i < M; ++i)
    {
        ++count_H[h[i] - 1];    // 0 オリジン
        ++count_W[w[i] - 1];
	}

    size_t max_H = 0;
    size_t max_W = 0;

    for (size_t i = 0; i < H; ++i)
    {
        if (max_H < count_H[i])
        {
            max_H = count_H[i];
        }
    }

    vector<size_t> max_H_index;
    for (size_t i = 0; i < H; ++i)
    {
        if (count_H[i] == max_H)
        {
            max_H_index.push_back(i);
        }
    }


    for (size_t i = 0; i < W; ++i)
    {
        if (max_W < count_W[i])
        {
            max_W = count_W[i];
        }
    }

    vector<size_t> max_W_index;
    for (size_t i = 0; i < W; ++i)
    {
        if (count_W[i] == max_W)
        {
            max_W_index.push_back(i);
        }
    }

    // (max_H_index[i], max_W_index[j]) の全組み合わせで、１つでも (h[k]-1, w[k]-1) と合わないものがあれば diff = 0

    size_t diff = 1;

    map<pair<size_t, size_t>, int> aaa;
    for (size_t m = 0; m < M; ++m)
    {
        pair<pair<size_t, size_t>, int> aa;
        aa.first.first = h[m] - 1;
        aa.first.second = w[m] - 1;
        aa.second = 1;

        aaa.insert(pair<pair<size_t, size_t>, int>(aa));
    }

    for (size_t i = 0; i < max_H_index.size(); ++i)
    {
        for (size_t j = 0; j < max_W_index.size(); ++j)
        {
            pair<size_t, size_t> aa;
            aa.first = max_H_index[i];
            aa.second = max_W_index[j];

            if (aaa.find(aa) == aaa.end())
            {
                diff = 0;
                break;
            }
        }

        if (diff == 0)
        {
            break;
        }
    }

    cout << (max_H + max_W - diff) << endl;


    return 0;
}


Measured memory_bytes: 36032
#include<stdio.h>
int main(){
    int a = 0,b = 0;
    int len = 0;
    int total = 0;
    scanf("%d%d",&a,&b);
    
    len = 2 * (a + b);
    total = a * b;
    printf("%d %d\n",total,len);
    return 0;
}


Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 5010;

char s[N * 2], ans[N], tmp[N];
int cur[N * 2];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k >> (s + 1);
  for (int i = 1; i <= n; ++i)
    s[i + n] = s[n - i + 1];
  char c = *min_element(s + 1, s + n + 1);
  int len = 0;
  for (int i = 1; i <= n * 2; ++i)
    if (s[i] == c)
      len = max(len, cur[i] = cur[i - 1] + 1);
  if (k >= 15 || (len << (k - 1)) >= n) {
    for (int rep = 0; rep < n; ++rep)
      putchar(c);
    putchar('\n');
    return 0;
  }
  for (int i = n + 1; i <= n * 2; ++i)
    if (cur[i] == len) {
      for (int j = 1; j <= (n - (len << (k - 1))); ++j)
        tmp[j] = s[i - len - j + 1];
      if (ans[1] == 0 || strcmp(ans + 1, tmp + 1) > 0)
        memcpy(ans + 1, tmp + 1, n - (len << (k - 1)));
    }
  for (int rep = 0; rep < len << (k - 1); ++rep)
    putchar(c);
  puts(ans + 1);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
n,x,m=map(int,input().split())
a=set()
b=[x]
for i in range(m):
  x=pow(x,2,m)
  if x in a:break
  a.add(x)
  b+=[x]
j=b.index(x)
n-=j
c=b[j:]
ans=sum(b[:j])+sum(c)*(n//len(c))+sum(c[:n%len(c)])
print(ans)

Measured memory_bytes: 77736
#include"iostream"
#include"vector"
using namespace std;
class branch
{
public:
  int key;
  branch *p;
  branch *left,*right;
  branch(){}
  branch(int key,branch *p)
  {
    this->key=key;
    this->p=p;
    this->left=NULL;
    this->right=NULL;
  }
};
branch *tree;
void insert(int z)
{
  branch *buf;
  branch *y=NULL;
  branch *x=tree;
  while(x!=NULL)
    {
      y=x;
      if(z<x->key)
        {
          x=x->left;
        }
      else
        {
          x=x->right;
        }
    }
  buf=new branch(z,y);
  if(y==NULL)tree=buf;
  else if(buf->key<y->key)y->left=buf;
  else y->right=buf;
}
int preParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  cout<<" "<<p->key;
  preParse(p->left);
  preParse(p->right);
}
int inParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  inParse(p->left);
  cout<<" "<<p->key;
  inParse(p->right);
}
int postParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  postParse(p->left);
  postParse(p->right);
  cout<<" "<<p->key;
}
int main()
{
  tree=NULL;
  int m;
  char cmd[20];
  cin>>m;
  for(int i=0;i<m;i++)
    {
      cin>>cmd;
      if(cmd[0]=='i')
        {
          int n;
          cin>>n;
          insert(n);
        }
      else if(cmd[0]=='p')
        {
          inParse(tree);
          cout<<endl;
          preParse(tree);
          cout<<endl;
        }
    }
  return 0;
}


Measured memory_bytes: 26444
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1, len(L)):
            if L[i] == L[j]:
                continue
            elif L[j] == L[k]:
                continue
            elif L[k] == L[i]:
                continue
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                ans += 1
print(ans)

Measured memory_bytes: 9208
#include <stdio.h>

int main(){
	int list[100]={0};
	int input;
	int max_times;
	int i, n;

	for(n=0; ~scanf("%d", &input); n++ ){
		list[input]++;
	}
	for( i=0, max_times=list[0]; i<n; i++ ){
		if( list[i] > max_times )
			max_times = list[i];
	}
	for( i=0; i<n; i++ ){
		if( list[i] == max_times )
			printf("%d\n", i);
	}
	return 0;
}
		

Measured memory_bytes: 596
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    s = IS()
    k = II()
    subs = []
    n = len(s)
    for i in range(k):
        for j in range(n-i):
            subs.append(s[j:j+(i+1)])
    subs = sorted(list(set(subs)))
    print(subs[k-1])

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  int n;cin >> n;
  vector <int> graph[n + 1];
  for(int i = 2;i <= n;i++){
    int p;cin >> p;
    graph[p].push_back(i);
  }
  for(int i = 1;i <= n;i++){
    cout << graph[i].size() << endl;
  }
}

Measured memory_bytes: 14568
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(long i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<long>>;
Graph G;
vector<long> dist;
//vector<bool> seen;

void dfs(long c, long d = 0, long p = -1) {
    dist.at(c) = d;
    for (auto nc : G[c]) {
        if (dist.at(nc) != -1) continue;

        dfs(nc, d+1, c);
    }
}

int main()
{
    long n;
    cin >> n;
    G = Graph(n);
    rep(i, n) {
        long a;
        cin >> a;
        a--;
        G[i].push_back(a);
    }

    dist = vector<long>(n, -1);
    //seen = vector<bool>(n, false);

    dfs(0);
    
    cout << dist.at(1) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll dp[2005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dp[0] = 1;
    for(ll i = 1; i <= 2000; i++) {
        for(ll j = 0; j + 3 <= i; j++) {
            dp[i] += dp[j];
        }
        dp[i] %= mod;
    }
    ll S;
    cin >> S;
    cout << dp[S] << endl;
    return 0;
}


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

// int addScore(int top, int add, vector <long long> &score,
//             vector <vector <int>> &tops){ //頂点, スコア
//     // cout << "CalledDone" << endl;
//     score[top] += add;
//     if (!tops[top].empty()){
//         for (int miki = 0; miki < tops[top].size(); miki++){
//             // cout << "Done4" << endl;
//             // cout << tops[top][miki] << endl;
//             // cout << add << endl;
//             addScore(tops[top][miki], add, score, tops);
//         }
//     }
//     return 0;
// }

int addScore(int top, /*int add,*/ vector <long long> &count,
             vector <vector <int>> &tree){
        for (auto yukiho : tree[top]){
            count[yukiho] += count[top];
            addScore(yukiho, count, tree);
        }
    }

int main(){
    int n, q;
    cin >> n >> q;
    // cout << n << endl;
    // cout << q << endl;
    // vector <int> a(n), b(n);
    // for (int tsumugi = 0; tsumugi < n; tsumugi++){
    //     cin >> a[tsumugi] >> b[tsumugi];
    // }
    vector <vector <int>> tree(n + 1, vector <int>(0));
    for (int kaede = 0; kaede < n - 1; kaede++){
        int temp1, temp2;
        cin >> temp1 >> temp2;
        tree[temp1].push_back(temp2);
        // cout << "Done1" << endl;
    }
    // vector <int> p(q), x(q);
    // for (int matsuri = 0; matsuri < q; matsuri++){
    //     cin >> p[matsuri] >> x[matsuri];
    //     // cout << "Done2" << endl;
    // }
    // unordered_map <int, int> work;
    // vector <int> work(n + 1);
    // for (int mizuki = 0; mizuki < q; mizuki++){
    //     int tp, tx;
    //     cin >> tp >> tx;
    //     work[tp] += tx;
    // }

    vector <long long> count(n + 1, 0);
    for (int shiho = 0; shiho < q; shiho++){
        int tp, tx;
        cin >> tp >> tx;
        count[tp] += tx;
    }

    // for (int kaori = 1; kaori <= n; kaori++){
    //     // cout << "Done3" << endl;
    //     // cout << p[kaori] << endl;
    //     // cout << x[kaori] << endl;
    //     // cout << kaori << endl;
    //     // cout << work[kaori] << endl;
    //     // addScore(p[kaori], x[kaori], count, tree);
    //     if (work[kaori] == 0) continue;
    //     addScore(kaori, work[kaori], count, tree);
    //     // cout << "End!! Next!!" << endl;
    // }

    addScore(1, count, tree);

    for (int reika = 1; reika <= n; reika++){
        cout << count[reika] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

last = [0] * 26
for di in range(d):
    minus = [c[i] * (di + 1 - last[i]) for i in range(26)]
    cnt = [s[di][i] + minus[i]  for i in range(26)]
    ti = cnt.index(max(cnt))
    last[ti] = di + 1
    print(ti + 1)


Measured memory_bytes: 74060
#include <iostream>                                             
using namespace std;                                            
                                                                
bool isPrime(int a) {                                           
  if (a==2) {                                                   
    return true;                                                
  }                                                             
  if (a<2 || a%2==0) {                                          
    return false;                                               
  }                                                             
  for (int i=3; i*i<=a; i+=2) {                                 
    if (a%i==0) {                                               
      return false;                                             
    }                                                           
  }                                                             
  return true;                                                  
}                                                               
                                                                
int main() {                                                    
  int n;                                                        
  cin >> n;                                                     
  int ans = 0;                                                  
  while (n--) {                                                 
    int x;                                                      
    cin >> x;                                                   
    if (isPrime(x)) {                                           
      ans++;                                                    
    }                                                           
  }                                                             
  cout << ans << endl;                                          
  return 0;                                                     
}                                                               
                                                                
          

Measured memory_bytes: 3100
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e5+9;
int n;
int a,b;
vector<int> v[sz];
bool visited[sz];
ll s[sz];
ll m=1e9+7;
ll add(ll a,ll b){return (a%m+b%m)%m;}
ll mul(ll a,ll b){return (a%m*b%m)%m;}
ll f[sz];
ll dp[sz];

ll modpow(ll b,ll p){
	if(!b) return 0;
	if(!p) return 1;
	ll u=modpow(b,p>>1);
	u=mul(u,u);
	if(p&1) u=mul(u,b);
	return u;
}

ll c(int N,int K){
	ll num=f[N];
	ll den=mul(f[K],f[N-K]);
	den=modpow(den,m-2);
	return mul(num,den);
}

void dfs(int i,int p=1){
	visited[i]=1;
	dp[i]=1;
	for(auto u:v[i]){
		if(u==p||visited[u]) continue;
		dfs(u,i);
		s[i]+=s[u];
		dp[i]=mul(dp[i],dp[u]);
		dp[i]=mul(dp[i],c(s[i],s[u]));
	}
	s[i]++;
}

void solve(int i,int p=1){
	visited[i]=1;
	ll dpi;
	for(int u:v[i]){
		if(u==p||visited[u]) continue;
		dpi=mul(dp[i],modpow(dp[u],m-2));
		s[i]--;
		dpi=mul(dpi,modpow(c(s[i],s[u]),m-2));
		s[i]-=s[u];
		s[i]++;
		s[u]+=s[i]-1;
		dp[u]=mul(dp[u],dpi);
		dp[u]=mul(dp[u],c(s[u],s[i]));
		s[u]++;
		solve(u,i);
		s[u]--;
		s[u]-=s[i];
		s[u]++;
		s[i]+=s[u];
	}
}

int main(){
	scanf("%d",&n);
	f[0]=f[1]=1;
	for(int i=2;i<=n;i++) f[i]=mul(i,f[i-1]);
	for(int i=0;i<n-1;i++){
		scanf("%d %d",&a,&b);
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1);
	memset(visited,0,sizeof(visited));
	solve(1);
	for(int i=1;i<=n;i++) printf("%lld\n",dp[i]);
	// for(int i=1;i<=n;i++) printf("%d\n",s[i]);
    return 0;
}

Measured memory_bytes: 18804
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if i%2==0 and a[i]%2==1:
        ans+=1
print(ans)

Measured memory_bytes: 68976
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template <class T>
class Lazy_Segment_Tree{
	private:
	int n;
	vector<T> date;
	void Set_Lazy(int k,T x){
		date[k]=min(date[k],x);
	}
	void Push(int k){
		Set_Lazy(k*2+1,date[k]);
		Set_Lazy(k*2+2,date[k]);
		date[k]=inf;
	}
	void Updatef(int a,int b,int k,int l,int r,T x){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			Set_Lazy(k,x);
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Updatef(a,b,k*2+1,l,m,x);
		Updatef(a,b,k*2+2,m,r,x);
	}
	public:
	Lazy_Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vector<T>(2*n-1,inf);
	}
	void Update(int a,int b,T x){
		Updatef(a,b,0,0,n,x);
	}
	T Open(int k){
		k+=n-1;
		T res=date[k];
		while(k>0){
			k=(k-1)/2;
			res=min(res,date[k]);
		}
		return res;
	}
};

class Segment_Tree{
	private:
	int n;
	vi date;
	int Rec(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return inf;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return min(Rec(a,b,k*2+1,l,m),Rec(a,b,k*2+2,m,r));
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1,inf);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]=min(date[k],x);
		while(k>0){
			k=(k-1)/2;
			date[k]=min(date[k*2+1],date[k*2+2]);
		}
	}
	int Query(int a,int b){
		return Rec(a,b,0,0,n);
	}
};

int n,q;
vi a,s;
vvi b;

int f(int l,int r,int t){
	int res=s[r]-s[l];
	if(!t) res=r-l-res;
	return res;
}

int main(){
	cin>>n;
	a=vi(n);
	s=vi(n+1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) s[i]+=s[i-1]+a[i-1];
	cin>>q;
	b=vvi(n+1);
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		b[r].push_back(l-1);
	}
	Lazy_Segment_Tree<int> lst(n);
	Segment_Tree st(n);
	int res=f(0,n,1),A0=0,A1=0;
	for(int r=1;r<=n;r++){
		if(a[r-1]) A1++;
		else A0++;
		for(auto l:b[r]){
			int t=f(0,l,1)+f(l,r,0);
			t=min(t,st.Query(0,l)+A1-f(l,r,1)+f(l,r,0));
			t=min(t,lst.Open(l)+A0);
			st.Update(r-1,t-A1);
			lst.Update(l,r,t-A0);
			res=min(res,t+f(r,n,1));
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 15488
// AtCoder Begginer Contest 136 A - Transfer
// https://atcoder.jp/contests/abc136/tasks/abc136_a

#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint A, B, C;
	cin >> A >> B >> C;
	
	uint room = A - B;
	int rest = C - room;
	
	if (rest < 0) {
		cout << 0 << endl;
	} else {
		cout << rest << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=200200,INF=1000010000;
int n,u,v,ans,rt,fa[N],c[N],du[N],f[N][2],mi[N],se[N],su[N],vi[N];
char s[N];
vector<int>ad[N],Ad[N];
queue<int>q;
void add(int u,int v){ad[u].push_back(v);du[v]++;}
void Add(int u,int v){Ad[u].push_back(v);du[v]++;}
int F(int x){return x?f[x][1]-f[x][0]:INF;}
void dfs1(int u){
	for(int v:Ad[u])if(v!=fa[u]){
		fa[v]=u,dfs1(v);su[u]+=f[v][0];
		if(F(v)<F(mi[u])) se[u]=mi[u],mi[u]=v;
		else if(F(v)<F(se[u])) se[u]=v;
	}
	f[u][0]=su[u]+!(c[u]^du[u]&1)+2;
	f[u][1]=su[u]+(du[u]>1?F(mi[u]):0)+!(c[u]^max(1,du[u]-1)&1)+1;
	//cout<<u<<':'<<f[u][0]<<' '<<f[u][1]<<'\n';
}
void dfs2(int u,int F0,int F1){
	int G0=F0+su[u]+!(c[u]^du[u]&1^1);
	int G1=F0+su[u]+min(F(mi[u]),F1-F0)+!(c[u]^max(1,du[u])&1);
	//cout<<u<<':'<<G0<<' '<<G1<<'\n';
	ans=min(ans,min(G0,G1)+1);
	for(int v:Ad[u])if(v!=fa[u]){
		int tmp=F(v==mi[u]?se[u]:mi[u]);
		tmp=min(tmp,F1-F0);
		G0=F0+su[u]-f[v][0]+!(c[u]^du[u]&1)+2;
		G1=F0+su[u]-f[v][0]+tmp+!(c[u]^max(1,du[u]-1)&1)+1;
		dfs2(v,G0,G1);
	}
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	scanf("%s",s+1);
	FOR(i,1,n) c[i]=s[i]=='B',rt|=!c[i];
	if(!rt) return puts("0"),0;
	FOR(i,1,n)if(c[i] && du[i]==1) q.push(i),vi[i]=1;
	while(q.size()){
		int u=q.front();q.pop();
		for(int v:ad[u])if(!vi[v] && c[v] && --du[v]==1)
			q.push(v),vi[v]=1; 
	}
	FOR(i,1,n) du[i]=0;
	FOR(i,1,n)if(!vi[i]){
		rt=i;
		for(int v:ad[i])if(!vi[v]) Add(i,v);
	}
	ans=INF;dfs1(rt);dfs2(rt,0,0);
	cout<<ans<<'\n';
}

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

typedef pair<int,int> P;

int main(){
    long double a,b,h,m,x1,x2,y1,y2,pi = 3.1415926535897932384626433832795028841971693993751058209749;
    cin >> a >> b >> h >> m;
    if (h > 12) h -= 12.0;
    long double jikaku = (60*h+m)*pi / 360;
    long double hunnkaku = m*pi / 30;
    x1 = cos(jikaku); x1 *= a;
    x2 = cos(hunnkaku); x2 *= b;
    y1 = sin(jikaku); y1 *= a;
    y2 = sin(hunnkaku); y2 *= b;
    long double res2 = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
    cout << fixed << setprecision(15) << sqrt(res2) << "\n";
}

Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    pair<ll, ll> war[m];
    rep(i, 0, m){
        cin >> war[i].second >> war[i].first;
    }

    sort(war, war + m);

    ll rem = -1;
    ll count = 0;
    rep(i, 0, m){
        if(war[i].second > rem){
            rem = war[i].first - 1;
            count++;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
import bisect

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

ans = 0
for b in B:
    ans += bisect.bisect_left(A,b) * (n - bisect.bisect_right(C,b))

print(ans)

Measured memory_bytes: 23240