akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  outl((n-1)/2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String []s=br.readLine().split(" ");
		int a=Integer.parseInt(s[0]);
		int b=Integer.parseInt(s[1]);
		int c=Integer.parseInt(s[2]);
		
		c-=(a-b);
		if(c<0)
			System.out.println(0);
		else
			System.out.println(c);		
	}
}




Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n),b(n);
  priority_queue<pair<ll,ll>> q;
  for(ll i = 0; i < n; ++i) cin >> a[i];
  for(ll i = 0; i < n; ++i){
    cin >> b[i];
    q.emplace(b[i],i);
  }
  ll ans = 0,val,idx;
  while(!q.empty()){
    auto p = q.top();
    q.pop();
    tie(val,idx) = p;
    if(b[idx] < a[idx]){
      cout << -1;
      return 0;
    }
    if(b[idx] != val or b[idx] == a[idx]) continue;
    ll val2 = b[(idx+1)%n]+b[(idx+n-1)%n];
    if(val < val2+a[idx]){
      cout << -1;
      return 0;
    }
    ll tmp = (val-a[idx])/val2;
    ans += tmp;
    val -= val2*tmp;
    b[idx] = val;
    if(val > a[idx]) q.emplace(val,idx);
  }
  cout << ans;
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int i;
  i = (int)(S.length());

  string ans;
  if(S[i-1] == 's'){
    ans = S + "es";
    cout << ans << endl;
  }else{
    ans = S + "s";
    cout << ans << endl;
  }    
}



Measured memory_bytes: 3620
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  cin>>n;
  ll a=n*100/108;
  ll f=0;
  for(ll i=0;i<10;i++){
    if(((a+i)*108/100)==n){
      f=a+i;
      break;
    }
  }
  if(f)cout<<f<<endl;
  else cout<<":("<<endl;
}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N){
        cin >> A[i];
    }
    rep(i, N){
        cin >> B[i];
    }
    rep(i, N){
        cin >> C[i];
    }

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    ll sum = 0;
    rep(i, N){
        auto itr_a = lower_bound(A.begin(), A.end(), B[i]);
        ll a_num = itr_a - A.begin();
        auto itr_c = upper_bound(C.begin(), C.end(), B[i]);
        ll c_num = C.end() - itr_c;
        sum += a_num * c_num;

    }

    cout << sum << endl;


    return 0;
}


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

int main(void) {
int E, Y;
cin >> E >> Y;
    if (E == 0) {
        if (Y <= 1911) {
            cout << "M" << Y - 1867 << endl;
        }
        else if (Y <= 1925) {
            cout << "T" << Y - 1911 << endl;
        }
        else if (Y <= 1988) {
            cout << "S" << Y - 1925 << endl;
        }
        else {
            cout << "H" << Y - 1988 << endl;
        }
        
    }
    else if (E == 1) {
        cout << 1867 + Y << endl;
    }
    else if (E == 2) {
        cout << 1911 + Y << endl;
    }
    else if (E == 3) {
        cout << 1925 + Y << endl;
    }    
    else if (E == 4) {
        cout << 1988 + Y << endl;
    }    
                  
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 15;
const ll LINF = 1e18 + 5;
int n, m, cnt[N];
bool state[N];
vector <int> p[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=m; i++)
 	{
 		int k;
 		cin >> k;
 		while(k--)
 		{
 			int s;
 			cin >> s;
 			p[s-1].pb(i);
 		}
 	}
 	for(int i=1; i<=m; i++) cin >> state[i];
 	int ans = 0;
 	for(int i=0; i<(1<<n); i++)
 	{
 		for(int j=0; j<n; j++)
 		{
 			if((i>>j)&1)
 			{
 				for(int k : p[j])
 				{
 					cnt[k] ^= 1;
 				}
 			}
 		}
 		bool ok = 1;
 		for(int i=1; i<=m; i++) 
 		{
 			if(state[i]^cnt[i]) ok = 0;
 			cnt[i] = 0;
 		}
 		ans += ok;
 	}
 	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	ll x;
	cin >> x;

	ll cnt = 0;
	ll money = 100;
	bool ok = true;
	while (ok) {
		ll risi = money / 100;
		if (money + risi >= x) {
			ok = false;
		}
		money += risi;
		cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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

int main() {
  while (true) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    }
    if (x < y) {
      cout << x << " " << y << endl;
    }
    else {
      cout << y << " " << x << endl;
    }
  }
}



Measured memory_bytes: 3008
#include <stdio.h>
 
int main(void){
    int stone[100000];
    int num[100000];
    int pos = 0;
    int n;
    int i;
    int d;
 
    while(scanf("%d",&n) && n){
        scanf("%d",&d);
        stone[pos] = d;
        num[pos] = 1;
 
        for(i=1;i<n;i++){
            scanf("%d",&d);
            if(stone[pos]==d){
                num[pos]++;
            }else{
                if((i+1) & 0x0001){
                    //奇数
                    pos++;
                    stone[pos]=d;
                    num[pos]=1;
                }else{
                    //偶数
                    if(pos>0){
                        num[pos]++;
                        num[pos-1]+=num[pos];
                        pos--;
                    }else{
                        stone[pos]=d;
                        num[pos]++;
                    }
                }
            }
        }
         
        d=0;
        for(i=0;i<=pos;i++){
            if(stone[i]==0){
                d+=num[i];
            }
        }
        printf("%d\n",d);
         
        pos=0;
    }
}

Measured memory_bytes: 608
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,m,i,j,t;
  cin>>n>>m;
  int a[n];
  for(i=0;i<n;i++)
  	cin>>a[i];
  sort(a,a+n);
  int diff=inf;
  for(i=0;i<n;i++)
  {
  	if(i+m-1<n)
  	{
  		diff=min(diff,abs(a[i]-a[i+m-1]));
  	}
  }
  cout<<diff;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main (){
char ny;
int dr[101][101],h,w,c=0,i;
cin>>h>>w;
for (int s=0;s<h;s++){
        for (int s_=0;s_<w;s_++){
                cin>>ny;
                dr[s][s_]=-1;
                if (ny=='c')dr[s][s_]=0;
        }
}
for (int s=0;s<h;s++){
        for (int s_=0;s_<w;s_++){
                if (dr[s][s_]==0){
                i=s_;
                        for (int s__=i;s__<w;s__++){
                                if (dr[s][s__]==0)c=0;
                                if (dr[s][s__]==-1){
                                c++;
                                dr[s][s__]=c;
                                }
                        }
                        c=0;
                }
        }
}

for (int s=0;s<h;s++){
        for (int s_=0;s_<w;s_++){
                if (s_==w-1){
                cout<<dr[s][s_];
                }
                else {
                cout<<dr[s][s_]<<" ";
                }
        }
cout<<endl;
}
return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>>s(n);
  rep(i,m){
    int k;
    cin>>k;
    rep(j,k){
      int a;
      cin>>a;
      a--;
      s[a].push_back(i);
    }
  }
  vector<int>is(m);
  rep(i,m)cin>>is[i];
  int ans=0;
  rep(bits,1<<n){
    vector<int>ok=is;
    rep(i,n){
      if(bits>>i&1){
        for(auto t:s[i]){
          ok[t]=(!ok[t]);
        }
      }
    }
    bool f=true;
    rep(i,m){
      if(ok[i])f=false;
    }
    if(f)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
/*
  A - One Card Poker
  <http://abc054.contest.atcoder.jp/tasks/abc054_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  int A,B;

  scanf("%d %d", &A, &B);

  if( A > B ){
    if( B == 1 ){
      printf("Bob\n");
    }else{
      printf("Alice\n");
    }
  }else if( A < B ){
    if( A == 1 ){
      printf("Alice\n");
    }else{
      printf("Bob\n");      
    }
  }else{
    printf("Draw\n");
  }

  return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;

//区間スケジューリング
//N個の区間が与えられ、どの2つの区間も時間帯を共有しないように
//最大個数の区間を選ぶ

/*
区間の終端でソートしてGreedyにとっていけば良い
*/
bool cmp(pair<long long,long long>a,pair<long long,long long>b){
    return a.second<b.second;
}

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

    vector<pair<long long,long long>>A;
    rep(i,N){
        long long x,l;
        cin>>x>>l;
        A.emplace_back(make_pair(x-l,x+l));
    }
    sort(A.begin(),A.end(),cmp);
    long long right=-1e9-1;
    
    int ans=0;

    rep(i,N){
        if(right<=A[i].first){
            ans++;
            right=A[i].second;
        }
    }
    cout<<ans<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 2420
#include <iostream> 
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	int X;
	cin >> X;
	if (X == 7) {
		cout << "YES" << endl;
	}
	else if (X == 5) {
		cout << "YES" << endl;
	}
	else if (X == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
x, k, d = map(int,input().split())
x = abs(x)
r = int(x/d)
if r >= k:
    print(abs(x-k*d))
else:
    k -=r
    s1 = abs(x-r*d)
    if not (k%2==0):
        print(abs(s1-d))
    else:
        print(s1)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define N 1000020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
char s[N], t[N];
queue<int> q;

int main(int argc, char const *argv[]) {
  int n = read();
  scanf("%s", s + 1);
  scanf("%s", t + 1);

  if (!strcmp(s + 1, t + 1)) {
    return puts("0"), 0;
  }

  int ans = 0;

  for (int i = n, j = n; i; -- i) {
    if (t[i] == t[i - 1]) continue;
    j = min(j, i);
    while (j && s[j] != t[i]) {
      -- j;
    }
    if (!j) {
      return puts("-1"), 0;
    }

    while (!q.empty() && q.front() >= i + q.size()) {
      q.pop();
    }

    q.push(j);

    if (i != j) {
      ans = max(ans, (int) q.size());
    }
  }

  printf("%d\n", ans + 1);

  return 0;
}
/*
7
atcoder
aaaccce
*/

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll x; cin >> x;
    ll a = x/500;
    x = x-(a*500);
    ll b = x/5;
    cout << a*1000 + b*5 << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, k;
	cin >> n >> k;

	double ans = 0.0;
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;
		int ti = i;
		while (ti < k) {
			ti *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}

	out(ans);

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool flag = false;
  int count = 0;

  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  for (int i = 0; i < n; i++){
    if(a[i] % 2 == 0){
      count++;
      if(a[i] % 3 == 0 || a[i] % 5 == 0) flag = true;
      else{
        flag = false;
        break;
      } 
    }
  }
  if(count == 0) cout << "APPROVED" << endl;
  else if (flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
    public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
    	
    	String sss = sc.nextLine();
    	sc.close();
    	String [] arr = sss.split("\\s");
    	int a = 0, b = 0;
    	for(int i = 0; i < arr.length; i++) {
    		if(arr[i] != null) {
    			a = Integer.parseInt(arr[i]);
    			i++;
    			b = Integer.parseInt(arr[i]);
    		}
    		
    	}
    	
    	if(a <= b) System.out.println("0");
    	if(a > b) {
    		System.out.println(a-b);
    	}
    }
}


Measured memory_bytes: 21844
/* 2020/03/17 Atcoder 三井住友信託銀行プログラミングコンテスト2019 D - Lucky PIN */

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
    int n, cnt = 0; 
    string s;
    cin >> n >> s;
    for(int i=0; i<1000; i++) {
        int a[3] = {i/100, (i/10)%10, i%10};
        int k = 0;
        for(int j=0; j<n; j++) {
            if(s[j] == ('0' + a[k])) k++;
            if(k == 3) break;
        }
        if(k == 3) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


line = input()
num_query = int(input())

for loop in range(num_query):

    input_str = list(input().split())

    if input_str[0] == 'replace':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + input_str[3] + line[right:]

    elif input_str[0] == 'reverse':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + line[left:right][::-1] + line[right:]

    else: #print
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        for i in range(left,right):
            print(line[i],end = "")
        print()


Measured memory_bytes: 6448
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;


ll par[100000]; // par[i]... iの親
ll mem[100000]; // iの(自分も含めた) 構成数

ll root(ll x) {
    // 自身が親と同一の時まで再帰的にrootをたどる
    if(par[x]==x) return x;
    else { // xの親を直接根にする(経路圧縮)
      return par[x] = root(par[x]);
    }
}

void unite(ll x, ll y) {
  ll rx = root(x);
  ll ry = root(y);
  if(rx==ry) return;
  else {
    // if(rx<ry) {
    //   ll tmp = rx;
    //   rx = ry;
    //   ry = tmp;
    // }
    mem[ry] += mem[rx];
    par[rx] = ry;
    return;
  }
}

int main() {
  int N, M, K;
  int a, b, c, d;
  cin >> N >> M >> K;

  rep(i, N) par[i] = i; // 最初は全て自分が親
  rep(i, N) mem[i] = 1;
  vector<int> fri(N, 0); // fri[i]... iの友達の数
  vector<int> ans(N, 0);

  rep(i, M)
  {
    cin >> a >> b;
    unite(a-1, b-1);
    fri[a - 1]++;
    fri[b - 1]++;
  }

  rep(i, N) {
    ans[i] = mem[root(i)] - fri[i] - 1;
  }

  // cout << "mem ";
  // rep(i, N) cout << mem[root(i)] << ' ';
  // cout << endl;

  rep(i, K) {
    cin >> c >> d;
    if(root(c-1)==root(d-1)) { // 同じunion でブロック
      ans[c-1]--;
      ans[d - 1]--;
    }
  }

  rep(i, N) {
    cout << ans[i];
    if(i<N-1) cout << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3840
n = int(input())
h = list(map(int, input().split()))
ans = 0
while True:
    if(max(h) == 0):
        break

    i = 0
    while(i < n):
        if(h[i] == 0):
            i+=1
        else:
            ans += 1
            while(i < n and h[i] > 0):
                h[i] -= 1
                i+=1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;

    if(k%2 == 0) cout << a-b << endl;
    else cout << b-a << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    print(math.ceil((a+b)/2))
    return

#B
def B():
    s = S()
    t = S()
    s.sort()
    t.sort(reverse = True)
    if s < t:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = I()
    d = [None for i in range(n+1)]
    d[0] = 2
    d[1] = 1
    for i in range(2,n+1):
        d[i] = d[i-1]+d[i-2]
    print(d[n])
    return

#D
def D():
    x,y,z = LI()
    for i in range(1000000)[::-1]:
        if i*y+(i+1)*z <= x:
            print(i)
            quit()
    return

#E
def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "#":
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39920
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>

using  namespace std;

typedef long long ll;
typedef pair < int,int> pii;
typedef pair <double, double> pt;

const int N = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

int n,x,y,t,lx,ly,lt;

int main(){
    lx = 0,ly = 0,lt = 0;
    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        scanf("%d%d%d",&t,&x,&y);
        if(!(abs(lx - x) + abs(y - ly) <= t - lt && (t - lt) % 2 == (abs(lx - x) + abs(y - ly)) % 2)){
            printf("No\n");
            return 0;
        }
        lx = x;ly = y;lt = t;
    }
    printf("Yes\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

bool is_prime[100001];
int prime[100001];

int main(int argc, char const* argv[])
{
	int q;
	cin >> q;
	fill(is_prime, is_prime + 100001, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 100001; i++){
			if(is_prime[i]){
					for(int j = 2; j * i < 100001; j++){
							is_prime[i * j] = false;
					}
					if(is_prime[(i+1)/2])res++;
			}
			prime[i] = res;
	}
	for(int i = 0; i < q; i++){
			int l, r;
			cin >> l >> r;
			cout << prime[r] - prime[l-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vec A(n);
    rep(i,n) cin>>A[i];
    double B[n+1];
    B[0]=0;
    rep(i,n) B[i+1]=B[i]+(double)(A[i]+1)/2;
    double ans=0;
    rep(i,n-k+1) ans=max(ans,B[i+k]-B[i]);
    cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 6368
n=int(input())
s=input()
l=[]
for i in s:
  if i==')':
    if len(l)>0:
      if l[-1]=='(':
        l.pop()
      else:
        l.append(i)
    else:
      l.append(i)
  else:
    l.append(i)
print(l.count(')')*'(' + s +l.count('(')*')')


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,d;
    cin>>s>>d;
    int  l=0;
    if(s[0]==d[0])
    {
        l++;
    }
    if(s[1]==d[1])
    {
        l++;
    }
    if(s[2]==d[2])
    {
        l++;
    }
    cout<<l<<endl;
return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

now = D[0]
zorome = 0
if now[0] == now[1]:
    zorome += 1
else:
    zorome = 0
for i in range(1, N):
    now = D[i]
    if now[0] == now[1]:
        zorome += 1
        if zorome == 3:
            print('Yes')
            sys.exit()
    else:
        zorome = 0
print('No')


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N;
  cin >> N;
  vector<ll> f(N+1,0);
  for(ll i=1;i*i<=N;i++){
    for(ll j=1;j*j<=N;j++){
      for(ll k=1;k*k<=N;k++){
        if(i*i+j*j+k*k+i*j+j*k+k*i<=N){
          f.at(i*i+j*j+k*k+i*j+j*k+k*i)++;
        }
      }
    }
  }
  rep(i,N){
    cout << f.at(i+1) << endl;
  }
}

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

signed main(){
    
    int n;
    string s;
    cin>>n>>s;
    int ans = 0;
    for(int i=0;i<n;){
        if(s[i] == 'W'){
            int p = i;
            i++;
            while(i<n && s[i] == 'B') {
                //cerr << 1<<" " << i << endl;
                i++;
            }
            if(i<n && s[i]=='.'){
                int t = i;
                t++;
                while(t<n && s[t]=='W') t++;
                if(t<n && s[t] == 'B') continue;
                ans = max(ans,i-p-1);
            }
        }
        else if(s[i] == 'B'){
            while(i<n && s[i]!='.'){
                //cerr << 2<<" " << i << endl;
                i++;
            }
        }
        else {
            //cerr << 2<<" " << i << endl;

            i++;
        }
    }
    reverse(s.begin(),s.end());
    for(int i=0;i<n;){
        if(s[i] == 'W'){
            int p = i;
            i++;
            while(i<n && s[i] == 'B') i++;
            if(i<n && s[i]=='.'){
                int t = i;
                t++;
                while(t<n && s[t]=='W') t++;
                if(t<n && s[t] == 'B') continue;
                ans = max(ans,i-p-1);
            }
        }
        else if(s[i] == 'B'){
            while(i<n && s[i]!='.') i++;
        }
        else i++;
    }
    cout << ans << endl;
       
}


Measured memory_bytes: 3200
<?php
  fscanf(STDIN,"%d %d",$a,$b);
	$split_number = explode("-",trim(fgets(STDIN)));
	//print_r($split_number);
	if(count($split_number)==2){
      if(strlen($split_number[0])==$a && strlen($split_number[1])==$b){
        echo "Yes\n";
      }else{
        echo "No\n";
      }
    }else{
      echo "No\n";
    }

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

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

int mygcd(int a, int b, int c)
{
    int temp = 0;
    temp = gcd(a, b);
    return gcd(temp, c);
};

int main()
{
    int k;
    cin >> k;
    int sum = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                sum += mygcd(a, b, c);
            }
        }
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
	int a, n[3];
	cin >> a;
	
	while(cin >> n[0] >> n[1] >> n[2]){
		sort(n, n + 3);
		for(int i = 0; i < 3; i++){
			n[i] = pow(n[i], 2);
		}
		
		if(n[0] + n[1] == n[2]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2948
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  if(n==3 || n==5 || n==7) std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}


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

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

	vector<int> xv(n);
	for (auto& x : xv) {
		cin >> x;
	}

	int ret = 1000000000;
	for (int i = 1; i <= 100; ++i) {
		int t = 0;
		for (auto& x : xv) {
			t += (x - i) * (x - i);
		}
		ret = min(ret, t);
	}

	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main
{
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        String[] sl = s.split("[\\s]+");
        int n = Integer.parseInt(sl[0]);
        int x = Integer.parseInt(sl[1]);
        
        int min = 999999;
        int sum = 0;
        
        for(int i = 0; i < n; i++)
        {
          int z = Integer.parseInt(r.readLine());
          sum += z;
          min = Math.min(min, z);
        }
        
        System.out.println(n + (x - sum) / min);
        
    }
    
}


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

int main() {
	int sx,sy,tx,ty,dx,dy;
	cin >> sx >> sy >> tx >> ty;

	dx = tx-sx;
	dy = ty-sy;

	rep(i,dy)
		cout << 'U';
	rep(i,dx)
		cout << 'R';
	rep(i,dy)
		cout << 'D';
	rep(i,dx)
		cout << 'L';

	cout << 'L';
	rep(i,dy+1)
		cout << 'U';
	rep(i,dx+1)
		cout << 'R';
	cout << 'D';

	cout << 'R';
	rep(i,dy+1)
		cout << 'D';
	rep(i,dx+1)
		cout << 'L';
	cout << "U" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC120A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = ReadInt;
            var B = ReadInt;
            var C = ReadInt;

            int ans = Math.Min(B / A, C);
            Console.WriteLine(ans);



        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
string s;
int main()
{
	cin>>s;
	int c[101],f[101];
	memset(c,-1,sizeof(c));
	memset(f,-1,sizeof(f));//全部赋值为-1防止影响 
	int jsc=0,jsf=0;
	int l=s.length();
	for(int i=0;i<=l;++i)
	{
		if(s[i]=='C')//找到就记录 
		{
			jsc++;
			c[jsc]=i;
		}
		if(s[i]=='F')//找到就记录 
		{
			jsf++;
			f[jsf]=i;
		}
	}
	if(jsc==0 || jsf==0)//特判等于0的时候不可能存在 
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=1;i<=jsc;++i)
	for(int j=1;j<=jsf;++j)
	{
		if(c[i]<f[j])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0; 
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

	int64 N;
	cin >> N;
	PLL r(1, 0);
	REP(i, N) {
	    int64 q, x;
	    cin >> q >> x;
	    if (q == 1) {
	        r.fs *= x; r.sc *= x;
	    } else if (q == 2) {
	        r.sc += x;
	    } else {
	        r.sc -= x;
	    }
	}
	cout << -r.sc << " " << r.fs << endl;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ullong;
#define MAX 10
ullong gcd(ullong a, ullong b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ullong lcm(ullong a, ullong b) {
	if (b > a)
		swap(a, b);
	return a / gcd(a, b) * b;
}
void compute(int n) {
	ullong d1, d2, v1, v2, G;
	pair<ullong, ullong> S[MAX];
	for (int i = 0; i < n; i++) {
		cin >> S[i].first >> S[i].second;
		G = gcd(S[i].first, S[i].second);
		S[i].first /= G;
		S[i].second /= G;
	}
	ullong l = lcm(S[0].first, S[1].first);
	for (int i = 2; i < n; i++)
		l = lcm(l, S[i].first);

	ullong A[MAX];
	for (int i = 0; i < n; i++)
		A[i] = S[i].second * (l / S[i].first);
	G = gcd(A[0], A[1]);
	for (int i = 2; i < n; i++)
		G = gcd(G, A[i]);
	for (int i = 0; i < n; i++)
		cout << A[i] / G << endl;
}
main() {
	int n;
	while( cin >> n && n ) compute(n);
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll N,M;
    cin >> N >> M;
    vector<ll> Hi(N);
    rep(i,N) cin >> Hi[i];
    
    vector<bool> check(N,true);

    rep(i,M){
        ll Ai,Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        if(Hi[Ai] > Hi[Bi]){
            check[Bi] = false;
        }
        else if(Hi[Ai] == Hi[Bi]){
            check[Ai] = false;
            check[Bi] = false;
        }
        else{
            check[Ai] = false;
        }
    }

    ll count = 0;
    rep(i,N) {
        if(check[i]) count++;
        // cout << check[i];
    }

    cout << count;
}

Measured memory_bytes: 3988
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	
	N = int(input())
	
	s4 = []
	s7 = []
	for i in range(101):
		if i % 4 == 0:
			s4.append(i)
		if i % 7 == 0:
			s7.append(i)
			
	if N % 4 == 0 or N % 7 == 0:
		print("Yes")
		sys.exit()
		
	tmp = []
	for i in s7:
		for j in s4:
			if i + j == N:
				print("Yes")
				sys.exit()
			
	print("No")
	
	
	
if __name__ == "__main__":
	main()


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

ll sppref[MAXN], spsuf[MAXN], spref[MAXN];

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	REPN(i, 1, n){
		scanf("%d", &v[i]);
		sppref[i] = sppref[i - 1];
		if (v[i] > 0){
			sppref[i] += v[i];
		}
		spref[i] = spref[i - 1] + v[i];
	}
	for(int i = n; i >= 1; i--){
		spsuf[i] = spsuf[i + 1];
		if (v[i] > 0){
			spsuf[i] += v[i];
		}
	}
	ll ans = 0ll;
	for(int i = 1; i + k - 1 <= n; i++){
		ll add = spref[i + k - 1] - spref[i - 1];
		ll cur = sppref[i - 1] + spsuf[i + k] + max(add, 0ll);
		ans = max(ans, cur);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2944
N=int(input())
T,A=map(int,input().split())
height_list =list(map(int,input().split()))
val =10000
site=0
for i in range(N):
	dif=T-0.006*height_list[i]
	if abs(A-dif)<=val:
		val = abs(A-dif)
		site = i
print(site+1)

Measured memory_bytes: 3064
#pragma region template

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

// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
inline T udiv(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
inline T rdiv(T a, T b) {
    return (a + b / 2) / b;
}

template <class T>
void print(T x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        // cin.tie(0);
        // ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion


ll ans = 0;

void solve(long long N, std::string S) {
    vector<char> v(N);
    S.erase(unique(begin(S), end(S)), end(S));
    cout << S.size() << endl;
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);

    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
#define int long long
int a[200001];
signed main()
{
    int n , sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int pr = 0;
    int ans = sum;
    for(int i = 1; i <= n; i ++)
    {
        pr += a[i];
        ans = min(ans , abs(sum - pr - pr));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;



vector<pair<int64_t, int64_t>> fs;//素因数分解の素数，指数のペア
 
void prime_factorize(LL N){
   vector<pair<LL, LL>> res;
   for (LL a = 2; a * a <= N;a++) {
	   if(N % a == 0){
	   LL ex = 0; //指数
 
	   //割れる限り割り続ける
	   while (N % a == 0) {
		   ++ex;
		   N /= a;
	   }
 
	   res.push_back(make_pair(a, ex));
       }
   }
 
   //最後に残った数について
   if ( N != 1) res.push_back(make_pair(N, 1));
   fs = res;
}
	
void factorization(int64_t base){//baseを素因数分解
    //base未満のiが約数か
    for(int i=2;i*i<=base;i++){
        //iで割り切れるなら限界まで割る
        
        if(base%i==0){
            int cnt=0;
            while(base%i==0){
                base/=i;
                cnt++;
            }
            fs.push_back(make_pair(i,cnt));
        }
    }
    //baseが素数
    if(base>1){
        fs.push_back(make_pair(base,1));
    }
}
int main(){
    int64_t n;
    cin>>n;
    
    
    //factorization(n);
    prime_factorize(n);
    int64_t ans=0;
    for(auto p : fs){
        int64_t e;
        e=p.second;
        int k=1;
        while(e-k>=0){
            e-=k;
            k++;
            ans++;
        }
    }

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

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

int main ()
{
	string s;
	cin >> s;
	int a, z;
	for (int i =0 ; i < s.size(); i ++) {
		if (s[i] == 'A') {a = i;
		break;
		}
	}
	for (int i = s.size()-1; i >= 0;i --)
	{
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z-a+1 << endl;
	return 0;
}


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

using namespace std;

const int N = 105;
int a[N][2];
unordered_map<int, int> adj[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    for (int i = 1; i<=n; i++) {
        cin >> a[i][0] >> a[i][1];
    }

    adj[1][a[1][1]] = a[1][0];
    adj[1][0] = 0;

    for (int i = 2; i<=n; i++) {
        for (auto e : adj[i-1]) {
            adj[i][e.first] = 1e9;
            adj[i][e.first + a[i][1]] = 1e9;
        }
    }

    adj[1][a[1][1]] = a[1][0];
    adj[1][0] = 0;

    for (int i = 2; i<=n; i++) {
        for (auto e : adj[i-1]) {
            adj[i][e.first] = min(adj[i][e.first], e.second);
            adj[i][e.first + a[i][1]] = min(adj[i-1][e.first] + a[i][0], adj[i][e.first + a[i][1]]);
        }
    }

    int sol = 0;
    for (auto e : adj[n]) {
        if (e.second <= w) {
            sol = max(e.first, sol);
        }
    }
    cout << sol << endl;
    return 0;
}


Measured memory_bytes: 116876
package main
import(
  "fmt"
  "sort"
)
func main(){
  var n, i int
  fmt.Scan(&n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
  }
  sort.Sort(sort.IntSlice(a))
  for i=0;i<n-1;i++{
    if a[i]==a[i+1]{
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
}


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

struct Seat {
	int li;
	int	ri;
};

int main() {
	int num_group = 0;
	int num_people = 0;
	cin >> num_group;
	vector <Seat> group(num_group);
	for (int i = 0; i < group.size(); i++) {
		cin >> group[i].li >> group[i].ri;
		num_people += (group[i].ri - group[i].li + 1);
	}
	cout << num_people << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  #include <stdlib.h>

  int *P;

  long long countup(int *A, int p, int r)
  {
    int q = p + (r-p)/2;
    int i, j, k, t;
    long long ct = 0;

    if (r - p < 3) {
      for (i = p; i < r; i++) {
        for (j = r; j > i; j--) {
      if (A[j] < A[j-1]) {
        t = A[j-1];
        A[j-1] = A[j];
        A[j] = t;
        ct++;
      }
        }
      }
      return ct;
    }
    ct += countup(A, p, q);
    ct += countup(A, q+1, r);

    i = p;
    j = q + 1;

    for (k = p; k <= r; k++) {
      if (i >= q + 1 || j >= r + 1) {
        if (i >= q + 1) P[k] = A[j++];
        else P[k] = A[i++];
      } else {
        if (A[i] > A[j]) {
      P[k] = A[j];
      ct += q - i + 1;
      j++;
        } else {
      P[k] = A[i];
      i++;
        }
      }
    }

    for (k = p; k <= r; k++) A[k] = P[k];

    return ct;
  }


  int main(int argc, char *argv[])
  {
    int n, i, j;
    int *A;

    long long a=0;

    scanf("%d", &n);
    A = (int *)malloc(sizeof(int) * n);
    P = (int *)malloc(sizeof(int) * n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    a = countup(A, 0, n - 1);

    printf("%lld\n", a);

    return 0;
  }



Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,M,a;
  cin>>N>>M;
  priority_queue<int> p;
  ll sum=0;
  for(ll i=0;i<N;i++){
    cin>>a;
    p.push(a);
    sum+=a;
  }
  for(ll h=0;h<M;h++){
    a=p.top();
    p.pop();
    p.push(a/2);
    sum-=a-a/2;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 892
N = int( input() )
h_list = list( map( int, input().split() ) )
high = 0
k = 0
for i in range(N):
    if h_list[i] > high:
        high = h_list[i]
    if high - h_list[i] >= 2:
        k = 1
if k == 0:
    print("Yes")
else:
    print("No")

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

int main()
{
	int K, X;
	scanf("%d%d", &K, &X);
	for (int i{X - K + 1}; i < X + K; i++)
		printf("%d%c", i, i + 1 == X + K? '\n': ' ');
	return 0;
}

Measured memory_bytes: 256
N = int(input())
words = [input() for _ in range(N)]

prev = words[0]
se = set([words[0]])

bl = True
for w in words[1:]:
  if w in se:
    bl = False
  if prev[-1] != w[0]:
    bl = False
  se.add(w)
  prev = w

answer = 'Yes' if bl else 'No'
print(answer)

Measured memory_bytes: 3064
#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 a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
        
    }
}

Measured memory_bytes: 3628