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

const int Honest = 1;
const int Unkind = 0;

void coutAllInVec(vector<int> vec)
{
    for (int i = 0; i < vec.size(); ++i)
    {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

bool judgeIsPossibleForSingleHonestList(int n, vector<int> honestList, vector<vector<pair<int, int>>> speakList)
{
    vector<int> charaList;
    for (int i = 0; i < n; i++)
    {
        if (count(honestList.begin(), honestList.end(), i))
        {
            charaList.push_back(Honest);
        }
        else
        {
            charaList.push_back(Unkind);
        }
    }

    for (int i = 0; i < speakList.size(); ++i)
    {
        if (charaList.at(i) == Honest)
        {
            for (int j = 0; j < speakList.at(i).size(); ++j)
            {
                int x = speakList.at(i).at(j).first - 1;
                int y = speakList.at(i).at(j).second;
                if (charaList.at(x) != y)
                {
                    return false;
                }
            }
        }
    }
    return true;
}

bool createHonestListAndJudge(int n, int honestNum, vector<int> honestList, vector<vector<pair<int, int>>> speakList)
{
    if (honestNum == honestList.size())
    {
        // coutAllInVec(honestList);

        return judgeIsPossibleForSingleHonestList(n, honestList, speakList);
    }
    else
    {
        for (int i = (honestList.size() == 0 ? 0 : honestList.at(honestList.size() - 1)); i < n; ++i)
        {
            if (!count(honestList.begin(), honestList.end(), i))
            {
                vector<int> newHonestList(honestList.size());
                copy(honestList.begin(), honestList.end(), newHonestList.begin());
                newHonestList.push_back(i);
                bool isPossible = createHonestListAndJudge(n, honestNum, newHonestList, speakList);
                if (isPossible)
                {
                    return true;
                }
            }
        }
        return false;
    }
}

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

    vector<vector<pair<int, int>>> speakList;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        vector<pair<int, int>> singlePersonSpeakVec;
        for (int j = 0; j < a; ++j)
        {
            vector<int> singleSpeakVector;
            int x, y;
            cin >> x >> y;
            singlePersonSpeakVec.push_back(make_pair(x, y));
        }
        speakList.push_back(singlePersonSpeakVec);
    }

    int maxHonestNum = 0;
    for (int honestNum = n; honestNum > 0; --honestNum)
    {
        // cout << "honestNum:" << honestNum << endl;

        vector<int> honestList;
        bool isPossible = createHonestListAndJudge(n, honestNum, honestList, speakList);

        if (isPossible)
        {
            maxHonestNum = honestNum;
            break;
        }
    }
    cout << maxHonestNum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL dp[110][101010];
int main(){
    int n, W;
    cin >> n >> W;
    vector<LL> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    rep(i, 110)rep(j, 101010) dp[i][j] = LLINF;
    dp[0][0] = 0;
    rep(i, n){
        rep(j, 100010){
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j+v[i]], dp[i][j] + w[i]);
            // if(dp[i+1][j] < INF) cerr << dp[i+1][j] << " ";
        }
        // cerr << endl;
    }
    int ans = 0;
    rep(j, 100010){
        if(dp[n][j] <= W) ans = j;
    }
    cout << ans << endl;

}


Measured memory_bytes: 87168
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      mut ab: [usize; 2],
    }
    ab.sort();
    ab.reverse();
    if ab[0] == ab[1] {
        println!("{}", ab[0] + ab[1]);
    } else {
        println!("{}", ab[0]*2-1);
    }
}


Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N = int(input())
B = list(map(int, input().split()))

ans = B[0]

for i in range(N-2):
    ans += min(B[i], B[i+1])

ans += B[N-2]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    long long sum = 0;
    int A[n];
    int mod = 1000000007; 
    long long ans = 0;
    for(int i = 0;i<n;i++){
    	cin>>A[i];
        sum += A[i];
        sum %= mod;
    }
    for(int i = 0;i<n;i++){
        sum -= A[i];
        if (sum < 0) sum += mod;
    	ans += sum*A[i];
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3916
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 , 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" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:chars,b:chars};
    println!("{}", if a[0]=='D' {
        if b[0]=='H' {'D'}
        else {'H'}
    } else {
        {b[0]}
    });
}


Measured memory_bytes: 4352
#60c
N,T = map(int, input().split())
t_list = [int(e) for e in input().split()]

ans = 0

start_time = 0
extend_start_time = 0

for i in range(N):
    #print(t_list[i])
    
    if t_list[i] - extend_start_time <= T:
        extend_start_time = t_list[i]
        #print("extended")
    else:
        ans += T + extend_start_time - start_time
        #print(extend_start_time,start_time)
        #print("ans += ",T +  extend_start_time - start_time)
        start_time = t_list[i]
        extend_start_time = t_list[i]

ans += T + extend_start_time - start_time
        
print(ans)

Measured memory_bytes: 25200
#include <iostream>
#include <algorithm>
#define int long long

using namespace std;

const int N = 1e5 + 10;

int a[N], cnt[N];

signed main() {
	int n;
	cin >> n;
	int res = 0;
	for (int i = 0; i < n; ++i) cin >> a[i], cnt[a[i]]++, res += a[i];
    int q;
    cin >> q;
    
    while (q--) {
    	int b, c;
    	cin >> b >> c;
    	res += (c - b) * cnt[b];
    	cnt[c] += cnt[b];
    	cnt[b] = 0;
    	cout << res << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 5032
#include <stdio.h>
#include <math.h>

int main(){
  int n;
  double s[1000],sum,ave,bunsan,hensa;
  int i;

  while(1){
    scanf("%d",&n);
    if(n==0) break;
    sum=0;
    ave=0;
    bunsan=0;
    hensa=0;

    for(i=0; i<n; ++i){
      scanf("%lf",&s[i]);
      sum+=s[i];
    }

    ave=sum/n;

    for(i=0; i<n; ++i){
      bunsan+=pow(s[i]-ave,2);
    }

    bunsan/=n;

    hensa=sqrt(bunsan);

    printf("%f\n",hensa);
    
  }


  return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, k, m;
int main(){
    while(cin>>n>>k>>m, n||k||m){
        vector<ll> stone;
        REP(i, 0, n) stone.emplace_back(i+1);

        ll idx=m-1;
        stone.erase(stone.begin()+idx);
        REP(i, 0, n-2){
            idx=(idx+k-1)%stone.size();
            stone.erase(stone.begin()+idx);
        }

        cout<<stone[0]<<endl;
    }
    return 0;
}


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

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

  cout << (A * B) << endl;

  return 0;
}

Measured memory_bytes: 3636
program main;
var 
   a : integer;
begin
    readln(a);
    if a < 1000 then 
        writeln(1000-a)
    else 
        begin 
            while ( a > 1000 ) do
                dec(a,1000);
            if a = 0 then 
                writeln('0')
            else
                writeln(1000-a);
        end;
end.

Measured memory_bytes: 1384
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n m
x1 ... xm

n m 10^5
xi -10^5 10^5
 */
int n,m;
int x[100000];
int l[100000];

int main(){
  cin>>n>>m;
  REP(i,m){
    cin>>x[i];
  }

  sort(x, x+m);
  
  REP(i,m-1){
    l[i] = x[i+1] - x[i];

  }

  sort(l,l+m-1);

  ll ans = 0;
  REP(i,m-n){
    ans += l[i];
    LOG("l[%d]=%d\n", i,l[i]);
  }


  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 1024
// A - Beginning
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	map<int,int> m;
	m[a] = m[b] = m[c] = m[d] = 1;
	string s ="1974";
	for(auto c:s) if(m[c-'0']!=1){ puts("NO"); return 0; }
	puts("YES");
}

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

bool isPrime(int x) {
    if (x <= 1) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int X;
    cin >> X;
    while (!isPrime(X)) X++;
    cout << X << endl;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var length, n int
	fmt.Scan(&n, &length)
	var s []string
	var tmp string
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		s = append(s, tmp)
	}
	sort.Strings(s)
	fmt.Println(strings.Join(s, ""))
}


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

int main(){
  string s, k="keyence";
  cin>>s;

  bool fl=false;
  for(int i=0; i<=7; i++){
    if(s.substr(0,i)==k.substr(0,i) && s.substr(s.size()-7+i)==k.substr(i)){
      fl=true;
      break;
    }
  }

  if(fl)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;

class Mat{
public:
  vector<vector<ll>> each;
  vector<vector<ll>> ret;
  ll mod;
  Mat(ll sum, ll cur, ll b, ll p10, ll mod){
    each = {{p10, 1, 0},{0,1,1},{0,0,1}};
    ret = {{sum},{cur},{b}};
    this->mod = mod;
  }
  vector<vector<ll>> mul(vector<vector<ll>>a, vector<vector<ll>>b){
    vector<vector<ll>> ret = vector<vector<ll>>(a.size(),vector<ll>(b[0].size(),0));
    for(int i=0;i<a.size();i++)
      for(int j=0;j<b[0].size();j++){
        ll tt = 0;
        for(int k=0;k<b.size();k++){
          tt=(tt+a[i][k]*b[k][j]%mod)%mod;
        }
        ret[i][j]=tt;
      }
    return ret;
  }
  ll calSum(ll n){
    vector<vector<ll>>tt={{1,0,0},{0,1,0},{0,0,1}};
    while(n){
      if(n&1){
        tt = mul(tt, each);
      }
      each = mul(each, each);
      n>>=1;
    }
    ret = mul(tt, ret);
    return ret[0][0];
  }
};

ll helper(ll x){
  ll ret = 0;
  while(x){
    ret=ret*10 + 9;
    x/=10;
  }
  return ret;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  ll n,a,b,mod;
  cin>>n>>a>>b>>mod;
  ll sum = a % mod;
  ll cur = a+b;
  n--;
  while(n){
    ll mx = helper(cur);
    ll cnt = (mx-cur)/b;
    Mat solve = Mat(sum, cur%mod, b%mod, (mx+1)%mod, mod);
    ll tcnt = min(n,cnt+1);
    ll nsum = solve.calSum(tcnt);
    //cout<<sum<<" "<<cur<<" "<<mx+1<<" "<<tcnt<<" "<<nsum<<endl;
    sum = nsum;
    cur = tcnt * b + cur;
    n-=tcnt;
  }
  cout<<sum<<endl;
  //bug(cur)
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
int sum[maxn],f[maxn];
int main(){
	m=100000;
	FOR(i,2,m)
		if(!f[i]){
			for(int j=2*i;j<=m;j+=i)
				f[j]=true;
		}
	FOR(i,2,m){
		sum[i]=sum[i-1];
		if(i%2){
			if(!f[i]&&!f[(i+1)>>1]){
				sum[i]++;
			}
		}
	}
	in(n);
	while(n--){
		int a,b;
		in2(a,b);
		out(sum[b]-sum[a-1]);
	}
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<char,int>;
const int inf = numeric_limits< int >::max()/3;

int bit[200010];
int dp[100000000];

int main(void){
  string s,t;
  cin >> s;
  cin >> t;
  int size = (int)s.size();
  int p = 0;
  for(int i = 0;i < t.size() && p < size;++i){
    if(t[i] == s[p])p += 2;
  }
  if(p >= size){
    puts("Yes");
    return 0;
  }
  
  p = 1;
  for(int i = 0;i < t.size() && p < size;++i){
    if(t[i] == s[p])p += 2;
  }
  if(p >= size)
    puts("Yes");
  else
    puts("No");
  return 0;
}

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

int main() {
  int N, K, ans=0;
  cin >> N >> K;
  vector<int> p(N);
  
  for(int i=0;i<N;i++){
   cin >> p.at(i);
  }
  sort(p.begin(),p.end());//,greater<int>());
  
  for(int i=0;i<K;i++){
   ans = ans + p.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <utility>

using namespace std;

// ?????§??¬?´???°
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
int main(int argc, char const* argv[])
{
    int x,y,m;
    cin >> x;
    cin >> y;

    if(y > x){
        swap(x,y);
    }
    do{
        m = x % y;
        x = y;
        y = m;
    } while(m != 0);

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,b,c;
  cin >> n;
  vector<int> a(n+1);
  long long ans = 0;
  rep(i,n+1) cin >> a[i];
  rep(i,n){
    cin >> b;
    c = a[i+1]+a[i];
    ans += min(c,b);
    a[i+1] = clamp(c-b,0,a[i+1]);
  }
  cout << ans << endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int n ;
    cin >> n ;
    if (n % 2 == 1 )
        cout << (n / 2) + 1 ;
    else
        cout << n / 2 ;


    return 0 ;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

string a,b;
int dat[3005][3005];

int lcs(int m,int n){
	repp(i,1,m,1){  
        repp(j,1,n,1){  
	        if(i==0||j==0)dat[i][j]=0;  
	        else if(a[i-1]==b[j-1])dat[i][j]=dat[i-1][j-1]+1;  
	        else dat[i][j]=max(dat[i-1][j],dat[i][j-1]);
        }  
    }
    return dat[m][n];
}

string backtrack(int x,int y){
	string temp="";
	if(x==0||y==0)return temp;
	if(dat[x][y]==dat[x-1][y])temp+=backtrack(x-1,y);
	else if(dat[x][y]==dat[x][y-1])temp+=backtrack(x,y-1);
	else temp+=a[x-1]+backtrack(x-1,y-1);
	return temp;
}

int main(){
	cin>>a;
	cin>>b;
	int len1=a.size();
	int len2=b.size();
	int maxx=max(len1,len2);
	repp(i,0,maxx,1){
		repp(j,0,maxx,1){
			dat[i][j]=-1;
		}
	}
	int l=lcs(len1,len2);
	string str=backtrack(len1,len2);
	reverse(str.begin(),str.end());
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     998244353
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int bin_exp(int b,int e)
{
	if(e==0)	
		return 1;
	int a=bin_exp(b,e/2);
	if(e&1)	
		return a*a*b;
	else 
		return a*a;
}

int powm(int x,int y,int m=MOD) 
{
	x=x%m;
	int res=1;
	while(y)
	{
		if(y&1)
			res=res*x;
		res%=m;
		y=y>>1;
		x=x*x;
		x%=m;
	}
	return res;
}

int modInverse(int a,int m=MOD)
{
	return powm(a,m-2,m);
}


int fact[200005];
int nCr(int n,int r)
{
	int res=(fact[n]*modInverse(fact[r]))%MOD;
	res=(res*modInverse(fact[(n-r)]))%MOD;
	return res;
}



int32_t main()
{
	fastIO
	inp_out();
	int n,m,k;
	cin>>n>>m>>k;

	fact[0]=1;
	for(int i=1;i<n;++i)
		fact[i]=(fact[i-1]*i)%MOD;

	int fa=0;
	for(int i=0;i<=k;++i)
	{
		int ans=nCr(n-1,i);
		int bleft=n-i;
		ans*=m;
		ans%=MOD;
		ans*=powm(m-1,bleft-1);
		ans%=MOD;
		fa+=ans;
		fa%=MOD;
	}

	cout<<fa;
	return 0;
}

Measured memory_bytes: 5212
def Two_Colors(n , sl , m , tl):

    ans = 0
    count = {}

    for i in range(n):
        if sl[i] in count:
            count[sl[i]] += 1
        else:
            count[sl[i]] = 1

    for i in range(m):
        if tl[i] in count:
            count[tl[i]] -= 1
        else:
            count[tl[i]] = -1

    for i in count.values():
        ans = max(ans , i)

    return ans

def main():
    n = int(input())
    sl = [str(input()) for i in range(n)]
    m = int(input())
    tl = [str(input()) for i in range(m)]
    print(Two_Colors(n , sl , m , tl))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        #region
        private static int ReadInt() => int.Parse(ReadLine());
        private static IEnumerable<int> ReadSplitInt() => Console.ReadLine().Split(' ').Select(i => int.Parse(i));
        private static IEnumerable<double> ReadSplitDouble() => Console.ReadLine().Split(' ').Select(i => double.Parse(i));

        private static bool IsEven(int n) => n % 2 == 0;
        #endregion

        public static void Main(string[] args)
        {
            var n = ReadInt();
            var l = ReadSplitInt().ToArray();

            var others = l.Sum() - l.Max();

            if (l.Max() < others)
                WriteLine("Yes");
            else WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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


static const double EPS = 1e-8;

char stage[20][20];

int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

class Data{
public:
	char dx;
	char dy;
	char stage[20][20];
	Data(char dx,char dy,char stage[20][20]){
		this->dx = dx;
		this->dy = dy;
		memcpy(this->stage,stage,sizeof(char)*(20*20));
	}
};


typedef pair <int,Data> PP;

int main(){

	int w,h;
	char sx,sy,gx,gy;
	while(~scanf("%d %d",&w,&h)){
		if(w==h && h==0) break;

		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				int n;
				scanf("%d",&n);
				stage[y][x] = n;

				if(stage[y][x]==2){
					sx=x;
					sy=y;
				}
				else if(stage[y][x]==3){
					gx=x;
					gy=y;
				}
			}
		}

		queue<PP> que;

		que.push(PP(0,Data(sx,sy,stage)));

		int res = 11;
		while(!que.empty()){
			int c = que.front().first;

			int qx = que.front().second.dx;
			int qy = que.front().second.dy;

			char tmpStage[20][20];
			memcpy(tmpStage,que.front().second.stage,sizeof(char)*(20*20));

			que.pop();

			for(int i=0;i<4;i++){
				for(int d=1;d<=max(w,h);d++){
					int dx = qx + tx[i]*d;
					int dy = qy + ty[i]*d;
					if(dx < 0 || dx >= w || dy < 0 || dy >= h) break;
					if(d==1 && tmpStage[dy][dx] == 1) break;

					if(tmpStage[dy][dx] == 1){
						
						char mx = dx - tx[i];
						char my = dy - ty[i];

						if(c+1 <= 10){
							//cost[my][mx] = c+1;
							tmpStage[dy][dx] = 0;
							que.push(PP(c+1,Data(mx,my,tmpStage)));	
							//cout << mx << " " << my << endl;
							tmpStage[dy][dx] = 1;
						}
						
						break;
					}
					else if(tmpStage[dy][dx] == 3){
						if(c+1 <= 10){
							res = min(res,c+1);
						}
						break;
					}
				}

			}
		}

		printf("%d\n", res > 10 ? -1 : res);
	}
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	string s,t;cin>>s>>t;
	int n=s.size(),m=t.size();
	int res=m;
	for(int i=0;i<n-m+1;++i){
		int r=0;
		for(int j=i;j-i<m;++j)r+=s[j]!=t[j-i];
		res=min(r,res);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i!=N/i)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  D=K/N;
  M=1;
  for(auto v:divisor(K))if(v<=D)M=v;
  Out(M);
}

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

int main(){
	int N;
	cin>>N;
	int a=N/100;
	int b=(N%100)/10;
	int c=(N%100)%10;
	if(a==7||b==7||c==7)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	int rn = uniform_int_distribution<int>(0, MAXN)(rng);

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

    int n,x;
    cin>>n>>x;
    int a[n];
    REP(i,n) cin>>a[i];
    sort(a,a+n);
    int ans = 0;
    REP(i,n) {
        if(x >= a[i]) ans++, x -= a[i];
        else {
            x = 0;
            break;
        }
    }
    if(x > 0) ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N):
    if X[i] == i + 1:
        if i < N - 1:
            X[i], X[i + 1] = X[i + 1], X[i]
        else:
            X[i - 1], X[i] = X[i], X[i - 1]
        ans += 1

print(ans)


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

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

    int differentCount = 0;
    for (int i = 1; i <= n; ++i)
    {
        int input;
        cin >> input;

        if (i != input)
        {
            ++differentCount;
        }
    }

    cout << ((differentCount <= 2) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
#include <utility>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

typedef complex<double> P;
typedef const P &rP;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

#define EPS 1e-7

double pi;

vector<P> z;

inline double sq(double x){ return x * x; }

double cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

double difangle(double a, double b){
	const double pi2 = 2.0 * pi;
	a -= b;
	while(a < 0.0) a += pi2;
	while(a >= pi2) a -= pi2;
	return a;
}

double radius(rP pa1, rP da12, rP pb1, rP db12){
	P db21 = -db12;
	P dab1 = pb1 - pa1;

	double D = cross(da12, db21);

	double t;
	if(abs(D) > EPS){
		t = cross(dab1, db21) / D;
	}
	else{
		t = 0.5 * abs(dab1);
	}
	return t;
}

pdd maxspeedcircle(int i, double ac){	//(speed, distance)
	rP a1 = z[i+1];
	rP a2 = z[i+2];
	P d1 = z[i+1] - z[i], d2 = z[i+3] - z[i+2];

	double sgn;
	if(cross(d1, a2 - a1) > 0.0){ sgn = 1.0; }
	else{ sgn = -1.0; }

	P v1 = polar(1.0, arg(d1) + 0.5 * pi * sgn);
	P v2 = polar(1.0, arg(d2) - 0.5 * pi * sgn);

	double r = radius(a1, v1, a2, v2);
	P c = a1 + v1 * r;

	double d;
	if(sgn > 0.0){
		d = difangle(arg(a2 - c), arg(a1 - c));
	}
	else{
		d = difangle(arg(a1 - c), arg(a2 - c));
	}
	
	double spd = sqrt(ac * r);

	return pdd(spd, r * d);
}

double maxspeedline(double v0, double L, double ac){
	return sqrt(sq(v0) + 2.0 * L * ac);
}

double time(double v0, double vL, double L, double a){
	double x = 0.5 * ((sq(vL) - sq(v0)) * 0.5 / a + L);
	double vx = sqrt(sq(v0) + 2.0 * a * x);
	return (2.0 * vx - v0 - vL) / a;
}

int main(){
	pi = acos(-1.0);

	int n;
	double ac, x, y, ans = 0.0;
	scanf("%d%lf", &n, &ac);
	
	z.resize(2 * n);
	for(int i = 0; i < 2 * n; ++i){
		scanf("%lf%lf", &x, &y);
		z[i] = P(x, y);
	}

	priority_queue<pdi,vector<pdi>,greater<pdi> > pq;
	pq.push( pdi(0.0, 0) );
	pq.push( pdi(0.0, n) );

	vector<double> spds(n + 1);
	vector<double> dists(2 * n - 1);
	for(int i = 0; i + 1 < n; ++i){
		pdd p = maxspeedcircle(i * 2, ac);
		spds[i+1] = p.first;
		dists[2*i+1] = p.second;

		pq.push( pdi(p.first, i+1) );
	}
	for(int i = 0; i + 1 < 2 * n; i += 2){
		dists[i] = abs(z[i+1] - z[i]);
	}

	while( !pq.empty() ){
		double spd = pq.top().first;
		int index = pq.top().second;
		pq.pop();
		if(spds[index] != spd) continue;

		if(index != 0){
			double ms = maxspeedline(spd, dists[index*2-2], ac);
			if(spds[index-1] > ms){
				spds[index-1] = ms;
				pq.push( pdi(ms, index-1) );
			}
		}
		if(index != n){
			double ms = maxspeedline(spd, dists[index*2], ac);
			if(spds[index+1] > ms){
				spds[index+1] = ms;
				pq.push( pdi(ms, index+1) );
			}
		}
	}

	for(int i = 0; i < n; ++i){
		if(i != 0) ans += dists[i*2-1] / spds[i];
		ans += time(spds[i], spds[i+1], dists[i*2], ac);
	}

	printf("%.10f\n", ans);
}

Measured memory_bytes: 4188
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    vector<int> B(N-1);

    rep(i,N-1){
        cin >> B[i];
    }

    vector<int> A(N);
    int ans=0;
    ans = B[0];
    REP(i,1,N-1){
        ans += min(B[i-1],B[i]);
    }

    //B配列の最後の値
    ans += B[N-2];

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int n, q;
  cin >> n >> q;
  UnionFind tree(n);
  rep(i, q) {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 0) {
      tree.unite(b, c);
    } else {
      bool f = tree.same(b, c);
      if(f) cout << 1<< endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}


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

signed main() {
    int n, k;
    string s;
    
    cin >> n >> k;
    cin >> s;
    
    for ( int i = 0; i < n; i++ ) {
        if ( i != k-1) {
            cout << s[i];
        } else {
            cout << char(s[i] - 'A' + 'a');
        }
    }
    cout << endl;
    return (0);
}

Measured memory_bytes: 3532
#include <iostream>

using namespace std;

int main()
{
    int n,a,b;
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++){
        cin >> a >> b;
        ans += b - a + 1;
        
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll powm2(int x){
    ll ref=1LL;
    ref = ref<<x;
    if(x%2LL)ref*=-1LL;
    return ref;
}

ll sumpm2[50];
char ans[50];
void solve(int n){
    if(n==0){
        return;
    }else if(n>0){
        for(int i=0; i<31; i+=2){
            if(n<=sumpm2[i]){
                ans[i]='1';
                n-=powm2(i);
                //cout<<i<<endl;
                break;
            }
        }
    }else if(n<0){
        for(int i=1; i<32; i+=2){
            if(n>=sumpm2[i]){
                ans[i]='1';
                n-=powm2(i);
                //cout<<i<<endl;
                break;
            }
        }
    }
    return solve(n);
}
int main(){
    int n;
    cin>>n;

    sumpm2[0] = 1LL;
    sumpm2[1] = -2LL;
    for(int i=2; i<32; i++){
        sumpm2[i] = powm2(i)+sumpm2[i-2];
    }
    fill(ans,ans+50,'0');

    solve(n);
    int k=0;
    for(int i=49; i>=0; i--){
        if(ans[i]=='1'){
            k=i;
            //cout<<k<<endl;
            break;
        }
    }
    for(int i=k; i>=0; i--){
        cout<<ans[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
const ll MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s;
int ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int n = s.size();
    char c = s[0];
    rep(i, 1, n) {
        if (c != s[i]) {
            ans++;
            c = s[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
	ll m;
	cin >> m;
	ll sum=0,v=0;
	ll d,c;
	FOR(i,m){
		cin >> d >> c;
		sum+=d*c;
		v+=c;
	}
	ll ans=v-1+(sum/9);
	if(sum%9==0)ans--;
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N_MAX 1000009
ll nums[N_MAX];
bool h[N_MAX];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    //SieveOfEratosthenes();
    // for(long long i=0;i<=100;i++){
    //     cout<<i<<" "<<prime[i]<<" ";
    //     cout<<endl;
    // }
    ll n;
    cin >> n;
    ll x;

    for (ll i = 0; i < n; i++)
    {
       cin>>x;
       nums[x]++;
     
    }
    if(nums[1]>1){
        cout<<0<<endl;
        return 0;
    }
    if(nums[1]==1){
        cout<<1<<endl;
        return 0;
    }

   
    //sort(arr, arr + n);
    ll cnt = 0;
   // unordered_map<ll, bool> h;
    for (ll i = 1; i < N_MAX; i++)
    {
        
        if(nums[i]==0||h[i]){
            continue;
        }

       // cout<<i<<endl;
        //cout<<nums[i]<<endl;
        if(nums[i]==1&&!h[i])
        cnt++;
        for(ll j=i;j<N_MAX;j+=i){
            //if(nums[j])
            h[j]=true;

        }
    }
    // for(ll i=2;i<N_MAX;i++){
    //     if(!h[i]&&nums[i]<2){
    //         //cout<<i<<" ";
    //         cnt++;
    //     }
    //     //cout<<endl;
    // }
   // cout<<endl;
    cout << cnt << endl;

    return 0;
}

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

int main() {
  // input
  std::vector<std::vector<int>> A(3), B(3);
  for (int i = 0; i < 3; i++) {
    A[i].resize(3);
    B[i].resize(3);
    for (int j = 0; j < 3; j++) {
      std::cin >> A[i][j];
      B[i][j] = false;
    }
  }
  int N;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    std::cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == b) B[j][k] = true;
      }
    }
  }

  // -- horizontal --
  for (int i = 0; i < 3; i++) {
    bool f{true};
    for (int j = 0; j < 3; j++) {
      if (!B[i][j]) {
        f = false;
        break;
      }
    }
    if (f) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  // || vertical ||
  for (int i = 0; i < 3; i++) {
    bool f{true};
    for (int j = 0; j < 3; j++) {
      if (!B[j][i]) {
        f = false;
        break;
      }
    }
    if (f) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  // diagonal {1, 5, 9}
  {
    bool f{true};
    for (int i = 0; i < 3; i++) {
      if (!B[i][i]) {
        f = false;
        break;
      }
    }
    if (f) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  // diagonal {3, 5, 7}
  {
    bool f{true};
    for (int i = 0; i < 3;i++){
      if(!B[i][2-i]){
        f = false;
        break;
      }
    }
    if(f){
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
(_, _, M) = [int(inp) for inp in input().split()]

A = [int(inp) for inp in input().split()]
B = [int(inp) for inp in input().split()]

minA = min(A)
minB = min(B)

min = minA+minB

for m in range(0, M):
    (aindex, bindex, waribiki) = [int(inp) for inp in input().split()]
    newmin = A[aindex-1]+B[bindex-1] -waribiki
    if (newmin < min):
        min=newmin

print(min)

Measured memory_bytes: 18616
# coding: utf-8
# Your code here!

h,w,k=map(int,input().split())
cake=[]


for i in range(h):
    row=list(input())
    cake.append(row)

white=[]

m=[[0 for i in range(w)] for j in range(h)]

num=0
for i in range(h):
    if not(i-1 in white):
        num+=1
    flg=0
    for j in range(w):
        if cake[i][j]=="#":
            if flg!=0:
                num+=1
            flg=1
        m[i][j]=num
    
    
    if flg==0:
        white.append(i)
    else:
        a=i
        while a-1 in white:
            m[a-1]=m[a]
            a-=1
            white.pop(-1)
    
if len(white)>0:
    a=white[0]
    while a in white:
        m[a]=m[a-1]
        a+=1
    
    
            
for i in range(h):
    print(*m[i])
        
        


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

int main() {
    int n, d, co = 0;
    cin >> n >> d;
    double x, y;
    rep(i, n) {
        cin >> x >> y;
        double r = sqrt(x * x + y * y);
        if (r <= d)
            co++;
    }
    cout << co << endl;
    return 0;
}

Measured memory_bytes: 3860
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
lld calc(lld x, lld y)
{
    return (x*x*x*x*x)-(y*y*y*y*y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    t=1;
    while(t--)
    {
        lld x;
        cin>>x;
        for(i=0;i<6000;i++)
            {
                for(j=-6000;j<=i;j++)
                    if(calc(i,j)==x)
                {
                    cout<<i<<" "<<j<<endl;
                    return 0;
                }
            }
    }
}



Measured memory_bytes: 3664
def resolve():
    def dist(x, y, dx, dy):
        return ((x - dx) ** 2 + (y - dy) ** 2) ** (1 / 2)

    x1, y1, x2, y2 = list(map(int, input().split()))

    x3 = x2-(y2-y1)
    y3 = y2+(x2-x1)
    x4 = x3-(y3-y2)
    y4 = y3+(x3-x2)
    print(x3, y3, x4, y4)

    return

resolve()

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


int n;
const int N=3003;
double a[N],dp[N][N];

double rec(int ind,int t) {
    if(ind==n && t>=n/2+1) 
        return 1;
    else if(ind==n)
        return  0;
    double &cur=dp[ind][t];
    if(cur!=-1)return cur;
    return cur=a[ind] * rec(ind + 1 , t + 1)  + (1 - a[ind]) * rec(ind + 1 , t);
}

void solve(){
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> a[i];
        for(int j=0;j<n;++j)
            dp[i][j]=-1;
    }
    cout << rec(0,0) << "\n";
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cout << fixed << setprecision(12) ;
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 74404
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H, W;
	cin >> H >> W;
	string S[110];
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		cout << S[i] << endl;
		cout << S[i] << endl;
	}
}

Measured memory_bytes: 256