akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int h[100000],count[100000];
    rep(i,N){
        cin >> h[i];
    }
    count[0]=0;
    count[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        count[i]=min(count[i-2]+abs(h[i]-h[i-2]),count[i-1]+abs(h[i]-h[i-1]));
    }
    cout << count[N-1] << endl;
}

Measured memory_bytes: 1024
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

ll a, b;

void solve()
{
    cout << ((a+b) % 2 == 0 ? to_string((a+b)/2) : "IMPOSSIBLE") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>

int main() {
  int n = 0, a = 0, b = 0;

  scanf(" %d", &n);

  if (n == 1)
    printf("Hello World");
  else if (n == 2) {
    scanf(" %d %d", &a, &b);
    printf("%d", a + b);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
int n, m;
vector<vector<ld>> dp;
vector<ld> a;
ld solve(int idx, int cnt) {
	if (idx > n || cnt >= m)
		return 0;
	if (idx == n)
		return 1;
	ld& ret = dp[idx][cnt];
	if (ret != -1)
		return ret;
	ld p1 = a[idx] * solve(idx + 1, cnt);
	ld p2 = (1 - a[idx]) * solve(idx + 1, cnt + 1);
	return ret = p1 + p2;

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	cin >> n;
	m = ceil(n, 2);
	a = vector<ld>(n);
	dp = vector<vector<ld>>(n, vector<ld>(n, -1));
	for (auto& i : a)
		cin >> i;
	cout << fixed << setprecision(10);
	cout << solve(0.0, 0.0);


}


Measured memory_bytes: 144256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M, C;
        cin >> N >> M >> C;
        vll B(M);
        vllvll A(N, vll(M));
        rep(i, 0, M) cin >> B[i];
        rep(i, 0, N) rep(j, 0, M) cin >> A[i][j];
        ll ans = 0;
        rep(i, 0, N) {
                ll tmp = 0;
                rep(j, 0, M) {
                        tmp += A[i][j] * B[j];
                }
                tmp += C;
                if (tmp > 0) ++ans;
        }
        cout << ans << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

Vi v[100001];
int dfs(int N,int p)
{
	int res=0;
	for(int next:v[N])
	{
		if(next==p)continue;
		res^=dfs(next,N)+1;
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	fup(i,1,n-1,1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	puts(dfs(1,-1)?"Alice":"Bob");
}

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

typedef long long ll;

void couting_sort(vector<int> &a,vector<int> &b,int k){
    vector<int> cou(k,0);
    for(int i=0;i<a.size();i++)cou[a[i]]++;
    for(int i=1;i<k;i++)cou[i]+=cou[i-1];
    for(int i=a.size()-1;i>=0;i--){
        b[cou[a[i]]-1]=a[i];
        cou[a[i]]--;
    }
}

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

    int n,ma=0;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        ma=max(ma,a[i]);
    }
    couting_sort(a,b,ma+1);
    for(int i=0;i<b.size();i++)cout << b[i] <<(i!=b.size()-1?" ":"\n");
}



Measured memory_bytes: 18472
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a , b , c ,d ;
    cin >> a >> b >> c >> d;
    if(a >= d ){
        cout << 0 << endl;
    }else if(c >= b){
        cout << 0 << endl;
    }else{
        cout << -max(a,c) +min(b,d) << endl;
    }
    return 0;
}

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

using ll = long long;

int main() {
    ll N, gA, sA, bA, gB, sB, bB;
    cin >> N >> gA >> sA >> bA >> gB >> sB >> bB;
    if (gA <= gB && sA <= sB && bA <= bB) {
        ll ans = 0;
        rep(g, N / gA + 1) {
            rep(s, (N - g * gA) / sA + 1) {
                ll b = (N - g * gA - s * sA) / bA;
                ll c = N + g * (gB - gA) + s * (sB - sA) + b * (bB - bA);
                if (c > ans) ans = c;
            }
        }
        cout << ans << endl;
        return 0;
    }
    if (gA >= gB && sA >= sB && bA >= bB) {
        ll ans = 0;
        rep(g, N / gB + 1) {
            rep(s, (N - g * gB) / sB + 1) {
                ll b = (N - g * gB - s * sB) / bB;
                ll c = N + g * (gA - gB) + s * (sA - sB) + b * (bA - bB);
                if (c > ans) ans = c;
            }
        }
        cout << ans << endl;
        return 0;
    }
    ll ans = 0;
    vector<vector<ll>> v = {{gA * sB * bB, gA, gB}, {gB * sA * bB, sA, sB}, {gB * sB * bA, bA, bB}};
    sort(v.begin(), v.end());
    if (v[1][0] < gB * sB * bB) {
        rep(i, N / v[0][1] + 1) {
            ll M = N - i * v[0][1];
            ll j = M / v[1][1];
            ll c = M - j * v[1][1] + i * v[0][2] + j * v[1][2];
            if (c > ans) ans = c;
        }
        ans += ans / v[2][2] * (v[2][1] -v[2][2]);
    } else {
        ll L = N + N / v[0][1] * (v[0][2] - v[0][1]);
        rep(k, 10000) {
            ll i = L / v[2][2] - k;
            if (i < 0) break;
            ll M = L - i * v[2][2];
            ll j = M / v[1][2];
            ll c = M - j * v[1][2] + i * v[2][1] + j * v[1][1];
            if (c > ans) ans = c;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

ll n,ans=0;

void check(ll a){
  bool ok1,ok2,ok3;
  ok1 = ok2 = ok3 = false;
  string sa = to_string(a);
  rep(i,sa.size()){
    if(sa[i]=='3') ok1 = true;
    if(sa[i]=='5') ok2 = true;
    if(sa[i]=='7') ok3 = true;
  }
  if(ok1 && ok2 && ok3 && a<=n) ans++;
}

void dfs(ll a){
  if(a > n) return;
  check(a);
  dfs(10*a+3);
  dfs(10*a+5);
  dfs(10*a+7);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> n;
  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
A = np.array(list(map(int,input().split())))
#print(A)

#print(np.where(A >= 3200))
a = len(np.where(A >= 3200)[0])
#print(A[A < 3200] // 400)
b = len(set(A[A < 3200] // 400))

print(max(1, b), b+a)


Measured memory_bytes: 18244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  for (int i = 0; i < N; i++) {
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  ll ans = 0;
  ll streak = 1;
  for (int i = 1; i < N; i++) {
    if (s[i-1] == s[i]) {
      streak++;
    } else {
      ans += (streak * (streak - 1)) / 2;
      streak = 1;
    }
  }
  ans += (streak * (streak - 1)) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>

#define POW(x) ((x) * (x))

double s[101][2];

int main(){
  int n, i, j, c, max;
  double x, y;
  while(scanf("%d", &n) && n){
    for(i = 0;i < n;i++) scanf("%lf,%lf", &s[i][0], &s[i][1]);
    for(max = 0, x = 0.;x <= 10.;x += .1){
      for(y = 0.; y <= 10.; y += .1){
	for(c = 0, i = 0;i < n;i++)
	  if(1.01 >= POW(s[i][0] - x) + POW(s[i][1] - y)) c++;
	max = c > max ? c : max;
      }
    }
    printf("%d\n", max);
  }
  return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
r, s, p = map(int, input().split())
hand = {"r": "p", "s": "r", "p": "s"}
score = {"r": r, "s": s, "p": p}
other = "o"
t = input()
hist = [other] * k

result = 0
for i, v in enumerate(t):
    i %= k
    if hist[i] != hand[v]:
        hist[i] = hand[v]
        result += score[hand[v]]
    else:
        hist[i] = other
print(result)




Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast()    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
	fast()
	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
        
    int ans=0;
    int dp[n+1];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
    
        dp[i]  = min(dp[i-2] + abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
    } 
    cout<<dp[n-1];
}   

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

using namespace std;


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

  // グーのとき: 貯金が出来る
  // グーのとき: 貯金を使って利益を得る
  // パーのとき: 貯金が出来る
  // パーのとき: 貯金を使って利益を得る

  int ret = 0;
  for(auto &p : S) ret -= p == 'p';
  cout << ret + S.size() / 2 << endl;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

bool check(const vector<int>& blocks){
	for(int i=0;i+1<blocks.size();i++){
		if(blocks[i] < blocks[i+1]) return false;
	}
	return true;
}

void dfs(vector<int>& blocks,int n,int remnants){	
	if(remnants==0){
		for(int i=0;i<blocks.size();i++){
			printf("%s%d",i==0 ? "" : " ",blocks[i]);
		}
		printf("\n");
		return;
	}

	for(int i=remnants;i>=1;i--){
		vector<int> next = blocks;
		next.push_back(i);
		if(!check(next)) continue;

		dfs(next,n,remnants-i);
	}
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		vector<int> blocks;
		if(n==0) break;
		dfs(blocks,n,n);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
using namespace std;
string st;
int sum=0,ans=0;
int main() {
	cin>>st;
	for(int i=0;i<st.size();i++)
	    if(st[i]=='R')
	        sum++;
	    else {
	        ans=max(ans,sum);
	        sum=0;
	    }
	ans=max(ans,sum);
	printf("%d\n",ans);
}

Measured memory_bytes: 3260
N=int(input())-1
a=input()
l=[None]*N
for i in range(N):
    l[i]=abs(int(a[i+1])-int(a[i]))
for i in range(19,0,-1):
    if N>2**i:
        t=2**i
        N-=t
        lb=[None]*N
        for i in range(N):
            if l[i+t//2]==1 and l[i]+l[i+t]==2:
                lb[i]=0
            else:
                lb[i]=abs(l[i]-l[i+t])
        l=lb
if len(l)==1:
    print(l[0])
else:
    print(abs(l[0]-l[1]))

Measured memory_bytes: 94876
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
vector<int> G[N];
int ea[N],eb[N],d[N],e[N],c[N];
int main()
{
    int n,x,y;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&x,&y);
        d[x]++;
        d[y]++;
        G[x].push_back(y);
        G[y].push_back(x);
        ea[i] = x, eb[i] = y;
    }
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    sort(c+1, c+1+n);
    int Min,id;
    for(int i=1;i<n;i++){
        Min = 1e9;
        for(int j=1;j<=n;j++){
            if(d[j] > 0 && d[j] < Min){
                Min = d[j];
                id = j;
            }
        }
        e[id] = c[i];
        d[id]--;
        for(int j=0;j<G[id].size();j++){
            d[G[id][j]]--;
        }
    }
    for(int i=1;i<=n;i++){
        if(e[i] == 0){
            e[i] = c[n];
            break;
        }
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        ans += min(e[ea[i]], e[eb[i]]);
    }
    printf("%d\n",ans);
    for(int i=1;i<=n;i++)printf("%s%d", (i==1 ? "" : " "), e[i]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<bitset<10>> vec(N, 0);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int l;
      cin >> l;
      l--;
      vec[l].set(i);
    }
  }
  
  bitset<10> p;
  for (int i = 0; i < M; i++) {
    int v;
    cin >> v;
    if (v == 1) {
      p.set(i);
    }
  }
  
  int ans = 0;
  for (int i = 0; i < (1<<N); i++) {
    bitset<10> v;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        v ^= vec[j];
      }
    }
    if (p == v) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int m = 1000005;
  vector<int> cnt(m);
  for(int x :a) {
    if(cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for(int i=x; i<m; i+=x) {
      cnt[i]++;
    }
  }
  int ans = 0;
  for(int x :a) {
    if(cnt[x] == 1) ans++; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7944
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const int S=1e5;
LL N,L,T;
LL X[S];
LL W[S];
P ps[S];
vector<int> is[2];
int main() {
	cin >> N >> L >> T;
	for(int i=0;i<N;i++){
		cin >> X[i] >> W[i];
		W[i]--;
		is[W[i]].push_back(i);
	}
	LL s=0;
	if(is[0].size()&&is[0][0]==0){
		for(auto i:is[1]){
			LL v=2*T-(X[i]-X[0]);
			if(v<=0)continue;
			s+=(v-1)/L+1;
			s%=N;
		}
	}
	else{
		for(auto i:is[0]){
			LL v=2*T-(L+X[0]-X[i]);
			if(v<=0)continue;
			//cerr << i << ": " << v << ", " << (v-1)/L << endl;
			s-=(v-1)/L+1;
			s%=N;
		}
	}
	if(s<0){
		s+=N;
	}
	for(int i=0;i<N;i++){
		if(W[i]==0){
			ps[i]=P((X[i]+T)%L,0);
		}
		else{
			LL v=(X[i]-T)%L;
			if(v<0){
				v+=L;
			}
			ps[i]=P(v,1);
		}
	}
	P t=ps[0];
	sort(ps,ps+N);
	int f=lower_bound(ps,ps+N,t)-ps;
	for(int i=0;i<N;i++){
		int j=(f-s+i+N)%N;
		//cerr << "j " << j << endl;
		cout << ps[j].first << endl;
	}

	return 0;
}



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

int main(){
  string N;
  cin >> N;
  
  if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include<iostream>
using namespace std;
const int MAXV = 100005; //素数表范围
int a[MAXV];
int main()
{
    int n;

    while(scanf("%d",&n)!=EOF)
    {
        int ans=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1; i<=n; i++)
        {  
            if(a[i]==i)
            {   
                if(a[i+1]!=i&&a[i]!=i+1)
                {
                    int t=a[i];
                    a[i]=a[i+1];
                    a[i+1]=t;
                    ans++;
                }
                else if(a[i-1]!=i&&a[i]!=i-1)
                {
                     int t=a[i];
                    a[i]=a[i-1];
                    a[i-1]=t;
                    ans++;
                }
            }
        }
        cout<<ans<<endl;

    }
    return 0;
}


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

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

  ll res = 0;
  rep(bit, 1<<(s.size()-1)) {
    ll tmp = 0;
    rep(i, s.size()-1) {
      tmp *= 10;
      tmp += s[i] - '0';
      if (bit & (1<<i)) res += tmp, tmp = 0;
    }
    tmp *= 10;
    tmp += s.back() - '0';
    res += tmp;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

class Solution {
public:
	/* time: O(n), space: O(1) */
	bool bingo(const vector<int>& A, const vector<int>& B) {
		unordered_map<int, int> h;
		for (int pos = 0; pos < 9; ++pos)
			h.emplace(A[pos], pos);

		int group[8] = {};
		for (int b : B) {
			const auto it = h.find(b);
			if (it != h.end()) {
				const int pos = it->second;
				const int row = pos / 3, col = pos % 3;
				if (++group[row] == 3)
					return true;
				if (++group[3 + col] == 3)
					return true;
				if (row == col && ++group[6] == 3)
					return true;
				if (row + col == 2 && ++group[7] == 3)
					return true;
			}
		}
		return false;
	}
};

int main() {
	vector<int> A(9);
	for (int i = 0; i < 9; ++i)
		cin >> A[i];
	int n;
	cin >> n;
	vector<int> B(n);
	for (int i = 0; i < n; ++i)
		cin >> B[i];

	Solution sol;
	const bool ans = sol.bingo(A, B);
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

const int MN = 100100;
int n;
ll a[MN];

bool solve() {
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        sm += (a[i]-1);
    }
    if (sm % 2 == 1) return true;
    int oc = -1;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2) {
            if (oc != -1) return false;
            oc = a[i];
        }
    }
    if (oc == 1) return false;
    ll gc = 0;
    for (int i = 0; i < n; i++) {
        ll aa = a[i]/2*2;
        gc = gcd(gc, aa);
    }
    for (int i = 0; i < n; i++) {
        a[i] /= gc;
    }
    return !solve();
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (solve()) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
  int h,w,n,big,ans;
  scanf("%d", &h);
  scanf("%d", &w);
  scanf("%d", &n);
  if(h>w){
    big=h;
  }else{
    big=w;
  }
  if(n%big != 0) ans=(int)n/big+1;
  else ans=(int)n/big;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(M):
    c[i], d[i] = map(int, input().split())

for i in range(N):
    d1 = float('inf')
    for j in range(M):
        d2 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if d1 > d2:
            d1 = d2
            check = j + 1
    print(check)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll dp[1000010][2][2];  // dp[i][j0][j9] : i項目までの場合の数。j0 = 1 のとき a_i = 0 なるiが存在。j9 = 1 のとき a_i = 9 なるiが存在。　

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

    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j0, 2) {
            rep(j9, 2) {
                exrep(x, 0, 9) {  // i項目にxを置くとする
                    if(x == 0) {
                        dp[i+1][j0 | 1][j9] += dp[i][j0][j9];
                        dp[i+1][j0 | 1][j9] %= mod;
                    }
                    else if(x == 9) {
                        dp[i+1][j0][j9 | 1] += dp[i][j0][j9];
                        dp[i+1][j0][j9 | 1] %= mod;
                    }
                    else {
                        dp[i+1][j0][j9] += dp[i][j0][j9];
                        dp[i+1][j0][j9] %= mod;
                    }
                }
            }
        }
    }
    
    out(dp[n][1][1]);
    re0;
}

Measured memory_bytes: 34876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n;
    cin >> n;
    vi d(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d ", &d[i]);
    }

    sort(d.begin(), d.end());
    int cnt = d[n / 2] - d[n / 2 - 1];
    cnt = cnt < 0 ? 0 : cnt;
    cout << cnt << endl;

    return 0;
}


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

#define MAX_N 100000
#define MAX_M 100000

int main() {
    int N, M;
    cin >> N >> M;
    pair<int, int> req[MAX_M+1];
    for (int i = 0; i < M; i++) {
        cin >> req[i].first >> req[i].second;
    }
    sort(req, req+M);
    int count = 0;
    int a = req[0].first;
    int b = req[0].second;
    // a-b間を切断したい
    for (int i = 1; i < M; i++) {
        if (b <= req[i].first) { // 区間の重なりがないとき
            count++;
            a = req[i].first;
            b = req[i].second;
        } else {                // 区間の重なりがあるとき
            a = req[i].first;
            b = min(req[i].second, b);
        }
    }
    count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)

def f(n):
	if n % 2 == 0:
		return int(n/2)
	else:
		return 3*n+1

def main(s):
	a = [0]*10000000
	a[s] = 1
	i = 1
	while True:
		s = f(s)
		i+=1
		if a[s] == 1:
			print(i)
			break
		a[s] = 1
	return

main(int(input()))


Measured memory_bytes: 81140
fun main() {
    val a = nextInt()
    println(a + a * a + a * a * a)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 34380
import sys

D = int(input())
C = list(map(int, sys.stdin.readline().rsplit()))
S = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(D)]

d = [0] * 26
res = 0
for i in range(D):
    index = max(enumerate(S[i]), key=lambda x: x[1])[0]
    print(index + 1)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 a,b,c,d,e,f,g;
void solve(){
	cin >> a >> b >> c >> d >> e >> f >> g;
	
	i64 ans = 0;
	
	if(a&&d&&e){
		if((a%2)+(d%2)+(e%2) >= 2){
			ans += 3;
			a--;
			d--;
			e--;
		}
	}
	ans += (a/2)*2;
	ans += b;
	ans += (d/2)*2;
	ans += (e/2)*2;
	
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	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)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll N, K, hu;
ll A[200000];

// ペア (i, i+1), (i, i+2), ..., (i, N-1) の中の key 以下の数の個数
ll binarySearch(int i, ll key){
	if(A[i] < 0){
		int ok = N;
		int ng = i;
		while(ok - ng > 1){
			int m = (ok+ng) / 2;
			if(A[i]*A[m] <= key) ok = m;
			else ng = m;
		}
		return N-ok;
	}
	else{
		int ok = i;
		int ng = N;
		while(ng - ok > 1){
			int m = (ng+ok) / 2;
			if(A[i]*A[m] <= key) ok = m;
			else ng = m;
		}
		return ok-i;
	}
}

signed main(){
	scanf("%lld%lld", &N, &K);
	rep(i, N){
		scanf("%lld", A+i);
		if(A[i] < 0) hu++;
	}
	sort(A, A+N);
	
	// その数以下のペアが K 個以上存在するか？
	// 答えは ok
	ll ng = -1000000000LL*1000000000LL-1LL;
	ll ok = 1000000000LL*1000000000LL+1LL;
	while(ok-ng > 1){
		ll m = (ng+ok) / 2;
		ll c = 0;
		rep(i, N) c += binarySearch(i, m);
		if(c >= K) ok = m;
		else ng = m;
		//cout << m << " " << c << " " << ng << " " << ok << endl;
	}
	printf("%lld\n", ok);
	//for(int m=-13; m<=10; m++){
	//	cout << m << " : ";
	//	ll c = 0;
	//	rep(i, N) cout << binarySearch(i, m) << " ";
	//	cout << endl;
	//}
}

Measured memory_bytes: 1792
s = input()
n = int(input())
head = ''
tail = s
for _ in range(n):
    q = input()
    if q[0] == '1':
        head, tail = tail, head
    else:
        _, f, c = q.split()
        if f == '1':
            head += c
        else:
            tail += c
print(head[::-1] + tail)



Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define eb pb

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for (int i=0; i<(n); i++)
#define REP rep
#define int long long
typedef long long ll;
typedef ll LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> inline bool MX(T&l, const T&r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T&l, const T&r){return l>r?l=r,1:0;}
int N;
//int cel[114514];
const int SIZE=1e6+500;
//int Solve() {
 //     }
 // return ans;
//}
LL A[SIZE];
vector<int> primes;
bool notprimes[SIZE];
signed main() {
  cin >> N;  
  EFOR(i,2,1e6){
    if(notprimes[i]==false){
      primes.pb(i);

      for(int j=i*i;j<1e6;j+=i){
        notprimes[j]=true;
      }
    }
  }

  REP(i,N) cin >> A[i];
  set<int> v;
  REP(i,N){
    LL x=A[i];
    REP(i,primes.size()){
      if(x%primes[i]==0){
        v.insert(primes[i]);
        while(x%primes[i]==0) x/=primes[i];
        
      }
      if(x!=1) v.insert(x);
    }

  }
  LL ans=0;
  for(auto p:v){
    LL x=0;
    REP(i,N) if(A[i]%p==0) x+=A[i]; 
    MX(ans,x);
  }

  cout << ans << endl;
}



Measured memory_bytes: 4896
f = lambda : map(int,input().split())

n, q = f()
s = input()

cnt = 0
ln = [0]*n
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    cnt += 1
  ln[i] = cnt
for _ in range(q):
  l, r = f()
  print(ln[r-1]-ln[l-1])

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

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

	int n; cin >> n;
	vector<long long> a(n);
	map<long long,long long> acnt;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(acnt.count(a[i])){
			acnt[a[i]] = acnt[a[i]] + 1;
		}else{
			acnt[a[i]] = 1;
		}
	}
	vector<long long> asum(1000000,-1);
	vector<long long> asum2(1000000);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		if(asum[a[i]] == -1LL){
			asum[a[i]] = (long long)(acnt[a[i]] * (acnt[a[i]] - 1) / 2);
			asum2[a[i]] = (long long)((acnt[a[i]]-1) * (acnt[a[i]] - 2) / 2);
			sum += (long long)asum[a[i]];
		}
	}
	for(int i = 0; i < n; i++){
		long long tmp = (long long)(asum[a[i]] - asum2[a[i]]);
		cout << (sum-tmp) << endl;
	}
}


Measured memory_bytes: 26752
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();

        out.println((10000 - N) % 1000);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32636
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    ll a[10002]={0};
    for(ll i=1;i<=102;i++)
        for(ll j=1;j<=102;j++)
        for(ll k=1;k<=102;k++){
            ll z=i*i+j*j+k*k+i*j+j*k+k*i;
            if(z<=10000)
                a[z]++;
        }
    for(ll i=1;i<=n;i++)
        cout<<a[i]<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> ans;
    while(true){
        int res = 0;
        int N; cin >> N;
        if(N == 0) break;
        int sum = 0;
        vector<int> A(N);
        rep(i, N){
            int temp; cin >> temp;
            sum += temp;
            A[i] = N*temp;
        }
        rep(i, N){
            if(A[i] <= sum) res++;
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3104
package main

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

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    line := readLine(reader)
    n, _ := strconv.Atoi(line)

    line2 := readLine(reader)
    arr := strings.Split(line2, " ")

    var cnt int = 0

    for i := 0; i < n - 2; i++ {
        a, _ := strconv.Atoi(arr[i])
        b, _ := strconv.Atoi(arr[i+1])
        c, _ := strconv.Atoi(arr[i+2])

        if (a < b && b < c) || (c < b && b < a) {
            cnt++
        }
    }

    fmt.Println(cnt)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>

using namespace std;

int main(){

    
    double a,b,x,h;
    cin >> a >> b >> x;
    
    h = x / (a*a);
    double th;

    if(2.*x>=a*a*b){
        th = atan(2.*(b-h)/a);
    }else{
        th = atan(a*b*b/(2.*x));
    }
    
    printf("%.9f", th * 180. / M_PI);
    // cout << endl;
    // cout << th * 180. / M_PI << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto cnt = new long[](10^^5+1);
	foreach (i; 0..N)
	{
		auto a = RD;
		auto b = RD;
		cnt[a] += b;
	}
	long pos, ans;
	foreach (i, e; cnt)
	{
		pos += e;
		if (pos >= K)
		{
			ans = i;
			break;
		}
	}
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 3964
N, M = map(int, input().split())
students = [list(map(int, input().split())) for i in range(N)]
checkpoints = [list(map(int, input().split())) for i in range(M)]

for s in students:
    min_distance = 4 * 10**8 + 1
    for i, c in enumerate(checkpoints):
        distance = abs(s[0] - c[0]) + abs(s[1] - c[1]) 
        if min_distance > distance:
            min_distance = distance
            point = i+1
    print(point)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n];
  int count =0;
  for(int i=1;i<=n;i++){
    cin>>arr[i];
    if(arr[i]%2==1 && i%2==1){
      count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
  
using namespace std;
 
#define MAX 55
#define INF (1<<29)
  
int N, M;
int memo[MAX][MAX][MAX][MAX][2][2];
vector<int> a, b;
  
int get_point(int turn, int al, int ar, int bl, int br)
{
    int ap = 0, bp = 0;   
    bool astop = 0, bstop = 0;
    for (int i = ar-1, j = br-1; i >= al || j >= bl; turn ^= 1) {
        if (turn == 0) {
            if (a[i] == -1) {
                bstop = 1;
            } else if (!astop) {
                ap += a[i];
            }
            i--;
        } else {
            if (b[j] == -1) {
                astop = 1;
            } else if (!bstop) {
                bp += b[j];
            }
            j--;
        }
    }
    return ap - bp;
}
  
int solve(int n, int m, int fn, int fm, int turn, int pass)
{    
    int res = memo[n][m][fn][fm][turn][pass];
    if (res != INF) {
        return res;
    }      
  
    res = (turn == 0 ? -INF : INF);
     
    if (turn == 0) {
        if (pass == 1) {
            res = max(res, 0);
        } else {
            res = max(res, solve(fn, fm, fn, fm, 1, (n == fn && m == fm))
                      + get_point(1, n, fn, m, fm));               
        }
        if (fn < N) {
            res = max(res, solve(n, m, fn+1, fm, 1, 0));
        }
    } else {
        if (pass == 1) {
            res = min(res, 0);
        } else {
            res = min(res, solve(fn, fm, fn, fm, 0, (n == fn && m == fm))
                      + get_point(0, n, fn, m, fm));   
        }
        if (fm < M) {
            res = min(res, solve(n, m, fn, fm+1, 0, 0));
        }        
    }
     
    return (memo[n][m][fn][fm][turn][pass] = res);
}
  
void init()
{
    fill(memo[0][0][0][0][0],
         memo[MAX-1][MAX-1][MAX-1][MAX-1][2], INF);
}
  
int main()
{
    cin >> N >> M;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    b.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> b[i];
    }
    init();
    cout << solve(0, 0, 0, 0, 0, 0) << endl;
    return 0;
}

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

void _139() {
    string s, t;
    cin >> s;
    cin >> t;

    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i])
            count++;
    }
    cout << count << endl;
}

void _138() {
    int a;
    string s;
    cin >> a;
    cin >> s;

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
}

void _137() {
    int a, b;
    cin >> a >> b;

    int add = a + b;
    int mult = a * b;
    int sub = a - b;

    cout << max(add, max(mult, sub)) << endl;
}

void _136() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}

void _135() {
    long long a, b;
    cin >> a >> b;

    if (abs(a - b) % 2 != 0)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a + b) / 2 << endl;
}

int main()
{
    _135();
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

vector<P> g[334];
int dp[334][334][334];

int main(void){
	int n,m,i,j,k,t,l,r,x;
	ll ans=0ll;
	cin >> n >> m;
	for(t=0; t<m; ++t){
		cin >> l >> r >> x;
		g[r].push_back(P(l,x));
	}
	dp[0][0][0] = 1;
	for(i=0; i<=n; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<=n; ++k){
				r = max(i,max(j,k));
				l = min(i,min(j,k));
				m = (i+j+k)-(l+r);
				if(l && (l == m || m == r)){
					continue;
				}
				for(t=(g[r].l_ength()-1); t>=0; --t){
					switch(g[r][t].second){
						case 3:
							if(!(g[r][t].first<=l)){
								dp[i][j][k] = 0ll;
							}
							break;
						case 2:
							if(!(l<g[r][t].first && g[r][t].first<=m)){
								dp[i][j][k] = 0ll;
							}
							break;
						case 1:
							if(!(m<g[r][t].first)){
								dp[i][j][k] = 0ll;
							}
							break;
					}
				}
				if(r==n){
					ans += dp[i][j][k];
					ans %= MOD;
					continue;
				}
				dp[r+1][j][k] += dp[i][j][k];
				dp[r+1][j][k] %= MOD;
				dp[i][r+1][k] += dp[i][j][k];
				dp[i][r+1][k] %= MOD;
				dp[i][j][r+1] += dp[i][j][k];
				dp[i][j][r+1] %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 133248
#include <iostream>
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr if(true) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }

void solve(long long N, long long T, vector<long long> t){
	ll ans = T;

	FOR(i,1,N){
		ans += min(T,t[i] - t[i-1]);
	}

	cout << ans << endl;
}



int main(){
	ios::sync_with_stdio(false);
	long long T;
	long long N;
	cin >> N;
	vector<long long> t(N-1+1);
	cin >> T;
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> t[i];
	}
	solve(N, T, t);
	return 0;
}


Measured memory_bytes: 3456
import java.util.*;
 
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>b){System.out.println("a > b");}
		if(a<b){System.out.println("a < b");}
		if(a==b){System.out.println("a == b");}
      
	}
}



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

int main() {
  char S;
  cin >> S;
  if(S=='a'||S=='i'||S=='u'||S=='e'||S=='o'){
    	cout<< "vowel" <<endl;
    }
  else{
   	 	cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 3628
n,x = map(int,input().split())
blist = input().split()
i = 0
b = 0
while i < n:
  b += int(blist[i])
  if b > x:
    print(i + 1)
    break
  else:
    if i == n - 1:
      print(n + 1)
      i += 1
    else:
      i += 1
  
    
  
  
  

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

#define i64 long long int
#define ran 202202

int n, k;
int s[ran];
map<int, vector<int> > v;
map<int, int> it;

int main() {
	scanf("%d%d", &n, &k);
	
	i64 ans = 0LL;
	
	s[0] = 0;
	v[0].push_back(0);
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d", &x);
		s[i] = (s[i-1]+x-1)%k;
		
		int cur = s[i];
		v[cur].push_back(i);
		while(v[cur][it[cur]] < i-(k-1)) it[cur]++;
		ans += (int)v[cur].size() - it[cur] - 1;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 32256
from operator import itemgetter
def main():
    N,M = map(int,input().split())
    py = [list(map(int,input().split())) for _ in range(M)]
    [py[i].append(i) for i in range(M)]
    py = sorted(py,key=itemgetter(1))
    py = sorted(py,key=itemgetter(0))
    now = 0
    num = 1
    ans = []
    for i in range(M):
        if now != py[i][0]:
            now = py[i][0]
            num = 1
        else:
            num += 1
        tmp = str(now).zfill(6)+str(num).zfill(6)
        ans.append([tmp,py[i][2]])
    ans = sorted(ans,key=itemgetter(1))
    for i in range(M):
        print(ans[i][0])


if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 100;

int n, m, b, c, a[N];
ll ans;
vector<pii> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	while(m--) {
		cin >> b >> c;
		vec.push_back(pii(c, b));
	}
	sort(vec.begin(), vec.end(), greater<pii>());
	int dex = 0;
	for (pii &p: vec)
		while(dex < n && p.second--) {
			a[dex] = max(a[dex], p.first);
			dex++;
		}
	for (int i = 0; i < n; i++)
		ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1784