akhauriyash/Code-Regression huggingface dataset:
N = int(input())

answers = [0 for i in range(10**4+1)]


for x in range(1,42):
    for y in range(x,100):
        for z in range(y,100):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if 0 <= n <= 10000:
                #if n == 9803:
                #    print(x,y,z,n)
                c = len(set([x,y,z]))
                if c == 1:
                    answers[n] += 1
                elif c == 2:
                    answers[n] += 3
                else:
                    answers[n] += 6
                

#print(answers[-100:])


for ans in answers[1:N+1]:
    print(ans)


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

int main()
{
	int n;
	int a[10];
	int max = 0;
	int total = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] > max)
		{
			max = a[i];
		}
	}
	for (int i = 0; i < n; i++)
	{
		total += a[i];
	}
	total -= max / 2;
	cout << total;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int P, Q, R;

    cin >> P >> Q >> R;

    cout << P + Q + R - max(max(P, Q), R) << '\n';

    return 0;
}


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

int main()
{
	string s;
	int n,t=0;
	cin>>n;
	set<string> a;
	while(t!=n)
	{
		cin>>s;
		t++;
		a.insert(s);
	}
	cout<<a.size();
	return 0;
}

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

int R[ 60 ];

int main( int argc, char *argv[] )
{
int i;
int N;
int M;
int a;
int b;

	cin >> N;
	cin >> M;
	for( i = 0; i < M; i++ )
	{
		cin >> a;
		cin >> b;
		R[ a ]++;
		R[ b ]++;
	}

	for( i = 1; i <= N; i++ ) cout << R[ i ] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<complex>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
const double PI = 4.0*atan(1.0);
typedef complex<double> Complex;
const Complex I(0, 1);
void fft(int n, double theta, Complex a[]) {
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = exp(i*theta*I);
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = a[j] - a[k];
        a[j] += a[k];
        a[k] = w * x;
      }
    }
    theta *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1);
    if (j < i) swap(a[i], a[j]);
  }
}
int b[1025][1025];
Complex p[1<<22];
Complex q[1<<22];
int main(){
	int a;
	scanf("%d",&a);
	int cnt=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++)scanf("%d",&b[i][j]);
	}
	int n=1;
	while(n<a*2)n*=2;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		cnt+=b[i][j];
		p[i*n+j]=q[(n-1-i)*n+(n-1-j)]=Complex(b[i][j],0);
	}
	fft(n*n,2*PI/n/n,p);
	fft(n*n,2*PI/n/n,q);
	
	for(int i=0;i<n*n;i++)p[i]=p[i]*q[i];
	fft(n*n,-2*PI/n/n,p);
	for(int i=0;i<n*n;i++)p[i]/=n*n;
	/*for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)printf("%.0f ",p[i*n+j].real());
		printf("\n");
	}*/
	double ret=0;
	long long sz=0;
	map<int,long long>m;
	for(int i=0;i<n*n;i++){
			int pi=i/n;
			int pj=i%n;
			if(pj>=n/2)continue;
			if(pj==0&&pi>=n/2)continue;
			long long v=(long long)(p[n*n-1-i].real()+0.5);
			if(i==0){v-=cnt;v/=2;}
			if(!v)continue;
			
			int I=min(pi,n-pi);
			int J=pj;
			int t=I*I+J*J;
			if(m.count(t)){
				m[t]+=v;
			}else{
				m[t]=v;
			}
			sz+=v;
			ret+=sqrt(t)*v;
	}
	printf("%.12f\n",ret/sz);
	int at=0;
	for(map<int,long long>::iterator it=m.begin();it!=m.end();it++){
		if(at==10000)break;
		at++;
		printf("%d %lld\n",(*it).first,(*it).second);
	}
}

Measured memory_bytes: 155840
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	a := io.NextInts(n)
	b, c := []int{}, []int{}
	for i := 0; i < n-1; i++ {
		for i < n-1 && a[i+1] <= a[i] {
			i++
		}
		min := a[i]
		if i == n-1 {
			break
		}
		for i < n-1 && a[i+1] >= a[i] {
			i++
		}
		max := a[i]
		b = append(b, min)
		c = append(c, max)
	}
	money, stock := 1000, 0
	for i := range b {
		buy := money / b[i]
		money -= buy * b[i]
		stock += buy

		sell := stock
		money += sell * c[i]
		stock -= sell
	}
	io.Println(money)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int e[n][n];
  memset(e,0,sizeof(e));
  for(int i=0,u,k;i<n;i++){
    cin>>u>>k;
    for(int j=0,v;j<k;j++){
      cin>>v;
      e[u-1][v-1]=1;
    }
  }
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cout<<e[i][j]<<" \n"[j==n-1];
  return 0;
}

Measured memory_bytes: 3144
S = list(input())

if len(S)%2 != 0:
  print("No")
else:
  for i in range(len(S)):
    if (i%2 == 0 and S[i] != "h") or (i%2 == 1 and S[i] != "i"):
        print("No")
        break
  else:
   	print("Yes")

Measured memory_bytes: 3060
input = raw_input

M = 10 ** 9 + 7
n, a, b = map(int, input().split(" "))

from math import factorial

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

#power_dict = {}
# kurikaeshi jijouhou
def power(n, r, mod):
    if r == 0: return 1
    #try:
    #    ret = power_dict[(n, r)]
    #except:
    if True:
        if r%2 == 0:
            ret = power(n*n % mod, r//2, mod) % mod
        if r%2 == 1:
            ret = n * power(n, r-1, mod) % mod
        #power_dict[(n, r)] = ret
    return ret


def comb(n, k, mod):
    k = min(k, n-k)
    bunshi = 1
    bunbo = 1
    for i in range(k):
        bunshi = bunshi * (n-i)
        bunshi = bunshi % M
        bunbo = bunbo * (i+1)
        bunbo = bunbo % M

    ret = (bunshi * power(bunbo, mod-2, mod)) % mod
    #a=framod(n, mod)
    #b=framod(k, mod)
    #c=framod(n-k, mod)
    #return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod
    return ret

#if True:
if False:
    comb_dict = {}
    comb_dict[(1, 0)] = 1
    comb_dict[(1, 1)] = 1

    zenbu2 = 1
    for i in range(2, n+1):
        new_comb_dict = {}
        new_comb_dict[(i, 0)] = 1
        new_comb_dict[(i, i)] = 1
        for j in range(1, i):
            tmp = comb_dict[(i-1, j-1)] + comb_dict[(i-1, j)]
            tmp = tmp % M
            new_comb_dict[(i, j)] = tmp
            if i == n:
                zenbu2 += tmp

        comb_dict = new_comb_dict


#zenbu = 1
#for i in range(n):
#    zenbu = zenbu * 2
#    zenbu = zenbu % M
#
#    assert zenbu not in values, (i, zenbu)
#    values.append(zenbu)
#zenbu = zenbu2

#out = 0
#for i in range(1, n+1):
#    if i == a or i == b:
#        continue
#    tmp = comb(n, i, M)
#    out += tmp

zenbu = power(2, n, M) - 1
#print("zenbu", zenbu)
A = comb(n, a, M)
#print("A", A)
B = comb(n, b, M)
#print("B", B)

out = zenbu - A - B
#out = zenbu - comb_dict[(n, a)] - comb_dict[(n, b)]
out = out % M
print(out)

Measured memory_bytes: 30188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	int n, k;
	string s;
	cin >> n >> k >> s;
	int a = 0;
	for (int i = 1; i < n; i++){
		a += (s[i] == s[i-1]);
	}
		
	cout << min(n-1, a+2*k) << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct pp{
	int a,b;
}e[100010];
int cmp(const pp&a,const pp&b)
{
	if(a.a<b.a) return 1;
	return 0;
}
int main ()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i) scanf("%d%d",&e[i].a,&e[i].b);
	sort(e+1,e+1+n,cmp);
	long long ans=0;
	for(i=1;i<=n;++i)
	{
		if(m>e[i].b)
		{
			m-=e[i].b;
			ans+=(long long)e[i].b*e[i].a; 
		}
		else
		{
			ans+=(long long)e[i].a*m;
			break;
		}
	} 
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import itertools
N = int(input())
for k in range(1000):
	if N * 2 == k * (k - 1):
		print("Yes")
		print(k)
		ans = [[] for i in range(k)]
		c = list(itertools.combinations(range(k), 2))
		for i in range(N):
			for j in c[i]:
				ans[j].append(i + 1)
		for i in ans:
			print(k - 1, end = " ")
			for j in i:
				print(j, end = " ")
			print()
		break
else:
	print("No")

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b >= a-b && a+b >= a*b) {
        cout << a+b << endl;
    } else if(a-b >= a+b && a-b >= a*b) {
        cout << a-b << endl;
    } else {
        cout << a*b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

ll n , a[300000];

int main(){
	cin >> n;
	REP(i,n){
		cin >> a[i+1];
	}

	REP(i,n){
		a[i+1] += a[i];
	}
	
	map< ll ,ll> m;

	REP(i,n+1){
		if (m.find(a[i]) == m.end())
			m[a[i]] = 1;
		else
		m[a[i]]++;
	}
	
	ll ans = 0;

	for(map<ll,ll>::iterator itr = m.begin();itr != m.end();itr++){
		ans += itr -> second * (itr->second -1)/2;
	}
	cout << ans <<endl;	

	return 0;
}




Measured memory_bytes: 14336
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a = chomp(readline())
	n = length(a)
	d = Dict{Char,Int}()
	for i in 1:n
		if haskey(d,a[i])
			d[a[i]] += 1
		else
			d[a[i]] = 1
		end
	end
	count = div(n*(n-1),2)+1
	for i in values(d)
		count -= div(i*(i-1),2)
	end
	println(count)
end
main()

Measured memory_bytes: 129800
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    string u;
double ans=0,x;
for(int i=0;i<n;i++)
{
    cin>>x>>u;
    if(u=="BTC")
    {
        ans+=(x*(double)380000);
    }
    else
    ans+=x;
}
cout<<ans<<endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

int main() {

    string s;
    cin >> s;
    vector<char> ans;

    for (int i = 0; i<s.size(); i++) {
        if (s[i] == '0') {
            ans.push_back('0');

        }
        if (s[i] == '1') {
            ans.push_back('1');

        }
        if (ans.size() >= 1 && s[i] == 'B') {
            ans.pop_back();

        }
    }
    for (int i = 0; i<ans.size(); i++) {
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll N;
	cin>>N;
	vector<ll> a(3 * N);
	REP(i, 3 * N) cin>>a[i];
	ll ans = 0;
	sort(ALL(a));
	REP(i, N) ans += a[3 * N - 2 * (i + 1)];
	cout<<ans<<endl;
}


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

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int P=N/R+1;
  int Q=N/G+1;
  int S=N/B+1;
  int Ans=0;
  for(int r=0; r<=P; r++){
    for(int g=0; g<=Q; g++){
      if(r*R+g*G>N){
        break;
      }
      if((N-r*R-g*G)%B==0){
        Ans++;
      }
    }
  }
  cout << Ans << endl;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

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

const int N = int(1e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n, a[N], preff[N], suff[N];
int main (){
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    for (int i = 1; i <= n; ++i){
        if (i == 1) preff[i] = a[i];
        else preff[i] = __gcd(preff[i - 1], a[i]);
    }
    for (int i = n; i >= 1; --i){
        if (i == n) suff[i] = a[i];
        else suff[i] = __gcd(suff[i + 1], a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        if (i == 1) ans = max(ans, suff[i + 1]);
        else if (i == n) ans = max(ans, preff[i - 1]);
        else  ans = max(ans, __gcd(preff[i - 1], suff[i + 1]));
    }
    return !printf ("%d\n", ans);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	string S,T; cin >> S >> T;
	cout << T + S << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
}


Measured memory_bytes: 26496
#include<bits/stdc++.h>
using namespace std;
 
int main (){
long long n,m,x[10001],y[10001],z[10001],a[10001],i,j,max=0,value;
cin >> n >> m;
for(i=0;i<n;i++) cin >> x[i] >> y[i] >> z[i];
for(j=0;j<8;j++){
for(i=0;i<n;i++) a[i]=(2*(j%2)-1)*x[i]+(2*(((j-j%2)/2)%2)-1)*y[i]+(2*(((j-j%4)/4)%2)-1)*z[i];
sort(a,a+n);
value=0;
for(i=0;i<m;i++) value+=a[n-1-i];
if(max<value) max=value;
}
cout << max << endl;
return 0;
}

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

int main() {
  size_t n;
  scanf("%zu", &n);

  if (n == 1) {
    puts("1");
    puts("0");
    return 0;
  }

  if (n == 2) {
    puts("2");
    puts("0");
    puts("11");
    return 0;
  }

  std::vector<std::string> res;
  for (size_t i = 2; i <= n; ++i) {
    std::string cur(i, '1');
    cur.front() = cur.back() = '0';
    res.push_back(cur);
  }

  printf("%zu\n", res.size());
  for (auto const& ri: res) printf("%s\n", ri.c_str());
}



Measured memory_bytes: 2924
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}
 
li mmi(li a){return power(a,mod-2);}
 
li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int a[4][4];

void solve(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				int b1=a[1][1]-i;
				int b2=a[1][2]-i;
				int b3=a[1][3]-i;
				if(b1==a[2][1]-j and b2==a[2][2]-j and b3==a[2][3]-j){
					if(b1==a[3][1]-k and b2==a[3][2]-k and b3==a[3][3]-k){
						cout<<"Yes";
						return ;
					}
				}
			}
		}
	}
	cout<<"No";
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
	int a,b;
 
	while(1)
	{
		int kai;
		int i = 1;
		int j = scanf("%d %d" , &a,&b);
		if(j==EOF) break;
 
		kai = a+b;
 
		while(kai > 9)
		{
			kai /= 10;
			i++;
		}
 
		printf("%d\n" , i);
	}
return 0;
}

Measured memory_bytes: 1028
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

sl = set()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.add(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)


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

  map<string, int> mp;
	int N;
	cin >> N;

	rep(i, N) {
		string s;
		cin >> s;
		mp[s]++;

	}

	cout << mp.size() << endl;
    
  return 0;
}

Measured memory_bytes: 19124
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 


int main(void)
{
   string b;
   std::cin >> b;
   if(b=="A")std::cout << "T" << std::endl;
   else if(b=="T")std::cout << "A" << std::endl;
   else if(b=="C")std::cout << "G" << std::endl;
    else std::cout << "C" << std::endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

const int INF = 8000000000000000001;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t1;
    cin >> t1;
    for (int q11 = 0; q11 < t1; q11++){
        int n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        priority_queue<p> f;
        f.push({0, n});
        set<int> s;
        bool flag1 = true;
        int ans = INF;
        while (!f.empty()){
            p x = f.top();
            f.pop();
            if (x.second == 0){
                flag1 = false;
                cout << min(ans, -x.first) << endl;
                break;
            }
            if (s.find(x.second) == s.end()) {
                if (x.second % 2 == 0 && (INF/d <= x.second/2 || a <= d * (x.second / 2))) {
                    f.push({x.first - a, x.second / 2});
                }
                if (x.second % 3 == 0 && (INF/d <= x.second/3*2 || b <= d * (x.second / 3 * 2))) {
                    f.push({x.first - b, x.second / 3});
                }
                if (x.second % 5 == 0 && (INF/d <= x.second/5*4 || c <= d * (x.second / 5 * 4))) {
                    f.push({x.first - c, x.second / 5});
                }
                if (INF/d >= x.second) {
                    ans = min(ans, d * x.second - x.first);
                }
                if (x.second % 2 != 0 || x.second % 3 != 0 || x.second % 5 != 0) {
                    f.push({x.first - d, x.second + 1});
                    f.push({x.first - d, x.second - 1});
                }
                s.insert(x.second);
            }
        }
        if (flag1){
            cout << ans << endl;
        }
    }
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int D[N][2];
	for (int i = 0; i < N; ++i) cin >> D[i][0] >> D[i][1];

	bool ok = false;
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (D[i][0] == D[i][1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(void) {
	long long int n, ans = 1;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (n == 0) {
			ans = 1;
			break;
		}
		else {
			ans *= i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2996
#include <stdio.h>
#define NIL -1
#define MAX 10000

struct Node{
  int parent;
  int left;
  int right;
};

struct Node L[MAX];
int n;
int data[MAX];
int he[MAX];


void depth(int j, int k)
{
  if(j == NIL)return;
  data[j] = k;
  depth(L[j].left,k+1);
  depth(L[j].right,k+1);
}

int height(int o)
{
  int h1 = 0;
  int h2 = 0;
  
  if( L[o].left != NIL )
    h1 = height(L[o].left) + 1;
  if( L[o].right != NIL )
    h2 = height(L[o].right) + 1;
  return he[o] = ( h1 > h2 ? h1 : h2);
}

int sibling(int o)
{
  if( L[o].parent == NIL )return NIL;
  if( L[L[o].parent].left != o && L[L[o].parent].left != NIL)
    return L[L[o].parent].left;
  if( L[L[o].parent].right != o && L[L[o].parent].right != NIL)
     return L[L[o].parent].right;
  return NIL;
}

void print( int o )
{
  int degree = 0;
  
  printf("node %d: parent = %d, sibling = %d, ",o,L[o].parent,sibling(o));
  if( L[o].left != NIL)degree++;
  if( L[o].right != NIL )degree++;
  printf("degree = %d, depth = %d, height = %d, ",degree,data[o],he[o]);
  if( L[o].parent == NIL ){
    printf("root");
  }
  else if( L[o].left == NIL && L[o].right == NIL ){
    printf("leaf");
  }
  else{
    printf("internal node");
  }
  printf("\n");
}

int main()
{
  int i;
  int a,b,c;
  int r=0;
  
  scanf("%d",&n);
  for( i = 0; i< n; i++) L[i].parent = NIL;
  for( i = 0 ; i < n ; i++){
    scanf("%d%d%d",&a,&b,&c);
    L[a].left = b;
    L[a].right = c;
    if( b != NIL )L[b].parent = a;
    if( c != NIL )L[c].parent = a;
  }
  for( i = 0 ; i < n; i++ )if( L[i].parent == NIL ) r = i;
  depth(r,0);
  height(r);
  
  for( i = 0 ; i < n; i++ )print(i);
  for( i = 0 ; i < n; i++ );
  return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
int main(){
  ll a,b,q,x,i,ls,lt,rs,rt;scanf("%lld%lld%lld",&a,&b,&q);
  ll s[a+2],t[b+2];s[0] = t[0] = -inf;s[a+1] = t[b+1] = inf;
  for(i=1;i<=a;i++) scanf("%lld",&s[i]);
  for(i=1;i<=b;i++) scanf("%lld",&t[i]);
  sort(s,s+a+2);sort(t,t+b+2);
  for(i=0;i<q;i++){
    scanf("%lld",&x);
    auto sa = lower_bound(s,s+a+2,x),ta = lower_bound(t,t+b+2,x);
    rs = *sa;rt = *ta;
    ls = *(sa-1);lt = *(ta-1);
    printf("%lld\n",min({x-min(ls,lt),max(rs,rt)-x,min(x-ls,rt-x)*2+max(x-ls,rt-x),min(x-lt,rs-x)*2+max(x-lt,rs-x)}));
  }
}

Measured memory_bytes: 2816
from itertools import accumulate


# エラトステネスの篩
# is_prime := 1~nが素数か否か
# table := 2~nのうち素数
def sieve(n):
    is_prime = [True for _ in range(n)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


Q = int(input())
L = [0]*Q
R = [0]*Q

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

max_R = max(R)
is_prime, table = sieve(max_R)

check = [0]*(max_R + 1)
for i in range(0, max_R + 1):
    if (i % 2 == 1):
        if (is_prime[i-1] and is_prime[(i+1)//2-1]):
            check[i] = 1

# 累積和
check = [0] + check
check = list(accumulate(check))

for i in range(Q):
    print(check[R[i] + 1] - check[L[i]])


Measured memory_bytes: 16204
H, W = gets.chomp.split(" ").map{|s| s.to_i}
coins = []
H.times do
  coins << gets.chomp.split(" ").map{|s| s.to_i}
end

route_arr = []
H.times do |i|
  W.times do |j|
    l = i % 2 == 0 ? j : W-1-j
    route_arr << [i, l]
  end
end

result_arr = []
route_arr.each_cons(2) do |f, s|
  i, j = f
  if coins[i][j] % 2 == 1
    n, m = s
    coins[n][m] += 1
    coins[i][j] -= 1
    result_arr << [i+1, j+1, n+1, m+1]
  end
end

p result_arr.length
result_arr.each do |arr|
  puts arr.join(" ")
end


Measured memory_bytes: 59132
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = -1;
    rep(i,1,10001){
        if ((int)((double)i*0.08/1) == a && (int)((double)i*0.1/1) == b){
            ans = i;
            break;
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    graph.get(a).add(b);
		    graph.get(b).add(a);
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		int[] costs = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		queue.add(new Path(0, 0));
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    costs[p.idx] = p.value;
		    for (int x : graph.get(p.idx)) {
		        if (costs[x] == Integer.MAX_VALUE) {
		            queue.add(new Path(x, p.value + 1));
		        }
		    }
		}
		int[] routes = new int[n];
		int idx = n - 1;
		int value = costs[n - 1];
		while (value >= 0) {
		    routes[idx] = value + 1;
		    for (int x : graph.get(idx)) {
		        if (costs[x] == value - 1) {
		            idx = x;
		            break;
		        }
		    }
		    value--;
		}
		int max = (routes[n - 1] + 1) / 2;
		value = 0;
		ArrayDeque<Path> deq = new ArrayDeque<>();
		deq.add(new Path(0, Integer.MIN_VALUE));
		while (deq.size() > 0) {
		    Path p = deq.poll();
		    if (routes[p.idx] <= n && routes[p.idx] > value) {
		        value = routes[p.idx];
		    } else if (routes[p.idx] != 0) {
		        continue;
		    } else {
		        routes[p.idx] = p.value;
		    }
		    int next;
		    if (routes[p.idx] <= max) {
		        next = Integer.MIN_VALUE;
		    } else {
		        next = Integer.MAX_VALUE;
		    }
		    for (int x : graph.get(p.idx)) {
		        deq.add(new Path(x, next));
		    }
		}
		int fCount = 0;
		int sCount = 0;
		for (int x : routes) {
		    if (x <= max) {
		        fCount++;
		    } else {
		        sCount++;
		    }
		}
		if (fCount > sCount) {
		    System.out.println("Fennec");
		} else {
		    System.out.println("Snuke");
		}
   }
   
   static class Path implements Comparable<Path> {
       int idx;
       int value;
       
       public Path(int idx, int value) {
           this.idx = idx;
           this.value = value;
       }
       
       public int compareTo(Path another) {
           return value - another.value;
       }
   }
}



Measured memory_bytes: 104592
#include<iostream>

using namespace std;

int main(){
	int A, B, C; cin >> A >> B >> C;

	if(A == B && A != C){

		cout << "Yes" << endl;
	}else if(A == C && A != B){

		cout << "Yes" << endl;
	}else if(B == C && A != B){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


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

res = 0
for i in range(n):
    tmp_res = 0
    tmp1 = set(s[:i])
    tmp2 = set(s[i:])
    for j in tmp2:
        if j in tmp1:
            tmp_res += 1
    if tmp_res > res:
        res = tmp_res
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<string.h>
#include<map>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
int hp[100];
int dp1[100050];
int dp2[100050];
const int inf = 1<<29;
pair<int, int> smagic[100];
pair<int, int> amagic[100];

int main() {
    int N,M,i,j,k,mp,dm,am,sm,maxhp;
    string name,range;
    while(cin>>N, N) {
        memset(hp, 0, sizeof(hp));
        rep(i,100005) dp1[i] = dp2[i] = inf;
        am = sm = maxhp = 0;
        rep(i,N) cin>>hp[i];
        rep(i,N) maxhp = max(maxhp, hp[i]);
        cin>>M;

        rep(i,M) {
            cin>>name>>mp>>range>>dm;
            if(range == "All") {
                amagic[am] = make_pair(mp,dm);
                am++;
            }else{
                smagic[sm] = make_pair(mp,dm);
                sm++;
            }
        }

        dp1[0] = dp2[0] = 0;
        rep(i,maxhp+1) {
            rep(j,am) {
                if(dp1[i] == inf) continue;
                int h = min(maxhp, i+amagic[j].second);
                dp1[h] = min(dp1[h],
                             dp1[i]+amagic[j].first);
            }
            rep(j,sm) {
                if(dp2[i] == inf) continue;
                int h = min(maxhp, i+smagic[j].second);
                dp2[h] = min(dp2[h],
                             dp2[i]+smagic[j].first);
            }
        }


        int smax = inf,amax = inf;
        for(i = 100004; i>=0; --i) {
            if(smax > dp2[i]) smax = dp2[i];
            if(amax > dp1[i]) amax = dp1[i];
            if(dp2[i] > smax) dp2[i] = smax;
            if(dp1[i] > amax) dp1[i] = amax;
        }

        ll ans = inf;
        for(int i=maxhp; i>=0; --i) {
            int j;
            ll tmp = dp1[i];
            rep(j,N) {
                if(hp[j]-i > 0) {
                    tmp += dp2[hp[j]-i];
                }
            }
            ans = min(tmp, ans);
        }

        cout<<ans<<endl;
    }
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll a, ll n) {
  ll ret = 1;
  while(n) {
    ret =ret * ((n % 2) ? a : 1) % MOD;
    a = a * a % MOD;
    n>>=1;
  }
	return ret;
}

ll comb(ll N, ll R) {
  if (N < 0 || R < 0 || N < R) return 0;
  ll n = 1, r = 1;
  R = min(R, N - R);
  for (ll i = 1; i <= R; i++) {
    n = n * N % MOD;
    r = r * i % MOD;
    N--;
  }
  return n * modpow(r, MOD - 2) % MOD;
}

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  int N;
  ll M;
  cin>>N>>M;
  map <ll, int> fact;
  fact = prime_factor(M);
  ll ans = 1;
  for (auto v:fact) {
    ll b = v.second;
    ans = ans * comb(b + N - 1, b) % MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll S;
	cin >> S;
	ll h = S/3600;
	ll m = (S%3600)/60;
	ll s = (S%3600)%60;
	cout << h << ':' << m << ':' << s << endl;
}


Measured memory_bytes: 3088
N = int(input())
A = [int(v) for v in input().split()]

def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1 % v2)

A.sort()
a1 = A[0]

for a2 in A[1:]:
    a3 = gcd(a1, a2)
    a1 = a1 * a2 // a3

v = a1
total = 0
for a in A:
    total += v // a 
#    while total > 1000000007:
#        total -= 1000000007

total %= 1000000007
print(total)

Measured memory_bytes: 4084
#include <iostream>
#include <iomanip> //setprecision
#include <cstdlib>
#include <cmath>

double abs(double coodinate1, double coodinate2); 

int main(void) {
    double x1;
    double y1;
    double x2;
    double y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    double dif_x = abs(x1, x2);
    double dif_y = abs(y1, y2);
    double target = dif_x * dif_x + dif_y * dif_y;

    std::cout << std::setprecision(12);
    std::cout << sqrt(target) << std::endl;

    return EXIT_SUCCESS;
}

double abs(double coodinate1, double coodinate2) {
    double dif = coodinate1 - coodinate2;
    if (dif < 0) {
        dif *= (-1.0);
    }
    return dif;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vi C(m), T(m);
    rep(i, m){
        int a, b; cin >> a >> b;
        C[i] = a;

        rep(j, b){
            int c; cin >> c;
            c--;
            T[i] |= bit(c);
        }
    }

    vector<vi> dp(m+1, vi(bit(n), inf));
    dp[0][0] = 0;

    rep(i, m){
        int ni = i + 1;
        int t = T[i];
        int c = C[i];

        rep(j, bit(n)){
            int cur = dp[i][j];
            if(cur == inf) continue;

            // not buy
            chmin(dp[ni][j], cur);

            // buy
            chmin(dp[ni][j | t], cur + c);
        }
    }

    int res = dp.back().back();
    if(res == inf) res = -1;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,k;
  cin>>n>>k;
  ll ans=n;
  ans=min(ans, n%k);
  ans=min(ans, abs(k-(n%k)));
  cout<<ans;
  	
  
  
  
  
  
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  string s;cin>>s;
  int l=s.length();
  int m=l/2;
  int ans=0;
  rep(i,m){
    if(s[i]!=s[l-1-i])ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#define N 1010
#define MXV 5010
#define INF (INT_MAX/2-10)
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
struct edges{
	int to,pre;
}e[N];int f[N],dp[MXV],X[N],h[N],etop;
inline int add_edge(int u,int v)
{
	return e[++etop].to=v,e[etop].pre=h[u],h[u]=etop;
}
int dfs(int x)
{
	for(int i=h[x];i;i=e[i].pre)
		if(!dfs(e[i].to)) return 0;
	for(int i=1;i<=X[x];i++) dp[i]=INF;
	for(int i=h[x]+(dp[0]=0);i;i=e[i].pre)
	{
		int a=X[e[i].to],b=f[e[i].to];
//		debug(x)sp,debug(e[i].to)sp,debug(a)sp,debug(b)ln;
		for(int j=X[x],t;j>=min(a,b);j--)
		{
			t=dp[j],dp[j]=INF;
			if(j>=a) dp[j]=min(dp[j],(a?dp[j-a]:t)+b);
			if(j>=b) dp[j]=min(dp[j],(b?dp[j-b]:t)+a);
		}
		for(int j=0;j<min(a,b);j++) dp[j]=INF;
	}
	for(int i=0;i<=X[x];i++) f[x]=min(f[x],dp[i]);
//	debug(x)sp,debug(f[x])ln;
	return f[x]<INF;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=2,x;i<=n;i++) scanf("%d",&x),add_edge(x,i);
	for(int i=1;i<=n;i++) scanf("%d",&X[i]),f[i]=INF;
	return !printf("%s\n",dfs(1)?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 256
h, w = map(int, input().split())

c = [[] * 10] * 10

a = [[] * w] * h

for y in range(10):
    cx = list(map(int, input().split()))
    c[y] = cx


for z in range(10):
    for y in range(10):
        for x in range(10):
            if c[y][x] > c[y][z] + c[z][x]:
                c[y][x] = c[y][z] + c[z][x]

for y in range(h):
    ax = list(map(int, input().split()))
    a[y] = ax

e = 0
for y in range(h):
    for x in range(w):
        if a[y][x] != -1 and a[y][x] != 1:
            i = a[y][x]
            e += c[i][1]
print(e)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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++)
using namespace std;
typedef long long ll;

int X, Y;

int main(){
  cin >> X >> Y;
  bool ok = false;
  rep(i, 101){
    rep(j, 101){
      if ((i + j == X) && (2*i + 4*j == Y)) ok = true;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3636
R, G, B, N = map(int, input().split())

count = 0


for r in range(N//R + 1):
	for g in range((N-r*R)//G + 1 ):
		if  (N - r*R - g*G) % B == 0:
				count += 1
				#print("r, g, b = " + str(r) + ", " + str(g) + ", " +  str((N - r*R - g*G)//B))

print(count)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, ans = 0;
  cin >> n;
  int a, b, c;
  cin >> a >> b;
  for (int i = 1; i < n - 1; i++) {
    cin >> c;
    if (a < b && b < c || c < b && b < a) {
      ans++;
    }
    a = b, b = c;
  }
  cout << ans << endl;
}

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

int main(){
	int N = 0, x = 0, sum = 0;
	vector<int> len;

	cin >> N;
	for (int i = 0; i < (N * 2); i++) {
		cin >> x;
		len.push_back(x);
	}

	sort(len.begin(), len.end());

	for (; 0 < len.size(); ) {
		len.pop_back();
		sum += len.at(len.size() - 1);
		len.pop_back();
	}

	cout << sum << endl;
}

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

using namespace std;

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

  map<int, int> xlist;
  for (int i = 0; i <= 50000; i++) {
    xlist[floor(float(i) * 1.08)] = i;
  }
  int n; cin>>n;
  auto found = xlist.find(n);
  if (found == xlist.end()) {
    cout << ":(" << endl;
  } else {
    cout << found->second << endl;
  }

  return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7

using namespace std;

bool DEBUG = false;

//https://maups.github.io/disciplinas/lab2/

main(){
    fastio;
    
    int MAX_VAL = 100;
    
    int m, d, x;
    cin >>m >>d;
    
    int maxTens = d/10;
    int maxOnes = d - 10*maxTens;
    if(DEBUG) cout <<"maxTens=" <<maxTens <<" maxOnes=" <<maxOnes <<endl;
    
    int ans = 0;
    
    for(int i=4; i<=m; i++){
    	for(int tens = 2; tens <=maxTens; tens++){
    		for(int ones = 2; ones <=9; ones++){
    			if(10*tens + ones > d) break;
    			if(tens * ones == i){
    				if (DEBUG) cout <<i <<"-" <<tens <<ones <<endl;
    				ans++;
    			}
    		}
    	}
    }
    
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,t5=0,t7=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7) t7++;
    if(b==7) t7++;
    if(c==7) t7++;
    if(a==5) t5++;
    if(b==5) t5++;
    if(c==5) t5++;
    if(t7==1 && t5==2) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main(){
    unsigned int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a*b>c*d){
        cout << a*b << endl;
    }else if(a*b<c*d){
        cout << c*d << endl;
    }else if(a*b==c*d){
        cout << a*b << endl;
    }else{

    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>

using namespace std;

int main()
{
    int size, count=0;
    cin>>size;
    string s;
    cin>>s;
    if(size>1)
    {
        std::string half = s.substr(0, s.length()/2);
        std::string otherHalf = s.substr(s.length()/2);
        if(half==otherHalf)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No";

    return 0;
}


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

int main() {
  int R;
  int G;
  int B;
  int N;
  cin >> R >> G >> B >> N;
  int maxR;
  int maxG;
  int ans = 0;
  maxR = N/R;
  for (int i=0; i<(maxR + 1); i++){
  maxG = (N - i*R)/G;
    for(int j=0; j<(maxG + 1); j++){
     if( (N - i*R -j*G)%B==0){
       ans++;
     }
      
    }
  
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    using P = pair<string,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(i,n) {
        pq.emplace(make_pair(s.substr(i,1),i));
    }
    set<string> subs;
    while(!pq.empty()) {
        auto nx = pq.top();
        pq.pop();
        int i = nx.second;
        string str = nx.first;
        subs.insert(str);
        if(subs.size() >= k) {
            cout << nx.first << endl;
            return 0;
        }
        if(i+1 >= n) continue;
        pq.emplace(str+s[i+1],i+1);
    }
}


Measured memory_bytes: 640
i = 0
a = []
while True:
    x = list(map(int, input().split()))
    a.append(x)
    if x[0] == 0 and x[1] == 0:
        break
    else:
        i = i+1

isize = len(a)-1
for i in range(isize):
    for j in range(a[i][0]):
        for k in range(a[i][1]):
            print('#', end='')
        print('\n', end='')
    print('\n', end='')


Measured memory_bytes: 7016