akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}

int main(void)
{
    ll n, k, ans;
    cin >> n >> k;
    vector<ll> a(n), s, ord(n+1,-1);
    rep(i,n) cin >> a[i];
    ll c = 1, l = 0;
    {
        ll v = 1; //1スタートなのでordのサイズはn+1
        while(ord[v] == -1){ //未訪問なら続行
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }
    if(k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}


Measured memory_bytes: 8432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << max(0, (H2 * 60 + M2 - K) - (H1 * 60 + M1)) << endl;
  return 0;
}


Measured memory_bytes: 3636
import decimal
INF = decimal.Decimal('Inf')
N = int(input())
h = tuple(map(int, input().split()))
dp = [INF for i in range(N)]
dp[0] = 0
def chmin(lis, i, j):
  if lis[i] > j:
    lis[i] = j

chmin(dp, 1, abs(h[1]-h[0]))
for i in range(2, N):
  chmin(dp, i, dp[i-1] + abs(h[i]-h[i-1]))
  chmin(dp, i, dp[i-2] + abs(h[i]-h[i-2]))

print(dp[N-1])

Measured memory_bytes: 21740
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
//#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int l[100010],r[100010];
bool is_prime(int n){
    for (int i = 2; i*i <=n; i++)
    {
        if(n%i==0){
            return false;
        }
    }
    return true;
    
}
int main(){
    int q;
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        cin>>l[i]>>r[i];
    }
    vector<int>v;
    for (int i = 3; i <=1e5; i++)
    {
        if(is_prime(i) && is_prime((i+1)/2)){
            v.push_back(i);
        }
    }
    #ifdef DEBUG
    for (int i = 0; i < 10; i++)
    {
        cerr<<v[i]<<" ";
    }
    cerr<<endl;
    
    #endif // DEBUG
    
    for (int i = 0; i < q; i++)
    {
        auto u=lower_bound(ALL(v),r[i])-lower_bound(ALL(v),l[i]);
      
        if(binary_search(ALL(v),r[i])){
            u++;
        }
        
        
       
        cout<<u<<endl;

        
    }
    //cout<<"\n";
    

    


    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

ll A[100005];
ll S[100005];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	REP(i, N)
	{
		if (i == 0)S[i] = A[i];
		else S[i] = S[i - 1] + A[i];
	}

	FOR(i, N, 1)
	{
		if (S[N - 1 - i] * 2 < A[N - i])
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int ansarr[100001];
int arr[31][100001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int s,t,c;
        cin>>s>>t>>c;
        arr[c][s]+=1;
        arr[c][t]-=1;
    }
    int ans=0;
    int count=0;

    for(int i=1;i<=k;i++){
        for(int j=0;j<=100000;j++){
            if(arr[i][j]==1){
                ansarr[j-1]+=1;
            }
            else if(arr[i][j]==-1){
                ansarr[j]-=1;
            }
        }
    }

    for(int i=0;i<=100000;i++){
        count+=ansarr[i];
        if(count>ans)
            ans=count;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x;
  cin >> N >> x;
  vector<long long> a(100010);
  for(long long i=0;i<N;i++){cin >> a[i];}
  long long count=0;
  if(a[0]>x){count+=a[0]-x; a[0]=x;}
  for(long long i=1;i<N;i++){
    if(a[i-1]+a[i]>x){
      count+=a[i-1]+a[i]-x;
      a[i]-=a[i-1]+a[i]-x;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main (void){
    int t;
    int h,m,s;
    
    cin >> t;
    
    s = t%60%60;
    m = t/60%60;
    h = t/60/60;
    
    cout << h<<":"<<m<<":"<<s<<endl;
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 3100
#include <iostream>



using namespace std;

int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=0;
	if(k>a)
	{
		k-=a;
		sum+=a;
		if(k>b)
		{
			k-=b;
			sum-=k;
		}
		
	}
	else
	{
		sum=k;
	}
	cout<<sum;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 2010;
struct data {
  int x, y, t;
} a[N];
int d[M][M], n, k;

void add(int lx, int ly, int rx, int ry) {
  if(lx > rx || ly > ry) return ;
  d[lx][ly]++, d[lx][ry + 1]--, d[rx + 1][ly]--, d[rx + 1][ry + 1]++;
}

int hx[N], hy[N];

int main() {
  scanf("%d%d", &n, &k);
  for(int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].x++, a[i].y++;
    char ch;
    cin >> ch;
    if(ch == 'W') a[i].t = 1;
    else a[i].t = 0;
  }
  int base = 2 * k;
  for(int i = 1; i <= n; ++i) {
    int x = a[i].x % k, y = a[i].y % k, t = a[i].t;
    int u = ((a[i].x / k) ^ (a[i].y / k)) & 1;
    hx[1] = k - x, hx[2] = k, hx[3] = x;
    hy[1] = k - y, hy[2] = k, hy[3] = y;
    for(int j = 1; j <= 3; ++j)
      hx[j] += hx[j - 1], hy[j] += hy[j - 1];
    for(int j = 1; j <= 3; ++j) 
      for(int k = 1; k <= 3; ++k) {
        if(((j ^ k ^ u) & 1) == t) {
          add(hx[j - 1] + 1, hy[k - 1] + 1, hx[j], hy[k]);
        }
      }
  }
  int ans = 0;
  for(int i = 1; i <= k * 2; ++i)
    for(int j = 1; j <= k * 2; ++j) { 
      d[i][j] = d[i][j] + d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1];
      ans = max(ans, d[i][j]);
    }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 17152
N, M = map(int, input().split())
switches = []
for i in range(M):
    switches.append(list(map(int, input().split()[1:])))
P = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    P_ = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            for k in range(M):
                if N - j in switches[k]:
                    P_[k] += 1
    for l in range(M):
        P_[l] = P_[l] % 2
    if P_ == P:
        ans += 1
print(ans)

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

 int a=0,b=0,c=0,d=0;
 int l=0,r=0;
   
  cin >> a >> b >> c >> d ;
  l=a+b;
  r=c+d;
  if(l > r){
  	cout << "Left" << endl;
  }else if(l < r){
  	cout << "Right" << endl;
  }else{
  	cout << "Balanced" << endl;
  }
  

}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

#define p2(a, b) cout << a << "\t" << b << endl
#define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl

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

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    std::string a,b;
    cin >> a >> b;
    bool flag = a[0] == b[2] && a[1] == b[1] && a[2] == b[0];
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
char op1,op2,op3 ;
int a,b,c,d;
void slove()
{
	if(a+b+c+d==7){op1='+';op2='+';op3='+';return;}
	if(a+b+c-d==7){op1='+';op2='+';op3='-';return;}
	if(a+b-c+d==7){op1='+';op2='-';op3='+';return;}
	if(a+b-c-d==7){op1='+';op2='-';op3='-';return;}
	if(a-b+c+d==7){op1='-';op2='+';op3='+';return;}
	if(a-b+c-d==7){op1='-';op2='+';op3='-';return;}
	if(a-b-c+d==7){op1='-';op2='-';op3='+';return;}
	if(a-b-c-d==7){op1='-';op2='-';op3='-';return;}
}

int main()
{
int s;
	while(cin>>s)
	{
		d=s%10;
		c=s/10%10;
		b=s/100%10;
		a=s/1000%10;
		slove();
		cout<<a<<op1<<b<<op2<<c<<op3<<d<<'='<<'7';

	}


	return 0;
 }

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

int N, M;
vector<vector<int>> adj;
vector<int> in_degree;
vector<int> depth;
vector<int> parent;

int get_depth(int node) {
    if (depth[node] >= 0)
        return depth[node];

    if (adj[node].empty())
        return depth[node] = 0;

    depth[node] = 0;
    parent[node] = -1;

    for (int p : adj[node])
        if (get_depth(p) + 1 > depth[node]) {
            depth[node] = get_depth(p) + 1;
            parent[node] = p;
        }

    return depth[node];
}

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

    cin >> N >> M;
    adj.assign(N, {});
    in_degree.assign(N, 0);

    for (int i = 0; i < N - 1 + M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[b].push_back(a);
    }

    depth.assign(N, -1);
    parent.assign(N, -1);

    for (int i = 0; i < N; i++) {
        get_depth(i);
        cout << parent[i] + 1 << '\n';
    }
}


Measured memory_bytes: 11392
#include <iostream>
using namespace std;
#include <vector>
#include <functional>
template<class T, class Lazy> struct LazySegTree {
  private:
  public:
    int size;
    vector<T> v; vector<Lazy> lazy;
    vector<int> seg_size;
    using F = function<T(T,T)>;
    using G = function<Lazy(Lazy,Lazy)>;
    using H = function<T(T,Lazy,int)>;
    F f; G g; H h;
    T default_value; Lazy default_lazy;
  public:
    LazySegTree(int n, T default_value, Lazy default_lazy, F f, G g, H h)
      : default_value(default_value), default_lazy(default_lazy), f(f), g(g), h(h) {
      size = 1;
      while (size < n) size *= 2;

      v.resize(2 * size - 1, default_value);
      lazy.resize(4 * size - 1, default_lazy);
      seg_size.resize(2 * size - 1, 1);

      for (int i = 0; i < size - 1; ++i) {
        int j = size - 2 - i;
        seg_size[j] = seg_size[2 * j + 1] + seg_size[2 * j + 2];
      }
    }
    void update(int index, T val) {
      update(index, index+1, default_lazy);
      index = index + size - 1;
      v[index] = val;
      while (index > 0) {
        index = (index - 1) / 2;
        v[index] = f(v[2 * index + 1], v[2 * index + 2]);
      }
    }
    void eval(int index) {
      v[index] = h(v[index], lazy[index], seg_size[index]);

      lazy[2 * index + 1] = g(lazy[index], lazy[2 * index + 1]);
      lazy[2 * index + 2] = g(lazy[index], lazy[2 * index + 2]);

      lazy[index] = default_lazy;
    }
    T query(int l, int r) { return query(l, r, 0, size, 0); }
    T query(int l, int r, int cur_l, int cur_r, int index) {
      // [l, r)に対するクエリ
      eval(index);
      if (cur_r <= l || r <= cur_l) return default_value;
      if (l <= cur_l && cur_r <= r) return v[index];

      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      return f(
          query(l, r, cur_l, mid, 2 * index + 1),
          query(l, r, mid, cur_r, 2 * index + 2));
    }
    void update(int l, int r, Lazy x) { update(l, r, x, 0, size, 0); }
    void update(int l, int r, Lazy x, int cur_l, int cur_r, int index) {
      // [l, r)に対して操作する

      eval(index);
      if (cur_r <= l || r <= cur_l) return;
      if (l <= cur_l && cur_r <= r) {
        lazy[index] = x;
        eval(index);
        return;
      }
      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      update(l, r, x, cur_l, mid, 2 * index + 1);
      update(l, r, x, mid, cur_r, 2 * index + 2);
      v[index] = f(v[2 * index + 1], v[2 * index + 2]);
    }
};

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int in(N); int in(Q);

  // 範囲和
  LazySegTree<long long, long long> T(N, 1e12, 0,
      [](long long a, long long b) {return min(a, b);},
      [](long long a, long long b) {return a + b;},
      [](long long a, long long b, int size) {return a + b;});

  rep(i, N) {
    T.update(i, i+1, -1e12);
    T.query(i, i+1);
  }

  rep(i, Q) {
    int com, s, t;
    ins(com, s, t);
    ++t;

    if (com == 0) {
      int in(x);
      T.update(s, t, x);
    } else
      cout << T.query(s, t) << endl;
  }

  return 0;
}



Measured memory_bytes: 9948
#include <iostream>
#include <vector>
using namespace std;
vector<int>vc[200];
int main() {
    int n , m;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++) {
        int u , v;
        cin >> u >> v;
        vc[u].push_back(v);
        vc[v].push_back(u);
    }
    for(int i = 1 ; i <= n ; i++) {
        cout << vc[i].size() << endl;
    }
    return 0;
}

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

int D;
const int N = 26;

int calc(const vector<int> &C, const vector<vector<int>> &S, vector<int> &T, vector<int> &L) {
    int res = 0;
    for(int d = 0; d < D; ++d) {
        res += S[d][T[d]];
        L[T[d]] = d;
        for(int i = 0; i < N; ++i) {
            res -= C[i] * (d - L[i]);
        }
    }
    return res;
}

int main() {
    cin >> D;
    vector<int> C(N);
    for(int i = 0; i < N; ++i) cin >> C[i];
    vector<vector<int>> S(D, vector<int>(N));
    for(int i = 0; i < D; ++i) {
        for(int j = 0; j < N; ++j) cin >> S[i][j];
    }
    vector<int> T(D);
    for(int i = 0; i < D; ++i) {
        cin >> T[i];
        T[i]--;
    }

    int M;
    cin >> M;
    while(M--) {
        int d, q;
        cin >> d >> q;
        d--, q--;
        vector<int> L(N, -1);
        T[d] = q;
        cout << calc(C, S, T, L) << '\n';
    }
    return 0;
}


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

int vis[3002][3002];
double dp[3002][3002];
double p[3002];
int n;
double coin(int pos,int head)
{
    if(head<0)
        return 0;
    if(pos==0)
    {
        if(head==0)
            return 1;
        else
            return 0;
    }
    if(vis[pos][head])
        return dp[pos][head];
    vis[pos][head]=1;
    return dp[pos][head]=p[pos]*coin(pos-1,head-1)+(1-p[pos])*coin(pos-1,head);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    double tot=0;
    for(int head=0;head<=n;head++)
    {
        int tail=n-head;
        if(head>tail)
            tot+=coin(n,head);
    }
    printf("%.9lf\n",tot);
}


Measured memory_bytes: 105124
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S,T; cin >> S >> T;
  int c = S.size() + T.size() ; string U;
  for(int i = 0; i < c; i++){ 
    if( i % 2 == 0){ U.push_back(S[i/2]);}
    else{ U.push_back(T[(i-1)/2]);}}
  
  cout << U << endl;
  
  return 0;}

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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

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

    return true;
}

inline void solve() {
    LL n, d;
    cin >> n >> d;

    int res = 0;

    LL x, y;

    REP(i, n) {
        cin >> x >> y;

        if (x * x + y * y <= d * d) {
            res++;
        }
    }

    cout << res << endl;
}


int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t;
    t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


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

int calc(int n) {

    int ans = 0;
    for (int i = 1; ; i++) {
        if (n >= i) ans++, n -= i;
        else break;
    }
    return ans;
}

void solve() {

    ll n;
    scanf("%lld", &n);

    int ans = 0;
    for (int i = 2; 1LL*i*i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) n /= i, cnt++;
            ans += calc(cnt);
        }
    }
    if (n != 1) ans++;
    printf("%d\n", ans);

}

int main(){
    solve();

	return 0;
}


Measured memory_bytes: 3828
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;

  auto nc = s.count('N');
  auto wc = s.count('W');
  auto sc = s.count('S');
  auto ec = s.count('E');
  auto f = true;
  if ((!nc && sc) || (nc && !sc)) {
    f = false;
  }
  if ((!wc && ec) || (wc && !ec)) {
    f = false;
  }
  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	fixed(cout);
	cout << setprecision(13);
	long a, l, x;
	while (cin >> a >> l >> x) {
		double h_1 = sqrt(l * l - a * a / 4.0);
		double h_2 = sqrt((x + l) * (x + l) / 4.0 - l * l / 4.0);
		cout << a * h_1 / 2 + l * h_2 << endl;
	}

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> odd,even;
    rep(i,N){
        int v;
        cin >> v;
        if(1&i) odd.push_back(v);
        else even.push_back(v);
    }
    //最頻値を取り出す
    int odd_mode1 = 0,odd_mode2 = 0,even_mode1 = 0,even_mode2 = 0;
    map<int,int> mapo,mape;
    rep(i,N/2){
        mapo[odd[i]]++;
        if(mapo[odd_mode1] < mapo[odd[i]]){   
            odd_mode2 = odd_mode1;
            odd_mode1 = odd[i];
        }
        if(odd_mode1 != odd[i] && mapo[odd_mode2] < mapo[odd[i]]){
            odd_mode2 = odd[i];
        }

        mape[even[i]]++;
        if(mape[even_mode1] < mape[even[i]]){
            even_mode2 = even_mode1;
            even_mode1 = even[i];
        }
        if(even_mode1 != even[i] && mape[even_mode2] < mape[even[i]]){
            even_mode2 = even[i];
        }
    }
    int res = 0;
    if(odd_mode1 == even_mode1){
        res = min(N-mapo[odd_mode1]-mape[even_mode2],N-mapo[odd_mode2]-mape[even_mode1]);
    }else{
        res = (N/2 - mapo[odd_mode1]) + (N/2 - mape[even_mode1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <queue>
using namespace std;

stack<char> S;
queue<int> Q;
stack<int> Slast;

void calc_area(int *total, bool last) {
    int sum = 0;
    int depth = 0;
    while (!S.empty()) {
        bool end = false;
        switch (S.top()) {
            case '\\':
                if (depth > 0) {
                    depth--;
                    sum += depth * 2 + 1;
                    if (depth == 0) {
                        if (last) {
                            Slast.push(sum);
                        }
                        else {
                            Q.push(sum);
                        }
                        *total += sum;
                        sum = 0;
                    }
                }
                break;
            case '/':
                depth++;
                sum += depth * 2 - 1;
                break;
            case '_':
                if (depth > 0) {
                    sum += depth * 2;
                }
                break;
        }
        S.pop();
    }

}

int main (void) {

    char c;
    int depth = 0;
    int total = 0;
    int sum = 0;

    while (scanf("%c", &c) != EOF) {
        switch (c) {
            case '/':
                if (depth > 0) {
                    depth--;
                    S.push(c);
                    if (depth == 0) {
                        calc_area(&total, false);
                    }
                }
                break;
            case '\\':
                depth++;
                S.push(c);
                break;
            case '_':
                if (depth > 0) {
                    S.push(c);
                }
                break;
            case '\n':
                if (depth != 0) {
                    calc_area(&total, true);
                }
                printf("%d\n", total/2);
                printf("%d", int(Q.size() + Slast.size()));
                while (!Q.empty()) {
                    printf(" %d", Q.front()/2);
                    Q.pop();
                }
                while (!Slast.empty()) {
                    printf(" %d", Slast.top()/2);
                    Slast.pop();
                }
                printf("\n");
                return 0;
            default:
                printf("Invalid charactor!!\n");
                return 1;
        }
    }
}



Measured memory_bytes: 2848
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    if (a > b) {
        REP(i, a) cout << b;
        cout << endl;
        return 0;
    }
    REP(i, b) cout << a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import sys
input = sys.stdin.readline

inf = float('inf')

def main():
    A, B, Q = list(map(int, input().split()))
    ls = [-inf] + [int(input()) for _ in range(A)] + [inf]
    lt = [-inf] + [int(input()) for _ in range(B)] + [inf]
    lx = [(int(input()), i) for i in range(Q)]
    ls.sort()
    lt.sort()
    lx.sort()
    ans = {}
    s = 1
    t = 1
    for i in range(Q):
        dist = -1
        x = lx[i][0]
        while s <= A and ls[s] < x:
            s += 1
        while t <= B and lt[t] < x:
            t += 1
        s_min = ls[s-1]
        s_max = ls[s]
        t_min = lt[t-1]
        t_max = lt[t]
        d = min(max(s_max-x, t_max-x),
                (s_max-x)*2 + (x-t_min),
                (t_max-x)*2 + (x-s_min),
                (s_max-x) + (x-t_min)*2,
                (t_max-x) + (x-s_min)*2,
                max(x-s_min,x-t_min))
        ans[lx[i][1]] = d
    for i in range(Q):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 36620
n=gets.to_i
line=gets.chomp.split().map(&:to_i)
answer=0
kari=0
line.each_cons(2) do |a, b|
  if a >= b
    kari +=1
    answer=[answer,kari].max
  else  
    answer=[answer,kari].max
    kari=0
  end  
end
puts answer

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

int v[2][200010], res[200010];

int f(int n)
{
    int res=0;
    while (n>0) {
        n%=__builtin_popcount(n);
        ++res;
    }
    return res;
}

int main()
{
    int n; cin>>n;
    string x; cin>>x;
    int d=count(begin(x), end(x), '1');

    for(int i=0; i<1+(d>1); ++i) {
        v[i][0]=1;
        for(int j=0; j<n; ++j)
            v[i][j+1]=v[i][j]*2%(i ? d-1 : d+1);
    }

    int r0=0,r1=0;
    for(auto& c: x) r0=(r0*2+(c-'0'))%(d+1);
    if (d>1) for(auto& c: x) r1=(r1*2+(c-'0'))%(d-1);
    reverse(begin(x), end(x));
    for(int i=0; i<n; ++i) {
        char& c=x[i];
        if (c=='0') {
            int t=(r0+v[0][i])%(d+1);
            res[i]=f(t)+1;
        }
        else {
            if (d>1) {
                int t=(r1-v[1][i]+d-1)%(d-1);
                res[i]=f(t)+1;
            }
        }
    }
    reverse(res, res+n);
    for(int i=0; i<n; ++i) cout<<res[i]<<'\n';
}


Measured memory_bytes: 6040
# include <bits/stdc++.h>
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.begin(),vc.end()
# define  pi            pair <long, long>
# define  long          long long
# define  pb            push_back
# define  p_f           pop_front
# define  p_b           pop_back
# define  se            second 
# define  vec           vector
# define  dob           double
# define  flo           float
# define  fi            first 
# define  a_b_c_d_e     queue
# define  a_b_c_d_q     cout
# define  a_b_c_d_m     set
# define  a_b_c_d_z     cin 
# define  qa_qa_qa      map
using namespace std;
int main()
{
        //* Author: ~{ Oriyon }~
        //* Codeforces is the best !!!
        long test = 1;
        //cin >> test;
        for (int hello = 1; hello <= test; hello += 1)
        {
                long Qwert = 0, Qwerty = 0, Qwertyu, Qwerytyu;
                long n;
                cin >> n;
                vector <long> v(n);
                long ans = 0;
                for (int i = 0; i < n; ++i){
                    cin >> v[i];
                }
                vector <long> dp(n, 0);
                dp[0] = v[0];
                for (int i = 1; i < n; ++i){
                    dp[i] += dp[i - 1] + v[i];
                    dp[i] %= 1000000007;
                }
                for (int i = 1; i < n; ++i){
                    ans += dp[i - 1] * v[i];
                    ans %= 1000000007;
                }
                cout << ans;
        }   
        /*
        5
        2 3 5 7 11
        */
}
/*
*   👍&&👍&&👍&&👍
*   ||||||||||||||        HELLO WORLD !!!
*   👊&&👊&&👊&&👊
*/



Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
#define cppio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;

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

const int maxn=1e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

int main(){
	int n;
	scanf("%d",&n);
	printf("%d",n==1?0:1);
	return 0;
}


Measured memory_bytes: 3740
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, m;
long w[105], v[105];
long dp[105][100005];

int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%ld%ld", &w[i], &v[i]);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			dp[i][j] = std::max(dp[i-1][j], dp[i][j-1]);
			if(j >= w[i]){
				dp[i][j] = std::max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
			}
		}
	}
	printf("%ld\n", dp[n][m]);
	return 0;
}


Measured memory_bytes: 79360
n = int(input())
b = list(map(int,input().split()))

ret = 0

for i in range(n):
    if i == 0:
        ret += b[i]
    elif i == (n-1):
        ret += b[n-2]
    else:
        ret += min(b[i],b[i-1])

print(ret)

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

int main() {
	int s,t,count=0;
	
	cin>>s;
	vector <int> sset(s);
	for(int i=0;i<s;i++){
		cin >> sset[i];
	}
	cin>>t;
	vector <int> tset(t);
	for(int i=0;i<t;i++){
		cin >> tset[i];
	}
	
	for(int i=0;i<t;i++){
		for(int j=0;j<s;j++){
			if(sset[j]==tset[i]){
				count++;
				break;
			}	
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int a[n],b[n];
        for(int i=0;i<n;i++)cin>>a[i]>>b[i];
        int ok = 0;
        for(int i=0;i+2<n;i++)ok |= (a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]);
        cout<<(ok ? "Yes" : "No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
package main

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

func solve() {
	n, k := getInt(), getInt()
	as := getIntSlice(n)

	var cntAllPattern = (k * (k - 1) / 2) % mod
	ans := 0
	for i, a1 := range as {
		x, y := 0, 0
		for j, a2 := range as {
			if a1 > a2 {
				y++
				if i < j {
					x++
				}
			}
		}
		x, y = x%mod, y%mod
		ans = (ans + (x*k)%mod) % mod
		ans = (ans + (y*cntAllPattern)%mod) % mod
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,x,y,z;
    cin>>x>>y>>z;
    n = x+y+z;
    array<ll,2> t[n];
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
        t[i] = {c[i] - b[i], i};
    }
    sort(t,t+n);
    ll ans = 0;
    ll l[n+1]={},r[n+1]={};
    priority_queue<ll> pq;
    ll now = 0;
    for(int i=0;i<n;i++){
        pq.push(a[t[i][1]] - b[t[i][1]]);
        now += b[t[i][1]];
        if(i < y){
            l[i] = now;
        }
        else{
            now += pq.top();
            pq.pop();
            l[i] = now;
        }
    }  
    while(pq.size())pq.pop();
    now = 0;
    for(int i=0;i<n;i++){
        pq.push(a[t[n-1-i][1]] - c[t[n-1-i][1]]);
        now += c[t[n-1-i][1]];
        if(i < z){
            r[i] = now;
        }
        else{
            now += pq.top();
            pq.pop();
            r[i] = now;
        }
    }
    for(int i=0;i<=x;i++){
        chmax(ans,l[y-1+i]+r[z-1+(x-i)]);
    }
    cout << ans << endl;
}

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

int main(void)
{
    long long X;
    cin >> X;

    if (400 <= X && X <= 599)
    {
        cout << 8 << endl;
        exit(0);
    }

    else if (600 <= X && X <= 799)
    {
        cout << 7 << endl;
        exit(0);
    }

    else if (800 <= X && X <= 999)
    {
        cout << 6 << endl;
        exit(0);
    }

    else if (1000 <= X && X <= 1199)
    {
        cout << 5 << endl;
        exit(0);
    }

    else if (1200 <= X && X <= 1399)
    {
        cout << 4 << endl;
        exit(0);
    }

    else if (1400 <= X && X <= 1599)
    {
        cout << 3 << endl;
        exit(0);
    }

    else if (1600 <= X && X <= 1799)
    {
        cout << 2 << endl;
        exit(0);
    }

    else if (1800 <= X && X <= 1999)
    {
        cout << 1 << endl;
        exit(0);
    }
}

Measured memory_bytes: 3672
#include <algorithm>
#include <atcoder/all>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

using mint = atcoder::modint998244353;

int cnt[110000];
mint factorial[220000];
mint inv_factorial[220000];
mint perfect[220000];
mint two_pow[220000];
vector<vector<mint>> polynomials[220000];

mint nCk(int n, int k)
{
    if (k < 0 || n < k)
        return 0;
    return factorial[n] * inv_factorial[k] * inv_factorial[n - k];
}

int main()
{
    factorial[0] = 1;
    perfect[0] = 1;
    two_pow[0] = 1;
    for (int i = 1; i < 220000; i++) {
        factorial[i] = factorial[i - 1] * i;
        perfect[i] = perfect[i - 1] * (2 * i - 1);
        two_pow[i] = two_pow[i - 1] * 2;
    }
    inv_factorial[220000 - 1] = factorial[220000 - 1].inv();
    for (int i = 220000 - 1; i > 0; i--) {
        inv_factorial[i - 1] = inv_factorial[i] * i;
    }

    int n;
    cin >> n;
    for (int i = 0; i < n * 2; i++) {
        int h;
        cin >> h;
        cnt[h]++;
    }
    mint odd = 0, even = 1;

    for (int h = 0; h < 110000; h++) {
        int c = cnt[h];
        if (c == 0)
            continue;
        vector<mint> polynomial;
        for (int k = 0; k * 2 <= c; k++) {
            polynomial.push_back(nCk(c, 2 * k) * perfect[k]);
        }
        polynomials[polynomial.size()].push_back(polynomial);
    }
    vector<mint> poly;
    for (int d = 2; d <= n + 10; d++) {
        for (int i = 0; i < polynomials[d].size(); i++) {
            if (poly.empty())
                poly = polynomials[d][i];
            else {
                auto new_poly = atcoder::convolution(poly, polynomials[d][i]);
                polynomials[new_poly.size()].push_back(move(new_poly));
                poly.clear();
            }
        }
    }
    if (poly.empty())
        poly = {1};
    mint ans = 0;
    for (int i = 0; i < poly.size(); i++) {
        mint cnt = poly[i] * perfect[n - i];
        if (i % 2 == 0)
            ans += cnt;
        else
            ans -= cnt;
    }
    cout << ans.val() << endl;
}

Measured memory_bytes: 18876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  string t;
  cin >> t;
  int n, w, s, e;
  n = t.find('N');
  w = t.find('W');
  s = t.find('S');
  e = t.find('E');
  if ((n == -1 && s != -1) || (s == -1 && n != -1) || (w == -1 && e != -1) || (e == -1 && w != -1)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll n;
ll a[20][20];
ll p[(1<<16)+20];
ll dp[(1<<16)+20];
ll vis[(1<<16)+20];

ll f(ll x){
	ll &r=dp[x];
	if(vis[x])return r;
	vis[x]=1;
	if(x==0){
		r=0; return r;
	}
	r=0;
	for(int s=x;s;s=(s-1)&x){
		r=max(r,p[s]+f(x^s));
	}
	return r;
}

int main(){FIN;
	cin>>n;
	fore(i,0,n){
		fore(j,0,n){
			cin>>a[i][j];
		}
	}
	fore(i,0,1<<n){
		fore(j,0,n){
			fore(jj,j,n){
				if((i&(1<<j))&&(i&(1<<jj))){
					p[i]+=a[j][jj];
				}
			}	
		}
	}
	//fore(i,0,1<<n)cout<<p[i]<<" ";
	cout<<f((1<<n)-1);
	
	return 0;
}

Measured memory_bytes: 1792
S=input()
# Python3 program to Split string into characters 
def split(word): 
    return [char for char in word]  
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
      
      
# Driver code 
word = S
splits=split(S)
Q=int(input())
flipcounter=0
prestring=[]
poststring=[]
for i in range(0,Q):
  inputforround=input()
  if inputforround=='1':
    flipcounter=flipcounter+1
  else:
    T,F,C=map(str,inputforround.split())
    if (int(F)+flipcounter)%2==1:
      prestring.append(C)
    else:
      poststring.append(C)

prestring.reverse()
for j in splits:
  prestring.append(j)
for k in poststring:
  prestring.append(k)
if flipcounter%2==1:
  prestring.reverse()
ans=convert(prestring)
print(ans)

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n,k;
 cin>>n>>k;
 if(n%k==0)
 cout<<"0"<<endl;
 else
 {
 	long long int x,y;
 	x=n%k;
 	y=k-x;
 	cout<<min(x,y)<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

S,d=gets.chomp.split(' ').map{|n| n}
K,d=gets.chomp.split(' ').map{|n| n.to_i}
list = []
len = S.size
0.upto(len-1){|i|
	i.upto(i+K){|j|
		str = S[i..j]
		list <<str
	}
}
list = list.uniq
# dpp list.sort
puts list.sort[K-1]


Measured memory_bytes: 5864
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
To compute x^y under modulo mod
int power(int x,unsigned int y){
    if(y==0)return 1;
    int p=power(x,y/2,m)%mod;
    p=(p*p)%mod;
    return(y%2==0)?p:(x*p)%mod;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    string s;
    cin>>s;
    int n=s.length();
    int cnt=0;
    rep(i,0,n/2){
    	if(s[i]!=s[n-i-1])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
n = int(input())
in_list = list(map(int,input().split()))
in_list.sort()
count = 0
for i in range(0, n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if in_list[i]!=in_list[j] and in_list[j]!=in_list[k]:
                if in_list[i]+in_list[j]>in_list[k]:
                    count += 1
                    

print(count)

Measured memory_bytes: 9188
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(long n, long a, long b) {
    long diff = b - a;
    if (diff % 2 == 0) {
      return diff / 2;
    }
    return Math.min(a + diff / 2, n - b + 1 + diff / 2);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long n = reader.nextLong();
    long a = reader.nextLong();
    long b = reader.nextLong();
    out.println(solve(n, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int change_suji( string str ){
  int i,len = str.size();
  int result = 0,kakeru = 1;
  for( i = len - 1; i >= 0; i-- ){
    result += kakeru * (str[i] - '0');
    kakeru *= 10;
  }
  return result;
}

string change_moji( int n ){
  string str;
  while(n){
    str += (n % 10) + '0';
    n /= 10;
  }
  reverse( str.begin(),str.end() );
  return str;
}

int main(){
  string str,moji;
  int i,L,max_suji,min_suji,cycle,memo[22],tmp,tmp_cnt,flag,tmp_suji;
 
  while(1){
    flag = 0;
    cin >> str >> L;
    if( str == "0" && L == 0 ) break;
    for( i = 0; i < 21; i++ ) memo[i] = 0;
    int cnt = 0;
    memo[0] = change_suji(str);    
    while(1){
      // cnt++;
      int len = str.size();
      if( L - len > 0 ){
	for(i = 1; i <= L-len; i++ ){
	  str+='0';
	}
      }
    
      sort( str.begin(), str.end() );
      reverse( str.begin(), str.end() );
      max_suji = change_suji(str);
  
      reverse( str.begin(), str.end() );
      min_suji = change_suji(str);
  
      cycle = max_suji - min_suji;
      cnt++;     
    
     
      for( i = cnt-1; i >= 0; i-- ){
	if( cycle == memo[i] ){
	  //  cout << "i" << i << " " << cycle << " " << memo[i] << endl;
	  tmp = i;
	  tmp_cnt = cnt - i;
	  tmp_suji = memo[i];
	  flag = 1;
	  break;
	}
      }
      if( flag == 1 ) break;
      memo[cnt] = cycle;   
      moji = change_moji(cycle);
        
      str = moji;
     
    }
    cout << tmp << " " << tmp_suji << " " << tmp_cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
// 解説動画視聴後に解答

// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
    
// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
    
fn main() {
    let a_b_x: Vec<f64> = read_vec();
    let side_length  = a_b_x[0];
    let box_height   = a_b_x[1];
    let water_volume = a_b_x[2];
    let result_degree: f64;
    let theta: f64;

    // 垂直状態で実際に入っている水を容器の横から見たときの面積
    let water_area: f64 = water_volume / side_length;
    // 横から見たときの容器の面積
    let box_area: f64 = side_length * box_height;
    // こぼれる寸前まで傾けた時に、容器の横から見たときの水が入っていない部分の面積
    let blank_area: f64 = box_area - water_area;
    
    // 場合分け
    if water_area >= box_area / 2.0
    {
        // こぼれる寸前まで傾けた時における、直角三角形の辺の高さ
        let height: f64 = (blank_area * 2.0) / side_length;

        // こぼれる寸前の角度
        theta = (height / side_length).atan();
    }
    else
    {
        // こぼれる寸前まで傾けた時における、直角三角形の辺の幅
        let width: f64 = (water_area * 2.0) / box_height;

        // こぼれる寸前の角度
        theta = (box_height / width).atan();
    }

    // ラジアン => 度数法
    result_degree = (theta / (std::f64::consts::PI * 2.0)) * 360.0;
    println!("{}", result_degree);
}


Measured memory_bytes: 4352