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

int main() {
  int N, A, b, i, j;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A;
    for (j = 0; !(A % 2); j++) {
      A /= 2;
    }
    if (!i || j < b) b = j;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
int main(){
    ll a,b;cin>>a>>b;
    ll x,y;
    extGCD(a,b,x,y);
    cout<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 3116
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 0, 0, -1, 1 };
vi yy = { -1, 1, 0, 0 };
string dir = "LRUD";

const int N = 3e5 + 50, oo = 3e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-9, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);



signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/
	//ПРОВЕРЯЙ ДЕФАЙНЫ ТУПОЙ!!!

	string s;
	cin >> s;

	if (s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8')
	{
		cout << "pon";
	}
	else
	{
		if (s.back() == '3')
		{
			cout << "bon";
		}
		else
		{
			cout << "hon";
		}
	}
}

Measured memory_bytes: 19000
n, m = gets.split.map(&:to_i)
a = Array.new(n)
b = Array.new(m)
for i in 0..n-1 do
	a[i] = gets.split.map(&:to_i)
end
for i in 0..m-1 do
	b[i] = gets.to_i
end
c = Array.new(n, 0)
for i in 0..n-1 do
	for j in 0..m-1 do
		c[i] += a[i][j] * b[j]
	end
	puts c[i]
end

Measured memory_bytes: 8912
n = int(input())
a = list(map(int, input().split()))

odd_pattern = [1 if A&1 else 2 for A in a]
all_odd = 1
for p in odd_pattern:
    all_odd *= p
# 全パターン数 - すべてが奇数となるパターン数
print(3**n - all_odd)

Measured memory_bytes: 9188
import sys
import random
import time
my_input = sys.stdin.readline

start = time.time()
D = int(input())
C = list(map(int, my_input().split()))
S = [list(map(int, my_input().split())) for _ in range(D)]


def main():
    cnt = 0
    best_ans, best_score = generate_first_ans()
    while time.time() - start < 1.82:
        cnt += 1
        ans = best_ans[:]

        x = random.random()
        if x > 0.35:
            si, sj = random.randint(0, 364), random.randint(0, 364)
            if si == sj:
                continue
            ans[si], ans[sj] = ans[sj], ans[si]
        else:
            si = random.randint(0, 364)
            sx = random.randint(0, 25)
            if ans[si] == sx:
                continue
            ans[si] = sx

        score = calc_score(ans)
        if score > best_score:
            best_score = score
            best_ans = ans

    #print(best_score, cnt)
    for a in best_ans:
        print(a + 1)


def generate_first_ans():
    best_ans = []
    best_score = 0
    last_day = [-1] * 26
    for d in range(365):
        d_ans = -1
        d_score = -float('inf')
        d_last_day = [-1] * 26
        for t in range(26):
            d_tmp_score = 0
            d_tmp_score += S[d][t]
            d_tmp_last_day = last_day[:]
            d_tmp_last_day[t] = d
            for c, ld in zip(C, d_tmp_last_day):
                d_tmp_score -= c * (d - ld)

            if d_tmp_score > d_score:
                d_ans = t
                d_score = d_tmp_score
                d_last_day = d_tmp_last_day[:]

        best_ans.append(d_ans)
        best_score += d_score
        last_day = d_last_day[:]

    return best_ans, best_score


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


if __name__ == "__main__":
    main()


Measured memory_bytes: 83864
import math

A, B = map(int, input().split())
min = B * 10
max = B * 10 + 9
flag = False
for i in range(min, max + 1):
    temp = math.floor(i * 0.08)
    if (temp == A):
        flag = True
        ans = i
        break
if flag:
    print(ans)
else:
    print('-1')
    

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
        int n = sc.nextInt();
        int p[] = new int[n];
        for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
        if(n == 0){
        	System.out.println(x);
            return;
        }
        for(int i = 0; i < n; i++){
        	int countm = 0;
            int countp = 0;
            for(int j = 0; j < n; j++){
            	if(x - i != p[j]){
                	countm++;
                }
                if(x + i != p[j]){
                	countp++;
                }
            }
            if(countm == n){
            	System.out.println(x - i);
                return;
            }else if(countp == n){
            	System.out.println(x + i);
                return;
            }
        }
        System.out.println(x - 1);
    }
}

Measured memory_bytes: 35724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  ll N, K;
  get(N, K);
  vector<vector<int>> G(N);
  FOR(i, N - 1) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  int leave;
  FOR(i, N) {
    if (G[i].size() == 1) {
      leave = i;
      break;
    }
  }
  ll ans = K;
  queue<int> q;
  vector<bool> visited(N);
  vector<int> passed(N);
  vector<ll> dp(N);
  dp[leave] = K;
  q.push(leave);
  visited[leave] = 1;
  vector<int> pre(N);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int x : G[v]) {
      if (!visited[x]) {
        q.push(x);
        ans = ans * max(0LL, (K - 1 - (v != leave) - pre[v])) % MOD;
        visited[x] = 1;
        pre[v]++;
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 8056
#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, M, Q; cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    REP(i, 0, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];

    ll ans = 0;
    vector<int> S(N, 1);
    while (1) {
        // for (auto s : S) cout << s << " ";
        // cout << endl;
        ll sum = 0;
        REP(i, 0, Q) {
            if (S[B[i] - 1] - S[A[i] - 1] == C[i]) sum += D[i];
        }
        ans = max(ans, sum);

        S.back()++;
        bool e = false;
        for (int i = N - 1; i >= 0; i--) {
            if (S[i] > M) {
                int end = -1;
                for (int j = i - 1; j>= 0; j--) {
                    S[j]++;
                    if (S[j] <= M) {
                        end = j;
                        break;
                    }
                }
                if (end == -1) e = true;
                for (int j = end + 1; j < N; j++) S[j] = S[end];
            }
        }
        if (e) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
def prime_factorize(n):
    i = 2
    res = {}
    while i * i <= n:
        if n % i != 0:
            i += 1
            continue
        res[i] = 0
        while n % i == 0:
            res[i] += 1
            n //= i
        i += 1
    if n != 1:
        res[n] = 1
    return res


n = int(input())
aaa = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm_ppf = prime_factorize(aaa[0])
for a in aaa[1:]:
    for p, c in prime_factorize(a).items():
        if p in lcm_ppf:
            lcm_ppf[p] = max(lcm_ppf[p], c)
        else:
            lcm_ppf[p] = c

lcm = 1
for p, c in lcm_ppf.items():
    lcm = lcm * pow(p, c, MOD) % MOD
# print(lcm)

ans = 0
for a in aaa:
    ra = pow(a, MOD - 2, MOD)
    ans = (ans + lcm * ra) % MOD
print(ans)


Measured memory_bytes: 4580
#include <iostream>

using namespace std;

int main() {
	int i, j, n, numbers[100];

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> numbers[i];
	}

	i--;

	for (j = i; j >= 0; j--) {
		if (j != i) cout << " ";
		cout << numbers[j];
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, H) = Read2Longs();
            var a = new long[N];
            var b = new long[N];
            for (var i = 0; i < N; i++)
            {
                (a[i], b[i]) = Read2Longs();
            }
            var amax = a.Max();
            var count = 0;
            foreach(var p in b.Where(x => x >= amax).OrderByDescending(x => x))
            {
                count++;
                H -= p;
                if(H <= 0)
                {
                    return count;
                }
            }
            while(H > 0)
            {
                count++;
                H -= amax;
            }
            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 50836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int k;
    cin>>k;
    vector<int> ans;
    ans.push_back(1);
    ans.push_back(2);
    if(k<11){
        cout<<k<<endl;
        return 0;
    }
    int lun=2;
    rep(i,k-12){
        
        bool flag=true;
        for(int i=lun-1;i>0;i--){
            if(ans[i]==9)continue;
            if(ans[i-1]-ans[i]>-1){
                ans[i]++;
                for(int x=i+1;x<lun;x++) ans[x]=max(0,ans[x-1]-1);
                flag = false;
                break;
            }
        }
        if(flag){
            if(ans[0]==9){
                ans[0]=1;
                for(int a=1;a<lun;a++){
                    ans[a]=0;
                }
                ans.push_back(0);
                lun++;
            }
            else{
                ans[0]++;
                for(int a=1;a<lun;a++){
                    ans[a]=max(0,ans[a-1]-1);
                }
            }
        }
    // for(auto x:ans){
    //     cout<<x;
    // }
    // cout<<endl;
    }
    
    for(auto x:ans){
        cout<<x;
    }
    cout<<endl;
}


Measured memory_bytes: 3564
#include<stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int n,i,x;
  int A[MAX];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  x = partition(A,0,n-1);

  for(i = 0;i < n-1;i++){
    if(i == x) printf("[%d] ",A[i]);
    if(i != x) printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}

int partition(int *A,int p,int r)
{
  int x,i,j,tmp;
  x = A[r];
  i = p-1;

  for(j = p;j <= r-1;j++){
    if(A[j] <= x){
      i = i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}

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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

vector<vector<ll>> rolling_hash(string s, int l, char st='0') {
  ll m1 = pow(10,9)+7, m2 = 998244353, mul = pow(10,5);
  ll tm1 = 1, tm2 = 1; rep(i,l) { tm1 = (tm1*mul)%m1; tm2 = (tm2*mul)%m2; }
  vector<vector<ll>> result;
  ll n1 = 0, n2 = 0;
  if (s.size()>=l) {
    rep(i,s.size()-l+1) {
      if (i==0) rep(i,l) { n1 = (n1*mul+(s[i]-st))%m1; n2 = (n2*mul+(s[i]-st))%m2; }
      else { n1 = ((n1*mul-tm1*(s[i-1]-st)+(s[i+l-1]-st))%m1+m1)%m1; n2 = ((n2*mul-tm2*(s[i-1]-st)+(s[i+l-1]-st))%m2+m2)%m2; }
      result.push_back((vector<ll>){n1,n2});
    }
  }
  else cout << "error: s.length()<l" << endl;
  return result;
}

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

vector<int> adj, len;

int dfs(int n, int p=-1) {
  if (len[n]!=-1) return len[n];
  if (n==p) return len[n] = INF;
  if (adj[n]==-1) return len[n] = 0;
  else return len[n] = min(INF, dfs(adj[n],(p==-1?n:p))+1);
}

int main() {
  string s, t; cin >> s >> t;
  int sl = s.length(), tl = t.length();
  string ts = s; rep(i,(tl+(sl-1))/sl+1) s += ts;

  vector<vector<ll>> rhs = rolling_hash(s,tl,'a'); rhs.resize(sl);
  vector<ll> rht = rolling_hash(t,tl,'a')[0];
  // for (auto x: rhs) debug(all(x));
  // debug(all(rht));

  adj.resize(sl,-1); len.resize(sl,-1);
  rep(i,sl) if (equal(all(rhs[i]),all(rht))) adj[i] = (i+tl)%sl;
  rep(i,sl) dfs(i);
  // debug(all(len));

  int result = 0; rep(i,sl) result = max(result,len[i]);
  if (result==INF) result = -1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 93308
n,x,m = map(int,input().split())
mod = m
num = []
ans = 0
cnt = 0
ch = x

#ループの始まりを特定
while True:
    if ch not in num:
        num.append(ch)
    else:
        st = ch #ループの開始している配列の初めの数字
        break
    ch *= ch
    ch %= mod

#ループの始まりの配列の添え字を特定
for i in range(len(num)):
    if num[i] == st:
        stnum = i #ループ開始の最初の配列のの番号
        break
else:
    stnum = len(num) - 1


if 0 in num:
    ans = sum(num[:n])
else:
    if (len(num)-stnum) != 0:
        rest = (n-stnum)%(len(num)-stnum) #余り
        qu = (n-stnum)//(len(num)-stnum)  #商
    else:
        rest = n
        qu = 0
    if n <= stnum + 1:
        ans = sum(num[:n])
    else:
        ans = sum(num[:stnum]) + sum(num[stnum:stnum+rest]) + sum(num[stnum:])*qu
print(ans)

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

int p[246913];
bool is_prime[246913];
int prime(int n){
	int sum = 0;
	for(int i=0;i<=2*n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=2*n;i++){
		if(is_prime[i] == true){
			p[sum++] = i;
		}
		for(int j=i+i;j<=2*n;j+=i){
			is_prime[j] = false;
		}
	}
	return sum;
}

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int ans = 0;
		int a = prime(n);
		for(int i=0;i<a;i++){
			if(p[i] > n && p[i] <= 2*n)
				ans++;
		}
		cout << ans << endl;
	}
	return 0;
}
	

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  char op; //文字にする
  while(true){
    cin >> a >> op >> b;
    if(op == '+'){
       cout << (a+b) << endl;
    }
    else if(op == '-'){
       cout << (a-b) << endl;
    }
    else if(op == '*'){
       cout << (a*b) << endl;
    }
    else if(op == '/'){
       cout << (a/b) << endl;
    }
    else{
        break;
        cout << endl;
    }
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	char a;
  int ans=0;
	while(1){
		scanf("%c",&a);
    while(a != '\n'){
      ans += a - '0';
      scanf("%c",&a);
    }
		if(ans==0)
      break;
    else{
      printf("%d\n",ans);
      ans = 0;
    }
	}
}


Measured memory_bytes: 3196
n,a = map(int,input().split())
x = [int(i) for i in input().split()]

sum_x = sum(x)

dp = [[[0 for i in range(n+1)]for j in range(sum_x+1)]for k in range(n+1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(sum_x+1):
            dp[i+1][k][j] += dp[i][k][j]
            if k + x[i] > sum_x:
                continue
            dp[i+1][k+x[i]][j+1] += dp[i][k][j]
            
ans = 0

for i in range(n):
    if a*(i+1) > sum_x:
        break
    ans += dp[n][a*(i+1)][i+1]

print(ans)

Measured memory_bytes: 111964
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

#define int long long

using namespace std;

void Main()
{
	int N;
	cin >> N;
	map<vector<int>, int> array_num;
	vector<string> s(N);

	for (int i = 0; i < N; i++) {
		string si;
		cin >> si;
		vector<int> s_arr(26, 0);
		for (int i = 0; i < si.size(); i++) {
			s_arr[si[i] - 'a']++;
		}
		array_num[s_arr]++;
	}

	int ans = 0;
	for (auto itr = array_num.begin(); itr != array_num.end(); itr++) {
		ans += itr->second * (itr->second - 1) / 2;
	}

	cout << ans << endl;

}
 
int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 30720
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
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 main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll K;
    cin >> K;
    vector<vector<ll>> ans;
    ans.pb({1, 2, 3, 4, 5, 6, 7, 8, 9});

    ll now = 0;
    while(1){
        vector<ll> tp;
        for(auto s : ans[now]){
            tp.pb(s * 10 + s % 10);
            if(s % 10 >= 1) tp.pb(s * 10 + s % 10 - 1);
            if(s % 10 <= 8) tp.pb(s * 10 + s % 10 + 1);
        }
        ans.pb(tp);
        ++now;
        if(now > 10) break;
    }

    vector<ll> a;
    for(auto E : ans){
        for(auto l : E){
            a.pb(l);
        }
    }
    sort(ALL(a));

    print(a[K - 1]);

    return 0;
}

Measured memory_bytes: 49940
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct range_edge_graph {
    int n;
    struct edge { int to; long long weight;};
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        g.resize(n<<2);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i)
            g[i].push_back({i+2*n, 0});
    }

    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, int w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> res;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) res.push_back({l2, w}), l2++;
            if (r2 & 1) --r2, res.push_back({r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(res);
    }

    vector<long long> dijkstra(int s) {
        s += n;
        vector<long long> dist(g.size(), numeric_limits<long long>::max());
        dist[s] = 0;
        using P = pair<long long, long long>;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (edge& e : g[v]) {
                if (dist[e.to] > dist[v] + e.weight) {
                    dist[e.to] = dist[v] + e.weight;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        vector<long long> res(dist.begin() + n, dist.begin() + 2*n);
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    range_edge_graph g(n);

    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        g.add_edge(l, r+1, l, r+1, c);
    }
    auto dist = g.dijkstra(0);
    long long ans = dist[n-1];
    cout << (ans == numeric_limits<long long>::max() ? -1 : ans) << endl;
}


Measured memory_bytes: 99512
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=1010;

char s[N][N];

int n,m,S,Sa,Sb;
int A,B;

bool construct1()
{
	memset(s,0,sizeof(s));
	int a=A,b=B;
	if(n&1)
	{
		for(int i=1;a && i<m;i+=2)
			s[n][i]='<',s[n][i+1]='>',a--;
	}
	if(m&1)
	{
		for(int i=1;b && i<n;i+=2)
			s[i][m]='^',s[i+1][m]='v',b--;
	}
	int x=1,y=1;
	while(a>0)
	{
		if(x>=n)return 0;

		s[x][y]='<',s[x][y+1]='>',a--;
		if(a)s[x+1][y]='<',s[x+1][y+1]='>',a--;

		y+=2;if(y>=m)x+=2,y=1;
	}
	while(b>0)
	{
		if(x>=n)return 0;

		s[x][y]='^',s[x+1][y]='v',b--;
		if(b)s[x][y+1]='^',s[x+1][y+1]='v',b--;

		y+=2;if(y>=m)x+=2,y=1;
	}

	return 1;
}

bool construct2()
{
	memset(s,0,sizeof(s));
	int a=A,b=B;

	if(a<2 || b<2)return 0;

	s[n-2][m-2]='<',s[n-2][m-1]='>',s[n-2][m]='^';
	s[n-1][m-2]='^',s[n-1][m-1]='.',s[n-1][m]='v';
	s[n][m-2]  ='v',s[n][m-1]  ='<',s[n][m]  ='>';

	a-=2,b-=2;
	for(int i=1;a && i<m-2;i+=2)
		s[n][i]='<',s[n][i+1]='>',a--;
	for(int i=1;b && i<n-2;i+=2)
		s[i][m]='^',s[i+1][m]='v',b--;

	int x=1,y=1;
	while(a>0)
	{
		if(x==n-2 && y==m-2)return 0;

		s[x][y]='<',s[x][y+1]='>',a--;
		if(a>0)s[x+1][y]='<',s[x+1][y+1]='>',a--;

		y+=2;if(y>=m)x+=2,y=1;
	}
	while(b>0)
	{
		if(x==n-2 && y==m-2)return 0;

		s[x][y]='^',s[x+1][y]='v',b--;
		if(b>0)s[x][y+1]='^',s[x+1][y+1]='v',b--;

		y+=2;if(y>=m)x+=2,y=1;
	}

	return 1;
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&A,&B);
	S=(n*m)/2;
	Sa=(m/2)*n;
	Sb=(n/2)*m;

	bool flag=1;

	if(A+B>S || A>Sa || B>Sb)flag=0;
	else if((n*m)&1)flag=construct1() || construct2();
	else flag=construct1();

	if(!flag)printf("NO\n");
	else
	{
		printf("YES\n");
		for(int i=1;i<=n;i++,printf("\n"))
			for(int j=1;j<=m;j++)printf("%c",s[i][j]?s[i][j]:'.');
	}

	return 0;
}


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

int main() {
    int n, ans = 0;
    string a, b, c;
    cin >> n;
    cin >> a >> b >> c;
    rep(i, n) {
        if (a[i] == b[i] && b[i] == c[i]) {
            // 
        } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main () {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];  
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      // mこ割り振る
      if (m == a[i]) {
        ans++; 
      }  
      break;
    }
    if (m >= a[i]) {
      m = m - a[i];
      ans++;  
    }  
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>

bool wins(const std::string &s, char ch) {
  for (int i=0; i<3; ++i) {
    if ([&] {
        for (int j=0; j<3; ++j)
        if (s[3*i+j] != ch) return false;
        return true;
    }()) {
      return true;
    }
    if ([&] {
        for (int j=0; j<3; ++j)
        if (s[i+3*j] != ch) return false;
        return true;
    }()) {
      return true;
    }
  }
  if (s[0] == s[4] && s[4] == s[8] && s[8] == ch)
    return true;
  if (s[2] == s[4] && s[4] == s[6] && s[6] == ch)
    return true;

  return false;
}

int testcase_ends() {
  char buf[16];
  if (scanf("%s", buf) == EOF)
    return 1;

  std::string s=buf;
  for (char ch: {'o', 'x'})
    if (wins(s, ch))
      return !printf("%c\n", ch);

  printf("d\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2636
n = int(input())
x_list = list(map(int, input().split()))

x_min = min(x_list)
x_max = max(x_list)

def calc_sum(x_list, P):
    sum = 0
    for x in x_list:
        sum += (x-P)**2
    return sum

sum_temp = 10**23
for i in range(x_min, x_max + 1):
    if calc_sum(x_list, i) < sum_temp:
        ans_point = i
        sum_temp = calc_sum(x_list, i)
print(calc_sum(x_list, ans_point))

Measured memory_bytes: 3064
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()
s = sum(A)
d = Counter(A)

q = ii()

for i in range(q):
    b,c = iim()
    m = d.pop(b,0)
    if m:
        d[c] = d.get(c,0)+m
    s += (c-b)*m
    print(s)


Measured memory_bytes: 21400
#include <iostream>
using namespace std;
int main(void){
    int s,a,b,c;
    while(cin>>a>>b,a){
        s=a+b; c=0;
        for(int i=1; i<5; i++){
            cin>>a>>b;
            if(s<a+b)
            s=a+b,c=i;
        }
        cout<<(char)(c+'A')<<' '<<s<<endl;
    }
}



Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

static int64_t W;
static vector<vector<int32_t>> value(4);
static int64_t weights[4];
static vector<vector<vector<vector<int32_t>>>> memo;

static int32_t dfs(int32_t rest0, int32_t rest1, int32_t rest2, int32_t rest3)
{
	if (memo[rest0][rest1][rest2][rest3] > numeric_limits<int32_t>::min())
		return memo[rest0][rest1][rest2][rest3];

	int32_t res = 0;
	if (rest0 > 0)
		res = max(res, dfs(rest0 - 1, rest1, rest2, rest3) + value[0][rest0 - 1]);
	if (rest1 > 0)
		res = max(res, dfs(rest0, rest1 - 1, rest2, rest3) + value[1][rest1 - 1]);
	if (rest2 > 0)
		res = max(res, dfs(rest0, rest1, rest2 - 1, rest3) + value[2][rest2 - 1]);
	if (rest3 > 0)
		res = max(res, dfs(rest0, rest1, rest2, rest3 - 1) + value[3][rest3 - 1]);

	memo[rest0][rest1][rest2][rest3] = res;
	return res;
}

int main()
{
	int32_t N;
	scanf("%d%" PRId64, &N, &W);

	int64_t first_w;
	int32_t first_v;
	scanf("%" PRId64 "%d", &first_w, &first_v);
	value[0].push_back(first_v);
	for (int32_t i = 1; i < N; i++) {
		int64_t w;
		int32_t v;
		scanf("%" PRId64 "%d", &w, &v);
		w -= first_w;
		value[w].push_back(v);
	}
	for (int32_t i = 0; i < 4; i++) {
		sort(value[i].begin(), value[i].end());
		weights[i] = first_w + i;
	}

	memo.resize(value[0].size() + 1);
	for (int64_t i = 0; i <= (int64_t)value[0].size(); i++) {
		memo[i].resize(value[1].size() + 1);
		for (int64_t j = 0; j <= (int64_t)value[1].size(); j++) {
			memo[i][j].resize(value[2].size() + 1);
			for (int64_t k = 0; k <= (int64_t)(int64_t)value[2].size(); k++) {
				memo[i][j][k].resize(value[3].size() + 1);
				for (int64_t l = 0; l <= (int64_t)value[3].size(); l++) {
					memo[i][j][k][l] = numeric_limits<int32_t>::min();
					if (((int64_t)value[0].size() - i) * weights[0] + ((int64_t)value[1].size() - j) * weights[1] +
					    ((int64_t)value[2].size() - k) * weights[2] + ((int64_t)value[3].size() - l) * weights[3] > W) {
						memo[i][j][k][l] = numeric_limits<int32_t>::min() + 1;
					}
				}
			}
		}
	}

	printf("%d\n", dfs(value[0].size(), value[1].size(), value[2].size(), value[3].size()));

	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        if(n > m){
            WriteLine(n-1);
        }else{
            WriteLine(n);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<vector<int>> f(n,vector<int>(10));
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n,vector<int>(11));
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin >> p[i][j];
    }
  }
  int ans=-1e9;
  for(int i=1;i<(1<<10);i++){
    int sum=0;
    for(int j=0;j<n;j++){
      int cnt=0;
      for(int k=0;k<10;k++){
        if((i>>k)&1&&f[j][k]){
          cnt++;
        }
      }
      sum+=p[j][cnt];
    }
    ans=max(ans,sum);
  }
  cout << ans << endl;
}

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


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

    vector<pair<long long, int>> fs;
    for (long long i = 2; i * i <= N; ++i) {
        int x = 0;
        while (N % i == 0) {
            N /= i;
            ++x;
        }
        fs.emplace_back(i, x);
    }
    if (N != 1) {
        fs.emplace_back(N, 1);
    }

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            ++b;
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = -1, tmp = 0, p = h[0];
  for (int i = 1; i < n; i++) {
    if (h[i] <= p) {
      tmp++;
      p = h[i];
      ans = max(ans, tmp);
    }
    else {
      p = h[i];
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

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

int main() {
  int N; cin >> N;
  vector<int> V(N), C(N); cin >> V >> C;
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += max(0, V[i]-C[i]);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

void q_sort(long numbers[], int left, int right);

int main(void){
  int j,N,K,i,min;
  long A[200000]={};
  long ans;
  if(scanf("%d",&N)>1){
    exit(0);
  }
  for(i=0;i<N;i++){
   if(scanf("%ld",&A[i])>1){
    exit(0);
   }
  }
  q_sort(A,0,N-1);
  for(i=0;i<N;i++){
      if(A[i]==A[i+1]){
	printf("NO");
	goto out;
      }
      if(i==N-1){
      printf("YES");
    }
  }
 out:
  return 0;
}

void q_sort(long numbers[], int left, int right)
{
    int l_hold, r_hold;
    long pivot,pa;

    l_hold = left;
    r_hold = right;
    pivot = numbers[left];
    while (left < right)
    {
        while ((numbers[right] >= pivot) && (left < right))
            right--;
        if (left != right)
        {
            numbers[left] = numbers[right];
            left++;
        }
        while ((numbers[left] <= pivot) && (left < right))
            left++;
        if (left != right)
        {
            numbers[right] = numbers[left];
            right--;
        }
   }
    numbers[left] = pivot;
    pivot = left;
    left = l_hold;
    right = r_hold;
    if (left < pivot)
      q_sort(numbers, left, pivot-1);
    if (right > pivot)
      q_sort(numbers, pivot+1, right);
}




Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLineIntSpilit();
            Array.Sort(s);
            Console.WriteLine(s[0] == s[1] ? s[2] : s[0]);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11348
n = int(input())
s = input()

cnt_e = [0] * (n + 1)
for i in range(n):
    if s[i] == 'E':
        cnt_e[i+1] = cnt_e[i] + 1
    else:
        cnt_e[i+1] = cnt_e[i]

cnt_w = [0] * (n + 1)
for i in range(n, 0, -1):
    if s[i-1] == 'W':
        cnt_w[i-1] = cnt_w[i] + 1
    else:
        cnt_w[i-1] = cnt_w[i]

res = 0
for i in range(n):
    res = max(res, cnt_e[i] + cnt_w[i+1])

print(n - res - 1)

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

int main() {
    string s, t, ans = "Yes";
    cin >> s >> t;
    if (s.size() + 1 != t.size()) ans = "No";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  printf("%d ", Z);
  printf("%d ", X);
  printf("%d", Y);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>

using namespace std;


int main(){

	int N;
	long long absSum = 0;
	int input;
	int smallest = 1000000000;
	bool Minus = false;
	long long answer = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> input;
		if (input < 0) Minus = !Minus;
		absSum += abs(input);
		smallest = min(smallest, abs(input));
	}

	if(Minus) answer = absSum - 2 * smallest;
	else answer = absSum;

	cout << answer;

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A,B;
    cin >> A >> B;

    if( (A+B)%2 == 0 ){
        cout << (A+B)/2;
    }else{
        cout << "IMPOSSIBLE";
    }
    cout << endl;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll D, T, S; cin >> D >> T >> S;

  if (S*T >= D) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int r, g, b; cin >> r >> g >> b;
    int tmp = 100*r + 10*g + b;
    if(tmp % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  int N,A;
  A=1;
  N=S.size();
  for(int i=0;i<N;i++){
    if(S.at(i)==S.at(N-i-1)){}
    else A++;
  }
  A/=2;
  cout<<A<<endl;
    
}

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


int main () {
    int s=0,t,n;
    cin>>t>>n;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        s+=k;
    }
    cout<<((s>=t)?"Yes":"No");
}

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

int main() {
	//input
	string S, T;
	cin >> S >> T;

	//calculation
	int output = 1000;
	int lenS = S.size();
	int lenT = T.size();
	for (int i = 0; i <= lenS - lenT; i++) {
		int temp = lenT;
		for (int j = 0; j < lenT; j++) {
			if (S[i + j] == T[j]) {
				temp--;
			}
		}
		if (output > temp) {
			output = temp;
		}
	}

	//output
	cout << output << endl;


	return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 3005
ll dp[maxn][maxn];

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

    string A, B;
    cin >> A >> B;

    for (int i = A.size() - 1; i >= 0; --i) {
        for (int j = B.size() - 1; j >= 0; --j) {
            if (A[i] == B[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }

    string res;
    int i = 0, j = 0;
    while (i < A.size() && j < B.size()) {
        if (A[i] == B[j]) {
            res += A[i];
            ++i;
            ++j;
        } else if (dp[i + 1][j] > dp[i][j + 1]) {
            ++i;
        } else {
            ++j;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 70656
MOD = 10 ** 9 + 7
INF = 10 ** 12
import sys
sys.setrecursionlimit(1000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  itertools import permutations
import numpy as np
def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort()
    change = [tuple(map(int,input().split())) for _ in range(m)]
    change.sort(key = lambda x:x[1],reverse=True)
    j = 0
    for i in range(m):
        lim = change[i][0]
        while j < n and a[j] < change[i][1] and lim > 0:
            a[j] = change[i][1]
            j += 1
            lim -= 1
        if j == n:
            break
    print(sum(a))
        



if __name__ =='__main__':
    main()  

Measured memory_bytes: 31084
#include<iostream>
#include<cstdlib>

using namespace std;

struct Node {
	int key;
	Node *parent;
	Node *left;
	Node *right;
};
Node* NIL;
Node* root = NIL;

void insert(Node* rot, int key)
{
	Node* z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->parent = NIL;
	z->left = NIL;
	z->right = NIL;

	Node* y = NIL;
	Node* x = rot;
	while (x != NIL)
	{
		y = x;
		if (key > x->key)
			x = x->right;
		else
			x = x->left;
	}

	z->parent = y;

	if (y == NIL)
		root = z;
	else if (key < y->key)
		y->left = z;
	else
		y->right = z;
}
Node* find(Node* rot, int key)
{

	Node* x = rot;
	while (x != NIL)
	{
		if (x->key == key)
			return x;
		if (key > x->key)
			x = x->right;
		else
			x = x->left;
	}
	return x;
}
void inOrder(Node* x)
{
	if (x->left != NIL)
		inOrder(x->left);

	cout << ' ' << x->key;

    if(x->right != NIL)
		inOrder(x->right);
}
void preOrder(Node* x)
{
	cout << ' ' << x->key;

	if (x->left != NIL)
		preOrder(x->left);

	if (x->right != NIL)
		preOrder(x->right);
}
Node* getNext(Node *x)
{
	if (x->right != NIL)
	{
		x = x->right;
		while (x->left!= NIL)
			x = x->left;

		return x;
	}
	else 
	{
		Node* y = x->parent;
		while (y != NIL && y->left != x)
		{
			x = y;
			y = x->parent;
		}
		return y;
	}

}
void deleteNode(Node* z)
{
	Node*y, *x;
	if (z->left == NIL || z->right == NIL)
		y = z;
	else
		y = getNext(z);

	if (y->left != NIL)
		x = y->left;
	else
		x = y->right;

	if (x != NIL)
		x->parent = y->parent;

	if (y->parent == NIL)
		root = x;
	else if (y == y->parent->left)
		y->parent->left = x;
	else
		y->parent->right = x;

	if (y != z)
		z->key = y->key;

	free(y);
}
int main()
{
	int n,key;
	char C[10];

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> C;
		if (C[0] == 'i')                     //insert key
		{
			cin >> key;
			insert(root, key);
		}
		else if(C[0] == 'p')               //print
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
		else if(C[0] == 'f')                //find key;
		{
			cin >> key;
			if (find(root, key) != NIL)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
		else if (C[0] == 'd')                //delete key;
		{
			Node* k;
			cin >> key;
			k = find(root, key);
			if (k != NIL)
				deleteNode(k);
		}
	}
	return 0;
}


Measured memory_bytes: 21772
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

void dfs(string s, ll c, ll d) {
  if (d == 0) {
    cout << s << endl;
    return;
  }
  for (ll i = 0; i <= c; i++) {
    string t = s;
    t += 'a' + i;
    dfs(t, c, d - 1);
  }
  string t = s;
  t += 'a' + c + 1;
  dfs(t, c + 1, d - 1);
}

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

  dfs("a", 0, n-1);

  return 0;
}


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

int main(void) {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	for (int i = 0; i < n - 1; i++) {
		if (h[i] - h[i+1] < 0) h[i+1]--;
		if (h[i] - h[i+1] > 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
  double a, b, c, x, t;
  cin >> a >> b >> x;
  
  if(x <= a * a * b / 2) {
    c = 2 * x / (a * b);
    t = atan(b / c);
  } else {
    c = 2 * x / (a * a) - b;
    t = atan((b - c) / a);
  }
  
  cout << fixed << setprecision(10) << 180 * t / M_PI << endl;
  return 0;
}

Measured memory_bytes: 4040