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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,mn=INF,mx=-1;

    int n,m;
    cin >>n;

    int ai;
    rep(i,n){
        cin>>ai;
        chmin(mn,ai);
        chmax(mx,ai);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<mx -mn<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
K = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

result = 0

for a in range(1, K+1):
    result += a
    #print('{} add'.format(a))
    b = a + 1
    while b <= K:
        result += 6 * gcd(a, b)
        #print('{} and {} add'.format(a, b))
        l = gcd(a, b)
        c = b + 1
        while c <= K:
            result += 6 * gcd(l, c)
            #print('{} and {} and {} add'.format(a, b, c))
            c+= 1
        b += 1
print(result)

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

using namespace std;

int main(){

	string S;
	cin >> S;

	if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2)==S.at(0)){
		cout << "No" <<endl;
	}
	
	else{
		cout << "Yes" <<endl;
	}
}

Measured memory_bytes: 3564
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
puts (N-2)*180

Measured memory_bytes: 1788
import java.io.*;
import java.util.function.*;
import java.util.stream.*;
 
class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        int[] HW = Stream.of(br.readLine().split(" ")).mapToInt(
                item -> new Integer(item)).toArray();
        Stream<String> lines = br.lines();
        
        // データ部分を抽出
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);
 
        // 枠線を決める
        // Streamは同じインスタンスで2度処理を実行できないため、Supplierを通す
        Supplier<Stream<String>> frame = () ->
                Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> out = Stream.concat(frame.get(), Stream.concat(a, frame.get())).map(
                item -> "#" + item + "#") ;        
 
        // 出力(末尾は改行を入れない)
        System.out.println(out.collect(Collectors.joining("\n")));
    }
}

Measured memory_bytes: 26836
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

int judge(vector<ll> v, ll p, int is_x){
    map<ll, int> mp[2];
    mp[1][0] = 1;
    int ii = 1;
    rep((int)v.size()){
        ii = 1 - ii;
        for(auto itr=mp[1-ii].begin();itr!=mp[1-ii].end();++itr){
            mp[ii][itr->first + v[i]] = 1;
            if(is_x && i == 0) continue;
            mp[ii][itr->first - v[i]] = 1;
        }
        mp[1-ii].clear();
    }
    return mp[ii][p];
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    s += 'T';
    ll x, y;
    cin >> x >> y;

    vector<ll> vx, vy;
    ll cnt = 0;
    int is_x = 1;
    rep((int)s.length()){
        if(s[i] == 'T'){
            if(cnt != 0){
                if(is_x) vx.push_back(cnt);
                else vy.push_back(cnt);
                cnt = 0;
            }
            is_x = 1 - is_x;
        }else{
            cnt++;
        }
    }
    
    if(judge(vx, x, (int)(s[0] == 'F')) && judge(vy, y, 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

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

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    rep(i,0,s.size()){
        if(s[i] == 'R')ans++;
    }
    if(n/2-ans < 0) ys();
    else ns();
}

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


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

int main() {
    int N;
    cin >> N;
    vl A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll sum = 0;
    ll cnt = 0;
    int r = 0;
    for (int l = 0; l < N; l++) {
        while (r < N && ((sum + A[r]) == (sum ^ A[r]))) {
            sum += A[r];
            r++;
        }

        cnt += r - l;

        if (r == l) {
            r++;
        } else {
            sum -= A[l];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 4840
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

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

	int len = str.length();

	cout << str[0] << len - 2 << str[len - 1];

	return 0;
}

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

int main() {
  ll n;cin>>n;
  string ans="";
  while(n){
    n--;
    ans+=(char)(n%26+'a');
    n/=26;
  }
  reverse(all(ans));
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
/*
struct city{
    int P;
    ll Y;
    int x;
}
*/

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main(){
    scanf("%d%d", &N, &M);
    rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());
    rep(i, M) printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(
        yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);

    return 0;
}



Measured memory_bytes: 7808
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    let number = 40;
    let mut counter_b = vec![0; number];
    let mut counter_a = vec![0; number];
    count(b, &mut counter_b, number);
    if a > 0 {
        count(a-1, &mut counter_a, number);
    }
    let mut ans = 0;
    for i in 0..number {
        if ((counter_b[i] - counter_a[i]) % 2) != 0 {
            ans += 2usize.pow(i as u32);
        }
    }
    println!("{}", ans);
}

fn count(n: usize, counter: &mut Vec<usize>, number: usize) {
    for i in 0..number {
        let num = 2usize.pow((i + 1) as u32);
        counter[i] = ((n + 1) / num) * num/2;
        if (n + 1) % num > num / 2 {
            counter[i] += ((n + 1) % num) - num / 2;
        }
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

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

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	int sum = 0;
	vint B(N-1); cin >> B;
	sum += B[0] + B[N-2];
	for (int i = 0; i < (int)B.size() - 1; i++) {
		sum += min(B[i], B[i+1]);
	}
	cout << sum << endl;	
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
W, H, x, y, r = list(map(int, input().split()))
dist1 = [W-x, x]
dist2 = [H-y, y]
dist3 = [sorted(dist1).pop(0), sorted(dist2).pop(0)]
if r <= sorted(dist3).pop(0):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5600
# 入力
N, A, B, C, D = map(int, input().split())
S = input()

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):max(C, D)]) and (
        C < D or
        '...' in S[(B - 2):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)


Measured memory_bytes: 3572
# 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina1(x):
    return int(x) - 1


def read_ints(mina=None):
    ret = map(int, read().split())
    if mina == None:
        return list(ret)
    else:
        return list(map(lambda x: x - 1, ret))


def read_a_int():
    return int(read())


from bisect import bisect_left, bisect_right
from collections import defaultdict
N = read_a_int()
A = read_ints()
tree = defaultdict(lambda: [])
for _ in ra(N - 1):
    u, v = read_ints(mina=1)
    tree[u].append(v)
    tree[v].append(u)

LIS = []
ans = [0] * N  # 各ノードのlen(LIS)を記録


def dfs(now, p):  # 現在のノード、親
    a = A[now]
    # LISの更新
    idx = bisect_left(LIS, a)
    is_append = False
    if idx == len(LIS):
        LIS.append(a)
        is_append = True
    else:
        old = LIS[idx]   # なんの値だったか持っておく
        LIS[idx] = a  # aに更新

    ans[now] = len(LIS)  # 答えを記録
    # 次のノードを探索
    for to in tree[now]:
        if to == p:
            continue
        dfs(to, now)

    # 抜けるときにLISを復元
    if is_append:
        del LIS[idx]
    else:
        LIS[idx] = old


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 232468
#include <iostream>

using namespace std;

void call(int n) {
  int i = 1;
  int x = i;
  for (int i = 1; i <= n; ++i) {
    x = i;
    bool outputRequired = (x % 3 == 0);
    if (!outputRequired) {
      do {
        if (x % 10 == 3) {
          outputRequired = true;
          break;
        }
      } while (x /= 10);
    }
    if (outputRequired) {
      cout << ' ' << i;
    }
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  call(n);
  return 0;
} 



Measured memory_bytes: 3100
#encoding:utf-8 No.0007 2014.9.30
weeks = gets.chomp
debt = 100000

i = 0
while true
 if i == weeks.to_i
  break
 end
 debt += debt * 0.05
 debt = (debt/1000).ceil * 1000
 i += 1
end

puts debt

Measured memory_bytes: 6096
#include <stdio.h>
 
int main(void){
 
  int a, b, c;
  int f = 1;
  int i = 0;
  
  while(f == 1){
    scanf("%d %d %d", &a, &b, &c);
    if((1 >= a <= 9 )&&(1 >= b <=9)&&(1 >= c <=9))
      f = 0;
  }
  
  if(a == b)
    i++;
  if(b == c)
    i++;
  if(c == a)
    i++;
  
  if(i == 1)
    printf("Yes");
  else
    printf("No");
  
  return 0;
  
 
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
struct data
{
	ll sz, sum, lim; 
} arr[55]; 
ll sz[55], sum[55], dp[55 * 55 * 55]; 
int w[55]; 
std::vector<int> son[55]; 
void dfs(int u)
{
	sz[u] = 1; 
	sum[u] = w[u]; 
	for (int v : son[u])
	{
		dfs(v); 
		sz[u] += sz[v]; 
		sum[u] += sum[v]; 
	}
}
int main()
{
	// freopen("ARC096-F.in", "r", stdin); 
	int n, x, d; 
	scanf("%d%d%d", &n, &x, &d); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", w + i); 
		if (i)
		{
			int u; 
			scanf("%d", &u); 
			son[--u].pb(i); 
		}
	}
	dfs(0); 
	for (int i = 0; i < n; i++)
	{
		int lim = i ? d - std::min(n, d) : x; 
		arr[i] = {sz[i], sum[i], lim};
	}
	memset(dp, 0x3f, sizeof(dp)); 
	dp[0] = 0; 
	for (int i = 0; i < n; i++)
	{
		for (int j = n * n * n; j >= 0; j--)
		{
			for (int k = 0; k <= std::min(n, i ? d : n) && sum[i] * k <= x && sz[i] * k <= j; k++)
				dp[j] = std::min(dp[j], dp[j - sz[i] * k] + sum[i] * k); 
		}
	}
	std::sort(arr, arr + n, [&] (const data &a, const data &b) { return a.sz * b.sum > a.sum * b.sz; }); 
	ll ans = 0; 
	for (int i = n * n * n; i >= 0; i--)
	{
		if (dp[i] > x)
			continue; 
		ll rem = x - dp[i], cur = i; 
		for (int j = 0; j < n && rem; j++)
		{
			cur += arr[j].sz * std::min(arr[j].lim, rem / arr[j].sum); 
			rem -= arr[j].sum * std::min(arr[j].lim, rem / arr[j].sum);
		}
		ans = std::max(ans, cur); 
	}
	printf("%lld\n", ans);
	return 0; 
}


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

    int N, K, S;

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

        const int MAX = pow(10, 9) + 1 - S;
        
        // make k pair
        for (size_t i = 0; i < N; i++)
        {
            if (i < K)
            {
                cout << S << endl;
            }
            else {
                cout << MAX << endl;
            }
        }
    }

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main() {
    int A,B,c=0;
    cin >> A >> B;
    if (A >= 13) {
        c = B;
    } else if(A >= 6 && A <= 12) {
        c = B / 2;
    } else if(A <= 5) {
        c = 0;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,t;
  cin >> s >> t;
  for(int i = 0; i < t.size(); i++)
    cout << s[i] << t[i];
  if(s.size() != t.size())
    cout << s[s.size() - 1];
  cout << endl;
}

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

using namespace std;

int main(){
  long long H, W;
  cin >> H >> W;
  
  long long s = min(H, W);
  if(H % 3 == 0 || W % 3 == 0) s = 0;
  
  for(int i = 1; i < H; i++){
    long long s1, s2, s3;
    s1 = i * W;
    s2 = (H - i) * (W / 2);
    s3 = (H - i) * (W - W / 2);
    long long s_max = max(s1, max(s2, s3));
    long long s_min = min(s1, min(s2, s3));
    s = min(s_max - s_min, s);
  }
  
  for(int j = 1; j < W; j++){
    long long s1, s2, s3;
    s1 = H * j;
    s2 = (H / 2) * (W - j);
    s3 = (H - H / 2) * (W - j);
    long long s_max = max(s1, max(s2, s3));
    long long s_min = min(s1, min(s2, s3));
    s = min(s_max - s_min, s);
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n;
    cin >> n;
    vector<string> vec;
    string a;
    for(int i = 0;i < n;i++){
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    cout << vec.size() << endl;
}



Measured memory_bytes: 11608
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val (acs, was) = LazyList
    .fill(M)(sc.nextInt() -> sc.next())
    .foldLeft((
      scala.collection.mutable.HashMap.empty[Int, Unit],
      scala.collection.mutable.HashMap.empty[Int, Int])
    ) {
      case ((acs, was), (p, "AC")) =>
        if (!acs.contains(p)) acs.update(p, ())
        acs -> was
      case ((acs, was), (p, "WA")) =>
        val penalty = if (acs.contains(p)) was else {
          val count = was.getOrElseUpdate(p, 0)
          was.update(p, count + 1)
          was
        }
        acs -> penalty
    }
  println(s"${acs.size} ${was.filter { case (i, _) => acs.contains(i) }.values.sum}")
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n;
cin>>n;
if(n%10==3){
  cout<<"bon";
}else if(n%10==0||n%10==1||n%10==6||n%10==8){
  cout<<"pon";
}else
{
  cout<<"hon";
;}




  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;
    const ll n = s.size();

    vector<ll> v(26, n);
    vector<vector<ll>> next(n+1, vector<ll>(26, n));
    for(ll i=n-1; i>=0; --i) {
        v[s[i]-'a'] = i;
        next[i] = v;
    }

    vector<pair<char,ll>> rec(n+1, {'$', n});
    vector<ll> dp(n+1, INF);
    dp[n] = 1;
    for(ll i=n-1; i>=0; --i) {
        REP(j, 26) {
            if(next[i][j] == n) {
                if(dp[i] > 1) {
                    dp[i] = 1;
                    rec[i] = {'a'+j, n};
                }
            } else {
                if(dp[i] > dp[next[i][j]+1]+1) {
                    dp[i] = dp[next[i][j]+1]+1;
                    rec[i] = {'a'+j, next[i][j]+1};
                }
            }
        }
    }

    string ans = "";
    ll idx = 0;
    while(idx < n) {
        ans += rec[idx].first;
        idx = rec[idx].second;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 53652
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iostream>
#define maxn 200009
using namespace std;
int n,K,L;
int p[maxn],q[maxn];
int findset1(int x){
	return p[x]==x?x:p[x]=findset1(p[x]);
}
void unionset1(int x,int y){
	p[findset1(x)]=findset1(y);
}
int findset2(int x){
	return q[x]==x?x:q[x]=findset2(q[x]);
}
void unionset2(int x,int y){
	q[findset2(x)]=findset2(y);
}
int cnt[maxn];
vector<int>G[maxn];
bool cmp(int x,int y){
	return findset1(x)<findset1(y);
}
int main(){
	cin>>n>>K>>L;
	for(int i=1;i<=n;i++){
		p[i]=i;q[i]=i;
	}
	for(int i=1;i<=K;i++){
		int r,s;
		scanf("%d%d",&r,&s);
		unionset1(r,s);
	}
	for(int i=1;i<=L;i++){
		int r,s;
		scanf("%d%d",&r,&s);
			unionset2(r,s);
	}
	for(int i=1;i<=n;i++)
		G[findset2(i)].push_back(i);
	for(int i=1;i<=n;i++)
		sort(G[i].begin(),G[i].end(),cmp);

	for(int i=1;i<=n;i++){
		int sz=G[i].size();
		int cur=0;
		while(cur<sz){
			int L=cur;
			while(cur+1<sz&&findset1(G[i][cur])==findset1(G[i][cur+1]))
				cur++;
			int R=cur;
			for(int j=L;j<=R;j++){
				cnt[G[i][j]]=R-L+1;
			}
			cur++;
		}
	}

	for(int i=1;i<=n;i++){
		printf("%d",cnt[i]);
		if(i==n)
			puts("");
		else
			printf(" ");
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    bool ans = true;
    REP(i,n) {
        int x; cin >> x;
        if (x % 2 == 0) {
            if (x % 3 != 0 && x % 5 != 0) ans = false;
        }
    }

    if (ans) OUT("APPROVED")
    else OUT("DENIED")

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N, M, i;
  int X, Y;

  scanf("%d %d %d %d", &N, &M, &X, &Y);

  int x[N], y[M];
  
  for(i=0; i<N; i++){
    scanf("%d", &x[i]);
    if(X<x[i])
      X=x[i];
  }
  for(i=0; i<M; i++){
    scanf("%d", &y[i]);
    if(y[i]<Y)
      Y=y[i];
  }

  if(X<Y)
    printf("No War\n");
  else
    printf("War\n");

  return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll ans = 0, A[2005], DP[2005][2005];
Pll P[2005];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%lld", A + i);
    P[i] = make_pair(A[i], i);
  }
  sort(P, P + N, greater<Pll>());

  for (int i = 1; i <= N; i++){
    ll Point = P[i - 1].first;
    ll Location = P[i - 1].second;
    for (int j = 0; j <= i; j++){
      ll now = 0;
      if (j > 0) now = max(now, DP[j - 1][i - j] + Point * abs(j - Location - 1));
      if (i - j > 0) now = max(now, DP[j][i - j - 1] + Point * abs(N - i + j - Location));
      DP[j][i - j] = now;
    }
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++){
    ans = max(ans, DP[i][N - i]);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 26528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  llong ans = 0;
  map<int, int> mp;
  REP(i,100001){
    mp[i] = 0;
  }

  REP(i,n){
   int a;
   cin >> a;
   mp[a]++;
   ans += a;
  }

  int q;
  cin >> q;
  REP(i,q){
    int b, c;
    cin >> b >>c;
    mp[c] += mp[b];
    ans = ans - b * mp[b] + c * mp[b];
    mp[b] = 0;
    
    cout << ans << endl;
  }

  return 0;

}





Measured memory_bytes: 7848
/*input
5
10 10 10 10 10
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
int a[401];
int pre[401];
int sum(int l,int r){
	return pre[r]-pre[l-1];
}
int dp[401][401];
int solve(int i,int j){
	if(i == j){
		return 0 ;
	}
	if(dp[i][j])return dp[i][j];
	int ans=1e18;
	for(int k=i;k<j;k++){
		ans=min(ans,solve(i,k)+solve(k+1,j)+sum(i,j));
	}
	return dp[i][j] = ans;
}
signed main() {
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++){cin>>a[i];pre[i]+=pre[i-1]+a[i];}
	cout << solve(1,n) <<endl;
return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int main()
{
    int K,A,B;
    scanf("%d %d %d",&K,&A,&B);
    for(int i=1;i<=1000;i++)
    {
        if(i*K<=B&&i*K>=A)
        {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

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

int main() {

    int N, M;
    cin >> N >> M;
    vector<vector<bool>> G(N, vector<bool>(N));
    vector<int> A(M), B(M);

    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        G[A[i]][B[i]] = G[B[i]][A[i]] = true;
    }

    int ans = 0;
    rep(i, M) {
        G[A[i]][B[i]] = G[B[i]][A[i]] = false;

        queue<int> que;
        vector<bool> flag(N);
        que.push(0);

        while (!que.empty()) {
            int now = que.front();
            que.pop();
            flag[now] = true;
            rep(j, N) {
                if (!G[now][j])
                    continue;
                if (flag[j])
                    continue;
                que.push(j);
            }
        }

        rep(j, N) {
            if (!flag[j]) {
                ans++;
                break;
            }
        }
        G[A[i]][B[i]] = G[B[i]][A[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

void swap(int *a, int *b) {
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i = i + 1;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i + 1], &A[r]);
  return i + 1;
}

int main() {
  int A[100000], n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  int base = partition(A, 0, n - 1);
  for (int i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    if (i == base)
      printf("[%d]", A[i]);
    else
      printf("%d", A[i]);
  }
  printf("\n");
}


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int A;
int N, big = -1, num;
int pre[100010] = {};

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

	cin>> N;
	for(int i = 0; i < N; i++){
		cin >> A;
		pre[A]++;pre[A+1]++;
		if(A == 0) continue;
		pre[A-1]++;
	}

	for(int i = 0; i < 100010; i++){
		if(pre[i] > big) big = pre[i];
	}
	cout << big;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int k=0, l=0, S;
	int A[4];
	cin >> S;
	A[3] = S % 10;
	A[2] = (S / 10) % 10;
	A[1] = (S / 100) % 10;
	A[0] = S / 1000;

	if (A[0] == 0&&A[1]!=0)
		k = 1;
	else if (A[0] == 1 && A[1] < 3)
		k = 1;
	if (A[2] == 0&&A[3]!=0)
		l = 1;
	else if (A[2] == 1 && A[3] < 3)
		l = 1;

	if (k == 0 && l == 0)
		cout << "NA";
	if (k == 1 && l == 1)
		cout << "AMBIGUOUS";
	if (k == 1 && l == 0)
		cout << "MMYY";
	if (k == 0 && l == 1)
		cout << "YYMM";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
inf = float('inf')
dp = [inf]*(n+1)
dp[0] = 0
a = 1
b = 6
c = 9
for i in range(1,n+1):
    if i>=b*6:
        b*=6
    if i>=c*9:
        c*=9
    if i<6:
        dp[i] = i
    elif i<9:
        dp[i] = min(dp[i],dp[i-b]+1)
    else:
        dp[i] = min(dp[i],dp[i-b]+1,dp[i-c]+1)
print(dp[n])

Measured memory_bytes: 3828
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];

            var T = 1L;
            var A = 1L;
            for (var i = 0; i < N; ++i)
            {
                var TA = Sarray();
                var t = Max(1, (T + TA[0] - 1) / TA[0]);
                var a = Max(1, (A + TA[1] - 1) / TA[1]);
                var mg = Max(t, a);
                T = TA[0] * mg;
                A = TA[1] * mg;
            }
            WriteLine($"{T + A}");
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long cot[105];
ll ans=0;
int main()
{
    int n;
    memset(cot,0,sizeof(cot));
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int t=i;
        for(int j=2;j*j<=t;j++)
            while(t%j==0) cot[j]++,t/=j;
        if(t>1) cot[t]++;
    }
    for(int i=2;i<=100;i++)
        for(int j=2;j<=100;j++)
            for(int k=j+1;k<=100;k++)
            {
                if(i==j||i==k) continue;
                if(cot[i]>=2&&cot[j]>=4&&cot[k]>=4) ans++;
            }
    for(int i=2;i<=100;i++)
        for(int j=2;j<=100;j++)
    {
        if(i==j) continue;
        if(cot[i]>=4&&cot[j]>=14) ans++;
    }
    for(int i=2;i<=100;i++)
        for(int j=2;j<=100;j++)
    {
        if(i==j) continue;
        if(cot[i]>=2&&cot[j]>=24) ans++;
    }
    if(n>=78) ans++;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n+2);
    a[0]=0;a[n+1]=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    int sum=0;
    for(int i=1;i<=n+1;i++){
        sum+=abs(a[i]-a[i-1]);
    }
    for(int i=1;i<=n;i++){
        if(a[i-1]<a[i]&&a[i+1]<a[i]||a[i-1]>a[i]&&a[i+1]>a[i]){
            cout<<(sum-min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))*2)<<endl;
        }else{
            cout<<sum<<endl;
        }
    }
    return 0;
}

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

int main() {
  // 入力を受け取る
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(auto i = A.begin(); i != A.end(); i++) {
    cin >> *i;
  }
  
  int count = 0;
  while (true) {
    auto ret = all_of(A.begin(), A.end(), [](int a) { return a % 2 == 0; });
    
    if (!ret) {
      break;
    }
    
    count++;
    for(auto i = A.begin(); i != A.end(); i++) {
      *i = (*i) >> 1;
    }    
  }
  cout << count << endl;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
long long int cara(long long int x);
int main() {

	//E
	int h, n;
	int a[1000], b[1000];
	int i, j, k;
	cin >> h >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	//体力hに対して使用する最小の魔力を求めるDP
	int DP[10001];
	DP[0] = 0;
	int min;
	for (i = 1; i <= h; i++) {
		min = 100000000;
		for (j = 0; j < n; j++) {
			if (a[j] >= i) {
				if (min > b[j]) {
					min = b[j];
				}
			}
			else {
				if (DP[i - a[j]] + b[j] < min) {
					min = DP[i - a[j]] + b[j];
				}
			}
		}
		DP[i] = min;
	}
	cout << DP[h] << endl;
	return 0;

	//D


	/*long long int n;
	cin >> n;
	cout << cara(n) << endl;
	return 0;*/

}
long long int cara(long long int x) {

	int i = 0;
	if (x == 1) {
		return 1;
	}
	else {
		return 1  + 2 * cara((long long int)(x / 2));
	}

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

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

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

	int n, m;
	cin >> n >> m;

	int P[m], Q[m];
	map< int, vector<int> > mp;

	for(int i = 0; i < m; i++){
		cin >> P[i] >> Q[i];

		//mp[P[i]].emplace_back(Q[i]);
		mp[P[i]].push_back(Q[i]);
	}

	for(auto &p : mp){
		sort(p.second.begin(), p.second.end()//, [&](int a, int b){
		//	return a < b;
		//}
		);
	}

	for(int i = 0; i < m; i++){
		auto it = lower_bound(mp[P[i]].begin(), mp[P[i]].end(), Q[i]) - mp[P[i]].begin();
		printf("%06d%06d\n", P[i], (int)it + 1);
		//cout << setfill('0') << setw(6) << P[i];
		//cout << setfill('0') << setw(6) << (int)it + 1 << endl;
	}

	// return 0;
}


Measured memory_bytes: 13184
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

func main() {
	defer stdout.Flush()

	n := readInt()
	c := readInt()
	progTable := make([][]int, c+1)
	for i := 0; i <= c; i++ {
		progTable[i] = make([]int, 100010)
	}
	maxT := 0
	for i := 0; i < n; i++ {
		s := readInt()
		t := readInt()
		c := readInt()
		progTable[c][s]++
		progTable[c][t]--
		maxT = maxInt(maxT, t+1)
	}

	for i := 1; i <= c; i++ {
		for j := 1; j < maxT; j++ {
			if progTable[i][j] == 1 {
				progTable[i][j-1] += 1
				progTable[i][j] = 0
			}
			progTable[i][j] += progTable[i][j-1]
		}
	}

	ans := 0
	for i := 1; i <= c; i++ {
		for j := 0; j < maxT; j++ {
			progTable[i][j] += progTable[i-1][j]
			ans = maxInt(ans, progTable[i][j])
		}
	}
	println(ans)
}



Measured memory_bytes: 26240
N,M=map(int,input().split())
l,r=[0]*N,[0]*N
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        l[b-1]=1
    if b==N:
        r[a-1]=1
for i in range(N):
    if l[i]+r[i]==2:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 11788
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		char[] list = scanner.nextLine().toCharArray();
		int ans = 0;
		int ran = list.length;
		for(int i = 0; i < ran / 2; i++) {

			if(list[i] != list[ran - i - 1]) {

				ans++;

			}
		}


		System.out.println(ans);

	}
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, k;
  cin >> n >> k;
  ul mod = 1e9+7;
  vector< ul > sqn;
  for (ul i=1; i*i<=n; ++i) {
    sqn.push_back(i);
    if (i*i < n) sqn.push_back(n/i);
  }
  sort(sqn.begin(), sqn.end());
  vector< vector< ul > > dp(k, vector< ul >(sqn.size(), 0));
  dp[0][0] = 1;
  for (ul i=1; i<sqn.size(); ++i) {
    dp[0][i] = sqn[i]-sqn[i-1];
  }
  for (ul i=1; i<k; ++i) {
    vector< ul > sum(sqn.size());
    sum[0] = dp[i-1][0];
    for (ul l=1; l < sqn.size(); ++l) {
      sum[l] += sum[l-1] + dp[i-1][l];
      sum[l] %= mod;
    }
    for (ul j=0; j<sqn.size(); ++j) {
      //dp[i][j] = dp[i-1][0];
      dp[i][j] = sum[sqn.size()-j-1];
      /*
      for (ul l=1; l<sqn.size()&&sqn[l]*sqn[j]<=n; ++l) {
        dp[i][j] += dp[i-1][l];
        dp[i][j] %= mod;
      }
      */
      if (j!=0) dp[i][j] *= (sqn[j]-sqn[j-1]);
      dp[i][j] %= mod;
    }
  }
  ul ans = 0;
  for (ul i=0; i<sqn.size(); ++i) {
    ans += dp[k-1][i];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

const int64_t MOD = 1e9+7;

//---------- べき乗 ----------
int64_t power(int64_t a, int64_t n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    int64_t res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

//---------- 逆元 ----------
int64_t inv(int64_t a){
    return power(a, MOD-2);
}

//---------- 階乗 ----------
vector<int64_t> factorial(int64_t n){
    vector<int64_t> res(n+1, 1);
    for(int i=1; i<=n; i++) res[i] = i * res[i-1] % MOD;

    return res; // nまでの階乗の配列を返す
}


//--------- 組み合わせ ---------
int64_t comb(int64_t n, int64_t r, vector<int64_t> f){
    return (f[n] * inv(f[r]) % MOD) * inv(f[n-r]) % MOD;
}

int main(){
  Int X, Y; cin >> X >> Y;

  Int A = 2*X-Y, B = 2*Y-X;
  if(A % 3 != 0 || B % 3 != 0 || A < 0 || B < 0){
    cout << 0 << endl; return 0;
  }
  A /= 3; B /= 3;

  vector<Int> f = factorial(A+B);
  cout << comb(A+B, A, f) << endl;
}




Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X,i,j,k, cnt=0;
  cin >> A >> B >> C;
  cin >> X;

  for(i=0;i<=A;i++){
    for(j=0;j<=B;j++){
    	for(k=0;k<=C;k++){
    		if(X == (500*i + 100*j + 50*k)){cnt++;}
  		}
  	}
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

constexpr int V = 100005;
vector<int> graph[V * 2];

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

    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        int X, Y;
        cin >> X >> Y;
        Y += V;
        graph[X].emplace_back(Y);
        graph[Y].emplace_back(X);
    }

    vector<int> cnt(2);
    vector<bool> used(V * 2);
    auto dfs = [&](auto&& self, int cur) -> void {
        used[cur] = true;
        ++cnt[cur / V];
        for(int nxt : graph[cur]){
            if(!used[nxt])  self(self, nxt);
        }
    };
    
    ll ans = 0;
    for(int v = 0; v < V * 2; ++v){
        if(used[v]) continue;
        cnt[0] = cnt[1] = 0;
        dfs(dfs, v);
        ans += (ll)cnt[0] * cnt[1];
    }
    ans -= N;
    cout << ans << endl;
}

Measured memory_bytes: 14400
a = []
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    a.append([H, W])
for i in range(len(a)):
    b = a[i]
    for j in range(b[0]):
        print('#' * b[1])
    print('')


Measured memory_bytes: 5628
fun main(args:Array<String>) {
    val S = readLine()!!
    val front = S.slice(0..1)
    val back = S.slice(2..3)

    assert(front.length == back.length)
    val maybe_mmyy =(Pair(front.toInt(), back.toInt())).let {
        val (f,b) = it
        f in 1..12 && b in 0..99 
    }

    val maybe_yymm =(Pair(front.toInt(), back.toInt())).let {
        val (f,b) = it
        f in 0..99 && b in 1..12 
    }


    when(Pair(maybe_mmyy, maybe_yymm)) {
        Pair(true,false) -> "MMYY"
        Pair(false,true) -> "YYMM"
        Pair(true,true) -> "AMBIGUOUS"
        else -> "NA"
    }.run(::println)
}
 

Measured memory_bytes: 33656
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

int main(){
    cin>>N;
    if(N%2)out(N/2+1);
    else out(N/2);
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    while (a[i] % 2 == 0) {
      ans++;
      a[i] /= 2;
    }
    continue;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x = int(input())
table = [1]
for i in range(2,1000):
	b = 2
	while i**b <= 1000:
		table.append(i**b)
		b += 1
table.sort()
k = 0
while k <= len(table)-1 and table[k] <= x:
	k += 1
print(table[k-1])

Measured memory_bytes: 3060
n, m = map(int, (input().split()))
got = set()
watbl = [0]*n

ans = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in got:
        continue
    else:
        if s == 'AC':
            got.add(p)
            ans += 1
        else:
            watbl[p - 1] += 1

pn = 0
for v in got:
    pn += watbl[v - 1]
print(ans, pn)

Measured memory_bytes: 12652
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String S = "";
        
        if(a > b){
            for(int i = 0; i < a; i++){
                S += b;
            }
        } else {
            for(int i = 0; i < b; i++){
                S += a;
            }
        }
        
        System.out.println(S);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MAX = 2e5 + 20;

vector<int> g[MAX];

vector<int> F(MAX,-1);

int cnt = 0;
int inc = 1;

void DFS(int s){
	F[s] = inc;
	cnt++;
	

	for(auto u : g[s]){
		if(F[u] == -1)
			DFS(u);
	}

}

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

	int N,M;
	cin >> N >> M;

	while(M--){
		int x,y;
		cin >> x >> y;

		g[x].pb(y);
		g[y].pb(x);
	}

	int ans = 0;

	for(int i = 1; i <= N; i++){
		if(F[i] == -1){
			cnt = 0;
			DFS(i);
			inc++;
			ans = max(ans,cnt);
		}
	}

	cout << ans << endl;	

	return 0;
}


Measured memory_bytes: 21144