akhauriyash/Code-Regression huggingface dataset:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

#UnionFindのクラス,0-indexed
class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents = [-1,0,-4,1,1,1]のように、親の添字かマイナス要素数を表す
        self.parents = [-1] * n
    # find: xの親がすべてrootになる。これにより計算量削減(O(N) for all (not each))
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n,m = map(int,ipt().split())
    uf = UnionFind(n+1)
    for i in range(m):
        a,b = map(int,ipt().split())
        uf.union(a,b)

    print(-min(uf.parents))

    return None

if __name__ == '__main__':
    main()


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

int main(void) {
  int n;
  cin >> n;
  if (n < 2) cout << 1;
  else if (n < 4) cout << 2;
  else if (n < 8) cout << 4;
  else if (n < 16) cout << 8;
  else if (n < 32) cout << 16;
  else if (n < 64) cout << 32;
  else cout << 64;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_c
import sys
from collections import deque

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    a = 'abcdefghijklmnopqrstuvwxyz'
    t = 0
    r = deque([]) 
    for i in range(15):
        N -= 26**i
        if N < 0:
            break
        r.appendleft(a[N // 26**i % 26])
    print(''.join(r))
    return

main()


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

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  
  cin >> nMaxSiz;
  rvnSort.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnBubbleSort(vector<int>& rvnSort, int& rnSortCnt)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = rvnSort.size() - 1; i > nSorting; i--)
    {
      if (rvnSort[i] < rvnSort[i - 1])
      {
        bSorting = true;
        swap(rvnSort[i], rvnSort[i - 1]);
        rnSortCnt++;
      }
    }
    nSorting++;
  }
}

void fnOutput(const vector<int>& cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}
    
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int nSortCnt = 0;
  vector<int> vnSort;

  fnInput(vnSort);
  fnBubbleSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 21904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int n;
  cin>>n;
  map<int,int> peo;
  rep(i,n){
    int a;
    cin>>a;
    peo[a]=i+1;
  }
  rep(i,n)cout<<peo[i+1]<<endl;
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b

using namespace std;



void solve()
{
  int n; cin >> n;
  ll ans = 1;
  while( n > 1){
    ans = (ans*n)%mod1;
    n--;
  }
  cout << ans;
}
int main()
{
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();

  return 0;
}

Measured memory_bytes: 256
h, n = map(int, input().split())
monster = [[0, 0] for i in range(n)]
 
for i in range(n):
  a, b = map(int, input().split())
  monster[i][0], monster[i][1] = a, b

dps = [0 for i in range(h + 1)]
for i in range(1, h + 1):
  ans = 10 ** 10
  for m in monster:
    ans = min(ans, dps[max(i - m[0], 0)] + m[1])
  dps[i] = ans

print(dps[h])

Measured memory_bytes: 42220
/**         srijan_de
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/       08.04.2020     **/
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
#include    <bits/stdc++.h>  
using       namespace       std;
using       lli=            long long  int;
using       ulli=           unsigned long long int;
using       ld=             long double;
#define     mem(a,val)      memset( a,  val,  sizeof(a) )
#define     b_s             binary_search
#define     u_b             upper_bound
#define     l_b             lower_bound
#define     nl              cout<<endl
#define     pb              push_back
#define     pf              push_front
#define     ppb             pop_back
#define     ppf             pop_front
#define     in              insert
#define     fi              first
#define     se              second
#define 	pqueue			priority_queue
const lli   MOD=            (int)1e9 + 7;
const lli   MOD1=           (int)1e9 + 9;
const lli   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
lli         tests=          1;
template<class x,class y>x max(x a,y b){return (a>b)?a:b;}
template<class x,class y>x min(x a,y b){return (a<b)?a:b;}
template<class x,class y>x log(x n,y r){return (n>r-1)?1+log(n/r,r):0;}

///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main() 
{
	auto start = clock();
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);	
	#ifndef ONLINE_JUDGE	
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	#endif
//	cout<<fixed;
//	cout<<scientific;
//	cout<<fixed<<setprecision(12);
	//cin>>tests;
	for(lli test=1;test<=tests;test++) 
	{
//		cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
		
		lli n;
		cin>>n;
		string s;
		cin>>s;
		
		lli r=0,g=0,b=0;
		
		for(lli i=0;i<n;i++)
		{
			if(s[i]=='R')
			r++;
			if(s[i]=='G')
			g++;
			if(s[i]=='B')
			b++;
		}
		lli ans=r*g*b;
		
		for(lli i=0;i<n-1;i++)
		{
			for(lli j=1;j<=(n-i)/2;j++)
			{
//cout<<i<<' '<<i+j<<' '<<i+j+j<<endl;
				if(i+j>=n)
				continue;
				if(i+j+j>=n)
				continue;
				
				if(s[i]!=s[i+j])
				{
					if(s[i]!=s[i+j+j])
					{
						if(s[i+j]!=s[i+j+j])
						{
							//cout<<'l'<<endl;
							ans--;
						}
					}
				}
			}
			
			
			
			
		}
		
		
		
		cout<<ans;
		
		
		
		
		
		
		
		
		
		
		
		
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
	}
	cerr<<endl<<endl<<endl<< "Time : " << double(clock() - start) / CLOCKS_PER_SEC <<endl;
	return 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.


Measured memory_bytes: 3800
n,k=map(int,input().split())
S=input()
i=0
a=0
for i in range(n-1):
  if S[i]==S[i+1]:
    a=a+1
    i=i=1
  else:
    i=i+1
for j in range(k):
  if a<=(n-3):
    a=a+2
    k=k+1
  elif a==(n-2):
    a=a+1
    k=k+1
  else:
    k=k+1
print(a)

Measured memory_bytes: 3316
N = int(input())
A = [int(input()) for _ in range(N)]

#先頭は増やせないから０以外なら終わり
if A[0] != 0:
    print(-1)
    exit()


ans = 0
prev = 0
for n in reversed(A):
    if prev != 0:
        # 後ろから見て１ずつ減少する場合
        if n == prev - 1:
            prev = n
        # 前以上のとき、新たにその数字のために階段を構成する（前の数字を作る仮定で作れない）ので、その分の操作数が必要
        elif n >= prev:
            ans += n
            prev = n
        # ２以上の差があると作れない
        else:
            print(-1)
            exit()
    else:
        ans += n
        prev = n


print(ans)


Measured memory_bytes: 11052
n = int(input())
h = list(map(int, input().split()))
ans = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)
print(ans)

Measured memory_bytes: 14252
import heapq
import bisect

N, M = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()

NK = []
for _ in range(M):
    B, C = map(int, input().split())
    NK.append((C, B))
NK = sorted(NK, key=lambda x: -x[0])

ans = 0
minPos = 0
for (n, k) in NK:
    #print(minPos, k)
    pos = min(bisect.bisect(nums, n, lo=minPos), minPos+k)
    if pos <= minPos:
        continue
    #print(nums[minPos:pos], '=> ', n, pos)
    #print('rest', nums[pos:])
    ans += n * (pos-minPos)
    minPos = pos

ans += sum(nums[minPos:])

print(ans)


Measured memory_bytes: 76312
# 入力
n = int(input())
A = list(map(int,input().split()))

A.sort()

ans = 0
can = 1 # lastの数が後何回足されうるか
will = n-1 # 次に足されるであろう数のindex
for i in range(n-1):
    ans += A[will]
    can -= 1
    if can == 0:
        # 足されきったら一つ小さい数へ
        can = 2 # 最大値以外は2回足されうる
        will -= 1
print(ans)


Measured memory_bytes: 31412
n=int(input())
even={}
odd={}
for i,x in enumerate(list(map(int,input().split()))):
    if i%2==0:
        if even.get(x,0)==0:
            even[x]=1
        else:
            even[x]+=1
    else:
        if odd.get(x,0)==0:
            odd[x]=1
        else:
            odd[x]+=1

even=sorted(even.items(),key=lambda x:x[1])
odd=sorted(odd.items(),key=lambda x:x[1])
ans=0
if even[-1][0]==odd[-1][0]:
    if len(even)==1 and len(odd)==1:
        ans=n//2
    elif even[-1][1]>odd[-1][1]:
        ans=n-even[-1][1]-odd[-2][1]
    elif even[-1][1]<odd[-1][1]:
        ans=n-even[-2][1]-odd[-1][1]
    else:
        if even[-2][1]>odd[-2][1]:
            ans=n-even[-2][1]-odd[-1][1]
        else:
            ans=n-even[-1][1]-odd[-2][1]
else:
    ans=n-even[-1][1]-odd[-1][1]
print(ans)

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


int32_t main(){
    int n,d;cin>>n>>d;
    d*=2;
    d++;
    int x=n/d;
    if(n%d!=0){
    	x++;
    }
    cout<<x<<endl;
    
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string a, b; cin >> a >> b;
	int cnt = 0;
	rep(i, 0, a.size())cnt += a[i] == b[i];
	cout << cnt << endl;

	return 0;
}


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

using namespace std;

int main() {
	string x;
	cin >> x;
	bool check = 0;
	int cnt = 1;
	for (int i = 1; i < x.size(); i++) {
		if (x[i] == x[i - 1])
			cnt++;
		else cnt = 1;
		if (cnt >= 3)
			check = 1;
	}
	if (check)
		printf("Yes\n");
	else printf("No\n");
	return 0;
} 

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

if n >= m:
    print(0)
    exit()

a = sorted(a)
diff = []
for i in range(1, m):
    diff += [abs(a[i] - a[i-1])]

diff = sorted(diff, reverse=True)

ans = a[-1] - a[0]
for i in range(n-1):
    ans -= diff[i]

print(ans)

Measured memory_bytes: 13968
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll INF = 10e+9;

int main() {
    cin>>N>>K;
    vector<int> h(N,0);
    vector<ll> dp(N,INF);
    rep(i,N) cin >> h.at(i);
    int step[K];
    int mink;
    rep(i,N){
        if(i == 0) {
            dp[0] = 0;
            continue;
        }
        mink = min(i,K);
        reps(j,1,mink+1){
            step[j] = abs(h[i] - h[i-j]);
            dp[i] = min(dp[i], dp[i-j] + step[j]);
            //cout << step[j] << ' ';
        }
        //cout << dp[i] << ' ';
    }
    cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

  if (a+b > c+d) pr("Left");
  else if (a+b < c+d) pr("Right");
  else pr("Balanced");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,H,A[251];
  scanf("%d\n",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1)printf("parent key = %d, ",A[i/2]);
    if(i*2<=H)printf("left key = %d, ",A[i*2]);
    if(i*2+1<=H)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
//তুমি চেয়ে আছো তাই, আমি পথে হেঁটে যাই
//হেঁটে হেঁটে বহুদুর বহুদুর যেতে চাই 
//I FAILED BADLY AND VERY PUBLICLY
//THAT'S WHAT I DESERVE 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0) 
const long long M = 1e5 + 10, oo = 1e18L + 7;
ll n, wt[120], val[120], ans = 0, smval = 0, w;
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> w;
    // dp[i] - ans if we have taken total i weight
    for (ll i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
        smval += val[i];
    }
    vector < ll > dp (smval + 5, oo);
    dp[0] = 0;
    for (ll i = 0; i < n; i++) {
        for (ll cval = smval - val[i]; cval >= 0; cval--) {
            dp[cval + val[i]] = min(dp[cval + val[i]], dp[cval] + wt[i]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= smval; i++) {
        if (dp[i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
  char s[100000];
  long int i,n=0;
  scanf("%s",&s);
  n=strlen(s);
  for(i=0;i<n;i++){
    if(i%2==0){
      printf("%c",s[i]);
    }
  }
  printf("\n");
  return(0);
}


Measured memory_bytes: 256
N,K = map(int, input().split())
x = list(map(int, input().split()))
score = float('inf')
for i in range(N - K + 1):
  l = x[i]
  r = x[i + K - 1]
  score = min(score, abs(l) + abs(r - l), abs(r) + abs(l - r))
print(score)

Measured memory_bytes: 15020
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define __gcd gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ctr=1;
    rep(i,1,n){
        if(s[i]!=s[i-1]) ctr++;
    }
    cout<<ctr;
}

int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    vchar te(N + 1);
    ll ans = 0;

    map<char, char> win;
    win['r'] = 'p';
    win['p'] = 's';
    win['s'] = 'r';
    map<char, int> pts;
    pts['r'] = R;
    pts['p'] = P;
    pts['s'] = S;
    rep(i, N)
    {
        if (i - K < 0)
        {
            te[i] = win[T[i]];
            ans += pts[te[i]];
        }
        else if (win[T[i]] != te[i - K])
        {
            te[i] = win[T[i]];
            ans += pts[te[i]];
        }
        else
        {
            te[i] = 'Z';
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {

	int[] dice = new int[6];

	public Main(int[] nums, String order) {
		dice = nums;
	}

	public void move(String order) {

		for(Character s : order.toCharArray()) {
			int buf;
	        switch(s){
	            case 'N':{
	                buf = dice[0];
	                dice[0] = dice[1];
	                dice[1] = dice[5];
	                dice[5] = dice[4];
	                dice[4] = buf;
	                break;
	            }
	            case 'E':{
	                buf = dice[0];
	                dice[0] = dice[3];
	                dice[3] = dice[5];
	                dice[5] = dice[2];
	                dice[2] = buf;
	                break;
	            }
	            case 'W':{
	                buf = dice[0];
	                dice[0] = dice[2];
	                dice[2] = dice[5];
	                dice[5] = dice[3];
	                dice[3] = buf;
	                break;
	            }
	            case 'S':{
	                buf = dice[0];
	                dice[0] = dice[4];
	                dice[4] = dice[5];
	                dice[5] = dice[1];
	                dice[1] = buf;
	                break;
	            }
	        }
		}
	}

	public int[] checkRight(int upper, int front) {

		Random rnd = new Random();
		for(int i=0; i<10000; i++) {
			int r = rnd.nextInt(4);
			switch(r) {
				case 0:
					move("W");
					break;
				case 1:
					move("E");
					break;
				case 2:
					move("S");
					break;
				case 3:
					move("N");
					break;
				default:
					break;
			}
			if(dice[0] == upper && dice[1] == front) break;
		}

		return dice;

	}

	public int[] checkSurfaces() {
		return dice;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		Boolean sameFlag = false;

		int[] nums1 = new int[6];
		int[] nums2 = new int[6];
		for(int i=0; i<6; i++) {
			nums1[i] = sc.nextInt();
		}

		for(int i=0; i<6; i++) {
			nums2[i] = sc.nextInt();
		}

		Main dice1 = new Main(nums1, "");
		Main dice2 = new Main(nums2, "");

		// 共通の数値２つを取り出す
		int upper = -1;
		int front = -1;
		for(int i=0; i<6; i++) {
			for(int j=0; j<6; j++) {
				if(nums1[i] == nums2[j]) upper = nums1[i];
			}
		}
		for(int i=0; i<6; i++) {
			if(nums1[i] == upper) continue;
			for(int j=0; j<6; j++) {
				if(nums1[i] == nums2[j]) front  = nums1[i];
			}
		}

		sc.close();

		int[] surface1 = dice1.checkRight(upper, front);
		int[] surface2 = dice2.checkRight(upper, front);

		if(Arrays.equals(surface1, surface2)) sameFlag = true;

		if(sameFlag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 26440
#include <unistd.h>
#include <cstdio>
#include <x86intrin.h>

double mat[3000][3000]; 
double dp0[3000] __attribute((aligned(32)));
double ymm[4];

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

#pragma clang attribute push(__attribute__((target("avx2"))), apply_to=function)
int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = (double)v;
    }
    __m256i mask0 = _mm256_set_epi64x(0, 0, 0, -1); 
    __m256i mask1 = _mm256_set_epi64x(-1, -1, -1, 0); 
    for (int y = 0; y < rr; y++) {
        __m256d work = _mm256_setzero_pd();
        //ymm[0] = ymm[1] = ymm[2] = ymm[3] = 0;
        for (int x = 0; x < cc; x++) {
            __m256d tmp = _mm256_maskload_pd(&dp0[x], mask0);
            work = _mm256_max_pd(work, tmp);
            //ymm[0] = std::max(ymm[0], dp0[x]);
            //int v = mat[y][x];
            __m256d v = _mm256_set1_pd(mat[y][x]);
            v = _mm256_andnot_pd(mask0, v);
            __m256d s = _mm256_permute4x64_pd(work, (2 << 6) + (1 << 4));
            s = _mm256_add_pd(s, v);
            work  = _mm256_max_pd(work, s);
            __m256d s2 = _mm256_permute4x64_pd(work, (1 << 6) + (0 << 4) + (3 << 2) + (2 << 0));
            __m256d s3 = _mm256_max_pd(work, s2);
            __m256d s4 = _mm256_permute_pd(s3, 5);
            __m256d s5 = _mm256_max_pd(s3, s4);

//            for (int c = 3; c > 0; c--) {
//                ymm[c] = std::max(ymm[c], ymm[c - 1] + v);
//            }
//            dp0[x] = std::max(std::max(ymm[0], ymm[1]), std::max(ymm[2], ymm[3]));
            _mm256_maskstore_pd(&dp0[x], mask0, s5);
        }
    }
    std::printf("%.0lf\n", dp0[cc - 1]);
    return 0;
}
#pragma clang attribute pop

Measured memory_bytes: 74348
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-8
int dfs(double remain, int n, double a, int denominator) {
    if(fabs(remain) < EPS) return 1;
    if(remain < EPS) return 0;
    if(n <= 0) return 0;
    if(remain - ((double) n) / ((double) denominator) > EPS) return 0;
    int result = 0;
    for(int i=denominator; i<=a; i++) {
        if(a / ((double) i) < EPS) break;
        result += dfs(remain - 1.0 / ((double) i), n - 1, a / ((double) i), i);
    }
    return result;
}
int main() {
    double p, q, a;
    int n;
    while(cin>>p>>q>>a>>n, p+q+a+n) {
        cout<<dfs(p/q,n,a,1)<<endl;
    }
}

Measured memory_bytes: 1228
s = input()
t = input()
s1 = list(s)
t1 = list(t)
ls = len(s1)
ls1=ls-1
lt = len(t1)
z=0
if s1 == t1:
	z = 1
elif s1!=t1:
    for i in range(ls-1):
        x = s1[0]
        y = s1[ls1]
        del s1[ls1]
        s1.insert(0,y)
        if s1 == t1:
            z = 1
if z == 0:
    print("No")
else:
  print("Yes")


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String S = s.next();
		String T = s.next();
		int A = s.nextInt();
		int B = s.nextInt();
		String U = s.next();

		if(U.equals(S)) {
			A--;
		} else if (U.equals(T)) {
			B--;
		}
		System.out.println(A + " " + B);
	}
}


Measured memory_bytes: 38640
#include <cstdio>
#include <iostream>

using namespace std;

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

  if(a == b + c || b == a + c || c == a + b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

ll mod_pow(ll x, ll n, int mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%mod;
		x = x*x%mod;
		n >>= 1;
	}
	return res;
}

signed main() {
	ll n, m;
	scanf("%lld %lld", &n, &m);
	ll ans = min(n, m / 2), ama = m-ans*2;
	if(ama > 0)
		ans += ama / 4;
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i,n) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())
for i in range(K):
  if A >= B:
    B *= 2
  elif B >= C:
    C *= 2
  #print(i, A, B, C)
if A < B and B < C:
  print("Yes")
else:
  print("No")

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b;
    cin >> a >> b;
    if(a==1) a = 14;
    if(b==1) b = 14;

    if(a-b>0) cout << "Alice" << endl;
    else if(a-b<0) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IL inline
using namespace std;
typedef long long LL;
typedef unsigned int U;
typedef unsigned long long LLU;
typedef pair<int,int> PII;
typedef long double LD;
IL LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
#define io read()
const int mod=998244353;
IL LL ksm(LL x,int y)
{
	LL tmp=1;
	while(y){
		if(y&1)	tmp=tmp*x%mod;
		x=x*x%mod;
		y>>=1;	
	}
	return tmp;
}
IL void upd(int &x,int y)
{
	x+=y;
	if(x>=mod)	x-=mod;	
}
const int N=308;
int n,m;
bitset<N> a[N];
int ans;
IL void gauss()
{
	int i,j;
	for(i=1,j=1;j<=m;++j){
		if(a[i][j]==0){
			int t;
			for(t=i+1;t<=n;++t){
				if(a[t][j])	break;
			}
			if(t>n)	continue;
			swap(a[t],a[i]);
		}
		for(int t=i+1;t<=n;++t){
			if(a[t][j])	a[t]^=a[i];	
		}
		++i;
	}
	//(i-1)个主元 
	for(int t=i+1;t<=n;++t){
		if(a[t][m+1]){
			ans=0;
			return;
		}
	}
	ans=ksm(2,m-i+1);
}
int main()
{
	n=io;m=io;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			a[i][j]=io;	
		}
	}
	gauss();
	printf("%lld",(ksm(2,n+m-1)-ksm(2,n-1)*ans%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   string s,t;
   cin >> s >> t;
   int S = s.length(),T = t.length();
   int ans = 0;
   for(int i=0;i<=S-T;++i)
   {
       int cnt = 0;
       for(int j=0;j<T;++j)
       {
           if(s[i+j] == t[j])++cnt;
       }
       ans = max(ans,cnt);
   }
//    cout << ans <<endl;
   cout << T-ans;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    long double a,b,c;
    cin>>a>>b>>c;

    if (a+b+2*sqrtl(a*b)<c) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

int h,w,k;
string s[6];
vector<set<int>> rows;
vector<set<int>> cols;

void permGen(int cur, set<int> se, bool b)
{
    if (b)
    {
        if (cur==h)
        {
            rows.push_back(se);
            return;
        }
    }
    else
    {
        if (cur==w)
        {
            cols.push_back(se);
            return;
        }
    }
    permGen(cur+1,se,b);
    se.insert(cur);
    permGen(cur+1,se,b);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>h>>w>>k;
    for (int i=0;i<h;++i)
        cin>>s[i];
    set<int> se;
    int ans=0,cur;
    permGen(0,se,1);
    permGen(0,se,0);
    for (auto i : rows)
        for (auto j : cols)
        {
            cur=0;
            for (int x=0;x<h;++x)
                for (int y=0;y<w;++y)
                    if (i.find(x)==i.end())
                        if (j.find(y)==j.end())
                            if (s[x][y]=='#')
                                ++cur;
            if (cur==k)
                ++ans;
        }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	string S; cin >> S;
	vector<int> r, g, b;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'R') r.push_back(i);
		if (S[i] == 'G') g.push_back(i);
		if (S[i] == 'B') b.push_back(i);
	}
	ll res = 0;
	for (auto ri : r) {
		for (auto gi : g) {
			int i = ri, j = gi;
			if (j < i) swap(i, j);
			ll ok = b.size();
			int ng_idx = j + j - i;
			auto iter = lower_bound(b.begin(), b.end(), ng_idx);
			if (iter != b.end() && *iter == ng_idx)
				--ok;
			if ((j - i) % 2 == 0) {
				ng_idx = (i + j) / 2;
				iter = lower_bound(b.begin(), b.end(), ng_idx);
				if (iter != b.end() && *iter == ng_idx)
					--ok;
			}
			if (i - j + i >= 0) {
				ng_idx = i - j + i;
				iter = lower_bound(b.begin(), b.end(), ng_idx);
				if (iter != b.end() && *iter == ng_idx)
					--ok;
			}
			res += ok;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
const long long MAX = 100, INF = 1e18, WHITE = 0, GRAY = 1, BLACK = 2;

long long n, M[MAX][MAX];

void init(){
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = INF;
        }
    }
}
// void dijkstra(int x){
//     int minv;
//     int d[MAX], color[MAX];
//     for (int i = 0; i < n; i++)
//     {
//         d[i] = INF;
//         color[i] = WHITE;
//     }
//     d[x] = 0;
//     color[x] = GRAY;
//     while (true)
//     {
//         minv = INF;
//         int u = -1;
//         for (int i = 0; i < n; i++){
//             if (minv > d[i] && color[i] != BLACK){
//                 u = i;
//                 minv = d[i];
//             }
//         }
//         if (u == -1) break;
//         color[u] = BLACK;
//         for (int v = 0; v < n; v++)
//             if (color[v] != BLACK && M[u][v] != INF)
//                 if (d[v] > d[u] + M[u][v])
//                 {
//                     d[v] = d[u] + M[u][v];
//                     color[v] = GRAY;
//                 }
//     }
//     if (d[0] == INF)
//         {
//             cout << "INF";
//         }
//         else
//         {
//             cout << d[0];
//         }
//     for (int i = 1; i < n; i++)
//     {
//         if (d[i] == INF)
//         {
//             cout << " INF";
//         }
//         else
//         {
//             cout << " " << d[i];
//         }
        
//     }
// }

int main(){
    int e;
    cin >> n >> e;
    init();
    for (int i = 0; i < e; i++)
    {
        int s, t, u;
        cin >> s >> t >> u;
        M[s][t] = u;
    }
    for (int i = 0; i < n; i++)
        M[i][i] = 0;
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            if (M[i][k] == INF)continue;
            for (int j = 0; j < n; j++)
            {
                if (M[k][j] == INF) continue;
                M[i][j] = min(M[i][j], M[i][k] + M[k][j]);
            }
            
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (M[i][i] < 0)
        {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
        
    }
    
    for (int i = 0; i < n; i++)
    {
        if (M[i][0] == INF)
            cout << "INF";
        else
            cout << M[i][0];
        for (int j = 1; j < n; j++)
        {
            if (M[i][j] == INF)
                cout << " INF";
            else
                cout << " " << M[i][j];
        }
        cout << endl;
    }
    
}


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

int main(void){

	int n;
	cin >> n;

	int runner = 0;
	int result = 0;

	int i = 0;
	while(i < n * 3){

		string buff;
		cin >> buff;

		if (buff == "HIT"){
			runner++;
			if (runner > 3){
				result++;
				runner = 3;
			}
		}
		else if (buff == "OUT"){
			i++;
			if (i % 3 == 0){
				cout << result << endl;
				runner = 0;
				result = 0;
			}
		}
		else if (buff == "HOMERUN") {
			result += (runner + 1);
			runner = 0;
		}

	}

	return 0;
}

Measured memory_bytes: 1212
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int A[5];
    int k;
    int minA = 124;
    int maxA = 0;
    REP(i,5){
        cin >> A[i] ;
        chmin(minA,A[i]);
        chmax(maxA,A[i]);
    }
    cin >> k;
    (maxA - minA > k)? cout << ":("<< endl : cout << "Yay!" << endl;


}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		Map<Integer, Integer> map = new HashMap<>();

		IntStream.range(0, n).forEach(i -> {int a = Integer.parseInt(sc.next());
											map.put(a, map.getOrDefault(a, 0) + 1);}
									 );

		int ans = (k < map.size()) ? map.values().stream()
												 .sorted()
												 .limit(map.size() - k)
												 .mapToInt(Integer::intValue)
												 .sum()
								   : 0;

		System.out.println(ans);

		sc.close();
	}
}

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

int main() {
    int ans = 0;
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i) >> B.at(i);
    }
    vector<vector<int>> DP1(N, vector<int>(T, 0)), DP2(N, vector<int>(T, 0));
    for(int i = 0; i < N; i++) {
        for(int j = 1; j < T; j++) {
            if(i == 0) {
                if(0 <= j - A.at(i))
                    DP1.at(i).at(j) = B.at(i);
            } else {
                DP1.at(i).at(j) = max(DP1.at(i - 1).at(j), DP1.at(i).at(j - 1));
                if(0 <= j - A.at(i)) {
                    DP1.at(i).at(j) =
                        max(DP1.at(i).at(j),
                            DP1.at(i - 1).at(j - A.at(i)) + B.at(i));
                }
            }
        }
    }

    for(int i = N - 1; i >= 0; i--) {
        for(int j = 1; j < T; j++) {
            if(i == N - 1) {
                if(0 <= j - A.at(i))
                    DP2.at(i).at(j) = B.at(i);
            } else {
                DP2.at(i).at(j) = max(DP2.at(i + 1).at(j), DP2.at(i).at(j - 1));
                if(0 <= j - A.at(i)) {
                    DP2.at(i).at(j) =
                        max(DP2.at(i).at(j),
                            DP2.at(i + 1).at(j - A.at(i)) + B.at(i));
                }
            }
        }
    }

    ans = max(B.at(0) + DP2.at(1).at(T - 1),
              B.at(N - 1) + DP1.at(N - 2).at(T - 1));
    for(int i = 1; i < N - 1; i++) {
        for(int j = 0; j < T; j++) {
            ans = max(ans, B.at(i) + DP1.at(i - 1).at(j) +
                               DP2.at(i + 1).at(T - j - 1));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

string doCut(string str, int cutPlace, int length) {
	string strmae;
	string strato;

	strato = str.substr(0, cutPlace);
	strmae = str.substr(cutPlace, length - cutPlace);

	return strmae + strato;
}


int main(){

	string str;
	int size;
	int length;
	while (true) {
		cin >> str;

		if (str == "-")break;

		cin >> size;
		length = str.length();
		for (int i = 0; i < size; i++) {
			int cutPlace;
			cin >> cutPlace;

			str = doCut(str, cutPlace, length);
		}
		cout << str << endl;
	}


	

	//system("pause");
    return 0;
}




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

int main(){
	int a, b, d, r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a % b;
	f = (double) a / b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}


Measured memory_bytes: 3228
N, K = map(int, input().split())
MOD = 10**9 + 7
S = N * (N + 1) // 2

ans = 1
for d in range(N + 1):
    if N - d < K:
        break
    mx = S - (d * (d + 1) // 2)
    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)
    ans += (mx - mi + 1) % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<int> u(n),v(n);
  for(int i=0;i<n;++i)cin>>u[i];
  v[0]=u[0];
  for(int i=1;i<n;++i)v[i]=u[i]-u[i-1];
  for(int i=0;i<n;++i)if(v[i]>0)sum+=v[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))
    count = [0, 0, 0]
    for p in P:
        if p <= A:
            count[0] += 1
        elif A < p <= B:
            count[1] += 1
        else:
            count[2] += 1
    return min(count)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int input[3];
  int n, cnt, cnt2, flag, tmp;

  scanf("%d", &n);

  for(cnt = 0; cnt < n; ++cnt) {
    scanf("%d %d %d", &input[0], &input[1], &input[2]);

    do {
      flag = 0;
      for(cnt2 = 0; cnt2 < 2; ++cnt2) {
        tmp = 0;
        if(input[cnt2] < input[cnt2 + 1]) {
          tmp = input[cnt2];
          input[cnt2] = input[cnt2 + 1];
          input[cnt2 + 1] = tmp;
          flag = 1;
        }
      }
    } while(flag != 0);
    
    if(((input[2] * input[2]) + (input[1] * input[1])) == (input[0] * input[0])) {
      printf("YES\n");
    }
    else {
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 1010;

int co = 0;
int x;

int32_t main() {
	FAST
	cin >> x;
	int sum = 100;
	while (sum < x) {
		sum += (sum * 0.01);
		co++;
	}
	cout << co;
}



Measured memory_bytes: 3688