akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
struct segtree
{
	#define lc now<<1
	#define rc now<<1|1
	int tag[MAXN*4];segtree(){memset(tag,63,sizeof(tag));}
	void modify(int now,int l,int r,int ql,int qr,int c)
	{
		if(ql>qr)return ;
		if(l==ql&&r==qr){tag[now]=c;return ;}int mid=(l+r)/2;
		if(qr<=mid)modify(lc,l,mid,ql,qr,c);
		else if(mid+1<=ql)modify(rc,mid+1,r,ql,qr,c);
		else modify(lc,l,mid,ql,mid,c),modify(rc,mid+1,r,mid+1,qr,c);
	}
	int query(int now,int l,int r,int p)
	{
		if(l==r)return tag[now];int mid=(l+r)/2;
		if(p<=mid)return min(tag[now],query(lc,l,mid,p));
		else return min(tag[now],query(rc,mid+1,r,p));
	}
}seg;
int n,l[MAXN],r[MAXN],ls[MAXN],lslen;
int a[MAXN],b[MAXN],K;
LL f[MAXN],sum;
int main()
{
//	freopen("a.in","r",stdin);
	n=read();K=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();b[i]=read();
		if(b[i]==1&&2*a[i]>K)return pr2(-1),0;
		sum+=a[i];a[i]=(a[i]+a[i-1])%K;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==1)l[i]=2*(K-a[i-1]),r[i]=2*(K-a[i]);
		else l[i]=0,r[i]=K-1;
		ls[++lslen]=(l[i]%=K);ls[++lslen]=(r[i]%=K);
	}sort(ls+1,ls+1+lslen);lslen=unique(ls+1,ls+1+lslen)-(ls+1);
	for(int i=1;i<=n;i++)
	{
		l[i]=lower_bound(ls+1,ls+1+lslen,l[i])-ls;
		r[i]=lower_bound(ls+1,ls+1+lslen,r[i])-ls;
	}
	for(int i=n;i>=1;i--)
	{
//		if(l[i]==0||r[i]==0)puts("no");
		int o=seg.query(1,1,lslen,l[i]);
		if(o<=n)f[i]=f[o]+ls[l[o]]-ls[l[i]]+(l[o]>l[i]?0:K);
		if(l[i]<=r[i])seg.modify(1,1,lslen,r[i]+1,lslen,i),seg.modify(1,1,lslen,1,l[i]-1,i);
		else seg.modify(1,1,lslen,r[i]+1,l[i]-1,i);
	}LL ans=(1LL<<63-1);
	for(int i=1;i<=lslen;i++)
	{
		int o=seg.query(1,1,lslen,i);LL t=0;
		if(o<=n)t=f[o]+ls[l[o]]-ls[i]+(l[o]>i?0:K);
		ans=min(ans,t);
	}pr2(ans+2*sum);
	return 0;
}


Measured memory_bytes: 7936
n,k = map(int, input().split())
for d in range(1,k+1):
    if (d!=1)&((n-k)<d-1):
        print(0)
        continue
    p=1
    for i in range(k-d+1,k):
        p*=i
    for j in range(1,d):
        p//=j
    r=1
    for i in range(n-k-d+2,n-k+2):
        r*=i
    for j in range(1,d+1):
        r//=j
    ans = p*r
    print(ans%(10**9+7))

Measured memory_bytes: 3316
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

ans = -1
N,M = I()
if N == 1 and M == 0:
    print(0)
    exit()
L = [set() for _ in range(N)]
for _ in range(M):
    s,c = I()
    if s == 1 and c == 0 and N > 1:
        print(-1)
        exit()
    L[s-1].add(c)
for i in range(N):
    if len(L[i]) == 0:
        if i == 0:
            L[i] = "1"
        else:
            L[i] = "0"
    elif len(L[i]) == 1:
        L[i] = str(list(L[i])[0])
    else:
        print(-1)
        exit()
print("".join(L))


Measured memory_bytes: 5548
n = int(input())
a = list(int(input()) for i in range(n))
M = max(a)

if a.count(M) > 1:
  for i in range(n):
    print(M)
elif n == 1:
  print(M)
else:
  M2 = sorted(set(a))[-2]
  for i in range(n):
    if a[i] == M:
      print(M2)
    else:
      print(M)


Measured memory_bytes: 17176
#include <stdio.h>
int main()
{
	int n, i, j, k, w, x, y;
	scanf("%d %d", &n, &x);

	do {
		w = 0;
		for (i = 1; i <= n-2; i++)
			for (j = i+1; j <= n-1; j++)
				for (k = j+1; k <= n; k++){
					y = i + j + k;
		            if (y == x) w+=1;}
		printf("%d\n", w);

		scanf("%d %d", &n, &x);
	} while (n!=0 && x!=0);

	return 0;
}

Measured memory_bytes: 2720
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    vector<long long> n;
    n.push_back(a);
    n.push_back(b);
    n.push_back(c);
    sort(n.begin(), n.end());
    if (n[0] + n[1] == n[2]) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#else
	#define DEBUG(x) true
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef pair<int,int> P;
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n,m;
	cin >> n >> m;
	vector<bool> po(n,false);
	//vector<bool> ro(n,false);
	vector<int> num(n,1);
	//ro[0] = true;
	po[0] = true;
	REP(i,m){
		int x,y;
		cin >> x >> y;
		x--; y--;
		num[x]--;
		num[y]++;
		if(po[x]){
			po[y] = true;
			// if(ro[x]){
			// 	ro[x] = false;
			// 	po[x] = false;
			// }
			if(num[x] == 0){
				po[x] = false;
			}
		}
	}
	int ans = 0;
	REP(i,n) ans += po[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A1(N);
  vector<int> A2(N);
  vector<int> A1sum(N+1);
  vector<int> A2sum(N+1);
  A1sum.at(0)=0;
  A2sum.at(0)=0;
  int sumx=0;
  int sumy=0;
  for(int i=0;i<N;i++){
    cin >> A1.at(i);
    sumx+=A1.at(i);
    A1sum.at(i+1)=sumx;
  }
  for(int i=0;i<N;i++){
    cin >> A2.at(i);
    sumy+=A2.at(i);
    A2sum.at(i+1)=sumy;
  }

  int ans=0;
  for(int i=1;i<N+1;i++){
    int x=A1sum.at(i)+A2sum.at(N)-A2sum.at(i-1);
    ans=max(ans,x);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

bool solve(const ll x, const vector<ll>& dx){
    if(dx.size() == 0){ return x == 0; }
    const ll total = accumulate(dx.begin(), dx.end(), 0);
    if(abs(x) > total){ return false; }
    vector<bool> ok(2 * total + 1, false);
    ok.at(total) = true;
    for(ll d : dx){
        vector<bool> nxt(2 * total + 1, false);
        for(int i = 0; i < ok.size(); ++i){
            if(i >= d){
                nxt.at(i) = ok.at(i - d);
            }
            if(i + d < ok.size()){
                nxt.at(i) = nxt.at(i) || ok.at(i + d);
            }
        }
        ok = nxt;
    }
    return ok.at(x + total);
}

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

    int pos = 0;
    for(; pos < s.size() && s.at(pos) != 'T'; ++pos){
        x--;
    }

    vector<ll> dx, dy;
    bool is_x = true;
    ll numf = 0;
    for(; pos < s.size(); ++pos){
        if(s.at(pos) == 'T'){
            if(numf > 0){
                if(is_x){
                    dx.push_back(numf);
                }else{
                    dy.push_back(numf);
                }
            }
            numf = 0;
            is_x = !is_x;
        }else{
            numf++;
        }
    }
    if(numf > 0){
        if(is_x){
            dx.push_back(numf);
        }else{
            dy.push_back(numf);
        }
    }

    if(solve(x, dx) && solve(y, dy)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<int> H(N);
    for(int i=0;i<N;i++)cin>>H[i];
    int count=0;
    int res=0;
    for(int i=0;i<N-1;i++){
        if(H[i]>=H[i+1]){
            count+=1;
        }
        else{
            res=max(res,count);
            count=0;
        }
    }
    res=max(res,count);
    cout<<res<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        char[] d = s.toCharArray();
        int[] c = new int[26];
        for (char x : d) {
            c[x - 'a'] += 1;
        }
        boolean answer = true;
        for (int i = 0; i < 26; i++) {
            if (c[i] % 2 != 0) {
                answer = false;
                break;
            }
        }
        System.out.println(answer ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int fact[200010];
int H, W, A, B;

ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    // printf("n = %lld, n-r = %lld, r = %lld\n", n, n-r, r);
    ll a = fact[n], b = fact[n-r], c = fact[r];
    ll ret = (a * mod_pow(b, MOD-2)) % MOD;
    (ret *= mod_pow(c, MOD-2)) %= MOD;
    return ret;
}

signed main() {
    cin >> H >> W >> A >> B;
    fact[0] = 1; rep(i,1,200010) fact[i] = (fact[i-1] * i) % MOD;

    int ans = 0;
    repq(i,B+1,W) {
        ll ra = combination_mod((H-A-1) + (i-1), (H-A-1), MOD);
        ll rb = combination_mod((A-1) + (W-i), (A-1), MOD);
        // printf("H-A = %lld, i = %lld, ra = %lld, rb = %lld\n", H-A, i, ra, rb);
        (ans += (ra * rb) % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

const long long INF = 9223372036854775807;

vector<pair<long long,long long>> SearchPair(long long n)
{
    vector<pair<long long,long long>> vecRes;
    for(long long i=1; i*i<=n; i++){
        if(n%i != 0)
            continue;

        vecRes.emplace_back();
        vecRes.back().first = i;
        vecRes.back().second = n/i;
    }

    return vecRes;
}

long long CalcDist(pair<long long,long long> strt, pair<long long,long long> fin)
{
    long long x, y, res;
    x = abs(fin.first - strt.first);
    y = abs(fin.second - strt.second);
    res = x + y;

    return res;
}

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

    vector<pair<long long,long long>> vecPair;
    vecPair = SearchPair(n);

    long long res = INF;
    pair<long long,long long> StartPos = make_pair(1, 1);
    for(long long i=0; i<vecPair.size(); i++){
        long long dist = CalcDist(StartPos, vecPair[i]);
        if(dist<res)
            res = dist;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a%2==1 && b%2==1) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23252
import sys
sys.setrecursionlimit(500000)
N = int(input())
E = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split(' '))
    E[a].append((b, i))
    E[b].append((a, i))
K = max(len(e) for e in E)
print(K)
ans = [-1] * (N - 1)


def dfs(v=1, p=0, p_col=-1):
    col = 1
    for u, idx in E[v]:
        if u != p:
            if col == p_col:
                col += 1
            ans[idx] = col
            dfs(u, v, col)
            col += 1


dfs()
for i in ans:
    print(i)


Measured memory_bytes: 85652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
struct edge {ll to,cost;};
#define VMAX 200000+10
    ll d[VMAX];
    ll N,M,L[VMAX],R[VMAX],D[VMAX];
    ll ans=0;
    std::vector<edge> G[VMAX];
    bool dijkstra(int s){
        //頂点数N 辺の数 E
        std::priority_queue<P,vector<P>,std::greater<P>> que;
        if(d[s]==INF) d[s]=0;
        que.push(P(d[s],s));
        while(!que.empty()){

            P p =que.top();que.pop();
            int v=p.second;
            for(int i=0;i<(signed)G[v].size();i++){
                edge e =G[v][i];
                    if(d[e.to]==INF)
{
                    d[e.to]=d[v]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
              else if(d[e.to]!=d[v]+e.cost){ 
                return false;
                }
              }
        }
        return true;
    }

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,M){
		cin>>L[i]>>R[i]>>D[i];
			G[L[i]].push_back({R[i],D[i]});
G[R[i]].push_back({L[i],-D[i]});
	}
    bool f=true;
    std::fill(d,d+N + 1,INF);
    EREP(i,N){
        if(!dijkstra(i))f=false;
    }
    cout<<(f?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 21744
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)
Q = sorted(Q, reverse=True)
R = sorted(R, reverse=True)

PQ_eat = P[:x] + Q[:y]
PQ_eat = sorted(PQ_eat)

r_now = 0
ans = sum(PQ_eat)
# print(PQ_eat)
# print(R)
for i in range(len(PQ_eat)):
    if r_now >= len(R):
        break
    if PQ_eat[i] < R[r_now]:
        ans -= PQ_eat[i]
        ans += R[r_now]
        r_now += 1
    else:
        break
print(ans)

Measured memory_bytes: 109864
#ifdef DEBUG
#include "../utils.cpp"
#endif
#include <bits/stdc++.h>
/*
Problem


Category
DP
 
URL:


考察:



Date: 2020/06/20
// 1926
// 1935
// 1950

*/
 

using namespace std;
using ll = int64_t;
#define int int64_t
#define INF 10e9

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int N;
vector<int> W;
vector<vector<int>> dp;
vector<vector<int>> memo;

/* ======================== */


void getInput() {
    cin>>N;
    if (N==0) {
        exit(0);
    }

    W = vector<int>(N);
    memo = vector<vector<int>>(N, vector<int>(N, INF));
    for(int i=0; i<N; ++i) {
        cin>>W[i];
    }
}

int getMemo(int s, int t) {
    assert(s >=0 and t>= 0 and s<N and t<N);
    if (memo[s][t] != INF) {
        return memo[s][t];
    } else {
        if (t - s == 0) {
            memo[s][t] = 1;
        } else if (t-s == 1) {
            if (abs(W[t] - W[s]) <= 1) {
                memo[s][t] = 0;    
            } else {
                memo[s][t] = 2;
            }
        } else if (t - s >= 2) {
            int score = getMemo(s, t-1) + 1;

            for(int i=t-1; i >= s; --i) {
                if (abs(W[t] - W[i]) > 1) continue;

                if (t-i==1 or getMemo(i+1, t-1) == 0) {
                    if (i-1 < s) {
                        score = 0;
                    }
                    else {
                        score = min(score, getMemo(s, i-1));
                    }
                }
            }
            memo[s][t] = score;
        }
    }
    return memo[s][t];
}
 

void solve() {
    cout<<N - getMemo(0, N-1)<<endl;
}
 
 
signed main(){
    while(1) {
        getInput();
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    long long x[n],y[n];
    vector<pair<long long,long long>>p(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        p[i]={x[i],y[i]};
    }
    sort(x,x+n);
    sort(y,y+n);
    long long m=5000000000000000000;
    for(int l=0;l<n-1;l++){
        for(int r=l+1;r<n;r++){
            for(int d=0;d<n-1;d++){
                for(int u=d+1;u<n;u++){
                    int point=0;
                    for(int i=0;i<n;i++)if(x[l]<=p[i].first && p[i].first<=x[r] && y[d]<=p[i].second && p[i].second<=y[u])point++;
                    if(point>=k)m=min(m,(x[r]-x[l])*(y[u]-y[d]));
                }
            }
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int H, N;
  cin >> H >> N;
  int A[100010];
  int total = 0;
  for(int i=0; i < N; ++i){
    cin >> A[i];
    total += A[i];
  }
  
  if(total >= H){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
my @data =<STDIN>;
my @num = split(/ /, $data[0]);
my $student_num = $num[0];
my @student_x;
my @student_y;
my $checkpoint_num = $num[1];
my @checkpint_x;
my @checkpint_y;
for(my $i=0;$i < $student_num; $i++) {
	@tmp = split(/ /, $data[1+$i]);
	push(@student_x, $tmp[0]);
	chomp $tmp[1];
	push(@student_y, $tmp[1]);
}
for(my $j=0;$j < $checkpoint_num; $j++) {
	@tmp = split(/ /, $data[$j+$student_num+1]);
	push(@checkpint_x, $tmp[0]);
	chomp $tmp[1];
	push(@checkpint_y, $tmp[1]);
}
for(my $i;$i < $student_num; $i++) {
	my $selectCheckpoint = 1;
	my $max= calcDistance($student_x[$i], $student_y[$i], $checkpint_x[0], $checkpint_y[0]);
	for($j=1;$j < $checkpoint_num; $j++) {
		my $calcResult = calcDistance($student_x[$i], $student_y[$i], $checkpint_x[$j], $checkpint_y[$j]);

		if($max > $calcResult) {
			$max = $calcResult;
			$selectCheckpoint = $j+1;
		}
	}
	print $selectCheckpoint,"\n";
}

sub calcDistance {
	($x1, $y1, $x2, $y2) = @_;
	return abs($x1-$x2) + abs($y1-$y2);
}


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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if ( a > c && c>b){
        cc("Yes");
    }else if( a<c&&c<b){
        cc("Yes");
    }else{
        cc("No");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	string s; cin >> s;
	int sum = 0;
	for(char ch : s) {
	    sum += (ch - '0');
	}
	cout << (sum % 9 == 0? "Yes" : "No");
}


Measured memory_bytes: 3780
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		System.out.println(solve(s));
		in.close();
	}

	private static String solve(String s) {
		char a = s.charAt(0);
		char b = s.charAt(1);
		if (a == b)
			if (s.charAt(2) == s.charAt(3) && s.charAt(2) != a)
				return "Yes";
			else
				return "No";
		else if (s.charAt(2) == a && s.charAt(3) == b)
			return "Yes";
		else if (s.charAt(2) == b && s.charAt(3) == a)
			return "Yes";
		else
			return "No";
	}
}


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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

using P = pair<int, int>;
constexpr int INF = (1 << 28);

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    SegmentTree<P> segtree(n + 1, [](P p1, P p2) { return min(p1, p2); }, P(INF, -1));
    segtree.update(n, P(0, n));

    vector<int> next(n, -1);
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '1') continue;

        auto p = segtree.query(i + 1, min(i + m + 1, n + 1));
        segtree.update(i, P(p.first + 1, i));
        next[i] = p.second;
    }
    if (segtree[0].first > n) {
        cout << -1 << endl;
        return 0;
    }
    int i = 0;
    while (i != n) {
        cout << next[i] - i << " ";
        i = next[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <set>
#define INF 1000000001
#define N 5003
using namespace std;
typedef pair<int,int> P;
int Bynary_Search(int,int,int,int);
int n,m,xsz,ysz,d[N][N],ans;
int pxy[2][N],x[N],y[N],x1,y1,x2,y2;
set<int> sx,sy;
P in[N];

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>x[i]>>y[i],sx.insert(x[i]),sy.insert(y[i]);
  int k=1;
  for(set<int>::iterator it=sx.begin();it!=sx.end();it++,k++) pxy[0][k]=*it;
  k=1;
  for(set<int>::iterator it=sy.begin();it!=sy.end();it++,k++) pxy[1][k]=*it;
  xsz=sx.size();
  ysz=sy.size();
  pxy[0][0]=pxy[1][0]=-INF;
  pxy[0][xsz+1]=pxy[1][ysz+1]=INF;
  for(int i=0;i<n;i++){
    int rx=Bynary_Search(x[i],0,xsz,0);
    int ry=Bynary_Search(y[i],1,ysz,0);
    d[ry][rx]++;
  }
  for(int i=0;i<ysz+1;i++)
    for(int j=1;j<xsz+1;j++) d[i][j]=d[i][j]+d[i][j-1];
  for(int i=0;i<xsz+1;i++)
    for(int j=1;j<ysz+1;j++) d[j][i]=d[j][i]+d[j-1][i];
  for(int i=0;i<m;i++){
    cin>>x1>>y1>>x2>>y2;
    int xb=Bynary_Search(x1,0,xsz,0),yb=Bynary_Search(y1,1,ysz,0);
    int xe=Bynary_Search(x2,0,xsz,1),ye=Bynary_Search(y2,1,ysz,1);
    ans=d[ye][xe];
    if(yb) ans-=d[yb-1][xe];
    if(xb) ans-=d[ye][xb-1];
    if(xb&&yb) ans+=d[yb-1][xb-1];
    if(xb>xe||yb>ye) ans=0;
    cout<<ans<<endl;
  }
  return 0;
}

int Bynary_Search(int s,int index,int sz,int c){
  int l=0,r=sz+2,m;
  while(l+1<r){
    m=(l+r)/2;
    if(s>=pxy[index][m]) l=m;
    else r=m;
  }
  if(c) return l;
  if(s==pxy[index][l]) return l;
  else return l+1;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s, tmp;
    cin >> s;

    // 処理
    int top, tail;
    top  = s.find('A');
    tail = s.rfind('Z');

    // 出力
    cout << tail - top + 1 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void) {
	int H, W;
	int n, i, j;
	while(n<1000000){
	scanf("%d %d",&H, &W);
	if(H == 0 && W == 0){
		break;
	}
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if(i==0 || i==H-1 || j==0 ||j==W-1){
					printf("#");
				}
				else{
				    printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2608
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    const int MAXV = (int)1e3;
    int N, W; cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<int>> dp(N + 1, vector<int>(N * MAXV + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) for (int sum_v = 0; sum_v <= N * MAXV; sum_v++) {
        chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        if (sum_v - v[i] >= 0) chmin(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i]);
    }
    int ans = 0;
    for (int val = 0; val <= N * MAXV; val++) if (dp[N][val] <= W) {
        chmax(ans, val);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 40192
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;
const int Max = 2e5;

int n, m, a, b, ans[Max + 5];
bool flag = 0;

struct Poi{
	int x;
	int y;
}tot1[Max + 5], tot2[Max + 5];

bool cmp1(Poi p, Poi q){
	return p.y < q.y;
}

bool cmp2(Poi p, Poi q){
	return p.x < q.x;
}

int main()
{
	scanf ("%d %d", &n, &m);
	int tot = 0;
	int cnt = 0;
	for (int i = 1; i <= m; i++){
		scanf ("%d %d", &a, &b);
		if (a == 1)	tot1[++tot].x = a, tot1[tot].y = b;
		if (b == n)	tot2[++cnt].x = a, tot2[cnt].y = b;
	}
	sort(tot1 + 1, tot1 + tot + 1, cmp1);
	sort(tot2 + 1, tot2 + cnt + 1, cmp2);
	int mid;
	for (int i = 1; i <= tot; i++){
		int l = 1, r = cnt;
		while (l <= r){
			int mid = (r + l) / 2;
			if (tot1[i].y == tot2[mid].x){
				flag = 1;
				break;
			}
			else if (tot1[i].y < tot2[mid].x)	r = mid - 1;
			else l = mid + 1;
		}
	}
	if (flag)	printf ("POSSIBLE\n");
	else printf ("IMPOSSIBLE\n");
}


Measured memory_bytes: 1792
// Problem : F - LCS
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define MM			1000000007
#define N			100005
#define pb 			push_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define Endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for(int i=begin;i<end;i++)
#define repr(i,begin,end) for(int i=end-1;i>=begin;i--)
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define re 			resize
 
 
 
signed main(void)
{ios
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		string s,t;
		cin>>s>>t;
		int n=sz(s),m=sz(t);
		int dp[n+1][m+1];
		memset(dp,0,sizeof(dp));
		rep(i,1,n+1)
		{
		    rep(j,1,m+1)
		    {
		        if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		    }
		}
		//cout<<dp[n][m];
		int ans=dp[n][m];
		string fin;
		for(int i=n;i>=1;i--)
		{
		    for(int j=m;j>=1;j--)
		    {
		        if(s[i-1]==t[j-1] and dp[i][j]==ans)
		        {
		            fin.pb(s[i-1]);
		            ans--;
		            break;   
		        }
		    }
		}
		reverse(all(fin));
		cout<<fin;
	}
}

Measured memory_bytes: 73960
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] over = new int[N];
    	for (int i = 0; i < N; i++) {
    		over[i] = sc.nextInt();
    	}
    	int[] under = new int[N];
    	for (int i = 0; i < N; i++) {
    		under[i] = sc.nextInt();
    	}
    	int max = 0;
    	for (int i = 0; i < N; i++) {
    		int candy = 0;
    		for (int j = 0; j < N; j++) {
    			if (j < i) {
    				candy += over[j];
    			} else if (j == i) {
    				candy += over[j];
    				candy += under[j];
    			} else {
    				candy += under[j];
    			}
    		}
    		if (max < candy) {
    			max = candy;
    		}
    	}
    	System.out.println(max);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    int a, b, cnt = 1;
    vector<int> v(n);
    rep(i, n) v[i] = i+1;
    do{
        bool fl_p = true;
        bool fl_q = true;
        rep(i, n) if(v[i] != p[i]) fl_p = false;
        rep(i, n) if(v[i] != q[i]) fl_q = false;
        if(fl_p) a = cnt;
        if(fl_q) b = cnt;
        cnt++;
    } while(next_permutation(all(v)));
    cout << abs(a - b) << endl;
}

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

using namespace std;

const int MAX_N = 1e2 + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N, W, w1, w, v;
	vector<int> pfxv[4] = {{(int)2e9}, {(int)2e9}, {(int)2e9}, {(int)2e9}};
	
	cin >> N >> W >> w1 >> v;
	pfxv[0].emplace_back(v);
	
	for (int i = 1; i < N; i++)
	{
		cin >> w >> v;
		pfxv[w - w1].emplace_back(v);
	}//for i
	
	for (int i = 0; i < 4; i++)
	{
		sort(pfxv[i].begin(), pfxv[i].end(), greater<int>());
		
		pfxv[i][0] = 0;
		for (int j = 1; j < (int)pfxv[i].size(); j++)
			pfxv[i][j] = pfxv[i][j - 1] + pfxv[i][j];
	}//for i
	
	int ans = 0;
	
	for (int i = 0; i < (int)pfxv[0].size(); i++)
	{
		for (int j = 0; j < (int)pfxv[1].size(); j++)
		{
			for (int k = 0; k < (int)pfxv[2].size(); k++)
			{
				for (int l = 0; l < (int)pfxv[3].size(); l++)
				{
					//w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l
					if ((long long)w1 * (i + j + k + l) + 1 * j + 2 * k + 3 * l > W)
						continue;
						
					ans = max(ans, pfxv[0][i] + pfxv[1][j] + pfxv[2][k] + pfxv[3][l]);
				}//for l
			}//for k
		}//for j
	}//for i
	
	cout << ans;
	
	return 0;
}//main


Measured memory_bytes: 256
#include <bits/stdc++.h>                                
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;

int n, h[100005];
int max_cur = 0;
                                                                                                                    
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	srand(time(0)); 
	#ifdef LOCAL
         	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif                              
        cin >> n;
        int cur = 0;
        for (int i = 0; i < n; i++) {
        	cin >> h[i];
        	if (i > 0 && h[i] <= h[i - 1]) {
        		cur++;
        		max_cur = max(cur, max_cur);
        	}
                else
                	cur = 0;
        }
        cout << max_cur;
        return 0;
}                

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





int main(){
	int N,M,C;
	cin>>N>>M>>C;
	int B[M];
	for(int i=0;i<M;i++){
		cin>>B[i];
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		int a = C;
		for(int j=0;j<M;j++){
			int x;
			cin>>x;
			a+=B[j]*x;
		}
		if(a>0){
			ans++;
		}
	}
	
	cout<<ans<<endl;
			
	
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
vector<pair<int, int>> v[15];
signed main(){
    cin >> N;
    rep(i, N){
        int A;
        cin >> A;
        rep(j, A){
            int x, y;
            cin >> x >> y;
            x--;
            v[i].pb({ x,y });
        }
    }
    int ans = 0;
    rep(i, 1<<N){
        bool ok = true;
        rep(j, N){
            rep(k, v[j].size()){
                if((i>>j)&1){ // i は正直者
                    if(((i>>v[j][k].first)&1) != v[j][k].second) ok = false;
                }
            }
        }
        if(ok){
            int tmp = 0;
            rep(j, N) tmp += (i>>j)&1;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     long double n, m, totalvotes = 0;
	cin >> n >> m;
	vector<long double> arr(n);
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
		totalvotes += arr[i];
	}
	long double ans = 0;
	for(int i=0;i<n;i++)
	{
		if (arr[i] >= totalvotes / (4 * m))
		    ans++;

	}

	if (ans<m)
		cout << "No";
	else
		cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] s = in.nextLine().split("");
        String[] cs = "CODEFESTIVAL2016".split("");
        int counter = 0;
        for (int x = 0; x < 16; x++){
        	if (s[x].equals(cs[x])){
        		continue;
        	}
        	counter++;
        }
        System.out.println(counter);
        
        in.close();
    }
}


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

int main() {

    int n;
    while (cin >> n and n) {

        // int sum=0, prev=0, ans=0;
        // rep(i, n) {
        //     sum += (i+1);
        //     if (sum >= n) {
        //         for (; sum>n and prev<i; ++prev) sum -= (prev+1);
        //         if (sum == n) {
        //             ans++;
        //         }
        //     }
        // }
        // cout << ans << endl;

        int p=1;
        int sum=0, ans=0;

        for (int i=1; i<n; ++i) {
            sum += i;
            if (sum >= n) {
                for (; sum > n and p<i; ++p) sum -= p;
                if (sum == n) ans++;
            }
        }

        cout << ans << endl;

    }

}

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

int main()
{
    string S, T;
    cin >> S >> T;
    vector<int> start(26, -1);
    vector<int> end(26, -1);
    for (int i = 0; i < S.size(); ++i){
        int a = S[i] - 'a';
        int b = T[i] - 'a';

        if( start[a] != -1 or end[b] != -1){
            if(start[a] != b or end[b] != a){
                cout << "No" << endl;
                return 0;
            }
        }

        start[a] = b;
        end[b] = a;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		ll x;cin>>x;
		if(i%2==0 and x&1){ans+=1;}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,x) for(ll i=0;i<x;i++)
#define INF 1e18
typedef long long ll;
using namespace std;

int main(){
    ll N,K;cin>>N>>K;
    ll ans=0;
    while(1){
        if(N>=pow(K,ans))ans++;
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
	int h=sc.nextInt();
	int w=sc.nextInt();
	sc.nextLine();
	char c[][]=new char[h][w];
	for(int i=0;i<h;i++){
	    String s=sc.nextLine();
	  
	   char  c1[]=s.toCharArray();
	   for(int j=0;j<w;j++){
	       c[i][j]=c1[j];
	   }
	}
	int  m=1000000007;
	int dp[][]=new  int[h][w];
	for(int i=0;i<h;i++)
	{
	    if(c[i][0]=='.')
	    dp[i][0]=1;
	    else
	    break;
	}
		for(int i=0;i<w;i++)
	{
	    if(c[0][i]=='.')
	    dp[0][i]=1;
	    else
	    break;
	}
	for(int i=1;i<h;i++){
	    for(int j=1;j<w;j++){
	        if(c[i][j]=='#') continue;
	        
	        dp[i][j]=((dp[i-1][j]%m+dp[i][j-1]%m))%m;
	    }
	}
	System.out.println(dp[h-1][w-1]);
		
	}
}


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

const int maxn = 2 * 1e5 + 1;

long long n, num[maxn] = {}, pl[maxn] = {}, xo[maxn] = {};

int main()
{
	cin >> n;
 	for (int i = 1; i <= n; i++)
 	{
 		cin >> num[i];
 		pl[i] = xo[i] = num[i];
 		pl[i] += pl[i - 1];
 		xo[i] ^= xo[i - 1];
	}
	
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int l = i, r = n, best = -1;
		while (l <= r)
		{
			
			int mid = (l + r) / 2 ;
			//cout << l << ' ' << r << ' ' << mid << '\n'; 
			if ((pl[mid] - pl[i - 1]) == (xo[mid] ^ xo[i - 1]))
			{	
				best = mid;
				l = mid + 1;
			}
			else 
			{
				r = mid - 1;
			}
			
		}
		
		ans += best - i + 1;
	}
		
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4992
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.trim().split(' ');
const OPERATOR = {
  '+': (a, b) => a + b,
  '*': (a, b) => a * b,
  '-': (a, b) => a - b,
  '/': (a, b) => a / b,
};

const stack = [];
list.forEach((value) => {
  if (OPERATOR[value]) {
    const a = stack.pop();
    const b = stack.pop();
    const result = OPERATOR[value](b, a);
    // console.log(a, b, result);
    stack.push(result);
  } else {
    // console.log(value);
    stack.push(value | 0);
  }
});

console.log(stack[0]);



Measured memory_bytes: 15392
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

static const int max_size = 11;

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

	ll size = S.size();
	ll minValue = 1 << 30;

	rep(i, 0, size - 1) {
		ll maxValue = 0;
		if (S[i] != S[i + 1]) {
			maxValue = (i + 1 > size - (i + 1)) ? i + 1 : size - (i + 1);

			if (minValue > maxValue) {
				minValue = maxValue;
			}
		}
	}
	if (minValue == 1 << 30) {
		minValue = size;
	}
	cout << minValue << endl;

	return 0;
}

Measured memory_bytes: 512
s = input()
YYMM, MMYY, ova = False, False, False
if(1 <= int(s[:2]) <= 12):
    MMYY = True
if(1 <= int(s[2:]) <= 12):
    YYMM = True

if(MMYY and YYMM):
    print('AMBIGUOUS')
elif(MMYY):
    print("MMYY")
elif(YYMM):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
using ld=long double;
const int INF=1e9;
const int MOD=998244353;
struct p{
  int gb,cnt,rui;
};
p dp[3005][3005];
void f(p &a,p b){
  int gb=a.gb+a.rui*a.cnt+b.gb+b.rui*b.cnt;
  int cnt=0;
  int rui=a.rui+b.rui;
  a={gb%MOD,0,rui%MOD};
}

signed main(){
  int n,s;cin>>n>>s;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<3005;i++)for(int j=0;j<3005;j++)dp[i][j]={0,0,0};
  int ans=0;
  for(int i=0;i<n;i++){
    f(dp[i+1][v[i]],{0,1,i+1});
    for(int j=1;j<=s;j++){
      if(j+v[i]<=s)f(dp[i+1][j+v[i]],dp[i][j]);
      f(dp[i+1][j],dp[i][j]);
    }
    ans+=(dp[i+1][s].gb+dp[i+1][s].rui*dp[i+1][s].cnt%MOD)%MOD;ans%=MOD;
  }
  cout<<ans<<endl;
}


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

int main() {
    int n, m;
    map<ll, ll> mp;
    cin >> n >> m;
    ll a[n] = {0};
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
        mp[a[i] % m]++;
    }

    ll ans = 0;
    for (auto e : mp) {
        if (e.first == 0) ans += e.second;
        ans += e.second * (e.second - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
package main

import (
	"fmt"
	"sort"
	"strconv"
)

type city struct {
	p, y, index int
	ans         string
}

type lessFunc func(p1, p2 *city) bool

type multiSorter struct {
	cities []city
	less   []lessFunc
}

func (ms *multiSorter) Sort(cities []city) {
	ms.cities = cities
	sort.Sort(ms)
}

func orderedBy(less ...lessFunc) *multiSorter {
	return &multiSorter{
		less: less,
	}
}

func (ms *multiSorter) Len() int      { return len(ms.cities) }
func (ms *multiSorter) Swap(i, j int) { ms.cities[i], ms.cities[j] = ms.cities[j], ms.cities[i] }
func (ms *multiSorter) Less(i, j int) bool {
	p, q := &ms.cities[i], &ms.cities[j]
	var k int
	for k = 0; k < len(ms.less)-1; k++ {
		less := ms.less[k]
		switch {
		case less(p, q):
			return true
		case less(q, p):
			return false
		}
	}
	return ms.less[k](p, q)
}

func main() {
	prefecture := func(c1, c2 *city) bool {
		return c1.p < c2.p
	}
	year := func(c1, c2 *city) bool {
		return c1.y < c2.y
	}
	indexSort := func(c1, c2 *city) bool {
		return c1.index < c2.index
	}

	var n, m int
	fmt.Scan(&n, &m)
	cities := make([]city, m)
	for i := range cities {
		fmt.Scan(&cities[i].p, &cities[i].y)
		cities[i].index = i
	}

	orderedBy(prefecture, year).Sort(cities)

	counter := 1
	for i := range cities {
		if i != 0 {
			if cities[i].p == cities[i-1].p {
				counter++
			} else {
				counter = 1
			}
		}
		tmpPref := strconv.Itoa(cities[i].p)
		for len(tmpPref) <= 5 {
			tmpPref = "0" + tmpPref
		}
		tmpCounter := strconv.Itoa(counter)
		for len(tmpCounter) <= 5 {
			tmpCounter = "0" + tmpCounter
		}
		cities[i].ans = tmpPref + tmpCounter
	}

	orderedBy(indexSort).Sort(cities)

	for _, c := range cities {
		fmt.Println(c.ans)
	}
}


Measured memory_bytes: 10624
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)

Measured memory_bytes: 20448