akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let vs = scan!(i64;5);
    let k = scan!(i64);
    for i in 0..vs.len() {
        for j in 0..vs.len() {
            if (vs[i] - vs[j]).abs() > k {
                println!(":(");
                return;
            }
        }
    }
    println!("Yay!")
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, k, s;
	cin >> n >>  k >> s;
	for (int i = 0; i < k; ++i) {
		cout << s << ' ';
	}
	if (s != 1e9) {
		for (int i = 0; i < n - k; ++i) {
			cout << s + 1 << ' ';
		}
	} else {
		for (int i = 0; i < n - k; ++i) {
			cout << 1 << ' ';
		}
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 1280
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main1() {
    let param = readInts()
    
    var ans = param[1] * param[3]
    
    for i in 0...1 {
        for j in 2...3 {
            if (param[i] * param[j] > ans){
                ans = param[i] * param[j]
            }
        }
    }
    
    print(ans)
}

main1()

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N;
int A[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N)A[i+1]+=A[i];

    int mi=LLONG_MAX;
    rep(t,2){
        int cost=0,cur=0;
        rep(i,N){
            int a=A[i]+cur;
            if((t+i)&1){
                if(a>0)continue;
                cost+=-a+1;
                cur+=-a+1;
            }
            else{
                if(a<0)continue;
                cost+=a+1;
                cur-=a+1;
            }
        }
        chmin(mi,cost);
    }
    cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
a=b=0
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
	p,s=input().rstrip().split()
	p=int(p)
	if ans[p-1]<=0:
		if s=="AC":
			a+=1
			b+=-ans[p-1]
			ans[p-1]=1
		else:
			ans[p-1]-=1
print(a,b)
		



Measured memory_bytes: 3828
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	if s[2:3] == s[3:4] && s[4:5] == s[5:6] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  ll a, b, c, x, y, sa, result = 0;
  cin >> a >> b >> c >> x >> y;
  if (c*2 <= a) {
    result += x*c*2;
    y -= x;
    if (y > 0) {
      result += min(c*2, b)*y;
    }
    puts(result)
    exit(0);
  }else if (c*2 <= b) {
    result += y*c*2;
    x -= y;
    if (x > 0) {
      result += min(c*2, a)*x;
    }
    puts(result)
    exit(0);
  }else if (c*2 >= a+b) {
    result += a*x;
    result += b*y;
    puts(result)
    exit(0);
  }else{
    result += min(x, y) * (c*2);
    if (x > y) {
      result += (x-y)*a;
    }else{
      result += (y-x)*b;
    }
  }
  puts(result)
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from functools import reduce
from operator import mul
from collections import defaultdict, Counter
from heapq import heappush, heappop
import sys
from math import sqrt, floor

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(N):
    ret = 0
    i = 2
    while True:
        step = i // 2
        start = (i + 1) // 2 * step
        if start > N:
            break
        end = N // step * step
        ret += (start + end) * ((end - start) // step + 1) // 2
        i += 1
    print(ret)


def main():
    N = int(input())
    solve(N)


def _test():
    """
    >>> solve(4)
    23

    >>> solve(100)
    26879

    >>> solve(10000000)
    838627288460105
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


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

int main() {
    int a,b;
    cin >> a >> b;
    int A = min(a,b);
    int B = max(a,b);
    int C = A;
    for(int i=0; i<B ;i++){
      cout << A; 
    }
    cout << endl;
   

}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int x,y,z;
  cin >> x>>y>>z;
  if((10*y+z)%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main(void){
  while(true){
    int x, y, s, max = 0;
    cin >> x >> y >> s;
    if(x == 0) break;
    for(int i = 1; i < s; i++){
      for(int j = 1; j < s; j++){
        int a = i, b = j;
        if( (a*(100+x)/100) + (b*(100+x)/100) == s){
          a = a * (100 + y) / 100;
          b = b * (100 + y) / 100;
          if(a + b > max) max = a + b;
        }
      }
    }
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#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(){
  string s;
  cin >> s;
  int a;
  a = s.size();
  string b = "abcdefghijklmnopqrstuvwxyz"
  rep(i,a){
    rep(j,26){
      if(s[i] == b[j]){
        b.erase(j,1);
      }
    }
  }
  if(b == "") puts("None");
  else cout << b[0] << endl;
  return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int N, C;
cin >> N >> C;
int D[C][C];
REP(i, C)REP(j, C) cin >> D[i][j];
int g[3][C];
REP(i, 3)REP(j, C){
    g[i][j] = 0;
}
REP(i, N)REP(j, N) {
    int x;
    cin >> x;
    g[(i + j) % 3][x - 1]++;
}
// print(g[0][0]);
int ans = MOD;
REP(i, C)REP(j, C)if(i != j)REP(k, C)if(i != k && j != k){
      int now = 0;
      REP(l,C) now += D[l][i] * g[0][l];
      REP(l,C) now += D[l][j] * g[1][l];
      REP(l,C) now += D[l][k] * g[2][l];
        ans = min(ans, now);
} 
print(ans);
}

Measured memory_bytes: 256
import math
A,B,H,M=input().split()
A=int(A)
B=int(B)
H=int(H)
M=int(M)
pi=math.pi
if (1<=A<=1000)and(1<=B<=1000)and(0<=H<=11)and(0<=M<=59):
    a=(pi/6)*(M/60)+2*pi*(H/12)
    b=(M/60)*2*pi
    c=b-a
    d=(A**2+B**2-2*A*B*math.cos(c))**(1/2)
    print(d)

Measured memory_bytes: 9532
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	bool rep = false;
	if (N%2 == 0) {
		rep = true;
		char c;
		string T = "";
		for (int i = 0; i < N/2; ++i) {
			cin >> c;
			T += c;
		}
		for (int i = 0; i < N/2; ++i) {
			cin >> c;
			if (T[i] != c) {
				rep = false;
				break;
			}
		}
	}
	if (rep) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,a,s=0;
	cin>>n;
	a=n;
	while(a!=0)
	{
		x=a%10;
		s+=x;
		a/=10;
	}
	if(n%s==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	// your code goes here
	  int h1,h2,k1,k2,a,b,c,d,H,K;
   scanf("%d%d%d%d%d%d%d%d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
   H=a*h1+b*h2+(h1/10)*c+(h2/20)*d;
   K=a*k1+b*k2+(k1/10)*c+(k2/20)*d;
   if(H>K){
      printf("hiroshi\n");
   }else if(H<K){
      printf("kenjiro\n");
   }else{
      printf("even\n");
      
   }
	return 0;
}



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

const int N = 10010;
int par[N], rank_[N];

void init(int n)
{
	for(int i = 0; i < n; ++i){
		par[i] = i;
		rank_[i] = 0;
	}
}

int find(int x)
{
	if(par[x] == x)
		return x;
	else
		return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if(x == y)
		return;
	
	if(rank_[x] > rank_[y])
		par[y] = x;
	else {
		par[x] = y;
		if(rank_[x] == rank_[y])
			rank_[x] ++;
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	cin >> n >> q;
	
	init(n);
	
	int c, x, y;
	for(int i = 0; i < q; ++i){
		cin >> c >> x >> y;
		if(c == 0)
			unite(x, y);
		else
			cout << same(x, y) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1388
from bisect import bisect_left


def solve(n, m, a_list):

    a_list_s = list(sorted(a_list))
    a_list_rs_cum = []
    cum = 0
    for v in reversed(a_list_s):
        cum += v
        a_list_rs_cum.append(cum)
    # print(a_list_rs_cum)
    left = 0
    right = 2 * 10 ** 5 + 1

    while right > left + 1:
        mid = (left + right) // 2
        res_mid = 0
        for i in range(n):
            res_mid += n - bisect_left(a_list_s, mid - a_list[i])
        if res_mid >= m:
            left = mid
        else:
            right = mid
    # print(left)
    res = 0
    res_cnt = 0
    for i in range(n):
        c = n - bisect_left(a_list_s, left - a_list[i])
        if c > 0:
            res += a_list_rs_cum[c - 1] + c * a_list[i]
            res_cnt += c
            # print(i, c)

    if res_cnt > m:
        res -= left * (res_cnt - m)
    # print(res, res_cnt)
    return res


def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(n, m, a_list)
    print(res)


def test():
    assert solve(5, 3, [10, 14, 19, 34, 33]) == 202
    assert solve(9, 14, [1, 3, 5, 110, 24, 21, 34, 5, 3]) == 1837
    assert solve(9, 73, [67597, 52981, 5828, 66249, 75177, 64141, 40773, 79105, 16076]) == 8128170


if __name__ == "__main__":
    test()
    main()


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

using namespace std;

typedef long long ll;

const ll INF = 1e15;
ll n, m, l, q, d[305][305], dis[305][305];

int main()
{
    cin >> n >> m >> l;
    for (ll i = 1; i <= n; i++) for (ll j = 1; j <= n; j++) d[i][j] = dis[i][j] = INF;
    for (ll i = 1; i <= m; i++)
    {
        ll x, y;
        cin >> x >> y;
        cin >> d[x][y];
        d[y][x] = d[x][y];
    }
    for (ll k = 1; k <= n; k++)
        for (ll i = 1; i <= n; i++)
            for (ll j = 1; j <= n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    for (ll i = 1; i <= n; i++)
        for (ll j = i + 1; j <= n; j++)
            if (d[i][j] <= l) dis[i][j] = dis[j][i] = 1;
    for (ll k = 1; k <= n; k++)
        for (ll i =1; i <= n; i++)
            for (ll j = 1; j <= n; j++)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
    cin >> q;
    for (ll i = 1; i <= q; i++)
    {
        ll s, t;
        cin >> s >> t;
        if (dis[s][t] < 1e13) cout << dis[s][t] - 1 << endl;
        else cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**10]*n
dp[0] = 0
if n-1 <= k:
    print(abs(h[-1]-h[0]))
else:
    for i in range(1,k+1):
        dp[i] = abs(h[i]-h[0])
    for i in range(k+1,n): 
        for j in range(1,k+1):
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))
    print(dp[-1])

Measured memory_bytes: 84636
# C - Switches

N, M = map(int, input().split())
switches = []
for _ in range(M):
    k, *s = map(int, input().split())
    switches.append([i - 1 for i in s])
lights = [int(p) for p in input().split()]

def f(i, on_off):
    if N <= i:
        result = 1
        for i in range(M):
            on = 0
            for j in switches[i]:
                on += on_off[j]
            if on % 2 != lights[i]:
                result = 0
        return result
    return f(i + 1, on_off + [1]) + f(i + 1, on_off + [0])

print(f(0, []))


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

vector< vector< int > > frd, blc;
vector< int > grp, siz;
void f(int v, int g){
    grp[v] = g;
    siz[g]++;
    for(int x: frd[v]) if(grp[x] == -1) f(x, g);
}
int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    frd.assign(n, vector<int>());
    blc.assign(n, vector<int>());
    grp.assign(n, -1);
    siz.assign(n, 0);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        frd[a].push_back(b);
        frd[b].push_back(a);
    }
    for(int i=0;i<k;i++){
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        blc[c].push_back(d);
        blc[d].push_back(c);
    }
    for(int i=0;i<n;i++) if(grp[i] == -1) f(i, i);
    for(int i=0;i<n;i++){
        int g = grp[i];
        int ans = siz[g] - frd[i].size() - 1;
        for(int v: blc[i]) if(grp[v] == g) ans--;
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 12672
N, K = map(int, input().split())
l = list(map(int, input().split()))

r = [0] * (N + 1)
for i in range(N):
  r[i + 1] = r[i] + l[i]
z = []
for i in range(N):
  for j in range(i, N):
    z.append(r[j + 1] - r[i])
z.sort()
def check(m):
  c = 0
  for x in z:
    if x & m == m:
      c += 1
  return c >= K
x = z[-1].bit_length()
res = 0
while x > 0:
  if check(res + pow(2, x - 1)):
    res += pow(2, x - 1)
  x -= 1
print(res)


Measured memory_bytes: 24872
#include<stdio.h>
#define N 100
int main(){
  int n,a[N],v,i,j,k,flag,count;
  flag = 1;
  count = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
      }
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	v=a[j];
	a[j]=a[j-1];
	a[j-1]=v;
	count++;
	flag =1;
      }
    }
  }
  for(k=0;k<n;k++){
      printf("%d",a[k]);
      if(k != n - 1)printf(" ");
      else printf("\n");
    }
  printf("%d\n",count);
  return 0;
}



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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t sum_of_digits(int64_t n) {
    int64_t ret = 0;

    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }

    return ret;
}

int main() {
    int64_t k;
    cin >> k;

    vector<int64_t> candidates;
    for (auto i : irange(1L, 1000L)) {
        int64_t d = i;
        for (auto j : irange(0L, 13L)) {
            candidates.push_back(d);
            d *= 10;
            d += 9;
        }
    }

    sort(candidates.begin(), candidates.end());
    candidates.erase(unique(candidates.begin(), candidates.end()),
                     candidates.end());

    sort(candidates.begin(), candidates.end(), [](int64_t n, int64_t m) {
        return make_pair(sum_of_digits(m) * n, n) <
               make_pair(sum_of_digits(n) * m, m);
    });

    int64_t m = 0;
    for (auto n : candidates) {
        if (m < n) {
            cout << n << "\n";
            m = n;
            --k;
            if (k == 0) {
                return 0;
            }
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    ll N,K;
    cin>>N>>K;
    vll H(N);
    F0R(i,N){
        cin>>H[i];
    }
    sort(all(H));
    reverse(all(H));
    ll move=0;
    for(int i=min(K,N);i<N;i++){
        move+=H[i];
    }
    out(move);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector> 
#include <stdio.h> 
#include <math.h> 
using namespace std;

int main(void) {
    int R; cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var a []int = make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var score int = 0
	for i := 0; i < N; i++ {
		if i % 2 == 0 {
			score += a[i]
		} else {
			score -= a[i]
		}
	}
	fmt.Println(score)
}

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

#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int p,q;
	while(cin >> p >> q) {
		vector<int> v;
		int m;
		p %= q;
		p *= 10;
		while(find(v.begin(), v.end(), p) == v.end()) {
			v.push_back(p);
			p %= q;
			p *= 10;
		}
		if(v[v.size()-1] == 0) {
			rep(i,v.size()-1) {
				cout << v[i]/q;
			}
			cout << endl;
		} else {
			rep(i,v.size()) {
				cout << v[i]/q;
			}
			cout << endl;
			bool f = 0;
			for(auto it = v.begin(); it != v.end(); ++it) {
				if(*it == p) {
					f = 1;
				}
				if(f) cout << "^";
				else cout << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char ma[111][111];
  cin>>h>>w;
  fill_n(*ma,111*111,'#');
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      cin>>ma[i][j];
  
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      cout<<ma[i][j];
    }
    cout<<endl;
  }
  return 0;
}


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

import numpy as np

def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

avg=sum(a)/N

print(getNearestValue(a,avg))

Measured memory_bytes: 12404
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int a,b,c;
int ans;
string s,t;
vector<int> vec;

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> a >> b;
    ans += b-a+1;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
S = input()
lis = list(S)
count = 0

for i in range(len(lis)):
    if i % 2 == 0:
        if lis[i] == 'R':
            count += 1
    if i % 2 != 0:
        if lis[i] == 'L':
            count += 1

    if lis[i] == 'U' or lis[i] == 'D':
        count += 1

if count == len(lis):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
#include<iostream> 
using namespace std;
int main(){
  int N=0,f=0,sum=0;
  cin >> N;
  f = N;
  while(f>0){
    sum+=f%10;
    f/=10;
  }
  if(N%sum == 0) cout << "Yes";
  else cout << "No";
  cout << endl;
}


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



int A[1001][1001] = {};

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for( int i = 0; i < H; ++i ) cin >> A[i];


    queue<vector<int>> q;
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ){
            if( A[i][j] == '#' ) q.push( {i,j,0} );
        }
    }
    

    int ans = 0;
    while( !q.empty() ){
        vector<int> tmp = q.front();
        q.pop();
        int i = tmp[0], j = tmp[1], level = tmp[2];
        ans = level;
        if( i+1 <  H and A[i+1][j] == '.'){
            A[i+1][j] = '#';
            q.push( {i+1, j, level+1} );
        }
        if( i-1 >= 0 and A[i-1][j] == '.'){
            A[i-1][j] = '#';
            q.push( {i-1,j,level+1} );
        }
        if( j+1 <  W and A[i][j+1] == '.'){
            A[i][j+1] = '#';
            q.push( {i, j+1, level+1} );
        }
        if( j-1 >= 0 and A[i][j-1] == '.'){
            A[i][j-1] = '#';
            q.push( {i, j-1, level+1} );
        }
    }

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

Measured memory_bytes: 56756
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 100333
#define MOD 1000
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<vector<long long> > mat;

ll n, ret = INF;

ll getDigit(ll a) {
	ll cnt = 0;
	while(a>0)	a/=10, cnt++;
	return cnt;
}

int main () {
	scanf("%lld",&n);	
	for(ll i=1;i*i<=n;i++) {
		if(n%i == 0) {
			ll cand = max(getDigit(i), getDigit(n/i));
			ret = min(ret, cand);
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=100000;
int n,m;
int a[N+1];
int dp[N+1];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++){
		dp[i]=inf;
		for(int j=max(1,i-m);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	}
	cout<<dp[n];
	return 0;
}
/*1
5 3
10 30 40 50 20
*/
/*2
3 1
10 20 10
*/
/*3
2 100
10 10
*/
/*4
10 4
40 10 20 70 80 10 20 70 80 60
*/

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a+b==c||a+c==b||b+c==a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

H, W = map(int, input().split())

G = [['.'] * ((W + 2))]
for _ in range(H):
    tmp = ['.'] + list(input()) + ['.']
    G.append(tmp)

G.append(['.'] * (W + 2))

move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if G[i][j] == '#':
            flag = False
            for dx, dy in move:
                if G[i + dx][j + dy] == '#':
                    flag = True
                    break
            if not flag:
                print ('No')
                exit()

print ('Yes')
                


Measured memory_bytes: 3064
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f_(i,a,b) for (int i=a;i>=b;i--)
#define f(i,a,b) for (int i=a;i<=b;i++)

string s;
ll dem=0,ans=0;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin>>s;
	for (int i=0;i<s.size()-1;i++) {
		if (s[i]=='A') {
			dem++;
		}
		else if (s[i]=='B'&&s[i+1]=='C') {
			ans+=dem;
			i++;
		}
		else dem=0;
	}
	printf("%lld", ans);
	return 0;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

ll Pow(ll a, ll b){
  if (b == 0) return 1;
  ll tmp = Pow(a, b / 2);
  tmp = (tmp * tmp) % mod;
  if (b % 2) return (tmp * a) % mod;
  return tmp;
}

ll gt[maxn], igt[maxn];

void init(){
  const int maxp = 2e5;
  gt[0] = 1;
  for (int i = 1; i <= maxp; ++i) gt[i] = (gt[i-1] * i) % mod;
  igt[maxp] = Pow(gt[maxp], mod - 2);
  for (int i = maxp - 1; i >= 0; --i) igt[i] = (igt[i+1] * (i+1)) % mod;
}

ll comb(int k, int n){
  return ( ( (gt[n] * igt[k]) % mod) * igt[n-k]) % mod;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  init();
  int n, m, a, b; cin >> n >> m >> a >> b;
  int _x = n - a - 1, y = b;
  ll ans;
  ans = (comb(n - 1, m - 1 - b + n - 1) );
  for (int x = 1; x <= _x; ++x){
    int X = n - 1 - x, Y = m - 1 - y;
    ans += (comb(x, x + y - 1) * comb(X, X + Y)) % mod;
    ans %= mod;
  }
  cout << ans;
return 0;
}




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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

int main() {
  cin.sync_with_stdio(false);

  int n;
  cin >> n;

  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x >= 3200) {
      x = 3200;
    }
    a[x / 400]++;
  }

  int mlc = 0;
  for (int i = 0; i < 8; i++) {
    if (a[i]) {
      mlc++;
    }
  }

  int mini = max(1, mlc);
  int maxi = mlc + a[8];

  cout << mini << " " << maxi << '\n';

  return 0;
}

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

int main() {
	int n;
  	cin >> n;
  	
  	int lt,rt;
  	int sum=0;
  
  	for (int i=0; i<n; i++){
    	cin >> lt >> rt;
      	sum = sum + rt - lt + 1;  
    }
  	cout << sum << endl;
  
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		bookNum   int
		studyNum  int
		goalLevel int
	)
	fmt.Scan(&bookNum, &studyNum, &goalLevel)

	bookPrices := []int{}
	levels := [][]int{}
	for i := 0; i < bookNum; i++ {
		bookPrice := 0
		fmt.Scan(&bookPrice)
		bookPrices = append(bookPrices, bookPrice)

		bookLevels := []int{}
		for j := 0; j < studyNum; j++ {
			level := 0
			fmt.Scan(&level)
			bookLevels = append(bookLevels, level)
		}
		levels = append(levels, bookLevels)
	}

	okPrices := []int{}
	for bits := 0; bits < (1 << uint64(bookNum)); bits++ {
		sumPrice := 0
		levelsums := make(map[int]int)

		for i := 0; i <= bookNum; i++ {
			if (bits>>uint64(i))&1 == 1 {
				sumPrice += (bookPrices[i])
				for j, v := range levels[i] {
					levelsums[j] = levelsums[j] + v
				}
			}
		}

		okNum := 0
		for _, v := range levelsums {
			if v >= goalLevel {
				okNum++
			}
			if okNum == studyNum {
				okPrices = append(okPrices, sumPrice)
			}
		}
	}

	if len(okPrices) == 0 {
		fmt.Println("-1")
	} else {
		fmt.Println(minInt(okPrices))
	}

}

func minInt(a []int) int {
	sort.Sort(sort.IntSlice(a))
	return a[0]
}


Measured memory_bytes: 3552
MAX_N = 100
MAX_X = 100
INF = 1_000_000_000

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

res = INF
for i in range(1, MAX_X + 1):
    t = 0
    for x in X:
        t += (i - x) ** 2
    res = min(res, t)
print(res)


Measured memory_bytes: 9120
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (ABC[0] == ABC[1]) Console.WriteLine(ABC[2]);
            else if (ABC[0] == ABC[2]) Console.WriteLine(ABC[1]);
            else Console.WriteLine(ABC[0]);
        }
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define sz(obj) ((int)(obj).size())
#define pf push_front
#define pb push_back

int main()
{
  int a;
  cin >> a;
  int s = a;
  char c;
  while (cin >> c, c != '='){
    cin >> a;
    if (c == '+') s += a;
    if (c == '-') s -= a;
    if (c == '*') s *= a;
    if (c == '/') s /= a;
  }
  cout << s << endl;
}

Measured memory_bytes: 1164
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    vector<int> ans(n);
    for (int i = 0; i < n - 1; i++) {
        int tem = 0;
        tem += s[i] + c[i];

        for (int j = i + 1; j < n - 1; j++) {
            chmax(tem, s[j]);

            if (tem % f[j] != 0) {
                tem += f[j] - (tem % f[j]);
            }

            tem += c[j];
        }

        ans[i] = tem;
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
S = list(input())

AGCT = ['A','G','C','T']
Ans = [0]
for i in range(len(S)):
    for j in range(len(S)):
        if all(AGCT.count(c) == 1 for c in (S[i:j+1])) == True:
            Ans.append(len(S[i:j+1]))

print(max(Ans))

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  ll a;
  cin >> a;
  cout << a*a*a + a*a + a << endl;
}



Measured memory_bytes: 3592
program main
	implicit integer(a-z)
    ans=0
    
    read(*,*)n
    
    do i=1,n
    	count=0
        do j=1,n
        	if(mod(i,j).eq.0.and.mod(i,2).eq.1) then
            	count=count+1
            end if
        end	do
        if(count.eq.8) ans=ans+1
    end do
    
    write(*,*)ans
    
end program main

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N,ko=1,co=1;
	string S[200001];
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	sort(S,S+N);
	S[N]="1";
	for(int i=0;i<N;i++){
		if(S[i]!=S[i+1]){
			ko=max(ko,co);
			co=1;
		}else co++;
	}
	for(int i=0;i+ko<=N;i++){
		if(S[i]==S[i+ko-1]&&S[i]!=S[i+ko])cout<<S[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 15232
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	int n;
	int m[101][101] = {};
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> m[i][j];
		}
	}
	for (int i = 0; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			m[i][j] += m[i][j - 1];
		}
	}
	for (int j = 0; j <= n; j++)
	{
		for (int i = 1; i <= n; i++)
		{
			m[i][j] += m[i - 1][j];
		}
	}
	int ans = -1000000000;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			for (int x = 1; x + j-1 <= n; x++)
			{
				for (int y = 1; y + i-1 <= n; y++)
				{
					ans = max(ans, m[i - 1][j - 1] + m[i + y - 1][j + x - 1] - m[i - 1][j + x - 1] - m[i + y - 1][j - 1]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1208
tmp = input().split()
value = [0 for _ in range(2)]
value[0] = int(tmp[0])
value[1] = int(tmp[1])
d = value[0] // value[1]
r = value[0] % value[1]
f = value[0] / value[1]
print("{} {} {:f}".format(d,r,f))



Measured memory_bytes: 5620
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        int count=0;
        Scanner scan = new Scanner(System.in);
        while(true){
            
            long a =scan.nextLong();
            if(a==0){
                break;
            }else{
                count++;
                System.out.println("Case "+count+": "+a);
            }
        }
    
        
        
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 1e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

ll dp[N][110];
ll w[110],v[110];

int main(){
	int n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
	for(int i=1;i<=W;i++)for(int j=1;j<=n;j++)dp[i][j] = -1e18;
	for(int i=1;i<=W;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			if(w[j] > i)continue;
			dp[i][j] = max(dp[i][j],dp[i-w[j]][j-1] + v[j]);
		}
	}
	cout << dp[W][n] << endl;
}

Measured memory_bytes: 86144
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.compareTo("2019/04/30") <= 0) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
	}
}


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





int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   char c=s[0];
   int sum=1;
   rep(i,n){
      if(c!=s[i]){
         c=s[i];
         sum++;
      }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 512
/* package codechef; // don't place package name! */
 
import java.util.*;
import java.lang.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
        public static void main (String[]args)
        {
            // your code goes here
            Scanner s = new Scanner(System.in);
            int n = s.nextInt();
            int r = n%10;
            if(r==2||r==4||r==5||r==7||r==9)
                System.out.println("hon");
            else if(r==0||r==1||r==6||r==8)
                System.out.println("pon");
            else
                System.out.println("bon");
 
        }
}

Measured memory_bytes: 35596
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  long long int a,b,c,e,i,line,count=0;
  cin >> a >> b >> c >> e;
  vector <long long int> d(4);
  /*
  for(i=0;i<4;i++)
  {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  */
  
  d[0] = a*c;
  d[1] = a*e;
  d[2] = b*c;
  d[3] = b*e;
  sort(d.begin(), d.end());
  cout << d[3];
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> B(N, 0);
    for (int i = 0; i < N - 1; i++) {
        int Bi;
        cin >> Bi;
        B[i] = Bi;
    }
    B[N - 1] = B[N - 2];

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

    int total = 0;
    for (int i = 0; i < N; i++) {
        total += A[i];
    }

    cout << total;

    return 0;
}


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

/*
  ll n , m ;
  cin >> n >> m ;
  ll a , b , c ;
  cin >> a >> b >> c ;
  vector<ll> A(n) ;
  cout << "Yes" << endl ;
  cout << "No"  << endl ;
*/

int main(){
    string s ;
    cin >> s ;
    ll mod = 2019 ;
    reverse(s.begin(),s.end()) ;
    ll now = 0 ;
    ll ans = 0 ;
    ll p = 1 ;
    map<ll,ll> mp ;
    mp[0]++ ;
    rep(i,s.size()){
      ll keta = ( s[i] - '0' ) ;
      now = keta*p + now ;
      now %= mod ;
      ans += mp[now] ;
      mp[now]++;
      p *= 10  ;
      p %= mod ;
      //cout << now << endl ;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    in(s);
    int ans=0;
    rep(i,3){
        if(s[i]=='R'){
            ans++;
        }
    }
    if(ans>=2&&s[1]!='R')ans--;
    out(ans);
}

Measured memory_bytes: 3720
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
n=len(s)
for i in range(n-2,0,-2):
    u=s[:i]
    #print(u)
    if u[:i//2]==u[i//2:]:
        #print(u)
        print(i)
        sys.exit()
    #print(i)


Measured memory_bytes: 9296
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        Set<Integer> d = new HashSet<>();
        
        for(int i = 0; i < n; i++){
            d.add(Integer.valueOf(br.readLine()));
        }
        
        out.println(d.size());
        out.close();
        
    }
}

Measured memory_bytes: 32528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	string S; cin >> S;
	bool flag = true;
	if (S.size() % 2 == 1) flag = false;
	for (int i = 0; i < S.size() / 2 && flag; i++) {
		if (S[i] != S[i + S.size() / 2]) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
$x = trim(fgets(STDIN));

if ($x >= 400 and $x < 600) {
    echo '8'.PHP_EOL;
} else if ($x >= 600 and $x < 800) {
    echo '7'.PHP_EOL;
} else if ($x >= 800 and $x < 1000) {
    echo '6'.PHP_EOL;
} else if ($x >= 1000 and $x < 1200) {
    echo '5'.PHP_EOL;
} else if ($x >= 1200 and $x < 1400) {
    echo '4'.PHP_EOL;
} else if ($x >= 1400 and $x < 1600) {
    echo '3'.PHP_EOL;
} else if ($x >= 1600 and $x < 1800) {
    echo '2'.PHP_EOL;
} else if ($x >= 1800 and $x < 2000) {
    echo '1'.PHP_EOL;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;


int n,cnt[105],dp[105];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n;

  for (int i=2; i<=n; i++) {
    int x = i;
    for (int j=2; x>1; j++) {
      while (x%j == 0) {
	cnt[j]++;
	x=x/j;
      }
    }
  }

  dp[1]=1;
  for (int i=100; i>=1; i--) {
    if (cnt[i]>0) {
      for (int j=75; j>=1; j--) {
	for (int x=1; x<=cnt[i]; x++) {
	  if ((x+1)*j <= 75) {
	    dp[(x+1)*j] += dp[j];
	  }
	}
      }
    }
  }

  cout<<dp[75]<<endl;
  return 0;
}


Measured memory_bytes: 256