akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<limits.h>
int main(){
	int n, m;
	int i, j;
	while(scanf("%d%d", &n, &m), n) {
		int cost[100][100] = {0};
		int determined[100] = {0}, undeterminednodes = n;
		int mincost[100] = {0};
		int costsum = 0;
		int minnode, minnodecost;

		// initialize cost table
		for(i = 0; i < n; i ++) {
			for(j = 0; j < n; j ++) {
				cost[i][j] = INT_MAX;
			}
		}

		// load
		for(i = 0; i < m; i ++) {
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			cost[a][b] = cost[b][a] = d/100-1;
		}

		// node 0 is determined
		minnode = 0;
		minnodecost = 0;

		// initialize mincost
		for(i = 0; i < n; i ++) {
			mincost[i] = INT_MAX;
		}

		while(undeterminednodes > 0) {
			// the node is determined
			determined[minnode] = 1;
			costsum += minnodecost;
			undeterminednodes --;
			mincost[minnode] = INT_MAX;

			// update mincost
			for(i = 0; i < n; i ++) {
				if(!determined[i]) {
					if(cost[minnode][i] < mincost[i])
						mincost[i] = cost[minnode][i];
				}
			}

			// select the nearest undetermined node
			minnodecost = INT_MAX;
			for(i = 0; i < n; i ++) {
				if(mincost[i] < minnodecost) {
					minnode = i;
					minnodecost = mincost[i];
				}
			}
		}
		printf("%d\n", costsum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}
char ca[100005];
int t[100005];
int s[100005];

int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	cin>>n>>m;
	cin>>ca;
	for(i=0;i<strlen(ca)-1;i++){
		t[i+1]=t[i];
		if(ca[i]=='A' && ca[i+1]=='C')t[i+1]++;
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		s[i]=t[b-1]-t[a-1];
	}
	array_show(s,m,'\n');
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,a,ma=100000000,cun;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a;
    cun = 0;
    while(a % 2 == 0){
      a = a / 2;
      cun++;
    }
    if(ma > cun){
      ma = cun;
    }
  }
  cout<<ma<<"\n";
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, a, b, ans, i, aa, bb;

	cin >> n >> a >> b;
	ans = a + b;
	aa = a;
	
	for (i = 1; i < n; i++) {
		cin >> a >> b;
		if (a > aa) {
			ans = a + b;
			aa = a;
		}
	}

	cout << ans << "\n";


	return 0;
}




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

int N, C, K, T[100000], departure, people, ans;

int main() {
    cin >> N >> C >> K;
    rep(i, N) cin >> T[i];

    sort(T, T + N);
    rep(i, N) {
        if (T[i] > departure || people >= C) {
            departure = T[i] + K;
            people = 1;
            ans++;
        } else {
            people++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,m,k,ans=0;
	string s="No";
	bool flag = false;

	cin >> n >> m >> k;

	vecll a(n), b(m);

	forll(i, 0, n)
		cin >> a[i];

	forll(i, 0, m)
		cin >> b[i];

	vecll minA(n + 1,0), minB(m + 1,0);

	forll(i, 0, n)
		minA[i + 1] = minA[i] + a[i];

	forll(i, 0, m)
		minB[i + 1] = minB[i] + b[i];

	ll now = m;

	forll(i, 0, n+1)
	{
		forllde(j, now)
		{
			if (minA[i] + minB[j] <= k)
			{
				now = j;
				ans = max(ans, i + j);
				break;
			}
		}
	}

	cout << ans;
}

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

# dp[i][j]: a[i], a[j] の選択肢があるとき、その後に蓄積されるX-Yの最大値
dp = [[0] * N for i in range(N)]

for i in range(N - 1, -1, -1):
  for j in range(i, N):
    if i == j:
      dp[i][j] = a[i]
    else:
      dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][N - 1])

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

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

int main(){
  int a;
  cin >> a;
  int Z[100000];
  for(int i=0; i<a; i++){
    cin >> Z[i];
  }
  int x=partition(Z,0,a-1);
  for(int i=0; i<a; i++){
    if(i==x){
      cout << '[' << Z[i] << ']';
    }else{
      cout << Z[i];
    }
    if(i<a-1){
      cout << ' ';
    }else{
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3468
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	ll ans = 0LL;
	for(ll i = 1LL; i<=N; ++i){
		if(!(i%5))continue;
		if(!(i%3))continue;
		ans += i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(N):
    if p[i] == i + 1:
        if i == N - 1:
            temp = p[N - 2]
            p[N - 2] = p[N - 1]
            p[N - 1] = temp
            count += 1
        else:
            temp = p[i + 1]
            p[i + 1] = p[i]
            p[i] = temp
            count += 1

print(count)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
#include <cstdlib>
#include <complex>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
//===============================================
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=(intial);i<n;i++)
#define loopn(j,n,ends) for(int j=int(n-1);j>=ends;j--)
#define loopm(name)  for(auto it : name)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
#define PI (ld)(3.14159265358979323846)
//===============================================
#define SF(a) scanf("%d",&a)
#define SF2(a,b) scanf("%d %d",&a,&b)
#define SFLL(a) scanf("%lld",&a)
#define SFLL2(a,b) scanf("%lld %lld",&a,&b)
#define PF(a) printf("%d\n",a)
#define PFLL(a) printf("%lld\n",a)
//===============================================
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const double EPS = 1e-4;
const ll oo = (ll) 1e8 + 7;
const ll N = 1e5 + 18;
const ll mod = 1073741824;
//int dx[] = { 0, 0, -1, 1 };
//int dy[] = { 1, -1, 0, 0 };
//int dx[] = { 1,1,0,-1,-1,-1,0,1 };
//int dy[] = { 0,1,1,1,0,-1,-1,-1 };
//freopen("largest.in", "r", stdin);
//freopen("output.txt", "w", stdout);
map<ll,int> mp;
int main()
{
	afify();
	int n;
	cin>>n;
	loop(i,0,n){
	    ll x;
	    cin>>x;
	    mp[x]++;
	}
	int m;
	cin>>m;
	loop(i,0,m){
        ll x;
        cin>>x;
        if(mp[x]>0)mp[x]--;
        else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;


	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll s, w; cin >> s >> w;

  if (w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int route[50];
  REP(i,50)route[i]=0;
  int n, m;
  cin >> n >> m;
  int b;
  REP(i,2*m){
      cin >> b;
      //dump(b);
      route[b-1]++;
      //dump(route[b-1]);
  }
  REP(i,n){
      cout << route[i] << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct {
  int a;
  int b;
} Drink;
int compare_int(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(void)
{
  int n,m;
  long long ans=0;
  Drink array[100010];
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d%d",&array[i].a,&array[i].b);
  }
  qsort(array,n,sizeof(Drink),compare_int);

  /*for(int i=0;i<n;i++){
  *  printf("%d %d\n",array[i].a,array[i].b);
  *}
  */

  for(int i=0;m>0;i++){
    while((array[i].a>0)&&(m>0&&array[i].b>0)){
      ans+=array[i].a;
      array[i].b--;
      m--;
    }
  }
  printf("%lld",ans);

  return 0;
}


Measured memory_bytes: 1788
<?php
  fscanf(STDIN, "%d", $length);
# スペース区切りの整数の入力
  fscanf(STDIN, "%s %s", $a, $b);

  $word1 = str_split($a);
  $word2 = str_split($b);

  $result = array();

  for($i = 0;$i < $length;$i++) {
   array_push($result, $word1[$i]);
   array_push($result, $word2[$i]); 
  }

  echo implode('', $result);

Measured memory_bytes: 4604
use std::io::{self, Read, Write};
use std::str::{self, FromStr};

pub struct IO<R: Read, W: Write>(R, io::BufWriter<W>);

impl<R: Read, W: Write> IO<R, W> {
    pub fn new(reader: R, writer: W) -> Self {
        Self(reader, io::BufWriter::new(writer))
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
        .0
        .by_ref()
        .bytes()
        .map(|b| b.unwrap())
        .skip_while(|&b| (b as char).is_whitespace())
        .take_while(|&b| !(b as char).is_whitespace())
        .collect::<Vec<u8>>();

        unsafe { str::from_utf8_unchecked(token.as_slice()) }
        .parse()
        .ok()
        .expect("Can't parse it.")
    }

    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


fn main() {
    let (r, w) = (io::stdin(), io::stdout());
    let mut rw = IO::new(r.lock(), w.lock());

    let s = rw.chars();
    println!("{}", s.iter().filter(|&&c| c == '1').count());
}

Measured memory_bytes: 2084
n,q=map(int,input().split())
s = input()
a = [0,0]
for i in range(1,n):
    a.append(a[i]+(s[i-1]=="A" and s[i]=='C'))
for i in range(q):
    l,r=map(int,input().split())
    print(a[r]-a[l-1]-(s[l-2]=='A' and s[l-1]=='C'))


Measured memory_bytes: 7684
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')


main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  ps <- map read . words <$> getLine :: IO [Double]
  let probs = foldl' (\vec p-> VU.zipWith (+) (VU.map (p*) $ VU.cons 0 $ vec)
                                   (VU.map ((1-p)*) $ flip VU.snoc 0 $ vec))
              (VU.singleton 1) ps
  print $ VU.sum $ VU.drop ((n+1) `shiftR` 1) probs


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n,m;
int w[101];
int s1, s2;
signed main() {
    cin >> n;
    int allsum = 0;
    for (int i=0;i<n;i++) {
        cin >> w[i];
        allsum += w[i];
    }

    int ans = INF;
    for (int t=1;t<n;t++) {
        for (int j=0;j<t;j++) {
            s1 += w[j];
        }
        s2 = allsum - s1;
        ans = min(ans, abs(s1-s2));
        s1 = 0;
        s2 = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 H : Twenty Questions
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>

using namespace std;

map<pair<vector<int>, int>, int> mp;
string qes[128];

int search(vector<int> &vi, int depth, int used, int m, int n){
	if(mp.count(make_pair(vi, used))) return mp[make_pair(vi,used)];
	if(vi.size() > (1<<(m-depth))) return 100;
	if(vi.size() == 1) return depth;
	int res = 100;
	for(int i=0;i<m;i++){
		if((used>>i)&1) continue;
		vector<int> a, b;
		for(int j=0;j<vi.size();j++){
			if(qes[vi[j]][i]=='0') a.push_back(vi[j]);
			else                   b.push_back(vi[j]);
		}
		if(a.empty()||b.empty()) continue;
		res = min(res, max(search(a, depth+1, used|(1<<i), m, n), search(b, depth+1, used|(1<<i), m, n)));
	}
	return mp[make_pair(vi,used)] = res;
}

int main(){
	int m, n;
	while(cin >> m >> n, m){
		for(int i=0;i<n;i++) cin >> qes[i];
		vector<int> vi(n);
		for(int i=0;i<n;i++) vi[i] = i;
		mp.clear();
		cout << search(vi, 0, 0, m, n) << endl; 
	}
}

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}



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

	int n; cin >> n;
	vector<set<int>> g(n);
	FOR (i, 1, n - 1) {
		int x, y; cin >> x >> y;
		g[x].insert(y), g[y].insert(x);
	}

	vi tmkc;
	FOR (i, 0, n - 1) if (sz(g[i]) == 1) tmkc.push_back(i);
	int l = n;
	while (!tmkc.empty()) {
		int x = tmkc.back();
		tmkc.pop_back();
		int y = *g[x].begin();
		if (sz(g[y]) == 2) {
			g[x].erase(y), g[y].erase(x);
			tmkc.push_back(y);
			--l;
		}
	}
	if (l == 2) {
		cout << "1\n";
		return 0;
	}
	int ans = 0;
	FOR (i, 0, n - 1) {
		int x = 0;
		for (int j : g[i]) {
			if (sz(g[j]) == 1) ++x;
		}
		ans += max(0, x - 1);
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 14972
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll x;
		cin>>x;
		if(x<=599)
		{
			cout<<"8"<<endl;
		}
		else if(x<=799)
		{
			cout<<"7"<<endl;
		}
		else if(x<=999)
		{
			cout<<"6"<<endl;
		}
		else if(x<=1199)
		{
			cout<<"5"<<endl;
		}
		else if(x<=1399)
		{
			cout<<"4"<<endl;
		}
		else if(x<=1599)
		{
			cout<<"3"<<endl;
		}
		else if(x<=1799)
		{
			cout<<"2"<<endl;
		}
		else if(x<=1999)
		{
			cout<<"1"<<endl;
		}

	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

int n;

//ll a[100002]={};
//ll b[100002]={};
//ll c[100002]={};

const ll INF=100000000001;
int main() {
	int a,b,c,d,e,f;

	cin>>a>>b>>c>>d>>e>>f;
	bool g[31]={};
	bool h[3001]={};

	for(int i=a;i<31;i+=a)g[i]=true;
	for(int i=b;i<31;i+=b)g[i]=true;
	for(int i=0;i<3001;i+=c){
		for(int j=0;i+j<3001;j+=d){
			h[i+j]=true;
		}
	}
	int ans1=100*a;
	int ans2=0;
	for(int i=1;i<30;++i){
		if(g[i]){
			for(int j=1;j+100*i<=f;++j){
				if(h[j]&&(j<=(e*i))){
					if((ans2*(100*i+j))<=(j*ans1)){
						ans1=100*i+j;
						ans2=j;

					}

				}
			}
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}


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

using namespace std;

struct respondent
{
    int K;
    vector<int> A;
};

int main()
{
    int N, M;
    cin >> N >> M;
    vector<respondent> r(N);
    int total = 0;
    for(int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        r[i].K = temp;
        for(int j = 0; j < temp; j++)
        {
            int temp1;
            cin >> temp1;
            r[i].A.push_back(temp1);
        }
    }
    
    for(int i = 1; i < M + 1; i++)
    {
        int count = 0;
        for(int j = 0; j < N; j++)
        {
            for(int k = 0; k < r[j].K; k++)
            {
                if(r[j].A[k] == i)
                {
                    count++;
                }
            }
        }
        if(count == N)
        {
            total++;
        }
    }
    
    cout << total;
    
    return 0;
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int N;cin>>N;
  int i=10,j=10;
  for(int i=1;i<10;i++)
    for(int j=1;j<10;j++)
      if(i*j==N)fin("Yes");
  fin("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first
#define  sec second
#define  SZ(x) (x.size())
#define  inf 0x3f3f3f3f
#define  PB push_back
#define  MP make_pair
#define  all(x) (x).begin(),(x).end()
#define  PII pair<int,int>
#define  E 2.7182818284590452353602874713527
using namespace std;

/**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//const ll mod = 10000019;
//const ll phi_mod_prime=mod-1;
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
ll phi(ll n){ ll rea=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ rea=rea-rea/i;while(n%i==0) n/=i;}}if(n>1) rea=rea-rea/n;return rea;}
//a^(b%modhi(mod)+phi(mod))%mod;
void exgcd(int a,int b,int &x,int &y,int &d){if(!b){x=1;y=0;d=a;}else exgcd(b,a%b,y,x,d),y-=a/b*x;}
inline int inv(int a,int mod){int x,y,d;exgcd(a,mod,x,y,d);x=(x%mod+mod)%mod;return x;}
/********************************Head----Template**********************************************/


const int INF = 0x3f3f3f3f;
const int maxn = 2000 + 7;

const int mod = 1000000007;

int n, m;
ll dp[maxn][maxn];
int a[maxn],b[maxn];

int main(){
    while(~scanf("%d%d",&n,&m)){
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=n;i++)  scanf("%d",&a[i]);
        for(int i=1;i<=m;i++)  scanf("%d",&b[i]);

        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i]==b[j])  dp[i][j]=dp[i-1][j]+dp[i][j-1]+1;
                else dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
                dp[i][j]=(dp[i][j]+mod)%mod;
            }
        }
        printf("%lld\n",(dp[n][m]+1)%mod);
    }
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

typedef long long int ll;

int main(){
  int n; cin >> n;
  ll a[n],b[n];
  rep(i,n){
    scanf("%lld %lld",&a[i],&b[i]);
  }
  ll last = 0;
  ll score;

  rep(i,n){
    if(last<a[i]){
      last = a[i];
      score = b[i];
    }
  }
  printf("%lld",last+score);
  return 0;
}

Measured memory_bytes: 1792
import sys
import os

def file_input():
    f = open('ABC168/input.txt', 'r')
    sys.stdin = f

def main():
    if os.getenv("ENV")=='LOCAL':
        file_input()

    N=input()

    if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
        print('hon')
    elif N[-1]=='3':
        print('bon')
    else:
        print('pon')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n, tmp;
    cin >> n;
    vector<int> even;
    for(int i=0; i<n; ++i){
        cin >> tmp;
        if(tmp % 2 == 1){
            even.push_back(tmp);
        }
    }
    if(even.size() % 2 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,q;cin>>n>>q;

    VVL w(n);
    REP(i,n){
        w[i].resize(3);
        LL s,t,x;cin>>s>>t>>x;
        w[i][0]=x;
        w[i][1]=s;
        w[i][2]=t;
    }
    SORT_ASC(w);
    map<LL,LL> d;
    REP(i,q){
        LL t;cin>>t;
        d[t]=i;
    }
    d[INF_LL]=-1;

    VL result(q,-1);
    REP(i,n){
        //cerr<<i<<" "<<w[i][0]<<" "<<w[i][1]<<" "<<w[i][2]<<endl;
        auto s = d.lower_bound(w[i][1]-w[i][0]);
        auto e = d.lower_bound(w[i][2]-w[i][0]);
        if(s==e){
            continue;
        }
        auto ss=s;
        while(ss!=e){
            result[ss->second] = w[i][0];
            ss++;
        }
        d.erase(s,e);
    }

    REP(i,q){
        cout<<result[i]<<endl;
    }


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 26880
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
      int N = sc.nextInt();
      String s = sc.next();
      int rcount = 0;
      int bcount = 0;
      for(int i=0;i<N;i++){
        if(s.charAt(i)=='R'){
          rcount++;
        }else{
          bcount++;
        }
      }
      if(rcount>bcount){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    string N;
    cin >> N;
    if(N.at(2)==N.at(3)&&N.at(5)==N.at(4))
    cout<<"Yes";
    else cout<<"No";

return 0;

}  



Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    c = list(acc([0]+aa))
    c.pop()
    cnt = 0
    for ai, ci in zip(aa, c):
        if ai <= 2*ci:
            cnt += 1
        else:
            cnt = 0
    print(cnt+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, p;
	cin >> a >> p;
	int c = 3 * a + p;
	cout << c / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<stdio.h>
int main()
{	int n,x=0,h[n],i,j,f=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);}
			for(i=0;i<n;i++){
				for(j=0;j<i;j++){
				if(h[i]<h[j]){
				f=-1;}
			}
	if(0<f){
	x++;}
	f=1;
	}
	printf("%d",x);
return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ls(x) (x * 2)
#define rs(x) (x * 2 + 1)
using namespace std;
const int maxn = 2e5 + 7, inf = 1e9 + 7;
int n, m, ans = 0;

struct Opt
{
    int l, r;
} p[maxn];

struct Node
{
    int lazy, maxx;
} node[maxn * 4];

bool cmp(const Opt &A, const Opt &B) { return A.l < B.l; }

void pushdown(int num, int nl, int nr)
{
    if (!node[num].lazy)
        return;
    int lz = node[num].lazy;
    node[num].lazy = 0;
    node[ls(num)].maxx += lz;
    node[ls(num)].lazy += lz;
    node[rs(num)].maxx += lz;
    node[rs(num)].lazy += lz;
}

void update(int num)
{
    node[num].maxx = max(node[ls(num)].maxx, node[rs(num)].maxx);
}

void build(int num, int nl, int nr)
{
    node[num].lazy = 0;
    if (nl == nr)
    {
        node[num].maxx = nr - m - 1;
        return;
    }
    int mid = (nl + nr) / 2;
    build(ls(num), nl, mid);
    build(rs(num), mid + 1, nr);
    update(num);
}
void add(int num, int nl, int nr, int ql, int qr, int ad)
{
    if (ql <= nl && nr <= qr)
    {
        node[num].maxx += ad;
        node[num].lazy += ad;
        return;
    }
    if (nr < ql || qr < nl)
        return;
    int mid = (nl + nr) / 2;
    pushdown(num, nl, nr);
    add(ls(num), nl, mid, ql, qr, ad);
    add(rs(num), mid + 1, nr, ql, qr, ad);
    update(num);
    return;
}

int quary(int num, int nl, int nr, int ql, int qr)
{
    if (ql <= nl && nr <= qr)
        return node[num].maxx;
    if (nr < ql || qr < nl)
        return -inf;
    int mid = (nl + nr) / 2;
    pushdown(num, nl, nr);
    return max(quary(ls(num), nl, mid, ql, qr), quary(rs(num), mid + 1, nr, ql, qr));
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &p[i].l, &p[i].r);
    sort(p + 1, p + n + 1, cmp);
    p[n + 1].l = inf;
    build(1, 0, m + 1);
    for (int i = 1; i <= n; i++)
    {
        add(1, 0, m + 1, 0, p[i].r, 1);
        if (p[i].l != p[i + 1].l && p[i].l <= m - 1)
            ans = max(ans, quary(1, 0, m + 1, p[i].l + 2, m + 1) - p[i].l);
    }
    ans = max(ans, n - m);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a, b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = double(a) / double(b);
    printf("%d %d %.8lf\n", d, r, f);
}



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

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

  if ((A+B) == (C+D) ) {
    cout << "Balanced" << endl;
  }
  else if ((A+B) > (C+D))  {
      cout << "Left" << endl;
    }
    else {
      cout<< "Right" << endl;
    }
  

  
}


Measured memory_bytes: 256
def main():
  n = int(input())
  a = list(input_list_str())
  index = n - 1
  ans = [a[index]]
  
  is_add = False
  for i in range(n-1):
    if is_add:
      index += 2
    else:
      index -= 2
    if index < 0:
      index = 0
      is_add = True
      
    ans.append(a[index])
    
    if index == 0 and is_add is False:
      index = -1
      is_add = True
    
      
  print(' '.join(ans))


def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

import math
import fractions
from functools import reduce
main()

Measured memory_bytes: 26608
def solve():
    i = (L//2019) + 1
    ans = 0
    if L <= 2019*i <= R:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()


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

typedef long long int ll;

int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	int cnt=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		if(i%2==0 && arr[i]%2==1)
			cnt++;
	}
	printf("%d\n",cnt);
}



Measured memory_bytes: 3748
#include<stdio.h>
#include<string.h>
int main()
{
    char s[101];
    scanf("%s",s);
    int pal=0,i,n;
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
            pal++;
    }
    printf("%d\n",pal/2);

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
 
//using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define null 0
#define pi 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define d0(x) cout<<x<<" ";
#define d1(x) cout<<x<<"\n";
#define d2(x,y) cout<<x<<" "<<y<<"\n";
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
 
//#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;} 
template<typename T, typename U> static inline void amax(T &x, U y){if (y > x)x = y;} 
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const  ll mod= 1000000007  ; 
const long long inf = (ll)1e18+17;
const int inff = 1500000000;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int test_case=0;
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
}
 
int main()
{  
    clock_t tt;tt = clock(); 
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    if(test_case==1)
    cin>>t;
    //pre();
    for(int i=1;i<=t;i++){
       //cout<<"Case #"<<i<<": ";
       solve();
    }
    tt = clock() - tt; double time_taken = ((double)tt)/CLOCKS_PER_SEC;   
    //printf("code took %f seconds to execute \n", time_taken); 
    return 0;
}
 
// ============== Notes =============== //
// common bugs
// - remove ios_base for interactive problems
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 3644
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000000ll
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//素数pair(特定の素因数,特定の素因数を含む個数)
struct pf{
    vector<long long> res;
    pf(long long N) {
        for (long long a = 2; a * a <= N; ++a) {
            if (N % a != 0) continue;
            if (N % a == 0) res.push_back(a);
        }
        if (N != 1) res.push_back(N);
    }
};


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

    ll n;
    cin>>n;
    vll a(n);
    ll f[1000005]={};
    rep(i,n){
        int a;
        cin>>a;
        f[a]++;
    }

    int judge=1;
    rep2(i,2,1000000){
        int tmp=0;
        rep2(j,1,1000000){
            if(i*j>1000000)break;
            tmp+=f[i*j];
        }
        chmax(judge,tmp);
    }

    
    if(judge==1)cout<<"pairwise coprime"<<endl;
    else if(judge==n)cout<<"not coprime"<<endl;
    else cout<<"setwise coprime"<<endl;
}

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

typedef long long ll;

int main() {

    ll N, min = 1000000000001;

    cin >> N;

    for(ll i = 1; i < 1000001; i++){
        if(N % i == 0){
            if(min > i + (ll)(N / i) - 2){
                min = i + (ll)(N / i) - 2;
            }
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

long long int ans = -1000000000, n;

void func2(vector<int>& v, vector<vector<int> >& f, vector<vector<int> >& p){
  long long int ret = 0;
  for(int i = 0; i < n; i++){
    int x = 0;
    for(int j = 0; j < 10; j++){
      if(v[j] == 1 && f[i][j] == 1) x++;
    }
    ret += p[i][x];
  }
  ans = max(ret, ans);
  return;
}

void func(vector<int>& v, vector<vector<int> >& f, vector<vector<int> >& p){
  if(v.size() == 10){
    int i;
    for(i = 0; i < v.size(); i++){
      if(v[i] != 0) break;
    }
    if(i == v.size()) return;
    //for(int i = 0; i < v.size(); i++) cout << v[i]; cout << endl;
    func2(v, f, p);
    return;
  }
  v.push_back(0);
  func(v, f, p);
  v.pop_back();
  v.push_back(1);
  func(v, f, p);
  v.pop_back();
  return;
}

void solve(){
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      cin >> f[i][j];
    }
  }
  vector<vector<int> > p(n, vector<int>(11));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 11; j++){
      cin >> p[i][j];
    }
  }
  vector<int> v;
  func(v, f, p);
  cout << ans << endl;
  return;
}

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


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

const int MAX_N = 100005;
int N;
int M;

int A[MAX_N]; // red
int B[MAX_N]; // white

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

    cin >> N >> M;

    for (int i = 0; i < N; ++i) {
        A[i] = 0;
        B[i] = 1;
    }
    A[0] = 1;
    B[0] = 0;

    while(M--) {
        int x;
        int y;

        cin >> x >> y;
        x--;
        y--;

        if (A[x] > 0) {
            A[x]--;

            A[y] = A[y] + B[y] + 1;
            B[y] = 0;
        } else {
            B[x]--;

            if (A[y] > 0) {
                A[y]++;
            } else {
                B[y]++;
            }
        }

        //for (int i = 0; i < N; ++i) {
        //    cout << A[i] << " " << B[i] << endl;
        //}
        //cout << endl;
    }

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        //cout << A[i] << " " << B[i] << endl;
        if (A[i] > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] dise = new int[7];
		
		for(int i = 1; i < 7; i++){
			dise[i] = scan.nextInt();
		}

		String houi = scan.next();
		int su = houi.length();
		char[] muki = new char[su];
		for(int j = 0; j < su; j++){
			muki[j] = houi.charAt(j);
		}

		for(int m = 0; m < su; m++){
			if(muki[m] == 'E'){
				int  e  = dise[1]; dise[1] = dise[4]; dise[4] = dise[6];
				dise[6] = dise[3]; dise[3] = e;
			}
			if(muki[m] == 'S'){
				int  s  = dise[1]; dise[1] = dise[5]; dise[5] = dise[6];
				dise[6] = dise[2]; dise[2] = s;
			}
			if(muki[m] == 'W'){
				int  w  = dise[1]; dise[1] = dise[3]; dise[3] = dise[6];
				dise[6] = dise[4]; dise[4] = w;
			}
			if(muki[m] == 'N'){
				int  n  = dise[1]; dise[1] = dise[2]; dise[2] = dise[6];
				dise[6] = dise[5]; dise[5] = n;
			}
		}
		System.out.println(dise[1]);
	}
}



Measured memory_bytes: 26312
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef pair<int,int> P;
int main(){
  const int INF=(1<<29);
  int k,dp[15][100010],i,j;
  scanf("%d\n",&k);
  queue<P> que;
  for(i=0;i<10;i++){
    for(j=0;j<k;j++){
      dp[i][j]=INF;
    }
  }
  for(i=1;i<10;i++){
    if(i>=k){
      break;
    }
    dp[i][i]=i;
    que.push(P(i,i));
  }
  while(!que.empty()){
    P p=que.front();
    que.pop();
    for(i=0;i<10;i++){
      if(dp[i][(10*p.second+i)%k]>dp[p.first][p.second]+i){
        dp[i][(10*p.second+i)%k]=dp[p.first][p.second]+i;
        que.push(P(i,(10*p.second+i)%k));
      }
    }
  }
  int ans=INF;
  for(i=0;i<10;i++){
    ans=min(ans,dp[i][0]);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 25912