akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 200000

int main(void)
{
	/*
	nは入力されるデータの個数を格納
	new_price - base_priceで利益を求め、diff_priceに代入する
	*/
	int i, n, base_price, new_price, diff_price;
	int price[MAXCOUNT];

	//データの個数を入力
	scanf("%d", &n);

	//データを入力
	for(i = 0; i < n; i++){
		scanf("%d", &price[i]);
	}

	//最大の利益を求める
	for(i = 0; i < (n - 1); i++){
		//ループの最初ならば初期値を代入
		if(i == 0){
			base_price = price[i];
			new_price = price[i + 1];
			diff_price = new_price - base_price;
		}
		//基準価格は最小にする
		else if(base_price > price[i]){
			base_price = price[i];
			new_price = price[i + 1];
			//最大利益が出るならば、更新する
			if(diff_price < (new_price - base_price)){
				diff_price = new_price - base_price;
			}
		}
		//変動後の価格は最大にする
		else if(new_price < price[i + 1]){
			new_price = price[i + 1];
			//最大利益が出るならば、更新する
			if(diff_price < (new_price - base_price)){
				diff_price = new_price - base_price;
			}
		}
	}

	//結果を出力
	printf("%d\n", diff_price);
	
	return 0;
}


Measured memory_bytes: 2584
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;


unordered_map<int, unordered_map<int, unordered_map<int, int>>> memo;
int gcd(int a, int b, int c) {
    if (memo.find(a) != memo.end() && memo[a].find(b) != memo[a].end() &&
            memo[a][b].find(c) != memo[a][b].end()) {
        return memo[a][b][c];
    }
    int ans = 1;
    int minv = min(a, min(b, c));

    for (int i = minv; i >= 1; --i) {
        if ((a % i) == 0 && (b % i) == 0 && (c % i) == 0) {
            ans = i;
            break;
        }
    }

    memo[a][b][c] = ans;
    return ans;
}

int gcd2(int a,int b) {
    if(a==b)
        return a;
    if(a>b)
        return gcd2(a-b,b);
    if(a<b)
        return gcd2(b-a,a);
    return 0;
}


unordered_map<int, int> memo2;
int main() {
    int k;
    cin >> k;
    int ans = 0;
    for (int a = 1; a <= 200; ++a) {
        for (int b = a; b <= 200; ++b) {
            int key = (a<<8) + b;
            memo2[key] = gcd2(a, b);
        }
    }
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                vector<int> nums{a, b, c};
                sort(nums.begin(), nums.end());
   //             cout << nums[0] << " " << nums[1] << " " << nums[2] << endl;
                int key = (nums[0] << 8) + nums[1];
                key = (memo2[key] << 8) + nums[2];
                ans += memo2[key];
            }
        }
    }

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


Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a;
	cin>>n>>a;
	vector<string> arr;
	for(int i =0;i<n;i++)
	{
		string a;
		cin>>a;
		arr.push_back(a);
	}
	sort(arr.begin(),arr.end());
	for(int i =0;i<arr.size();i++)
		cout<<arr[i];
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n;
string s;
int main(){
	n=read();
	while(n){
		if(n%26==0){
			s+='z',n=n/26-1;
			continue;
		}
		s+=n%26+'a'-1;
		n/=26;
	}
	for(int i=s.size()-1;i>=0;i--)
		cout << s[i];
	return 0;
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
       n: usize,
       s: chars,
    );
    let mut s_map = vec![0; 6];
    let mut s_num = vec![0; 3];
    let mut s: Vec<char> = s;
    let mut e = 0;
    for i in 0..n {
        let mut j = 1;
        while j * 2 + i < n {
            if s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j] { e += 1 }
            j += 1;
        }
    }
    let mut ans:usize = 0;
    s.reverse();
    for c in s {
        match c {
            'R' => {
                ans += s_map[0] + s_map[1];
                s_map[2] += s_num[2];
                s_map[5] += s_num[1];
                s_num[0] += 1;
            }
            'G' => {
                ans += s_map[2] + s_map[3];
                s_map[0] += s_num[2];
                s_map[4] += s_num[0];
                s_num[1] += 1;
            }
            _ => {
                ans += s_map[4] + s_map[5];
                s_map[1] += s_num[1];
                s_map[3] += s_num[0];
                s_num[2] += 1;
            }
        }
    }
    ans -= e;
    println!("{}", ans);
}


Measured memory_bytes: 2112
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second

ll n, a[maxn], s;
string st[2] = {"First", "Second"};

int main(){
    fast_io;

    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    if(n % 2 == 0){
        for(ll i = 0; i < n; i++){
            s += a[i];
        }
        if(s & 1) cout << "First";
        else cout << "Second";
        return 0;
    }
    ll t = 0;
    while(true){
        s = 0;
        for(ll i = 0; i < n; i++){
            s += a[i];
        }
        if(s % 2 == 0){
            cout << st[t];
            return 0;
        }
        ll x = -1;
        for(ll i = 0; i < n; i++){
            if((a[i] & 1) == 1 && a[i] > 1) x = i;
        }
        if(x == -1){
            cout << st[1 - t];
            return 0;
        }
        a[x]--;
        ll g = 0;
        for(ll i = 0; i < n; i++){
            g = __gcd(g, a[i]);
        }
        for(ll i = 0; i < n; i++){
            a[i] /= g;
        }
        t = 1 - t;
    }

    return 0;
}


Measured memory_bytes: 4424
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if S.startswith('YAKI'):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
bool vis[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;cin>>n>>q;
  vis[1]=true;
  ll now=1;
  for(int i=0;i<q;i++){
    ll a,b;cin>>a>>b;
    vis[now-1]=true;
    vis[now+1]=true;
    if(now==a)now=b;
    else if(now==b)now=a;
    bool tmp=vis[a];
    vis[a]=vis[b];
    vis[b]=tmp;
    vis[now]=true;
  }
  vis[now-1]=true;
  vis[now+1]=true;
  ll ans=0;
  for(int i=1;i<=n;i++)ans+=vis[i];
  cout<<ans<<endl;
  return 0;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    ll n,m,ans=0;
    cin>>n>>m;
    if(n==1){
        if(m==1){
            cout<<1<<endl;
        }
        else{
            cout<<m-2<<endl;
        }
    }
    else if(m==1){
        cout<<n-2<<endl;
    }
    else{
        cout<<(n-2)*(m-2)<<endl;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 int A[50];

 int suretu(int a){
   if(a==0 || a==1)return A[a]=1;
   if(A[a]!=-1)return A[a];
   return A[a]=suretu(a-1)+suretu(a-2);
 }
 int main()
 {
   int kazu,i;
   for(i=0;i<50;i++)A[i]=-1;
   scanf("%d",&kazu);
   printf("%d\n",suretu(kazu));
   return 0;
 }



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int n,h;
int f[405],in[405],out[405],ok[405];
inline int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
}
int main(){
	scanf("%d%d",&n,&h);
	for(int i=0;i<=2*h;++i) f[i]=i;
	for(int i=1,a,b,c,d;i<=n;++i){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int x=(c?-c:a)+h,y=(d?d:-b)+h;
		++out[x]; ++in[y]; f[find(x)]=find(y);
	}
	for(int i=0;i<h;++i) if(out[i]>in[i]) return puts("NO"),0;
	for(int i=h+1;i<=2*h;++i) if(in[i]>out[i]) return puts("NO"),0;
	for(int i=0;i<=2*h;++i) if(out[i]!=in[i]) ok[find(i)]=1;
	for(int i=0;i<=2*h;++i) if((in[i]||out[i])&&!ok[find(i)]) return puts("NO"),0;
	return puts("YES"),0;
}

Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var hwk = Input.ar;
        var dp = new long[hwk[0]+1, hwk[1]];
        dp[0, 0] = 1;
        for(var i=1;i<=hwk[0];i++)
            for(var j = 0; j < hwk[1]; j++)
            {
                var ct = new[] { 0, 0, 0 };
                for(var k = 0; k < (1 << hwk[1]-1); k++)
                {
                    var bo = new bool[hwk[1]-1];
                    for (var h = 0; h < hwk[1]-1; h++)
                        if ((1 & k >> h) == 1)
                            bo[h] = true;
                    var b = false;
                    for (var q = 0; q < hwk[1] - 2; q++)
                        if (!b) b = bo[q] && bo[q + 1];
                        else break;
                    if (b) continue;
                    if ((j == 0 || !bo[j - 1]) && (j == hwk[1] - 1 || !bo[j])) ct[1]++;
                    if (j != 0 && bo[j - 1]) ct[0]++;
                    if (j != hwk[1] - 1 && bo[j]) ct[2]++;
                }
                if (j != 0)
                    dp[i, j - 1] = (dp[i, j - 1] + dp[i - 1, j] * ct[0]) % Input.MOD;
                if (j != hwk[1] - 1)
                    dp[i, j + 1] = (dp[i, j + 1] + dp[i - 1, j] * ct[2]) % Input.MOD;
                dp[i, j] = (dp[i, j] + dp[i - 1, j] * ct[1]) % Input.MOD;
            }
        WriteLine(dp[hwk[0], hwk[2] - 1]);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
import math
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    ans = 1
    for i in range(2, N + 1):
        ans *= i
        ans %= 1e9 + 7
    return int(ans)


if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,p;
string s;
int d[200];
char c[200];

int solve(){
  if('0'<=c[p]&&c[p]<='9')return c[p++]-'0';
  int k=p++,res=(c[k]=='*'?1:0);
  while(d[p]==d[k]+1){
    if(c[k]=='+')res+=solve();
    if(c[k]=='*')res*=solve();
  }
  return res;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    d[n]=0;
    for(int i=0;i<n;i++){
      cin>>s;
      d[i]=s.size();
      c[i]=s[s.size()-1];
    }
    p=0;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
long gcd(long a, long b){
    if(a==0 || b==0){
        return a+b;
    }
    return gcd(b%a,a);
}
int main() {
    std::ios::sync_with_stdio(false);
    
    long n, k;
    cin >> n >> k;
    long ar[n];
    long gc;
    for(long i = 0; i<n; i++){
        cin >> ar[i];
        if(i==0){
            gc = ar[i];
        }
        else{
            gc = gcd(gc,ar[i]);
        }
    }
    sort(ar,ar+n);
    if(k%gc==0 && ar[n-1]>=k){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

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

int main() {
    int a,b;
    string s;
    cin>>a>>b>>s;
    int i=0;
    int n=0;
    bool x;
    while(i<s.size()){
        if(s.at(i)=='-')n++;
        i++;
    }

    if(s.at(a)=='-'){
        x=true;
    }else{
        x=false;
    }
    if(n!= 1)x=false;

     
    if(x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll N,M;
	cin>>N>>M;
	vll A;
	A.pb(0LL);
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	for(int i=1;i<=N;i++)
		A[i]+=A[i-1];
	map<ll,ll> pam;
	for(int i=0;i<=N;i++)
		pam[A[i]%M]++;
	ll ans=0;
	for(pll P:pam)
		ans+=P.second*(P.second-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4980
S=input()
# 2文字ずつ消していく。偶数か奇数か判別
def ss(S):
    if len(S)%2==0:
        # 偶数
        for i in range(2,len(S),2):
            s=S[:len(S)-i]
            #print(s)
            if s[:len(s)//2]==s[len(s)//2:]:
                return print(len(s))
    else:
        # 奇数
        for i in range(1,len(S),2):
            s=S[:len(S)-i]
            #print(s)
            if s[:len(s)//2]==s[len(s)//2:]:
                return print(len(s))
    return

ss(S)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define pll pair<ll,ll>
#define vll vector<long long>
#define f first
#define s second
long long mod = 1e9+7;
typedef vector<map<char,int>> vmci;

// int diry[] = {-1,-1,-1,0,0,1,1,1};
// int dirx[] = {-1,0,1,-1,1,-1,0,1};

ll pow(ll x, ll y, ll p) {
    ll res = 1;
    x %= p;
    if(x == 0) {
        return 0;
    }
    while(y > 0) {
        if(y & 1) {
            res = (res * x) % p;
        }
        y >>= 1;
        x = (x * x) % p;
    }
    return res;
}

// ll factorial(ll n) 
// { 
//     int res = 1, i; 
//     for (i = 2; i <= n; i++) 
//         res *= i; 
//     return res; 
// }

void seg_sieve(ll max,ll arr[]){
    ll i,j;
    for(i=2;i*i<=max;i++){
        if(arr[i]==0){
            for(j=i*i;j<=max;j+=i)
                arr[j]=1;
        }
    }
}


vector<ll> getdivs(ll n){
    vector<ll> a;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(n/i==i){
                a.push_back(i);
            }
            else{
                a.push_back(i);
                a.push_back(n/i);
            }            
        }
    }
    return a;
}

int lte(vector<ll> array, int start_idx, int end_idx, ll search_val) {

   if( start_idx == end_idx )
      return array[start_idx] <= search_val ? start_idx : -1;

   int mid_idx = start_idx + (end_idx - start_idx) / 2;

   if( search_val < array[mid_idx] )
      return lte( array, start_idx, mid_idx, search_val );

   int ret = lte( array, mid_idx+1, end_idx, search_val );
   return ret == -1 ? mid_idx : ret;
}

bool noob(const pii &a,const pii &b){
    if(a.second == 0 ) return true;
    return a.first*1.0/a.second > b.first*1.0/b.second;
}

unordered_map<bitset<1000>,int> dp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;    
    // cin>>t;        
    while(t--){           
        string s,t;
        cin>>s>>t;
        int gmin=INT_MAX,lmin = INT_MAX;
        for(int i=0;i<=s.length()-t.length();i++){
            lmin = 0;
            // cout<<i<<' ';
            for(int j=0;j<t.length();j++){
                if(s[i+j] != t[j]) lmin++;
            }
            gmin = min(lmin,gmin);
        }
        cout<<gmin;
    }
    
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int N,M,X;
    cin >> N >> M >> X;
    int cnt=0;
    int cnt2=0;
    vector<int> vec1(M);

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

    for (int k=0;k<M;k++){
    
       if (vec1[k]<X){
           cnt++;
       }else{
         cnt2++;
       }
    }
    if (cnt>cnt2){
        cout << cnt2 << endl;
    }else{
        cout << cnt << endl;
    }

}

Measured memory_bytes: 256
//g++  5.4.0

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string a;
    cin>>a;
    for(ll i=0;i<a.size();++i)
    {
        if(a[i]=='9')
        {
            a[i]='1';
        }
        else
        {
            a[i]='9';
        }   
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn=1e5+5;
struct student{
    int seq,num;
    bool operator<(student s)const{return num<s.num;}
}stu[maxn];

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        stu[i].seq=i;
        cin>>stu[i].num;
    }
    sort(stu+1,stu+n+1);
    for(int i=1;i<=n;i++)
        cout<<stu[i].seq<<" ";
    return 0;
}


Measured memory_bytes: 1536
A, B, K = map(int, input().split())

if B - A + 1 <= 2*K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

struct point {
	int index;
	int x, y;
	
	point() {
		x=INT_MIN;y=INT_MIN;
		index = -1;
	}
	
	point(int in_index, int in_x, int in_y) {
		index = in_index;
		x = in_x;
		y = in_y;
	}
};

struct node {
	point p;
	node* left, * right;
	
	node() {
		p= point();
		left = NULL;
		right = NULL;
	}
};

bool compareX(const point& p1,const point& p2)
{
	return p1.x < p2.x;
}

bool compareY(const point& p1,const point& p2)
{
	return p1.y < p2.y;
}

point* sortX(point* p_start, point* p_end) {
	sort(p_start, p_end, compareX);
	return p_start+(p_end-p_start)/2;
}

point* sortY(point* p_start, point* p_end) {
	sort(p_start, p_end, compareY);
	return p_start+(p_end-p_start)/2;
}

void build(node* n_node, point* p_start, point* p_end, int index) {
	point* mid = index % 2 ? sortY(p_start, p_end) : sortX(p_start, p_end);
	if(p_start>=p_end)
		return;
	n_node->p = *mid;
	n_node->left = new node();
	n_node->right = new node();
	build(n_node->left, p_start, mid, index+1);
	build(n_node->right, mid + 1, p_end, index+1);
}

void search(int sx, int tx, int sy, int ty, node* now, int index, vector<int> &ans) {
	if(now == NULL) {
		return;
	}
	if(index %2) {
		if(now->p.y >= sy && now->p.y <= ty) {
			if(now->p.x >= sx && now->p.x <= tx) {
				ans.push_back(now->p.index);
			}
			search(sx, tx, sy, ty, now->left, index + 1, ans);
			search(sx, tx, sy, ty, now->right, index + 1, ans);
		}
		else if(now->p.y < sy) {
			search(sx, tx, sy, ty, now->right, index + 1, ans);
		}
		else if(now->p.y > ty) {
			search(sx, tx, sy, ty, now->left, index + 1, ans);
		}
	}
	else {
		if(now->p.x >= sx && now->p.x <= tx) {
			if(now->p.y >= sy && now->p.y <= ty) {
				ans.push_back(now->p.index);
			}
			search(sx, tx, sy, ty, now->left, index + 1, ans);
			search(sx, tx, sy, ty, now->right, index + 1, ans);
		}
		else if(now->p.x < sx) {
			search(sx, tx, sy, ty, now->right, index + 1, ans);
		}
		else if(now->p.x > tx) {
			search(sx, tx, sy, ty, now->left, index + 1, ans);
		}
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
	int numbers;
	cin>>numbers;
	point *p = new point[numbers];
	for(int i=0;i<numbers;i++) {
		int x, y;
		cin>>x>>y;
		p[i] = point(i, x, y);
	}
	node* root;
	root = new node();
	build(root, p, p + numbers, 0);
	int ansnumbers;
	cin >> ansnumbers;
	for(int i=0;i<ansnumbers;i++) {
		int sx, tx, sy, ty;
		cin >> sx >> tx >> sy >> ty; 
		vector<int> ans;
		search(sx, tx, sy, ty, root, 0, ans);
		sort(ans.begin(), ans.end());
		int size = ans.size();
		for(int j=0;j<size;j++) {
			printf("%d\n", ans[j]);
				//cout<<ans[j]<<endl;
		}
		printf("\n");
	}
	return 0;
} 


Measured memory_bytes: 54440
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord 

main :: IO ()
main = readLn >>= flip replicateM (head <$> readLine) >>= printRes . solve
    where
        printRes = mapM_ print 

solve :: [Int] -> [Int]
solve as = map select as
    where
        (a0 : a1 : _) = sortOn Down as 
        select a 
            | a == a0 = a1 
            | otherwise = a0

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 72572
#include<iostream>
#include<cmath>
#define f(x) (x)*(x)
using namespace std;
int n;
int a[1001];
int cnt;
int ans;
int ans2;
int ans3;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt+=a[i];
    }
    int t=cnt/n;
    for(int i=1;i<=n;i++){
        ans+=f(a[i]-t);
        ans2+=f(a[i]-t-1);
        ans3+=f(a[i]-t+1);
    }
    int tt=ans<ans2? ans:ans2;
    tt=tt>ans3? ans3:tt;
    cout<<tt;
    return 0;
}

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

typedef struct {
    char suit;
    int value;
} Cards;

void BubbleSort(Cards C[], int N) {
    Cards temp;
    for (int i = 0; i < N; i++) {
        for (int j = N-1; j >= i+1; j--) {
            if (C[j-1].value > C[j].value) {
                temp = C[j-1];
                C[j-1] = C[j];
                C[j] = temp;
            }
        }
    }    
}

void SelectionSort(Cards C[], int N) {
    Cards temp;
    int minj;
    for (int i = 0; i < N-1; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (C[minj].value > C[j].value) {
                minj = j;
            }
        }

        if (i != minj) {
            temp = C[i];
            C[i] = C[minj];
            C[minj] = temp;
        }
    }
}

void printCards(Cards C[], int N) {
    for (int i = 0; i < N-1; i++) {
        cout << C[i].suit << C[i].value << ' ';
    }
        cout << C[N-1].suit << C[N-1].value << endl;
}

void isStable(Cards bC[], Cards sC[], int N) {
    bool stable = true;
    for (int i = 0; i < N; i++) {
        if (bC[i].suit != sC[i].suit) {
            stable = false;
            break;
        }
    }

    if (stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    Cards bC[N], sC[N];

    for (int i = 0; i < N; i++) {
        cin >> bC[i].suit >> bC[i].value;
    }

    for (int i = 0; i < N; i++) {
        sC[i] = bC[i];
    }

    BubbleSort(bC, N);
    SelectionSort(sC, N);

    printCards(bC, N);
    isStable(bC, bC, N);
    printCards(sC, N);
    isStable(bC, sC, N);

    return 0;
}



Measured memory_bytes: 3084
n=int(input())
c=input()
rlen=c.count("R")
wlen=c.count("W")
r=0
w=0
if rlen==0:
    print(0)
else:
    for i in c:
        if i=="R":
            r+=1
        else:
            w+=1
        if w==rlen-r:
            print(w)



Measured memory_bytes: 9468
n = int(input())
a = list(map(int, input().split()))
dp = [[None]*n for _ in range(n)]
for d in range(n):
  for l in range(n-d):
    r = l + d
    if d:
      dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1])
    else:
      dp[l][r] = a[l]
print(dp[0][n-1])

Measured memory_bytes: 163592
using System;

namespace JKTX_AOJ2015
{

    class Trump
    {
        public const int TRUMP_NUM = 13;

        public bool[] S = new bool[TRUMP_NUM + 1];
        public bool[] H = new bool[TRUMP_NUM + 1];
        public bool[] C = new bool[TRUMP_NUM + 1];
        public bool[] D = new bool[TRUMP_NUM + 1];
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n, cnt = 0;
            Trump trump = new Trump();

            n = int.Parse(Console.ReadLine());

            while (n != cnt)
            {
                string[] str = Console.ReadLine().Split(' ');

                switch (str[0])
                {
                    case "S":
                        trump.S[int.Parse(str[1])] = true;
                        break;
                    case "H":
                        trump.H[int.Parse(str[1])] = true;
                        break;
                    case "C":
                        trump.C[int.Parse(str[1])] = true;
                        break;
                    case "D":
                        trump.D[int.Parse(str[1])] = true;
                        break;
                }

                cnt++;
            }


            /*
             *??????????????????????????¶???!!
             */
            for (int i = 1; i <= Trump.TRUMP_NUM; i++)
            {
                if (trump.S[i] != true)
                {
                    Console.WriteLine("S {0}", i);
                }
            }
            for (int i = 1; i <= Trump.TRUMP_NUM; i++)
            {
                if (trump.H[i] != true)
                {
                    Console.WriteLine("H {0}", i);
                }
            }
            for (int i = 1; i <= Trump.TRUMP_NUM; i++)
            {
                if (trump.C[i] != true)
                {
                    Console.WriteLine("C {0}", i);
                }
            }
            for (int i = 1; i <= Trump.TRUMP_NUM; i++)
            {
                if (trump.D[i] != true)
                {
                    Console.WriteLine("D {0}", i);
                }
            }
        }
    }
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M;
ll A[1010], B[1010], C[1010];
ll d[110][110];

int main(int argc, char **argv)
{
	cin >> N >> M;
	REP(i, 110)REP(j, 110) d[i][j] = INF*(i!=j);
	REP(i, M)
	{
		ll a, b, c; cin >> a >> b >> c;
		--a, --b;
		A[i] = a;
		B[i] = b;
		C[i] = c;
		d[a][b] = d[b][a] = c;
	}

	REP(v, N)REP(s, N)REP(t, N)
		d[s][t] = min(d[s][t], d[s][v] + d[v][t]);

	ll res{M};
	REP(m, M)
	{
		bool ok{false};
		REP(j, N)
		{
			if (d[j][A[m]] == d[j][B[m]] + C[m]) ok = true;
		}
		res -= ok;
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int flg=0;
  for(int i=9;i>0;i--){
    if(n%i==0){
      if(n/i<10){
        flg=1;
        break;
      }else{
        break;
      }
    }
  }
  if(flg==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include <cstdio>
const int maxn = 100005;
struct node {
  int num;
  bool flag;
}s[maxn];

int main() {
	int m,n;
	scanf("%d%d",&n,&m);
	s[1].flag = true;
	s[1].num = 1;
	for(int i = 2; i <= n; i++) {
		s[i].flag = false;
		s[i].num = 1;
	}
	while(m--) {
		int x, y;
		scanf("%d%d", &x,&y);
		s[x].num--;
		s[y].num++;
		if(s[x].flag == true) s[y].flag = true;
		if(s[x].num == 0) s[x].flag = false;
	}
	int count = 0;
	for(int i = 1; i <= n; i++) {
		if(s[i].flag ==true) {
			count++;
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 896
program main
	implicit none
    integer i,j,n,flag,l,k,tmp
    integer,allocatable :: a(:)
    
    flag=1 !distinct
    
    read(*,*) n
    allocate(a(n))
    read(*,*) (a(i),i=1,n)
    
    l=n/2+1
    k=n
    do while(k/=1)
      if(l>1)then
        l=l-1
        tmp=a(l)
      else
        tmp=a(k)
        a(k)=a(1)
        k=k-1
        if(k==1) then
           a(1)=tmp
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j<k)then
           if(a(j).lt.a(j+1))j=j+1
        endif
        if (tmp<a(j))then
           a(i)=a(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     a(i)=tmp
  enddo
  do i=1,n-1     
     if (a(i)==a(i+1)) then
        flag=0
        goto 99
     end if
  end do
99 continue
    if (flag==1) then
       write(*,'(a)') 'YES'
    else
       write(*,'(a)') 'NO'
    end if
end program main

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	string x;
	cin >> x;
	sort (x.begin() , x.end());
	if (x[0] == x[1] && x[0] != x[2] && x[2] == x[3])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
       operate(h-1, j, h-1, j+1)

print(len(ans))
for i in ans:
    print(i[0],i[1],i[2],i[3])

Measured memory_bytes: 30276
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  ll N,M, lcm=1; cin>>N>>M;
  ll A[N];
  for(int i=0; i<N; i++){
    ll cur; cin>>cur;
    A[i]=cur;
    ll g=gcd(lcm,cur);
    lcm=lcm*cur/g;
  }
  
  ll res=lcm/2;
  for(int i=0; i<N; i++){
    if(res%A[i]!=A[i]/2){
      cout<<0<<endl;
      return 0;
    }
  }
  
  ll ans=M/lcm;
  ll val=M%lcm;
  if(val>=lcm/2){
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

vector<int> eratosthenes(int n) {
  vector<int> v(n);
  for (int i=2; i<n; i++) v[i] = i;
  for (int i=2; i*i<n; i++)
    if (v[i])
      for (int j=i*i; j<n; j+=i)
        v[j] = 0;
//  v.erase(remove(ALL(v),0),v.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
  return v;
}

int main() {
  vector<int> table = eratosthenes(1000000);
  vector<int> prime = table;
  prime.erase(remove(ALL(prime),0),prime.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
 
  int n;
  while(cin >> n, n) {
    int res = 0;
    for (int i=0; prime[i] <= n/2; ++i) {
      if (table[n - prime[i]])
        res++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[51];
	double ans;
	int i;
	cin >> n;
	for(i=0;i<n;i++)	cin>>box[i];
	sort(box,box+n);
	ans=(double)box[0];
	for(i=1;i<n;i++)	ans=(double)(ans+box[i])/2;
	printf("%.5lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
import Control.Monad

matrixVectorMultiplication :: Num a => [[a]] -> [a] -> [a]
matrixVectorMultiplication m v = map (sum . zipWith (*) v) m

main :: IO ()
main = do
  [n, m] <- fmap (map read . words) getLine
  mat <- replicateM n $ fmap (map read . words) getLine
  vec <- fmap (map read) (replicateM m getLine)
  mapM_ print (mat `matrixVectorMultiplication` vec)

Measured memory_bytes: 7436
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];

    int dp_table[n];
    dp_table[0] = 0;

    for (int i = 1; i < n; i++)
    {
        int minn = 10e9;
        for (int j = 1; j <= min(k, i); j++)
        {
            minn = min(minn, dp_table[i - j] + abs(h[i] - h[i - j]));
        }
        dp_table[i] = minn;
    }
    cout << dp_table[n - 1] << endl;
    return 0;
}

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

int n, m;
vector<pair<long long, int>> shop;
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    shop.push_back(make_pair(a, b));
  }
  sort(shop.begin(), shop.end(), [&](const pair<long long, int>&s1, pair<long long, int> &s2) {return s1.first < s2.first;});
  long long v = 0;
  for (int j = 0; j < n; j++) {
    int cnt = min(m, shop[j].second);
    m -= cnt;
    v += shop[j].first * cnt;
    if (m == 0) {
      break;
    }
  }
  cout << v << endl;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, M;
int P[100050];
bool g[100050];
int pp[100050];
string S[100050];

int main(){
    cin >> N >> M;
    if(M==0){cout << 0 << " " << 0 << endl; return 0;}
    FOR(i,1,M+1)cin >> P[i] >> S[i];
    int p=0, a=0;
    int tmp=0;
    FOR(i,1,M+1)
    {
      if(!g[P[i]])
      {
        if(S[i]=="AC"){
          a++;
          p+=pp[P[i]];
          g[P[i]]=true;
        }
        else
        {
          pp[P[i]]++;
        }
      }
    }
    cout << a << " " << p << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;
string s,t;

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

        vector<vector<int>> v;
        rep(i,m)
        {
                int p,y;
                cin>>p>>y;
                vector<int> w;
                w.push_back(p);
                w.push_back(y);
                w.push_back(1);
                w.push_back(i);
                v.push_back(w);
        }
        sort(ALL(v));

        rep2(i,1,m)
        {
                if(v.at(i).at(0)==v.at(i-1).at(0))
                {
                        v.at(i).at(2)=v.at(i-1).at(2)+1;
                }
        }

        for(auto &it : v)
        {
                swap(it.at(0),it.at(3));
                swap(it.at(2),it.at(3));
        }

        sort(ALL(v));

/*
        for(auto i : v)
        {

                for(auto j : i)
                {
                        cout<<j<<" ";
                }
                cout<<endl;
        }
        cout<<endl;*/

        for(auto it : v)
        {
                printf("%06d%06d\n",it.at(2),it.at(3));
        }
}

Measured memory_bytes: 7472
p5_list = [11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381]

N=int(input())

print(*p5_list[:N])

Measured memory_bytes: 3064
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,ans=0,last=-1;cin>>n;
	string s;cin>>s;
	rep(i,0,n)
	{
		if((s[i]-'a')!=last)
		{
			ll j = i+1;
			while(j<n&&s[j]==s[i]) j++;
			ans++;
			i=j-1;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define lli long long int
#include<vector>
#include<algorithm>
int main(){
  lli n,sum=0;
  cin>>n;
  vector<lli>v(n);
  for(lli i=0;i<n;i++){
    cin>>v[i];
    sum+=v[i];
  }
  lli k=*max_element(v.begin(),v.end());
  sum-=k/2;
  cout<<sum;
  return 0;
}

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

int N;
vector<vector<int>> G;

int dfs(int s, int par){
    int ret = 0;
    for(int t : G[s]){
        if(t == par) continue;
        ret ^= 1+dfs(t, s);
    }
    return ret;
}

int main(){
    cin >> N;
    G.resize(N);
    for(int i=0; i<N-1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    cout << (dfs(0, -1)==0 ? "Bob" : "Alice") << endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  ll s; cin >> s;
  ll maxn = 1000001;
  set<ll> st;
  st.insert(s);
  for(ll i = 2; i < maxn; i++) {
    if(s % 2 == 0) {
      s = s / 2;
    } else {
      s = 3 * s + 1;
    }
    if(st.count(s)) {
      cout << i << endl;
      return 0;
    }
    st.insert(s);
  }

  return 0;
}


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

typedef long long ll;

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

    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[A.size()-1]-A[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e4 + 5;
const long oo = 1e15;

string s;
long n , ans;
long r[MAXN] , g[MAXN] , b[MAXN];

void Solve() {
    fd(i , n , 1) {
        if (s[i] == 'R') {
            r[i] = r[i + 1] + 1;
            g[i] = g[i + 1];
            b[i] = b[i + 1];
        }
        else if (s[i] == 'G') {
            r[i] = r[i + 1];
            g[i] = g[i + 1] + 1;
            b[i] = b[i + 1];
        }
        else {
            r[i] = r[i + 1];
            g[i] = g[i + 1];
            b[i] = b[i + 1] + 1;
        }
    }
    //cerr << r[1] << " " << g[1] << " " << b[1] << "\n";
    ft(i , 1 , n - 2) {
        ft(j , i + 1 , n - 1) {
            //cerr << "INDEX " <<  i << " " << j << "\n";
            if (s[i] == 'R' && s[j] == 'G') {
                ans += b[j + 1];
                if (s[2 * j - i] == 'B') ans--;
                //cerr << "THIS IS ANWSER IN 1 " << ans << "\n";
            }
            else if (s[i] == 'R' && s[j] == 'B') {
                ans += g[j + 1];
                if (s[2 * j - i] == 'G') ans--;
                //cerr << "THIS IS ANWSER IN 2 " << ans << "\n";
            }
            else if (s[i] == 'G' && s[j] == 'B') {
                ans += r[j + 1];
                if (s[2 * j - i] == 'R') ans--;
                //cerr << "THIS IS ANWSER IN 3 " << ans << "\n";
            }
            else if (s[i] == 'G' && s[j] == 'R') {
                ans += b[j + 1];
                if (s[2 * j - i] == 'B') ans--;
            }
            else if (s[i] == 'B' && s[j] == 'G') {
                ans += r[j + 1];
                if (s[2 * j - i] == 'R') ans--;
            }
            else if (s[i] == 'B' && s[j] == 'R') {
                ans += g[j + 1];
                if (s[2 * j - i] == 'G') ans--;
            }
        }
    }
    cout << ans;
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n;
    cin >> s;
    s = '#' + s;
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 3780
while True:
    n= int(input())
    if n== 0: break
    datasets= [list(map(int, input().split())) for _ in range(n)]
    for d in datasets:
        av= sum(d)//3
        if 100 in d:
            print("A")
        elif sum(d[:2])//2 >=90:
            print("A")
        elif av>= 80:
            print("A")
        elif av>= 70:
            print("B")
        elif av>= 50 and d[0]>= 80 or d[1]>= 80:
            print("B")
        else:
            print("C")

Measured memory_bytes: 7664