akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int time = A + B;

		if (time >= 24) {
			time = time - 24;
		}
		System.out.println(time);
	}

}

Measured memory_bytes: 21972
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var _N = cin.ReadInt;
            var N = _N.ToString().ToCharArray();
            var sum = 0;
            for(int i = 0; i < N.Length; i++)
            {
                sum += int.Parse(N[i].ToString());
            }
            if (_N % sum == 0)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

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

int Get(string S) {
	int sum = 0;
	for (int i = 0; i < S.size() - 1; ++i) {
		if (S[i] == 'A' && S[i + 1] == 'B') {
			sum++;
		}
	}
	return sum;
}
int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	int A = 0, B = 0;
	int BA = 0;

	string S[10000];
	cin >> N;
	int sum = 0;
	rep(i, 0, N) {
		cin >> S[i];
		if (S[i].front() == 'B' && S[i].back() == 'A') {
			BA++;
		}
		else if (S[i].front() == 'B')
			B++;
		else if (S[i].back() == 'A')
			A++;

		sum += Get(S[i]);
	}

	if (BA > 0) {
		sum += BA - 1;
		if (A > 0) {
			A--;
			sum++;
		}
		if (B > 0) {
			B--;
			sum++;
		}
	}
	sum += min(A, B);
	cout << sum;
	return 0;

}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

int main(){
    ll n; cin >> n;
    bitset<10> bs[n];
    rep(i,n){
        rep(j,10){
            int t; cin >> t;
            bs[i][j] = t;
        }
        // debug(bs[i]);
    }
    vector<vector<ll>> p(n, vector<ll>(11));
    rep(i,n)rep(j,11)cin >> p[i][j];

    // print(p);

    ll ans = -INF;
    rep(i,(1LL << 10)){
        ll temp = 0;
        if(!i)continue;
        bitset<10> b(i);
        rep(j,n){
            bitset<10> t = b & bs[j];
            temp += p[j][t.count()];
            // debug(t);
        }
        // debug(i);debug(temp);
        // if(temp == 0){debug(i);debug(b);debug(b&bs[1])}
        chmax(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000;
struct edge {int to, label;};
//隣接リスト
vector<edge> G[50];

bool dfs(int v, int p, int target, ll &path) {
  if (v == target) {
    return true;
  }
  for (int i; i < G[v].size(); i++) {
    edge e = G[v][i];
    if (e.to == p) continue;
    if (dfs(e.to, v, target, path)) {
      path |= (1LL << e.label);
      return true;
    }
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back({b, i});
    G[b].push_back({a, i});
  }
  
  //path[i] はi番目のpathに含まれる辺たちを記録
  int M;
  cin >> M;
  
  ll path[M];
  for (int i = 0; i < M; i++) {
    path[i] = 0;
  }
  
  for (int i = 0; i < M; i++) {
    int u, v; cin >> u >> v; u--; v--;
    dfs(u, -1, v, path[i]);
  }
  
  //共通部分はor演算で求まる
  ll bits;
  ll ans = 0;
  
  for (bits = 0; bits < (1LL << M); bits++) {
    ll val = 0;
    for (int i = 0; i < M; i++) {
      if (bits & (1LL << i)) {val |= path[i];}
    }
    int c = __builtin_popcountl(val);
    int b = __builtin_popcountl(bits);
    if (b % 2 == 1) { ans -= 1LL<<(N-1-c); }
    else { ans += 1LL<<(N-1-c); }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufp[225816],ufr[225816];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(x == ufp[x]){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return;
	}
	if(ufr[x]<ufr[y]){
		std::swap(x,y);
	}
	ufr[x] += ufr[y];
	ufp[y] = x;
}

int main(void){
	int n,m,a,b,ans=0,i;
	std::cin >> n >> m;
	ufinit(n);
	for(i=0; i<m; ++i){
		std::cin >> a >> b;
		--a; --b;
		unionf(a,b);
	}
	for(i=0; i<n; ++i){
		ans = std::max(ans,ufr[ufind(i)]);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 5192
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
int ball[15];
int leftFront, rightFront;
bool isOK;
void DFS(int depth)
{
    if(depth == 10 || isOK)
    {
        isOK = true;
        return;
    }

    if(ball[depth] > leftFront)
    {
        leftFront = ball[depth];
        DFS(depth + 1);
    }

    if(ball[depth] > rightFront)
    {
        rightFront = ball[depth];
        DFS(depth + 1);
    }

    return;
}
int main(void)
{
	int n;
	scanf("%d", &n);

	while(n--)
    {
        for(int i = 0; i < 10; i++)
            scanf("%d", &ball[i]);

        isOK = false;
        leftFront = 0;
        rightFront = 0;

        DFS(0);

        if(isOK)
            printf("YES\n");
        else
            printf("NO\n");
    }

	return 0;
}



Measured memory_bytes: 3120
# ncrをうまく使う感じ
# 二項定理はググった https://qiita.com/r_u__r_u/items/5e5baeb0194854cbf156

from math import factorial

n, k = map(int, input().split())
nn = n - k + 1  # 使える箇所


def ncr(n, r):
    res = 1
    for i in range(1, r+1):
        res = res * (n-i+1)//i
    return res


def calc(k):
    return [factorial(k)//(factorial(i)*factorial(k-i)) for i in range(k+1)]


nikouteiri = calc(k-1)

for i in range(1, k + 1):
    # 使える箇所からi個とり、kをi個のグループに分けたやつをかける
    print((ncr(nn, i) * nikouteiri[i-1]) % (10**9+7))


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    int n;
    cin>>n;
    while(n){
        int a[n]={};
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        int ans=INF;
        for(int i=0;i<n-1;i++){
            if(a[i+1]-a[i]<ans) ans=a[i+1]-a[i];
        }
        cout<<ans<<endl;
        cin>>n;
    }
    return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int n,m;
int coin[20] = { 0 };
int memo[21][50001];

int solve(int par, int remain);
//par:?????????????????¢,remain:???????????????

int main(){
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> coin[i];
  }
  memset(memo,-1,sizeof(memo));
  //sort(coin,coin + 20,greater<int>());
  cout << solve( 0, n) << endl;
}

int solve(int par, int remain){
  if(par == m)return 1 << 24;
  if(remain == 0)return 0;
  if(memo[par][remain] != -1)return memo[par][remain];
  int rec = 1 << 24;
  rec = min(rec,solve(par + 1,remain));
  if(remain >= coin[par]){
    rec = min(rec,solve(par + 1,remain - coin[par]) + 1);
    rec = min(rec,solve(par,remain - coin[par]) + 1);
  }
  return memo[par][remain] = rec;
}

Measured memory_bytes: 8392
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 262150
#define inf 2147483647
using namespace std;
struct pos1{int l, r;}pos[N][19];
int n, m, k, w[N], now, dp_l[N], dp_r[N], bin[19], x, ff;
int main(){
	scanf("%d%d", &n, &m);
	bin[0]=1; for(int i=1; i<=18; i++)bin[i]=bin[i-1]<<1;
	for(int i=1; i<=n; i++)scanf("%d", &w[i]); w[0]=w[1]-m-1; w[n+1]=w[n]+m+1;
	k=-1; x=m<<1;
	while(x){
		k++; x>>=1; now=0;
		for(int i=1; i<=n; i++){
			if(w[i]-w[i-1]>x)now=i;
			pos[i][k].l=now;
		}
		now=n+1;
		for(int i=n; i; i--){
			if(w[i+1]-w[i]>x)now=i;
			pos[i][k].r=now;
		}
	}
	dp_l[0]=0; dp_r[0]=n+1;
	for(int i=1; i<=bin[k]-1; i++){
		dp_l[i]=0; dp_r[i]=n+1;
		for(int j=1; j<=k; j++)if(i&bin[j-1]){
			dp_l[i]=max(dp_l[i], pos[dp_l[i-bin[j-1]]+1][j].r);
			dp_r[i]=min(dp_r[i], pos[dp_r[i-bin[j-1]]-1][j].l);
		}
	}
	for(int i=1; i<=n; i++)if(pos[i][0].l==i){
		ff=0;
		for(int j=0; j<=bin[k]-1; j++)if(dp_l[j]>=pos[i][0].l-1&&dp_r[bin[k]-1-j]<=pos[i][0].r+1){ff=1; break;}
		for(int j=pos[i][0].l; j<=pos[i][0].r; j++)if(ff)printf("Possible\n"); else printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 35072
a,b,h,m=map(int,input().split())

import numpy as np
t=60*h+m
w1=2*np.pi/(12*60)
w2=2*np.pi/60

delta=(w1-w2)*t

ans=np.sqrt(a**2+b**2-2*a*b*np.cos(delta))

print(ans)


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

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

  if (N.at(0) == N.at(1) && N.at(1) == N.at(2)) {
    cout << "Yes" << endl;
  }
  else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    M = m = sum(p[:K])
    for i in range(N-K):
        m = m - p[i] + p[i + K]
        M = max(M, m)
    print((1*K+M)/2)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
    int ans=0,a[5];
    r(i,5){
        cin>>a[i];
        ans+=a[i];
        a[i]=a[i]%10;
        if(!a[i])a[i]=10;
    }
    sort(a,a+5);
    r(i,4)ans+=10-a[5-i-1];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{

    int sec;
    cin >> sec;
    int h, m, s;
    h = sec / 3600;
    sec %= 3600;
    m = sec / 60;
    s = sec % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

template<typename T>
using V = vector<T>;

template<typename T>
using V2 = V<V<T>>;

template<typename T>
using V3 = V<V2<T>>;

void solve(){
  int n;ll x, d;
  cin >> n >> x >> d;
  if(d==0){
    if(x==0) cout << 1;
    else cout << n+1;
    return;
  }
  if(d<0){ d *= -1; x*=-1;}
  map<int,vector<pair<ll,ll>>> v;
  for(ll i=0; i<n+1; ++i){
    ll il, ir, l, r;
    il = (i-1)*i/2;
    l = il*d + i*x;
    ir = (2*n-i-1)*i/2;
    v[(l+(1<<30)*d)%d].emplace_back(l, (ir-il+1));
  }
  ll ans = 0;
  for(auto x: v){
    auto xs = x.second;
    ll m = xs.size();
    FOR(i,0,m) xs[i].first = (xs[i].first-x.first)/d;
    V<pair<ll,ll>> vs;
    FOR(i,0,m){
      vs.emplace_back(xs[i].first,1);
      vs.emplace_back(xs[i].first+xs[i].second,-1);
    }
    sort(vs.begin(), vs.end());
    ll cnt = 0, pre = -(1<<30);
    for (auto e : vs) {
      ll len = e.first-pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}

Measured memory_bytes: 22144
#include <iostream>
using namespace std;
using lld = long long int;

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


int main(){
    lld N,W;
    cin>>N>>W;
    lld v[N],w[N];
    lld dp[N+1][W+1];
    for(int i=0;i<N;i++){
        cin >> w[i]>>v[i];
        for(int j=0;j<W+1;j++){
            dp[i+1][j]=0;
        }
    }
    
    for(int i=0;i<W+1;i++){
        dp[0][i]=0;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<W+1;j++){
            if(j-w[i]>=0){
                chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[N][W]<<endl;
    return 0;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> lr(k);
  rep(i, k){
    int a, b;
    cin >> a >> b;
    b++;
    lr.at(i) = {a, b};
  }
  vector<mint> imos(n, 0);
  mint ans = 1;
  rep(i, n){
    ans += imos.at(i);
    for(auto p : lr){
      if(i+p.first < n) imos.at(i+p.first) += ans;
      if(i+p.second < n) imos.at(i+p.second) -= ans;
    }
    // rep(j, n){
    //   cerr << imos.at(j).x << " ";
    // }
    // cerr << endl;
  }
  cout << imos.at(n-1).x << endl;
  // vector<mint> dp(n, 0);
  // vector<mint> imos(n, 0);
  // mint now = 0;
  // dp.at(0) = 1;
  // rep(i, n){
  //   now += imos.at(i);
  //   dp.at(i) = now;
  //   for(auto p : lr){
  //     if(i+p.first < n) imos.at(i+p.first) += dp.at(i);
  //     if(i+p.second < n) imos.at(i+p.second) -= dp.at(i);
  //   }
  //   rep(j, n){
  //     cerr << dp.at(j).x << " ";
  //   }
  //   cerr << " : ";
  //   rep(j, n){
  //     cerr << imos.at(j).x << " ";
  //   }
  //   cerr << endl;
  // }
  // cout << dp.at(n-1).x << endl;
  return 0;
}

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

int main()
{

   
     long long int x,k,d;
     cin>>x>>k>>d;

     x=abs(x);
     long long int ans=0;
     long long int r=x%d;
     int moves=x/d;
      if(x/d<=k)
      {
          if((k-moves)%2==0)
          {
              ans=r;
          }
          else
          {
              ans=abs(r-d);
          }
      }
      else
      {
          ans=x-k*d;
      }
      cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	int N ,i,j,k,l,m, count,max;
	char S[300];
	scanf("%d", &N);
	scanf("%s", S);
	max =0;
	for(i=1;i<N;i++){
		count=0;
			for(k=0;k<i;k++){
				for(j=k+1;j<N;j++){
					if (S[k]==S[j]){
						count++;
						break;
				    }
				}	
			}
			for(l=0;l<=k;l++){
				for(m=l+1;m<i;m++){
					if(S[l]==S[m]){
						count--;
						break;
					}
				}	
			}
		
		if(max<count){
			max=count;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
times = int(input())
line = input()
list1 = []
if times <= 1:
  print("%s" % 0)
else:
  for i in line.split():
    if i:
      list1.append(int(i))
  mem = [0] * times
  mem[-2] = abs(list1[-1] - list1[-2])
  for i in range(len(list1)-3, -1, -1):
    step1 = abs(list1[i] - list1[i+1]) + mem[i+1]
    step2 = abs(list1[i] - list1[i+2]) + mem[i+2]
    mem[i] = min(step1,step2)
  print("%s" % mem[0])


Measured memory_bytes: 14400
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmp[200001], tmp2[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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


	int N = getint(), K = getint();
	int A[200001];
	rep(i, N) {
		A[i] = (getint() + K - 1) % K;
	}

	int B[200001];
	B[0] = 0;
	rep(i, N) {
		B[i + 1] = B[i] + A[i];
		if (B[i + 1] >= K) B[i + 1] -= K;
	}
	rep(i, N + 1) A[i] = i;

	pakuripair_sort(N + 1, B, A);
	int kazu = 0;
	int mae = B[0];
	int C[200001];
	rep(i, N + 1) {
		if (mae != B[i]) {
			kazu++;
			mae = B[i];
		}
		C[A[i]] = kazu;
	}
	rep(i, N + 1) A[i] = 0;

	ll kotae = 0;
	rep(i, N + 1) {
		kotae += A[C[i]];
		A[C[i]]++;
		if (i - K + 1 >= 0) A[C[i - K + 1]]--;
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include "cstdio"

int main (){
    int n;
    scanf("%d",&n);
    int a[100];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int j=n-1;j>=0;j--){
        printf("%d",a[j]);
        if(j) printf(" ");
    }
    printf("\n");
}

Measured memory_bytes: 2704
N = int(input())
a = list(map(int,input().split()))

min_cost = 10**15
for i in range (-100,101):
    cost = 0
    for j in range (len(a)):
        cost +=(a[j]-i)**2
    
    if min_cost >=cost:
        min_cost = cost

print(min_cost)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {

    long long int N;cin>>N;
    long long int count=0;
    long long int maximum=0;
    vector<long long int> H(N);
    for(long long int i=0;i<N;i++){
        cin>>H[i];
    }
  
  
  rep(i,N-1) {
if(H[i]>=H[i+1]) {
count++;
  maximum=max(count,maximum);
}
else if (H[i]<H[i+1]) {
  count=0;
}
  }
cout<<maximum<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;

LL n, ans, a[10005];

int main()
{
	scanf("%lld", &n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", &a[i]);
		while(a[i]%2==0)
		{
			a[i]/=2;
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define INF 10e20
static const int MAX_N=10e5,MAX_M=10e5;
long long N,M,K,X,Y,Z;
int maxs=-1,mini=INF,ans,res;
long long A[MAX_N],B[MAX_N],C[MAX_N];
int a,b,c,d,e,f,g;
int x,y,z;
int i,j,k,l,m,n;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " "; 

long long pan(int i,long long val){
	if(i<=0)
		return val;
	else if(val<=1)
		return 0;
	
	if(val<A[i-1]+2)
		return pan(i-1,val-1);
	else if(val==A[i-1]+2)
		return B[i-1]+1;
	else if(val<=A[i]-1)
		return (long long)B[i-1]+1+pan(i-1,val-2-A[i-1]);
	else
		return B[i];
}


int main(void){
	cin >> N >> M;
	A[0]=1;
	B[0]=1;
	rep(i,0,N){
		A[i+1]=A[i]*2+3;
		B[i+1]=B[i]*2+1;
	}
	cout << pan(N,M) << endl;
	return 0;
}

Measured memory_bytes: 4352
import Control.Applicative ((<$>))
import Control.Monad (unless)
import Data.List (delete)
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V
import Text.Printf

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> words <$> getLine >>= printf "%f\n"
    main

solve :: Int -> [String] -> Double
solve n [s, t, b] = f n (iv b // [(idx s, 1.0)]) ! (idx t)
  where f p bd | p == 0 = bd
               | otherwise = f (p-1) (V.accum (+) (iv b) g)
          where g = do
                  i <- mvi b
                  j <- [i-5, i-1, i+1, i+5]
                  if bd ! j < 0 then return (i, 0.25 * (bd ! i))
                    else return (i, 0.25 * (bd ! j))

mvi :: String -> [Int]
mvi b = delete (idx b) [6, 7, 8, 11, 12, 13, 16, 17, 18]

iv :: String -> Vector Double
iv b = V.replicate 25 (-1) // [(i, 0) | i <- mvi b]

idx :: String -> Int
idx "A" = 6
idx "B" = 7
idx "C" = 8
idx "D" = 11
idx "E" = 12
idx "F" = 13
idx "G" = 16
idx "H" = 17
idx "I" = 18
idx _ = -1



Measured memory_bytes: 5040
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  char mozi[1200];
  gets(mozi);
  int len =strlen(mozi);
  for(i=0;i<len;i++){
    if(mozi[i]>='A' && mozi[i]<='Z')mozi[i]+='a'-'A';
    else if(mozi[i]>='a' && mozi[i]<='z')mozi[i]-='a'-'A';
  }
  for(j=0;j<len;j++){
    printf("%c",mozi[j]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if((i%2==0&&s[i]=='L')||(i%2==1&&s[i]=='R'))
        {
            cout<<"No"<<endl;
            return 0;
        }

    }
    cout<<"Yes"<<endl;


    return 0;
}




Measured memory_bytes: 256
using System;

namespace _171_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var readData = Console.Read();
            if (readData >= 'a' && readData <= 'z')
            {
                Console.WriteLine('a');
            }
            else if (readData >= 'A' && readData <= 'Z')
            {
                Console.WriteLine('A');
            }
        }
    }
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    
    // 何文字ずらすか
    rep(i, n) {
        // 重なっている部分のチェック
        bool flag = true;
        rep(j, n-i) {
            if (s[i+j] != t[j]) flag = false;
        }
        if (flag) {
            cout << n+i << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,mx,sum,k,i,mx2;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	mx=a;
	mx=max(mx,b);
	mx=max(mx,c);
	sum=a+b+c;
	mx2=mx;
	for(i=0;i<k;i++)	{
		mx2=mx2*2;
	}
	sum=sum-mx+mx2;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
X,K,D=map(int,input().split())
zX = abs(X)

maxDist=K*D
if(zX>maxDist):
  print(zX-maxDist)
else:
  sabun=maxDist-zX
  ans1 = sabun % (D*2)
  ans2 = abs(ans1 - (D*2))
  if(ans1 > ans2):
    print(ans2)
  else:
    print(ans1)

Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
ll a[334334], memo[334334]; ll n;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)memo[i] = a[i];
	sort(memo, memo + n);
	rep(i, n) {
		if (a[i] <= memo[n / 2 - 1])cout << memo[n / 2] << endl;
		else cout << memo[n / 2 - 1] << endl;
	}
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

signed main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int a,b;
  cin >> a >> b;
  if(13 <= a){
      cout << b;
  }else if(6 <= a){
      cout << (b/2);
  }else{
      cout << 0;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
      cin.tie(NULL);
      ios::sync_with_stdio(false);
      int a,b,sum=0;
      int som=1;
      cin>>a>>b;
      while(true){
        if(som>=b) break;
        sum++;
        som--;
        som+=a;
      }
      cout<<sum<<'\n';
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような(l,r]内の下限を求める
// l:[X] 定義域の下端
// r:[X] 定義域の上端
// judge:[F = X -> bool] 値 X を評価する関数
// lower:[bool] false にすると代わりに[l,r)内の上限を求める
// eps:[X] 終了距離

template <typename X, typename F>
X BinSearch(X l, X r, F judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

int med(int a, int b, int c) {
    vector<int> v{a, b, c};
    sort(WHOLE(v));
    return v[1];
}

void experiment(vector<int> &a) {
    int N = (a.size() + 1) / 2;
    string delim = "";
    for(int i = 0; i < 2 * N - 1; i++) {
        cout << delim << a[i];
        delim = " ";
    }
    cout << endl;
    for(int i = 1; i < N; i++) {
        cout << string(2 * i, ' ');
        delim = "";
        for(int j = 0; j < 2 * (N - i) - 1; j++) {
            a[j] = med(a[j], a[j + 1], a[j + 2]);
            cout << delim << a[j];
            delim = " ";
        }
        cout << endl;
    }
}

int main() {
    int N, M;
    cin >> N;
    M = 2 * N;
    vector<int> A(M - 1);
    for(int &a : A) cin >> a;
    int ans = BinSearch(0, M - 1, [&](int k) -> bool {
        // ans <= k かどうか
        int j = M, a = -1;
        // 最も近い (1,1) か (0,0) を探す
        for(int d : {-1, 1}) {
            for(int i = 0; i < N - 1; i++) {
                int x = A[N - 1 + d * i] <= k;
                int y = A[N - 1 + d * (i + 1)] <= k;
                if(x == y) {
                    if(i < j) {
                        a = x;
                        j = i;
                    }
                    break;
                }
            }
        }
        if(j == M) a = A[0] <= k;
        return a;
    });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int c[52][28],l[28];
string s[52];

int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    rep(i,n)cin>>s[i];
    rep(i,n)rep(j,s[i].size())c[i][s[i][j]-'a']++;
    rep(i,26)
    {
        int mn=55,flag=1;
        rep(j,n)
        {
            if(c[j][i]==0)
            {
                flag=0;
                break;
            }
            else mn=min(mn,c[j][i]);
        }
        if(flag)l[i]=mn;
    }
    rep(i,26)if(l[i]!=0)rep(j,l[i])cout<<(char)(i+'a');
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int n;
	while(cin>>n&&n!=0){
		int a=-1, b=-1, sum = 0;
		bool l = true;
		vector<string>u;
		for (int i = 0; i < n; i++) {
			int c;
			cin >> c;
			if(!l) {
				if (c == b + 1) {
					b = c;
					false;
				}
				else if(b-a!=0){
					u.push_back(to_string(a) + "-" + to_string(b));
					sum++;
					l = true;
				}
				else {
					u.push_back(to_string(a));
					sum++;
					l = true;
				}
			}
			if (l) {
				a = c;
				b = c;
				l = false;
			}
		}
		if (b - a != 0) {
			u.push_back(to_string(a) + "-" + to_string(b));
			sum++;
			l = true;
		}
		else {
			u.push_back(to_string(a));
			sum++;
			l = true;
		}
		for (int i = 0; i < sum; i++) {
			if(i==0) cout << u[i];
			else cout << " " << u[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3224
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################
n = I1()
a = I2()
M = -float()
t = 0
for i in range(n-1):
    if a[i] >= a[i+1]:
        t+=1

    else:
        M = max(M,t)
        t=0
print(max(t,M))



Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define N 1009
#define infinity INT_MAX

typedef long long int ll;
long long int a,b,x,sd,c,d=0,f=INT_MAX,e,g,h,sf=1000000007,k=0,lm,y,z,testcase,n,m,ansr=0;
 int main()
{

        //freopen("input.txt","r",stdin);
      cin>>n;
      for(ll i=1;i<=n;i++)
      {
          for(ll j=1;j<=n;j++)
          {
              if(__gcd(i,j)<=1)
              {
                  ansr=ansr+n;
                  continue;
              }
              for(ll k=1;k<=n;k++)
              {
                  ansr=ansr+__gcd(i,__gcd(j,k));
              }
          }
      }
      cout<<ansr;
}



Measured memory_bytes: 3596
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(16);

    int n;
    cin >> n;
    long double P = 380000;

    long double x;
    string u;
    long double res = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x >> u;
        if (u == "BTC") {
            res += x * P;
        } else {
            res += x;
        }
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
int upcmpll(const void *a, const void *b){
    return (*(ll*)a == *(ll*)b ? 0 : (*(ll*)a > *(ll*)b ? 1 : -1));
}
void sort_u(ll *a, int n){ qsort(a, n, sizeof(ll), upcmpll); }


int main(){
    int n;
    scanf("%d", &n);
    ll L[105];
    rep(i, n) scanf("%lld", &L[i]);

    sort_u(L, n);
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if(L[i] == L[j]) continue;
            for (int k = j+1; k < n; k++){
                if(L[j] == L[k]) continue;
                if(L[i]+L[j] > L[k] && L[j]-L[i] < L[k]) ans++;
            }
        }
    }

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

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

#define ll long long
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fr1(i,b,a) for(int i=b;i>=a;i--)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
long double infd=1.0/0.0;
const double pi=2*acos(0.0);
const int MOD=1e9+7;

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        string s;
        cin>>s;
        int ans=0;
        for(int i=0;i<_sz(s)/2;i++){
            if(s[i]!=s[_sz(s)-1-i])
                ans++;
        }
        cout<<ans<<nl;
    }
    return 0;
}



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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

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

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

    ll s = 0;
    ll dp[52][50*50+2];
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<N;i++){
        for(int j=i;j>=1;j--){
            for(int k=s;k>=0;k--){
                if(dp[j][k] >= 1) dp[j + 1][k + x[i]] += dp[j][k];
            }
        }
        dp[1][x[i]] += 1;
        s += x[i];
    }

    ll ans = 0;
    for(int i=1;i<=50;i++){
        ans += dp[i][i * A];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
def comb(n,k):
    if k==0 or k==n:
        return 1
    mod=10**9+7
    r=min(k,n-k)
    s=n
    inv=[0,1]
    for c in range(2,r+1):
        inv.append((-(mod//c)*inv[mod%c])%mod)
        s=(((s*(n+1-c))%mod)*inv[c])%mod
    return s


s=int(input())
ans=0
for c in range(s//3):
    ans+=comb(s-2*c-3,c)
    ans%=10**9+7
print(ans)

Measured memory_bytes: 9220
import kotlin.math.max

fun main() {
    val (n, m) = nextIntList()
    val uf = UnionFindTree(n)

    repeat(m) {
        val (a, b) = nextIntList()
        uf.unite(a - 1, b - 1)
    }

    var MAX = 0
    (0 until n).forEach {
        MAX = max(MAX, uf.size(it))
    }

    println(MAX)
}

class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            val tmp = rx
            rx = ry
            ry = tmp
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

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

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

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

Measured memory_bytes: 69004
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

const INF = 1 << 30

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N := nextInt()
	G := make([]map[int]int, N+1)
	e := make([][2]int, N-1)
	for i := 0; i < len(G); i++ {
		G[i] = make(map[int]int)
	}
	for i := 0; i < N-1; i++ {
		a, b := nextInt2()
		G[a][b] = 0
		G[b][a] = 0
		e[i][0], e[i][1] = a, b
	}
	k := 0
	for i := 0; i < len(G); i++ {
		chmax(&k, len(G[i]))
	}

	u := 1
	queue := []int{u}
	for len(queue) > 0 {
		u, queue = queue[0], queue[1:]
		prec := 0
		for _, color := range G[u] {
			if color != 0 {
				prec = color
				break
			}
		}
		c := cond(prec == 1, 2, 1)
		for v, color := range G[u] {
			if color != 0 {
				continue
			}
			G[u][v] = c
			G[v][u] = c
			c++
			if c == prec {
				c++
			}
			queue = append(queue, v)
		}

	}

	fmt.Fprintln(out, k)
	for i := 0; i < len(e); i++ {
		a, b := e[i][0], e[i][1]
		fmt.Fprintln(out, G[a][b])
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInt2() (int, int)      { return nextInt(), nextInt() }
func nextInt3() (int, int, int) { return nextInt(), nextInt(), nextInt() }
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func cond(condition bool, t, f int) int {
	if condition {
		return t
	}
	return f
}
func abs(a int) int { return cond(a < 0, -a, a) }
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmin(&ret, a[i])
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmax(&ret, a[i])
	}
	return ret
}
func chmin(a *int, b int) { *a = cond(*a < b, *a, b) }
func chmax(a *int, b int) { *a = cond(*a > b, *a, b) }


Measured memory_bytes: 36936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int[] kupc = new int[4];
		char[] s = stdIn.next().toCharArray();
		for(int i=0;i<s.length;i++){
			if(s[i]=='K'){
				kupc[0]++;
			}
			else if(s[i]=='U'){
				kupc[1]++;
			}
			else if(s[i]=='P'){
				kupc[2]++;
			}
			else if(s[i]=='C'){
				kupc[3]++;
			}
		}
		System.out.println(Math.min(kupc[0], Math.min(kupc[1], Math.min(kupc[2], kupc[3]))));
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)

int x[101], y[101];

void no() {
	printf("Impossible\n");
	exit(0);
}

int main() {
	int n;
	scanf("%d", &n);
	int mx = 0, mn = 1e9;
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		++x[t];
		if (t > mx)mx = t;
		if (t < mn)mn = t;
	}
	if (x[mx] == 1)no();
	if (n > 2 && mx == 1)no();
	int z = mx - mx / 2;
	if (mn != z)no();
	if (mx & 1 && x[mn] != 2)no();
	if (!(mx & 1) && x[mn] != 1)no();
	int r = mx;
	while (r > mn) {
		if (x[r] < 2)no();
		--r;
	}
	printf("Possible\n");
}

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

class UnionFind {
  public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind tree(N);

    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree.merge(a, b);
    }

    set<int> pars;
    rep(i, N) { pars.insert(tree.root(i)); }

    cout << pars.size() << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    vec<ll> a(n);
    ll sum=0,k=0;;
    rep(i,n){
        cin >> a[i];
        if(a[i]<0){
            a[i]*=-1;
            k++;
        }
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    cout << (k%2==0 ? sum : sum - 2*a[0]) << endl;
}

Measured memory_bytes: 3968