akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n,d;
    cin>>n>>d;

    cout<<((n%(2*d+1))? n/(2*d+1)+1:n/(2*d+1))<<endl;
    
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  ll beki=1;
  for(ll i=0;i<m;i++) {
    beki*=2;
  }
  ll ans=((n-m)*100+1900*m)*beki;
  cout << ans << endl;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<char> a(H*W);
  for(int i=0;i<H*W;i++){
    cin >> a[i];
  }
  for(int i=0;i<=W+1;i++){
    cout << "#";
  }
  cout << endl << "#";
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << a[W*i+j];
    }
    cout << "#" << endl << "#";
  }
  for(int i=0;i<W+1;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  set<int>S;
  for(int i=0;i<K;i++){
   int d; cin>>d;
    S.insert(d);
  }int ans;
  for(int i=N; ;i++){
  string s=to_string(i);
    int n=s.size();
    bool x=true;
    for(int j=0;j<n;j++){
      char a=s.at(j);
      int b=a-'0';
      if(S.count(b)){x=false; break;}
    
    }if(x){
      ans=i; break;
    }
  
  
  }cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    vector<int> pass[200005];
    int ans[100005] = {};
    int A, B;
    for (int i = 0; i < M; i++)
    {
        cin >> A >> B;
        pass[A].emplace_back(B);
        pass[B].emplace_back(A);
    }

    queue<int> que;
    que.push(1);
    ans[1] = 1;
    int f;
    while (!que.empty())
    {
        f = que.front();
        que.pop();
        for (int i : pass[f])
        {
            if (!ans[i])
            {
                que.push(i);
                ans[i] = f;
            }
            
        }
        
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


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

int main()
{
  int n; cin >> n;
  int a;
  string s = to_string(n);
  for (char c : s)
  {
    a += (c - '0');
  }
  if (!(n % a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize1; n]
    }
    let mut ps = vec![];
    let mut set = HashSet::new();
    let mut p = 0;
    while set.insert(p) {
        ps.push(p);
        p = v[p];
    }
    let mut l = 0;
    while ps[l] != p {
        l += 1;
    }
    if k < l {
        println!("{}", ps[k] + 1);
    } else {
        println!("{}", ps[(k - l) % (ps.len() - l) + l] + 1);
    }
}


Measured memory_bytes: 8160
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    int ans = 0, s, k;
    cin >> k >> s;

    for (int i=0; i<=k; i++){
        for (int j=0; j<=k; j++){
            if(s - i - j <= k and s- i - j >= 0)  ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

mn = 100000
for i in range(0,n-1):
    mae = w[:i+1]
    usiro = w[i+1:]
    if (abs(sum(mae)-sum(usiro)) < mn ):
        mn = abs(sum(mae)-sum(usiro))

print(mn)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


constexpr int MOD = 2019;
int64_t solve(const string & s) {
    int64_t ans = 0;
    vector<int64_t> cur(MOD), prv;
    for (char c : s) {
        cur.swap(prv);
        cur.assign(MOD, 0);
        prv[0] += 1;
        REP (i, MOD) {
            cur[(i * 10 + c - '0') % MOD] += prv[i];
        }
        ans += cur[0];
    }
    return ans;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 3756
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=100005;
int n,m,ans;
int f[maxn],p[maxn];

int Find(int x){return f[x]==x?x:f[x]=Find(f[x]);}
void Union(int x,int y){x=Find(x);y=Find(y);f[x]=y;}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,n)scanf("%d",&p[i]),f[i]=i,p[i]--;
	rep(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		Union(p[u],p[v]);
	}
	rep(i,n)if(Find(i)==Find(p[i]))ans++;
	printf("%d",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


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

ll ta[1000000];

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll x = 0;
    rep(i, n){
        x = GCD(x, a[i]);
    }
    if(x == 1){
        rep(i, n){
            auto mp = prime_factor(a[i]);
            for(auto p: mp){
                if(ta[p.first] != 0){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                ta[p.first]++;
            }
        }
        cout << "pairwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
}


Measured memory_bytes: 11756
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		N = ri();
		Console.WriteLine(N * N * N);
	}
	int N;
	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define MAXN 1007
using namespace std;

double x[MAXN], y[MAXN];

int main(){
    int n;
    cin >> n;
    for(register int i = 1; i <= n; ++i){
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    double k = 1;
    for(register int i = 1; i < n; ++i){
        k *= i;
    }
    for(register int i = 1; i <= n; ++i){
        for(register int j = i + 1; j <= n; ++j){
            ans += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    ans *= 2;
    ans /= n;
    printf("%.7lf\n", ans);
    return 0;
}


Measured memory_bytes: 764
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    h,w = map(int, sys.stdin.readline().split())
    a = [list(list(sys.stdin.readline().rstrip())) for i in range(h)]
    c = [list(row) for row in zip(*a)]
    b = [x for x in a if "#" in x]
    c = zip(*[y for y in zip(*b) if "#" in y])
    for d in c:
        print("".join(d))

    # #zip exercize
    # l = [[1, 2, 3], [4, 5, 6]]
    # l_t = list(zip(*l))
    # print(l_t)


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

int n;
vi a, b;

bool Odd(int bit) {
  int ans = 0, p = (1 << bit);
  for (int x : a)
    if (x & p)
      ans++;
  return (ans & 1);
}

void Copy(int bit) {
  int p = (1 << bit);
  for (int i = 0; i < n; i++)
    if (a[i] & p)
      b[i] |= p;
}

void Negate(int bit) {
  int p = (1 << bit);
  for (int i = 0; i < n; i++)
    if ((a[i] & p) == 0)
      b[i] |= p;
}

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  return 1;
}

void Process() {
  b.assign(n, 0);
  for (int i = 0; i < 31; i++) {
    if (Odd(i))
      Negate(i);
    else
      Copy(i);
  }
  for (int x : b)
    cout << x << " ";
  cout << "\n";
}

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

  while (Read())
    Process();

  return 0;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

int n;
int a[200000 + 5];
int p[200000 + 5];
vector<int>ans;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = n; i >= 1; i--)
	{
		int sum = 0;
		for (int k = i;k<=n; k += i)
			sum += p[k];
		if ((sum % 2) == a[i])p[i] = 0;
		else {
			ans.push_back(i);
			p[i] = 1;
		}
	}
	printf("%d\n", ans.size());
	for (int i = 0; i < ans.size(); i++)
		printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		final int N = s.nextInt();
		final int K = s.nextInt();

		ArrayList<Integer> lengthList = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			lengthList.add(Integer.parseInt(s.next()));
		}
		lengthList.sort(null);

		int ans = 0;
		for(int i = N-1; i > N-1-K; i--) {
			ans += lengthList.get(i);
		}
		System.out.println(ans);

	}

}


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

int main() {
  int n;
  cin >>n;
  n%=100;
  n%=10;
  if(n==2||n==4||n==5||n==7||n==9){
    cout <<"hon"<<endl;
  }else if(n==0||n==1||n==6||n==8){
    cout <<"pon"<<endl;
  }else{
    cout <<"bon"<<endl;
  }
}


Measured memory_bytes: 3636
n = int(input())
S = []
judge = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(n):
    s = input()
    judge[s] += 1
print('AC x', judge['AC'])
print('WA x', judge['WA'])
print('TLE x', judge['TLE'])
print('RE x', judge['RE'])

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

ll n,cap;
ll w[105];
ll val[105];
ll dp[105][100005];

ll fun(ll ind, ll remcap){
    ll&ans = dp[ind][remcap];
    if(ans!=-1)return ans;
    if(ind==n-1){
        if(remcap>=w[ind])return ans=val[ind];
        return ans=0;
    }
    ll ans1=-1,ans2;
    if(remcap>=w[ind])ans1=val[ind]+fun(ind+1,remcap-w[ind]);
    ans2=fun(ind+1,remcap);
    return ans=max(ans1,ans2);
}

int main() {
    for(ll i=0;i<105;i++)memset(dp[i],-1,sizeof(dp[i]));
    cin>>n>>cap;
    for(ll i=0;i<n;i++){
        cin>>w[i]>>val[i];
    }
    cout<<fun(0,cap);
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll ans = k;
  for (int i = 0; i < n - 1; i++) ans *= (k - 1);
  cout << ans << endl;
  return 0;
}


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;
using P = pair<int,int>;

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

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

    vector<int> town(N);
    iota(town.begin(), town.end(), 0);
    double ans = 0;
    do
    {
        for (int i = 0; i < N - 1; i++)
        {
            ans += sqrt((x[town[i + 1]] - x[town[i]]) * (x[town[i + 1]] - x[town[i]]) 
                        + (y[town[i + 1]] - y[town[i]]) * (y[town[i + 1]] - y[town[i]]));
        }
        
    } while (next_permutation(town.begin(), town.end()));
    
    double sum = 1;

    for (size_t i = 1; i <= N; i++)
    {
        sum *= i;
    }
    
    cout << setprecision(20) << ans / sum << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    ll tmp;
    while (y != 0) {
        tmp = x;
        x = y;
        y = tmp % y;
    }
    return x;
}

template<typename T>
T lcm(T x, T y){
    return (x * y) / gcd(x,y);
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n;
    cin >> n;

    ll ans=0;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        ans += a-1;
    }

    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }


Measured memory_bytes: 256
'''
from math import gcd
from itertools import accumulate, combinations, permutations, product
from bisect import bisect, bisect_left
from collections import Counter, defaultdict, deque
from heapq import heappush, heappop
from functools import reduce
from operator import add, mul, sub, truediv, floordiv, mod

from decimal import *
getcontext().prec = 500

import string
ascii = string.ascii_lowercase
'''
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    K, T = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort(reverse=1)
    cake = []
    x = []
    n = (K + 1) // 2
    for i in range(T):
        if A[i] > n:
            cake += [i] * n
            x += [i] * (A[i] - n)
        else:
            cake += [i] * A[i]
    cake += x
    turn = [0] * K
    j = 0
    for i in range(0, K, 2):
        turn[i] = cake[j]
        j += 1
    for i in range(1, K, 2):
        turn[i] = cake[j]
        j += 1
    ans = 0
    for i in range(1, K):
        ans += turn[i-1] == turn[i]
    print(ans)


main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
  #ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
  fastio
  lli n,i,d=0,f;
  cin>>n;
  for(i=1;i<=n;i++)
  {
  	cin>>f;
  	if(i%2!=0&&f%2!=0)
  		d++;
  }
  cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int gcd(int,int,int);
int main(void){
  int N=0;
  long count=0;
  scanf("%d",&N);
  for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
      for(int k=1;k<N+1;k++){
        count=count+gcd(i,j,k);
      }
    }
  }
  printf("%ld",count);
  return 0;
}
int gcd(int a,int b,int c){
  int ans=0;
  int min=a;
  if(b<min)min=b;
  if(c<min)min=c;
  for(int i=min;i>0;i-=1){
    if(a%i==0 && b%i==0 && c%i==0){
      ans=i;
      break;}
  }
  return ans;
}

Measured memory_bytes: 1692
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int type = 0;

int n, m;

struct S
{
    ll a;
    ll b;
    ll c;
    
    ll f() const
    {
        ll x = a, y = b, z = c;
        
        if (type & (1 << 0)) x *= -1;
        if (type & (1 << 1)) y *= -1;
        if (type & (1 << 2)) z *= -1;
        
        return x+y+z;
    }
    /*
     Intuitively finds a < b given the bitmask
     1 prioritizes min and 0 prioritizes max
     */
    friend bool operator<(const S &one, const S &two)
    {
        return one.f() < two.f();
    }
    
};

S arr[1001];

ll solve()
{
    sort(arr+1, arr+1+n);
    ll ret = 0;
    for (int i = 1; i <= m; i++) ret += arr[i].f();
    return abs(ret);
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++) cin >> arr[i].a >> arr[i].b >> arr[i].c;
    
    ll ret = 0;
    for (int i = 0; i < 8; i++)
    {
        type = i;
        ret = max(ret,solve());
    }
    
    cout << ret << '\n';
    
    return 0;
    
}




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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint pow(const modint x, ll r) {
        return x^r;
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

vector<vector<int>> g;
ll n, k;

modint dfs(int pre, int cur, int minus){
    modint res = k - minus >= 0 ? k - minus : 0;
    int done = 0;
    for(int to : g[cur]) if(to != pre) {
        res *= dfs(cur, to, (pre != -1) + 1 + done);
        done++;
    }
    return res;
}

int main(void){
    cin >> n >> k;
    g.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout << dfs(-1, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool o(int a, int b){
  if(-1 < a && a < 10 && -1 < b && b < 10)
    return true;
  return false;
}

int main(){

  int paper[10][10];
  char a;
  int x,y,size;
  int num=0,most=0;

  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      paper[i][j] = 0;

  while(cin >> x >> a >> y >> a >> size){
    switch(size){
    case 1:
      if(o(x,y))paper[x][y]++;
      if(o(x+1,y))paper[x+1][y]++;
      if(o(x-1,y))paper[x-1][y]++;
      if(o(x,y+1))paper[x][y+1]++;
      if(o(x,y-1))paper[x][y-1]++;
      break;
    case 2:
      if(o(x,y))paper[x][y]++;
      if(o(x+1,y))paper[x+1][y]++;
      if(o(x-1,y))paper[x-1][y]++;
      if(o(x,y+1))paper[x][y+1]++;
      if(o(x,y-1))paper[x][y-1]++;
      if(o(x+1,y+1))paper[x+1][y+1]++;
      if(o(x-1,y-1))paper[x-1][y-1]++;
      if(o(x-1,y+1))paper[x-1][y+1]++;
      if(o(x+1,y-1))paper[x+1][y-1]++;
      break;
    case 3:
      if(o(x,y))paper[x][y]++;
      if(o(x+1,y))paper[x+1][y]++;
      if(o(x-1,y))paper[x-1][y]++;
      if(o(x,y+1))paper[x][y+1]++;
      if(o(x,y-1))paper[x][y-1]++;
      if(o(x+1,y+1))paper[x+1][y+1]++;
      if(o(x-1,y-1))paper[x-1][y-1]++;
      if(o(x-1,y+1))paper[x-1][y+1]++;
      if(o(x+1,y-1))paper[x+1][y-1]++;
      if(o(x+2,y))paper[x+2][y]++;
      if(o(x-2,y))paper[x-2][y]++;
      if(o(x,y+2))paper[x][y+2]++;
      if(o(x,y-2))paper[x][y-2]++;
      break;
    }
  }
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++){
      if(paper[i][j] == 0)
	num++;
      if(paper[i][j] > most)
	most = paper[i][j];
    }
  cout << num << endl << most << endl;

  return 0;
}

Measured memory_bytes: 1160
n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort(reverse=True)
bc = [tuple(map(int, input().split())) for i in range(m)]
bc.sort(key=lambda x:-x[1])

ans = 0
cnt = 0
ai=0
bci=0

while cnt < n:
    if bci >= len(bc) or bc[bci][1] < a[ai]:
        ans += a[ai]
        cnt += 1
        ai += 1
        continue
    tmp = min([n-cnt, bc[bci][0]])
    ans += tmp * bc[bci][1]
    cnt += tmp
    bci+=1

print(ans)


Measured memory_bytes: 25692
#include <stdio.h>

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


Measured memory_bytes: 2040
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
char a[200010];
int main()
{
	scanf("%s",&a);
	int sum = 0;
	int len = strlen(a);
	for(int i = 0;i < len;i++){
		sum += (a[i] - '0');
	}
	if(sum % 9 == 0) printf("Yes\n");
	else printf("No\n");
	//printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3940
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		// long time = System.currentTimeMillis();
		new Main().run();
		// System.err.println(System.currentTimeMillis() - time);
	}

	void run() {
		Scanner sc = new Scanner();
		String s = sc.next();
		int n = s.length();
		int[] h = new int[n];
		for (int i = 0; i < n; ++i) {
			if (i > 0) {
				h[i] = h[i - 1];
			}
			h[i] ^= 1 << (s.charAt(i) - 'a');
		}
		int[] f = new int[1 << 26];
		Arrays.fill(f, Integer.MAX_VALUE / 3);
		for (int i = 0; i < n; ++i) {
			int hash = h[i];
			if (Integer.bitCount(hash) <= 1) {
				f[hash] = 1;
			}
			for (int j = 0; j < 26; ++j) {
				f[hash] = Math.min(f[hash], f[hash ^ (1 << j)] + 1);
			}
		}
		System.out.println(f[h[n - 1]]);
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 289364
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int n=s.length()-2;
        System.out.print(s.charAt(0));
        System.out.print(n);
        System.out.println(s.charAt(s.length()-1));


}
        
        
    }


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int x;
    cin >> x;

    if (x >= 30) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
	
int main (){
	int aa;
	cin >> aa;
	int a;
	int b;
	a = (aa-aa%2)/2;
	b = aa- a;
	cout << a*b << endl;
	return 0;
}


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

bool ATGC( char x ) {
  if (x == 'A' || x == 'T' || x == 'G' || x == 'C' ){
    return true;  
  } else {
    return false;  
  }
}
int main () {
  int ans = 0,temp = 0;
  string s;
  cin >> s;
  for ( auto c : s ) {
    if ( ATGC(c) ) ans = max( ans, ++temp );  
    else temp = 0;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

string f(string n) {

    if (n[0] == n[1] && n[0] == n[2]) {
        return "Yes";
    }

    if (n[1] == n[2] && n[1] == n[3]) {
        return "Yes";
    }

    if (n[0] == n[1] && n[0] == n[2] && n[1] == n[3]) {
        return "Yes";
    }

    return "No";
}

int main() {

    string n;
    cin >> n;

    string result = f(n);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Main {
  public static void main(String [] args) {
    FastReader fr = new FastReader();
    int N = fr.nextInt();
    if (N % 2 != 0) {
      N = N/2;
    } else {
      N = N/2 - 1;
    }
	System.out.println(N);
  }
}
 
class FastReader {
  BufferedReader br;
  StringTokenizer st;
 
  public FastReader() {
    br = new BufferedReader(new
        InputStreamReader(System.in));
  }
 
  String next() {
    while (st == null || !st.hasMoreElements())
    {
      try
      {
        st = new StringTokenizer(br.readLine());
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
    return st.nextToken();
  }
 
  int nextInt() {
    return Integer.parseInt(next());
  }
 
  long nextLong() {
    return Long.parseLong(next());
  }
 
  double nextDouble() {
    return Double.parseDouble(next());
  }
 
  String nextLine() {
    String str = "";
    try {
      str = br.readLine();
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    return str;
  }
}

Measured memory_bytes: 21200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, m, nume, numo, cur;

int main() {
	fastio; cin >> n >> m;
	nume = m/2; numo = m - nume;
	cur = 1;
	DEC(i, nume, 1) {
		cout << cur << " " << cur + 2*i << "\n";
		cur++;
	}
	cur = 2*nume + 1 + 1;
	DEC(i, numo, 1) {
		cout << cur << " " << cur + 2*i-1 << "\n";
		cur++;
	}
}


Measured memory_bytes: 3612
//packages
#include <bits/stdc++.h>//C++14 GCC mode!!!
//alias and namespaces
using namespace std;
//macros
#define REP(i,O,N) for(int i=O;i<N;i++)//うーん、python同様にRange関数でも実装してしまおうかしら…？
#define rep(i,N) for(int i=0;i<N;i++)
#define all(v) v.begin(),v.end()//v.end()-i は[-i]相当
#define debug(x) cerr<< #x <<":"<<x<<endl;
//functions   



//solution
int solution(std::vector<std::vector<bool>> grid){
    
    return 0;
}
int main(void){
    //input
    int N;
    cin>>N;
    std::vector<std::vector<int>> travel(N);
    
    rep(i,N){
        int t,a,b;
        cin >> t >> a >> b;
        travel.at(i)={t,a,b};
    }
    bool ans =1;
    int distance,timediff,x,y;
    rep(i,N){
        x = (i==0)?0:travel[i-1][1];
        y = (i==0)?0:travel[i-1][2];
        timediff = (i==0)?travel[0][0]:(travel[i][0]-travel[i-1][0]);
        distance = abs(travel[i][1]-x)+abs(travel[i][2]-y);
        ans= (distance-timediff <=0 and (distance-timediff)%2==0)?ans:0;
        }
    
    
    //output
    cout<<((ans==1)?"Yes":"No")<<endl;//true to yes
    //cout << solution(apoints)<<endl;//value
    //cout << ans<<endl;//other
    
}


Measured memory_bytes: 5760
N,K = map(int,input().split())
a = []
b = []
s = [0 for i in range(10**5 + 1)]
for i in range(N):
  x,y = map(int,input().split())
  s[x] += y

for i in range(1,len(s)):
  if s[i]>=K:
    print(i)
    exit()
  K-=s[i]
  

Measured memory_bytes: 5928
n = int(input())
ana_map = {}
for i in range(n):
    s = input()
    bucket = [0 for _ in range(26)]
    
    for c in s:
        bucket[ord(c) - ord('a')] += 1
    
    if(ana_map.get(str(bucket)) is None): ana_map[str(bucket)] = 1
    else: ana_map[str(bucket)] += 1

res = 0
for key in ana_map.keys():
    res += ana_map[key] * (ana_map[key]-1) / 2
print(int(res))

Measured memory_bytes: 23600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


signed main()
{
	int f[4] = {};
	int A, B;
	cin >> A >> B;
	f[A] = true;
	f[B] = true;
	for (int i = 1; i <= 3; i++)
	{
		if (!f[i])
		{
			cout << i << endl;
			return 0;
		}
	}
}




Measured memory_bytes: 504
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  var N = nextInt();
  var len = s.length;
  if(len == 1){
    myout(Math.floor((len * N) / 2));
    return;
  }
  var isAllSame = true;
  var s1 = myconv(s, 6);
  var s2 = myconv(s + s, 6);
  
  var output = 0;
  var s1count = 0;
  var s2count = 0;
  
  for(var i = 1; i < s1.length; i++){
    var mae = s1[i - 1];
    var ato = s1[i];
    if(mae != ato){
       isAllSame = false;
       break;
    }
  }
  
  if(isAllSame){
    myout(Math.floor(N * len / 2));
    return
  }
  
  for(var i = 1; i < s1.length; i++){
    var mae = s1[i - 1];
    var ato = s1[i];
    if(mae == ato){
       s1count++;
       s1[i] = "X";
    }
  }
  for(var i = 1; i < s2.length; i++){
    var mae = s2[i - 1];
    var ato = s2[i];
    if(mae == ato){
       s2count++;
       s2[i] = "X";
    }
  }
  if(N == 1){
    myout(s1count);
  }else{
    myout((s2count - s1count) * (N - 1) + s1count);
  }
  
}

Measured memory_bytes: 7372
s = str(input())

if len(s) % 2 == 0:
    a = s[:len(s)//2]
    b = s[len(s)
          //2:]

else:
    a = (s[:len(s)//2])
    b = (s[len(s)//2 + 1:])

a = list(a)    
b = [i for i in reversed(b)]
#print(a,b)
ans =0
for i in range(len(a)):
    if a[i] != b[i]:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n,m) for (int i=n; i<m; i++)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

int dfs(int i, int d, long long sum);

long long  ssum=0;
int l;
string s;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> s;
    l = s.length();

    dfs(1,0,0);
    cout<<ssum<<endl;
    return 0;
}

int dfs(int i, int d, long long sum){
    if (i==l){
        sum = sum+stoll(s.substr(d,i-d));
        ssum += sum;
        return 0;
    }
    else{
    dfs(i+1,i,sum+stoll(s.substr(d,i-d)));
    dfs(i+1,d,sum);
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX_SIZE = 1010;

typedef unsigned long long ull;

int to_num(char c){
  if(isupper(c)) return c - 'A';
  if(islower(c)) return 26 + c - 'a';
  if(isdigit(c)) return 52 + c - '0';
  if(c == '+') return 62;
  if(c == '/') return 63;
  assert(false);
}

void input(int H, int W, bool grid[MAX_SIZE][MAX_SIZE]){
  REP(y, H) {
    string s;
    cin >> s;
    REP(bx, s.size()){
      int n = to_num(s[bx]);
      for(int dx = 5; dx >= 0; dx--){
        int x = bx * 6 + dx;
        grid[y][x] = n % 2;
        n /= 2;
      }
    }
  }
}

int W, H, P;
bool image[MAX_SIZE][MAX_SIZE];
bool pattern[MAX_SIZE][MAX_SIZE];
ull hash[MAX_SIZE][MAX_SIZE];
ull tmp[MAX_SIZE][MAX_SIZE];
ull compute_hash(bool a[MAX_SIZE][MAX_SIZE], int W, int H){
  ull B1 = 9973ULL;
  ull B2 = 100000007ULL;

  ull t1 = 1; // B1のP乗
  ull t2 = 1; // B2のP乗
  REP(_, P) t1 *= B1;
  REP(_, P) t2 *= B2;

  // 横方向
  for(int y = 0; y < H; y++){
    ull e = 0;
    REP(x, P) e = e * B1 + a[y][x];
    for(int x = 0; x + P <= W; x++){
      tmp[y][x] = e;
      e = e * B1 - a[y][x] * t1 + a[y][x + P];
    }
  }

  // 縦方向
  for(int x = 0; x < W; x++){
    ull e = 0;
    REP(y, P) e = e * B2 + tmp[y][x];
    for(int y = 0; y + P <= H; y++){
      hash[y][x] = e;
      e = e * B2 - tmp[y][x] * t2 + tmp[y + P][x];
    }
  }
}

void rotate(){
  bool tmp[MAX_SIZE][MAX_SIZE];
  memcpy(tmp, pattern, sizeof tmp);
  for(int y = 0; y < P; y++){
    for(int x = 0; x < P; x++){
      pattern[x][P - 1 - y] = tmp[y][x];
    }
  }
}
void reflect(){
  bool tmp[MAX_SIZE][MAX_SIZE];
  memcpy(tmp, pattern, sizeof tmp);
  for(int y = 0; y < P; y++){
    for(int x = 0; x < P; x++){
      pattern[y][P - 1 - x] = tmp[y][x];
    }
  }
}
int main(){
  while(cin >> W >> H >> P && W){
    input(H, W, image);
    input(P, P, pattern);
    set<ull> hash_set;
    for(int r = 0; r <= 8; r++){
      compute_hash(pattern, P, P);
      hash_set.insert(hash[0][0]);

      if(r == 4) reflect();
      else rotate();
    }
    compute_hash(image, W, H);
    int ans = 0;
    for(int y = 0; y + P <= H; y++){
      for(int x = 0; x + P <= W; x++){
        if(hash_set.count(hash[y][x])) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 19576
using namespace std;
#include<string.h>
#include <sstream>
typedef long long int ll;
typedef long double ld;
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <map>
//#define N 4
#include <stack>
#include <unordered_set>
#include <math.h>
#include <cstring>
#include <bitset>
#include <numeric>
#include <set>
#include <sstream>
#include <list>
#include <queue>
#define PI 3.14159265358979323846264338327950
#define mp make_pair
#define inf 1e9
//#define M 1000000007
#define M 1000000007
#define N 100000

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k <= a) {
		cout << k << endl;
	} else if (a + b >= k) {
		cout << a << endl;
	} else {
		cout << a - (k - a - b) << endl;
	}
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int maxi = max(a, max(b, c));
  cout << maxi*10 + (a+b+c-maxi) << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            Console.ReadLine();
            var an = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Console.WriteLine("{0} {1} {2}", an.Min(), an.Max(), an.Sum());
        }
    }
}

Measured memory_bytes: 10420