akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<llong> a(n,0);
    REP(i,n) {cin>>a[i]; a[i]*=2;}
    llong cnt=0;
    REP(i,n)
    {
        cnt=a[i]-cnt;
    }
    cnt/=2;
    REP(i,n)
    {
        cout<<cnt<<" ";
        cnt=a[i]-cnt;
    }
    cout<<endl;

    return  0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    ll a, b, c;
    cin>>a>>b>>c;
    ll ans;
    if(a%2==0 || b%2==0 || c%2==0) ans=0;
    else{
        ans=min(a*b, b*c);
        ans=min(ans, a*c);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    rep(i,h){
        bool rev_fl = i<b;
        rep(j,w){
            if(j<a){
                if(rev_fl) cout << 1;
                else cout << 0;
            }else {
                if(rev_fl) cout << 0;
                else cout << 1;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int n; cin >> n;
  int ans=0;
  set<int> s;
  rep(i,n){
    int k; cin >> k;
    if(s.find(k)==s.end()){
      s.insert(k);
    } else {
      s.erase(k);
    }
  }
  
  cout << s.size() << endl;
  return 0;
}


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

int main() {
  int X,A,B;
  cin>>X>>A>>B;
  if(A-B>=0){
    cout<<"delicious"<<endl;
  }
  else{
    if(X>=B-A){
      cout<<"safe"<<endl;
    }
    else{
      cout<<"dangerous"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int N = 2e5+5,M = 1e6+5;
int h[N],n,c,ans[N];
const int inf = 1e18;
struct line{
    int k,b;
    line(int _k,int _b) {
        k = _k;
        b = _b;
    }
    line() {
        k = 0;
        b = inf;
    }
    int operator()(int x) {
        return k*x+b;
    }
};
line t[4*M];

void upd(int v,int tl,int tr,line nw) {
    int tm = (tl + tr)/2;
    if (t[v](tm) > nw(tm))
        swap(t[v],nw);
    int a1 = t[v](tl) <= nw(tl);
    int a2 = t[v](tr) <= nw(tr);
    if (a1 && a2) return;
    if (a1) upd(v*2+1,tm+1,tr,nw);
    else upd(v*2,tl,tm,nw);
}
int get(int v,int tl,int tr,int pos) {
    int tm = (tl + tr)/2;
    int val = t[v](pos);
    if (tl == tr) return val;
    if (pos <= tm)
            return min(val,get(v*2,tl,tm,pos));
    else return min(val,get(v*2+1,tm+1,tr,pos));
}

main() {
    ios::sync_with_stdio(0);
    cin >> n >> c;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    upd(1,1,M,line(-2*h[1],h[1]*h[1]));
    for (int i = 2; i <= n; i++) {
            ans[i] = get(1,1,M,h[i]) + h[i]*h[i] + c;
            upd(1,1,M,line(-2*h[i],ans[i]+h[i]*h[i]));
    }
    cout << ans[n];
}


Measured memory_bytes: 69224
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

bool comp(const pii &a,const pii &b){
    if(a.second > b.second)return true;
    return false;
}

int main(){
    int n;
    cin >> n;
    vector<pii> a(n);
    int m = 0;
    int tmp;
    rep(i,n){ 
        cin >> tmp;
        a[i] = make_pair(i,tmp);
    }

    sort(a.begin(),a.end(),comp);

    // rep(i,n){
    //     cout << a[i].first << " " << a[i].second << endl;
    // }

    rep(i,n){
        if(a[0].first == i){
            cout << a[1].second << endl;
        }else{
            cout << a[0].second << endl;
        }
    }

    return 0;
}

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

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

    vector<long long> T(N);
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i] >> A[i];
    }

    long long T1 = T[0];
    long long A1 = A[0];
    for (int i = 1; i < N; i++) {
        long long ratio = max((T1 + T[i] - 1) / T[i], (A1 + A[i] - 1) / A[i]);
        T1 = T[i] * ratio;
        A1 = A[i] * ratio;
    }

    cout << T1 + A1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

signed main(){
  int n;cin>>n;vector<int> b(n);rep(i,n)cin>>b[i];reverse(b.begin(), b.end());
  vector<int> ans(n);
  rep(i,n){
    bool np = true;
    rep(j,b.size()){
      if(b[j] == b.size()-j){
        ans[n-i-1] = b[j];
        b.erase(b.begin()+j);
        np = false;
        break;
      }
    }
    if(np){
      cout << "-1" << endl;
      return 0;
    }
  }
  rep(i,n)cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N,P=2019;
    string S;
    cin >> S;
    N=S.size();

    ll ans = 0;
    if (P == 2 || P == 5) {
        REP(i, 0, N) if ((S[N - i - 1] - '0') % P == 0) ans += N - i;
    } else {
        vector<ll> mods(P, 0);

        ll cur = 0, coef = 1;
        mods[cur]++;
        REP(i, 0, N) {
            cur = (cur + coef * (S[N - i - 1] - '0') % P) % P;
            coef = coef * 10 % P;
            mods[cur]++;
        }

        REP(i, 0, P) {
            ans += mods[i] * (mods[i] - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3752
// https://atcoder.jp/contests/abc134/tasks/abc134_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    multiset<int, greater<int>> st;
    REP(i, N) {
        int t;
        cin >> t;
        auto it = st.lower_bound(t - 1);
        // 検索値より小さい値が見つかったら削除
        if (it != st.end()) {
            st.erase(it);
        }
        st.insert(t);
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14

int main(){
    ll x, p, n1, y, z, n2, n3; cin >> x >> p >> n1 >> y >> z >> n2 >> n3;
    ll ans = p+(x/2+y/2+z/2)*2;
    ll xx = x%2;
    ll yy = y%2;
    ll zz = z%2;
    if (x!=0&&xx==0&&yy==1&&zz==1) ans+= 1;
    else if (y!=0&&xx==1&&yy==0&&zz==1) ans+=1;
    else if (z!=0&&xx==1&&yy==1&&zz==0) ans+=1;
    else if (xx==1&&yy==1&&zz==1) ans += 3;
    
    cout << ans << endl;
}

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


int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    string str;
    int A, B, C;
    int count = 0;
    while(getline(cin, str)){
        stringstream ss;
        ss << str;
        ss >> A;
        ss >> B;
        ss >> C;


        count++;
        break;
    }



    if (A + B + C == 17){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%lld", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 3e2 + 5;
const double eps = 1e-9;
using namespace std;
pii a[MAXN];
pii b[MAXN];
vi adj[MAXN];
int vis[MAXN], match[MAXN];

int path(int u)
{
    for (int v: adj[u])
    {
        if (vis[v]) continue;
        vis[v] = 1;
        if (match[v] == -1 || path(match[v]))
        {
            match[v] = u;
            match[u] = v;
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n;
    ni(n);
    for (int i = 0; i < n; i++)
    {
        ni(a[i].f);
        ni(a[i].s);
    }
    for (int i = 0; i < n ; i++)
    {
        ni(b[i].f);
        ni(b[i].s);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i].f < b[j].f && a[i].s < b[j].s)
            {
                adj[i].pb(j + n);
                adj[j + n].pb(i);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < MAXN; i++) match[i] = -1;
    for (int i = 0; i < n; i++)
    {
        memset(vis, 0, sizeof vis);
        if (match[i] == -1)
            ans += path(i);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    char a, b;
    scan(a, b);
    writeln(a == b ? "H" : "D");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int day = 0;
		switch (s) {
		case "SUN":
			day = 7;
			break;
		case "MON":
			day = 6;
			break;
		case "TUE":
			day = 5;
			break;
		case "WED":
			day = 4;
			break;
		case "THU":
			day = 3;
			break;
		case "FRI":
			day = 2;
			break;
		case "SAT":
			day = 1;
			break;
		}
		System.out.println(day);
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
using namespace std;
int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if ((A1 + A2 + A3) < 22) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
       int k,a,b;cin>>k>>a>>b;
       for(int i=a;i<=b;i++){
       	if(i%k==0){
       		cout<<"OK"<<endl;return 0;
		   }
	   }
	   
	   cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3636
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].emplace_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].emplace_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  double a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<double> water;
  vector<double> sugar;
  a *= 100;
  b *= 100;
  for(int i = 0; i < f + 1; i++) {
    if(i * a > f){
      break;
    }
    for(int j = 0; j < f + 1; j++) {
      if(a * i + b * j <= f) {
        water.push_back(a * i + b * j);
      }else{
        break;
      }
    }
  }
  vector<int> dp(3000, 0);
  dp[0] = 1;
  for(int i = 0; i < f + 1; i++) {
    if(i * c > f){
      break;
    }
    for(int j = 0; j < f + 1; j++) {
      if(j * d + i * c <= f){
        sugar.push_back(j * d + i * c);
      }else{
        break;
      }
    }
  }
  double maxi = 0;
  pair<int, int> ans = {0, 0};
  for(auto p : water) {
    
    //cout << p << " ";
    for(auto q : sugar) {
      if(p + q == 0){
        continue;
      }
      //cout << q << " ";
      if(p + q > f) {
        continue;
      }
      double per = (double) q /(double)(p + q);
      /*
      if(per > e / (100. + e)) { //e * p/100 < q
        continue;
      }
      */
      if(maxi <= per && per <= e / (100. + e)) { // per < 100 * q / (p + q)
        maxi = per;
        ans.first = p;
        ans.second = q;
      }
    }
    //cout << endl;
  }
  cout << ans.first + ans.second << " " << ans.second << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int cnt = 0;
  for (;a <= b; a++) {
      string s = to_string(a);
      if (s[0]==s[4] && s[1]==s[3]) cnt++;
  }

  cout << cnt << endl;
}

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

#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int main() {
    int N; cin >> N;
    vector<int> H(N);
    FOR(i, 0, N) cin >> H[i];

    int count = 1;
    int maxi=H[0];

    FOR(i, 1, N) {
        if(H[i] >= maxi) {
            maxi= max(maxi, H[i]);
            count++;
        }
    }

    printf("%d\n", count);
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);
const int  MAX= 3007;

ll dp[MAX][MAX],a[MAX];

/*
 * dp[p][q] = best score of X-Y
 */


ll solve(int p , int q ) {
    if(dp[p][q] != -1) {
        return dp[p][q];
    }

    if( p > q ) {
        return 0;
    }

    if(p == q) {
        return dp[p][q] = a[p];
    }    


    return dp[p][q]=max(solve(p,p) - solve(p+1,q) , solve(q,q) - solve(p,q-1));
}


int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 0; i < MAX; i++) {
        for(int j = 0; j < MAX; j++) {
            dp[i][j] = -1;
        }
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n ; i++) {
        cin >> a[i];
    }

    cout<<solve(1,n)<<endl;

    return 0;
}



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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long Answer = 1;
        boolean ans = true;
        int An[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            An[A[i]]++;
            if (N % 2 == 0 && A[i] % 2 == 0) {
                ans = false;
            } else if (N % 2 == 1 && A[i] % 2 == 1) {
                ans = false;
            }
        }
        if (N % 2 == 1 && ans == true) {
            for (int i = 0; i < N; i = i + 2) {
                if (i == 0 && An[i] != 1) {
                    ans = false;
                    break;
                } else if (i != 0 && An[i] != 2) {
                    ans = false;
                    break;
                }
                if (i != 0) {
                    Answer = Answer * 2 % 1000000007;
                }
            }
        } else if (ans == true) {
            for (int i = 1; i < N; i = i + 2) {
                if (An[i] != 2) {
                    ans = false;
                    System.out.println(i);
                    break;
                }
                Answer = Answer * 2 % 1000000007;
            }
        }
        if (ans) {
            System.out.println(Answer);
        } else {
            System.out.println("0");
        }
    }
}

Measured memory_bytes: 50800
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int A,B,C,D,E,F;

signed main(void) {
    cin>>A>>B>>C>>D>>E>>F;
    double max_dense=-1;
    int ans_total;
    int ans_sugar;
    int max_sugar=F*E/(E+100);
    REP(d, 0, max_sugar/D) { //d:Dを行う回数
        int rest_max_sugar=max_sugar-d*D;
        REP(c, 0, rest_max_sugar/C) { //c:Cを行う回数
            int sugar_total=d*D+c*C;
            int necessary_water=(sugar_total*100+(E-1))/E;
            int max_water=F-sugar_total;
            // cout <<"sugar_total:"<<sugar_total<<endl;
            // cout << "max_water:" << max_water << endl;
            REP(b, 0, max_water/(B*100)) {
                // cout << "b:" << b << endl;
                int rest_necessary_water=necessary_water-b*B*100;
                // cout << "rest_necessary_water:" << rest_necessary_water << endl;
                int a;
                if (rest_necessary_water<0) a=0;
                else if (sugar_total==0 && b==0) a=1;
                else a=(rest_necessary_water+A*100-1)/(A*100);
 
                int water_total=a*A*100+b*B*100;
                if (water_total==0) continue;
                // cout <<"w:"<< water_total << endl;
                // cout<<"density:"<<(double)sugar_total/(sugar_total+water_total)<<endl;
                if (water_total+sugar_total<= F) {
                    if (max_dense==-1) {
                        max_dense=(double)sugar_total/(sugar_total+water_total);
                        ans_total=sugar_total+water_total;
                        ans_sugar=sugar_total;
                    } else if ((double)sugar_total/(sugar_total+water_total)>max_dense) {
                        max_dense=(double)sugar_total/(sugar_total+water_total);
                        ans_total=sugar_total+water_total;
                        ans_sugar=sugar_total;
                    }
                }
            }
        }
    }
    cout << ans_total << " " << ans_sugar << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			for (int i = 1; i < 10; i++)
			{
				for (int j = 1; j < 10; j++)
				{
					if (i * j == n)
					{
						Console.WriteLine("Yes");
						return;
					}
				}
			}
			Console.WriteLine("No");
		}
	}
}


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

int main(){
 int N,M,p;
 cin>>N>>M>>p;

 int d[10001];
 d[0]=p;

 for(int i=1;i<=M;i++){
	cin>>d[i];
 }

 sort(d,d+M+1);

 int c_min=N-1;

 for(int i=0;i<M+1;i++){
	int q=d[i];
	int r1=d[(i-1+M+1)%(M+1)];
	int r2=d[(i+1)%(M+1)];

	int c1=((p-q+N)%N)*2+(r1-p+N)%N;
	int c2=((q-p+N)%N)*2+(p-r2+N)%N;

	c_min=min(c_min,min(c1,c2));
 }
cout <<c_min*100<<endl;
return 0;

}

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

int main(){
  char a[100][100];
  int h, w;
  cin >> h >> w;

  bool tumeru = false;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < h; ++i){
    tumeru = true;
    for(int j = 0; j < w; ++j){
      if(a[i][j] != '.'){
        tumeru = false;
        break;
      }
    }
    if(tumeru == true){
      --h;
      for(int k = i; k < h; ++k){
        for(int l = 0; l < w; ++l){
          a[k][l] = a[k + 1][l];
        }
      }
      --i;
    }

  }

  for(int i = 0; i < w; ++i){
    tumeru = true;
    for(int j = 0; j < h; ++j){
      if(a[j][i] != '.'){
        tumeru = false;
        break;
      }
    }
    if(tumeru == true){
      --w;
      for(int k = i; k < w; ++k){
        for(int l = 0; l < h; ++l){
          a[l][k] = a[l][k+1];
        }
      }
      i--;
    }

  }

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cout << a[i][j];
    }
    cout << endl;
  }



}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	string s;
  cin>>s;
  int sum = 0, mn = 0;
  rep(i, s.size()){
    if(s[i]=='(') sum++;
    else sum--;
    mn = min(mn, sum);
  }
  s = string(-mn, '(')+s;
  s = s+string(sum-mn, ')');
  cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
long long res[100007];
 
int main() {
    int n;
    cin >> n;
    long long mass[n];
    for(int i = 0; i < n; i++){
        cin >> mass[i];
        res[i] = INT_MAX;
    }
    res[0] = 0;
    for(int i = 0; i < n; i++){
        long long temp1 = abs(mass[i + 1] - mass[i]);
        long long temp2 = abs(mass[i + 2] - mass[i]);
        res[i + 1] = min (res[i+1] , res[i] + temp1); 
        res[i + 2] = min (res[i+2] , res[i] + temp2); 
    }
    cout << res[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n )-1; i >= ( m ); i--)
using namespace std;
typedef long long int ll;
const int k_mod = 1e9 + 7;

int main() {
	int n , W;
	cin >> n >> W;
	int* v = new int[n];
	int* w = new int[n];
	rep(i,0,n){
		cin >> w[i] >> v[i];
	}
	ll* array = new ll[W+1]();
	printf("\n\n");
	rep(i,0,n){
		rep_d(j, W+1, w[i]){
			array[j] = max(array[j], array[j-w[i]] + v[i]);
		}

	}
	printf("%lld\n", array[W]);
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S, T;
    cin >> S >> T;

    vector<vector<int>> to(26), from(26);
    REP(i, S.length()) {
        to[S[i] - 'a'].push_back(T[i] - 'a');
        from[T[i] - 'a'].push_back(S[i] - 'a');
    }
    

    bool ok = true;
    REP(i, 26) {
        set<int> tmps;
        REP(j, to[i].size()) {
            tmps.insert(to[i][j]);
        }
        if (tmps.size() > 1) {
            ok = false;
            break;
        }
        set<int> tmpt;
        REP(j, from[i].size()) {
            tmpt.insert(from[i][j]);
        }
        if (tmpt.size() > 1) {
            ok = false;
            break;
        }
    }
    if (ok) print("Yes");
    else print("No");
}

signed main() {
    solve();
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

	rep(i, ty - sy) cout << 'U';
	rep(i, tx - sx) cout << 'R';
	rep(i, ty - sy) cout << 'D';
	rep(i, tx - sx) cout << 'L';
	cout << 'L';
	rep(i, ty - sy + 1) cout << 'U';
	rep(i, tx - sx + 1) cout << 'R';
	cout << 'D' << 'R';
	rep(i, ty - sy + 1) cout << 'D';
	rep(i, tx - sx + 1) cout << 'L';
	cout << 'U' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
signed main(void) {
	ios::sync_with_stdio(false);
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	vector<int>a(n), m(n + 1);
	for (int i = 0; i < n; i++)
		a[i] = s[n - 1 - i] - '0';

	int ans = 0;
	if (p == 2 || p == 5) {
		for (int i = 0; i < n; i++)
			if (a[i] % p == 0)
				ans += n - i;
		cout << ans << endl;
		return 0;
	}

	int t = 1;
	for (int i = 0; i < n; i++) {
		m[i + 1] = (m[i] + a[i] * t) % p;
		t = (t * 10) % p;
	}

	vector<int>cnt(p);
	for (int i = 0; i <= n; i++) {
		ans += cnt[m[i]];
		cnt[m[i]]++;
	}

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

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9;
const int maxN = 400;

ll l, dist0[maxN][maxN], dist1[maxN][maxN];
int n, m;

void init(ll dist[maxN][maxN]){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            dist[i][j] = INF;
        }
    }

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

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

    cin >> n >> m >> l;

    init(dist0);
    init(dist1);

    for(int i = 0; i < m; i++){
        int u, v;   ll w;   cin >> u >> v >> w;
        dist0[u][v] = min(dist0[u][v], w);
        dist0[v][u] = min(dist0[v][u], w);
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dist0[i][j] = min(dist0[i][j], dist0[i][k] + dist0[k][j]);
            }
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(dist0[i][j] <= l){
                dist1[i][j] = min(dist1[i][j], 1LL);
                dist1[j][i] = min(dist1[j][i], 1LL);
            }
        }
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }

    int q;  cin >> q;

    while(q--){
        int s, f;   cin >> s >> f;
        if(dist1[s][f] >= INF){
            cout << "-1\n";
            continue;
        }
        cout << dist1[s][f] - 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

void bubble_sort(int *data,int n)
{
	int i, j;
	for (i = 0; i < n - 1; i++){
		for (j = 0;j < n - i - 1; j++){
			if (data[j] < data[j + 1]){
				data[j] += data[j + 1];
				data[j + 1] = data[j] - data[j + 1];
				data[j] -= data[j + 1];
			}
		}
	}
}

int main(void)
{
	int data[5];
	int i;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &data[i]);
	}
	
	bubble_sort(data, 5);
	
	for (i = 0; i < 5; i++){
		if (i != 0) printf(" ");
		printf("%d", data[i]);
	}
	
	printf("\n");
	
	return (0);
}

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

int main() {
    int x = 0, n = 0;
    int p[100];
    cin >> x >> n;
    for (int i = 0; i < n; i++) cin >> p[i];

    bool subset[101];
    for (int i = 0; i <= 100; i++) subset[i] = false; 
    for (int i = 0; i < n; i++) subset[p[i]] = true;

    int min = 255;
    int ans = 0;
    for (int i = -1; i <= 101; i++) {
        if (i >= 0 && i <= 100 && subset[i]) continue;
        if (abs(x - i) < min) {
            min = abs(x - i);
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 {0} else {MOD - self.0})
    }
}

impl std::fmt::Display for ModInt {
    fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl std::str::FromStr for ModInt {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let val = s.parse::<u32>()?;
        Ok(ModInt::new(val))
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------
use std::io::Read;

fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {a} else {gcd(b, a % b)}
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: u32 = it.next().unwrap().parse().unwrap();
    let w: u32 = it.next().unwrap().parse().unwrap();
    let t: u32 = it.next().unwrap().parse().unwrap();
    let a = gcd(h, t);
    let b = gcd(w, t);
    let h = h / a;
    let w = w / b;
    let mut sum = ModInt::one();//不動
    sum += ModInt(2).pow(h) - ModInt(2);// 横と不動
    sum += ModInt(2).pow(w) - ModInt(2);// 縦と不動
    sum += ModInt(2).pow(gcd(h, w));// 縦横
    let s = a as u64 * b as u64;
    let s = s % (MOD - 1) as u64;
    let ans = sum.pow(s as u32);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
from collections import deque
n, q = map(int, input().split())
A = [deque() for i in range(n)]
for i in range(q):
    tmp = input().split()
    tmp[1] = int(tmp[1])
    if tmp[0] == "0":
        A[tmp[1]].append(tmp[2])
    elif tmp[0] == "1" and len(A[tmp[1]]) != 0:
        print(A[tmp[1]][0])
    elif tmp[0] == "2" and len(A[tmp[1]]) != 0:
        A[tmp[1]].popleft()


Measured memory_bytes: 20840
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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

//////////////////////////////////////////////////

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    ll asum = 0, bsum = 0;
    rep(i,n) cin >> a[i], asum+=a[i];
    rep(i,n) cin >> b[i], bsum+=b[i];

    // 操作の度にasumは2,bsumは1増えるので
    // 以下の場合は、成立しない
    if (bsum < asum) {
        cout << "No" << endl;
        return 0;
    }

    // 変更回数は一意
    ll change = bsum-asum;

    // aの最低変更回数を調べる
    // bの最低変更回数を調べる
    ll cnt_a = 0, cnt_b = 0;
    rep(i,n) {
        if (a[i]<b[i]) {
            cnt_a += (b[i]-a[i]+1)/2;
            cnt_b += (b[i]-a[i])%2;
        } else {
            cnt_b += a[i]-b[i];
        }
    }

    // cout << cnt_a << ' ' << cnt_b << endl;
    if (cnt_a < cnt_b || cnt_a > change) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n = int(input())
num = list(map(int, input().split()))
q = int(input())
change = [0 for i in range(q)]
for i in range(q):
    change[i] = list(map(int, input().split()))

dic = {}
for i in num:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i, j in enumerate(dic):
    ans += j*dic[j]

for i in range(q):
    if change[i][0] in dic:
        ans += dic[change[i][0]] * (change[i][1] - change[i][0])
        if change[i][1] in dic:
            dic[change[i][1]] += dic.pop(change[i][0])
        else:
            dic[change[i][1]] = dic.pop(change[i][0])
    print(ans)

Measured memory_bytes: 37236
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;
	return 0;
}


Measured memory_bytes: 256
#AGC031-B
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
if n%2==0:
    print(n*(n-2)//2)
    for i in range(n):
        for j in range(n):
            if i<j and i+j+2!=1+n:
                print(i+1,j+1)
else:
    print((n-1)*(n-3)//2+n-1)
    for i in range(n-1):
        for j in range(n-1):
            if i<j and i+j+2!=1+n-1:
                print(i+1,j+1)
    for i in range(n-1):
        print(i+1,n)

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

int main() {
  int n;
  scanf("%d", &n);
  map<string, int> c;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    c[s]++;
  }
  printf("AC x %d\n", c["AC"]);
  printf("WA x %d\n", c["WA"]);
  printf("TLE x %d\n", c["TLE"]);
  printf("RE x %d\n", c["RE"]);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

void solve(std::string S)
{
  int cnt = 0;
  rep(i, S.size() / 2)
  {
    if (S[i] != S[S.size() - i - 1])
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}

signed main()
{
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,q;
    int S[100000],T[50000];
    scanf("%d",&n);
    int i;
    for(i=0;i<=n-1;i++)scanf("%d",&S[i]);
    scanf("%d",&q);
    for(i=0;i<=q-1;i++)scanf("%d",&T[i]);
    int ans=0;
    for(i=0;i<=q-1;i++){
        int sta=0,end=n;
        int t=T[i];
        while(sta<end){
            int mid=(sta+end)/2;
            if(t==S[mid]){
                ans++;
                sta=end;
            }else if(t<S[mid]){
                end=mid;
            }else{
                sta=mid+1;
            }
        }
    }
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
int main(){

	int A,B,C,D,P;
	
	cin >> A >> B >> C >> D >> P;
		
	int planX, planY;

	planX = A * P;

	if(C > P)
		planY = B;
	else
		planY = B + D * (P - C);

	if(planX < planY)
		cout << planX << endl;
	else
		cout << planY << endl;

	/*
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;

	int answer;
	if(A < 0){
		answer = -A * C + D + B * E;
	}
	if(A > 0){
		answer = (B - A) * E;
	}
	cout << answer << endl;
	*/

	return 0;
}


Measured memory_bytes: 3080
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]

b = 0
for i in range(m-1):
    if a[i+1] - a[i] == 1:
        b = 1
if b == 1:
    print(0)
else:
    kaidan = [1,2]
    for i in range(2,n):
        kaidan.append(kaidan[i-1]+kaidan[i-2])
    kaidan = [0] + kaidan

    a = [-1] + a + [n+1]
    ans = 1
    for i in range(m+1):
        if a[i+1]-a[i]-2 != 0:   
            ans = ans * kaidan[a[i+1]-a[i]-2]
    print(ans%(10**9+7))

Measured memory_bytes: 477444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
int dp[N], f[N], invf[N], n, a[N];
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        y /= 2;
        x = x * x % mod;
    }
    return res;
}
int c(int n, int k){
    if (k > n || n < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    invf[n] = binpow(f[n], mod - 2);
    for (int i = n - 1; i >= 0; i--) invf[i] = invf[i + 1] * (i + 1) % mod;
    for (int i = 0; i < n; i++){
        a[i] = c(n - 1 - (i + 1), n - 1 - i - (i + 1)) * f[i] % mod * f[n - 1 - i] % mod;
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans = (ans + (a[i] - a[i + 1]) * (n - i - 1)) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 27112
A = list(map(int, input().split()))
line = [[0, 1, 2], [0, 2, 1], [1, 0, 2], 
        [1, 2, 0], [2, 0, 1], [2, 1, 0]]
ans = sum(A)

for i in range(len(line)):
  tmp = 0
  for j in range(1,3):
    tmp += abs(A[line[i][j]] - A[line[i][j-1]])
  ans = min(ans, tmp)
print(ans)
    

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

int main(){
  int n,count;
  string s;
  cin >> n;
  cin >> s;
  for(int i=0;i<n-2;i++){
    if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
      count++;
  }
  cout << count << endl;
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

vector<Vec> tree;
ll n, k;

ll permutation(ll n, ll k){
	ll res = 1;
	rep(i, k){
		res *= n-i;
		res %= MOD;
	}
	return res;
}

void dfs(ll node, ll p, ll &ans){
	if(!node) ans *= permutation(k-1, tree[node].size());
	else ans *= permutation(k-2, tree[node].size()-1);
	ans %= MOD;
	for(ll i : tree[node]) if(i != p) dfs(i, node, ans);
}

int main(void){
	cin >> n >> k;
	tree.resize(n);
	rep(i, n-1){
		ll a, b;
		cin >> a >> b;
		a--, b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}

	ll ans = k;
	dfs(0, 0, ans);
	co(ans);

	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n,k; cin >> n >> k;
	double ans = 0.0;
	rep(i,n){
		int point = i+1;
		double p = 1.0/n;
		while(point<k){
			point *= 2;
			p *= 0.5;
		}
		ans += p;
	}
	cout16 << ans << endl;
}




Measured memory_bytes: 256