akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)2e5 + 7, MOD = (int)1e9 + 7;

int n;
int h[N],a[N];
ll dp[N];
ll t[4*N];

ll get(int v,int l,int r,int tl,int tr){
	if(r<tl || l>tr)return 0;
	if(tl<=l && tr>=r){
		//cout << l << ' ' << r << endl;
		return t[v];
	}
	int md=(l+r)/2;
	return max(get(v+v,l,md,tl,tr),get(v+v+1,md+1,r,tl,tr));
}

void upd(int v,int l,int r,int pos,ll val){
	if(l==r){
		t[v]=val;
		//cout << l << ' ' << r << ' ' << val << endl;
		return;
	}
	int md=(l+r)/2;
	if(md>=pos)upd(v+v,l,md,pos,val);
	else upd(v+v+1,md+1,r,pos,val);
	t[v]=max(t[v+v],t[v+v+1]);
}

int main(){
		
	NFS

	cin >> n;
	
	for(int i=1;i<=n;i++)cin >> h[i];
	for(int i=1;i<=n;i++)cin >> a[i];
	
	for(int i=1;i<=n;i++){
		ll mx=get(1,1,n,1,h[i]);
		dp[h[i]]=max(dp[h[i]],mx + a[i]);
		//cout << h[i] << ' ' << dp[h[i]] << ' ' << mx << endl;
		upd(1,1,n,h[i],dp[h[i]]);
	}
	
	cout << t[1] << endl;
	
	ioi
}

Measured memory_bytes: 9600
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int X;
    cin >> X;

    if(X==7 || X==5 || X==3){
        cout << "YES";
    }else{
        cout << "NO";
    }


}

Measured memory_bytes: 256
// QQ.cs
// ?????????????????¨?????¨?????????????????°??????

using System;

class QQ {
    static void Main(){
        for (int i = 1; i < 10; i++)
        {
            for(int j = 1; j < 10; j++){
                Console.WriteLine("{0}x{1}={2}", i, j ,i*j);
            }
        }
    }
}

Measured memory_bytes: 8916
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    if n==1:
      return [[1,0]]
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N = inputI()
print( min(factorization((x&(-x)))[0][1] for x in inputIL() ))


Measured memory_bytes: 38640
import math

l = input().split()
N = int(l[0])

l = input().split()
A = [0] * 13
for a in l:
    index = int(a) // 400
    if index < 8:
        A[index] = 1
    else:
        A[index] += 1

# print(N, A)

num_colored = sum(A[:8])
num_free = sum(A[8:])

print(max(1, num_colored), num_colored + num_free)


Measured memory_bytes: 38256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    try:
        n = input()
    except:
        break
    A = raw_input().split()
    E = [[] for i in range(7)]
    for s in A:
        u = int(s[0])
        v = int(s[1])
        E[u].append(v)
        E[v].append(u)
    cnt = 0
    for i in range(7):
        if len(E[i]) % 2 == 1:
            cnt += 1
    if cnt > 2:
        print "No"
        continue
    used = [len(E[i]) == 0 for i in range(7)]
    def func(num):
        if used[num]:
            return
        used[num] = True
        for u in E[num]:
            func(u)
    for i in range(7):
        if len(E[i]) > 0:
            func(i)
            break
    if False in used:
        print "No"
    else:
        print "Yes"


Measured memory_bytes: 5036
import java.util.Scanner;

public class Main {


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

		int hei, wid, cnt_wid;

		while(true){
			hei = scan.nextInt();//??????????????????
			wid = scan.nextInt();//?¨????????????????
			if(hei == 0 && wid == 0){//???????????????0???0????????\???????????????????????????
				break;
			}
			for(int cnt_hei = 0; cnt_hei < hei; cnt_hei++){//?????????????????????
				for(cnt_wid = 0; cnt_wid < wid; cnt_wid++){//?¨???????????????????
					if(cnt_hei % 2 == 0){//??¶??°???????\???°???????????????
						if(cnt_wid % 2 == 0){
							System.out.print("#");
						}
						else{
							System.out.print(".");
						}
					}else{
						if(cnt_wid % 2 == 0){
							System.out.print(".");
						}
						else{
							System.out.print("#");
						}
					}
						
				}
				System.out.println();
			}
		System.out.println();
		}
        scan.close();
    }
}

Measured memory_bytes: 34884
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int n;
  scanf("%d",&n);
  int h[n+10];
  for(int i=0;i<n+10;i++){
    h[i]=0;
  }
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  int max=0;
  int count=0;
  for(int i=0;i<n-1;i++){
    if(h[i+1]<=h[i]){
      count++;
    }else{
      count=0;
    }
    chmax(&max,count);
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 2096
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

struct edge {
  int dst;
  int d;
  int id;
};

std::vector<edge > edges[104];
int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  int a, b, c;
  for (int i=0; i<M; i++){
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    a--;
    b--;
    edges[a].push_back((edge){b, c, i});
    edges[b].push_back((edge){a, c, i});
  }
  std::vector<bool> used(M+4, false);
  for (int i=0; i<N; i++){
    std::vector<int > dist(N+4, -1);
    std::priority_queue<std::pair<int, int > > queue;
    dist[i]=0;
    queue.push(std::make_pair(0, i));
    while(queue.size()>0){
      int v = queue.top().second;
      int d = queue.top().first;
      queue.pop();
      if (dist[v]!=-1 && dist[v]<d) continue;
      for (auto &entry : edges[v]){
        int vv = entry.dst;
        int dd = entry.d;
        if (dist[vv]==-1 || dist[vv]>d+dd){
          dist[vv] = d+dd;
          queue.push(std::make_pair(d+dd, vv));
        }
      }
    }
    for (int j=0; j<N; j++){
      if (j==i) continue;
      std::queue<std::pair<int, int > > q;
      q.push(std::make_pair(dist[j], j));
      //int d = dist[j];
      //int v = j;
      while(q.size()>0){
      //while(d>0){
        int cnt = 0;
        int temp_dd, temp_vv, temp_id;
        int d = q.front().first;
        int v = q.front().second;
        q.pop();
        for (auto &entry : edges[v]){
          int dd = entry.d;
          int vv = entry.dst;
          int id = entry.id;
          //printf("d-dd=%d-%d=%d =? %d\n",d,dd,d-dd,dist[vv]);
          if (d-dd==dist[vv]){
            //d-=dd;
            //v=vv;
            //used[id]=true;
            //break;

            q.push(std::make_pair(d-dd, vv));
            used[id]=true;
            //printf("used[%d]=true\n", id);

            //temp_dd = dd;
            //temp_vv = vv;
            //temp_id = id;
            cnt++;
            //if (cnt>1){
            //  printf("Error");
           // }
          }
        }
        //d -= temp_dd;
        //v = temp_vv;
        //used[temp_id]=true;
      }
    }
  }
  int ans = 0;
  for (int i=0; i<M; i++){
    if (!used[i]) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}

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


int main () {
	lli n,q,h,s,d,ans;
	cin >> q >> h >> s >> d >> n;

	q *= 4;
	h *= 2;

	s = min(min(q,h),s);
	d = min(d,2*s);

	ans = n/2*d + (n&1)*s;

	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
num = list(map(int,list(input())))
for i in range(2**3):
    ans = num[0]
    siki = str(num[0])
    for h in range(3):
        if ((i>>h)&1):
            ans += num[h+1]
            siki += ('+'+str(num[h+1]))
        else:
            ans -= num[h+1]
            siki += ('-'+str(num[h+1]))
    if ans == 7:
        print(siki+'=7')
        break

Measured memory_bytes: 3064
import numpy as np
from numba import njit

N,K = map(int, input().split())
A = np.array(list(map(int, input().split())))

@njit
def main(N, K, A):
  for _ in range(min(K, 42)):
    A_ = np.zeros_like(A)
    for n in range(N):
      A_[max(0, n - A[n])] += 1
      if n + A[n] + 1  < N:
        A_[n + A[n] + 1] -= 1
    A = A_.cumsum()
        
  return A

print(*main(N, K, A))

Measured memory_bytes: 125032
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   string S;
   cin >> S;
   int sum=0;
   for(int i=0;i<S.length();i++){
      if(S[i]=='?'){
         S[i]='D';
      }
   }
   cout << S << endl;
   
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;

int x[10],y[10];

double dist(int i, int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx+dy*dy, 0.5);
}

int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> x[i] >> y[i]; 
  }
  double sum = 0.0;
  vector<int> v(n);
  rep(i,n) v[i] = i+1;
  do{
    for(int i = 0; i < n-1; ++i)sum += dist(v[i], v[i+1]);
  } while(next_permutation(v.begin(),v.end()));
  int factorial = 1;
  for(int i = 2; i <= n; ++i) factorial *= i;
  cout << fixed << setprecision(10);
  cout << sum/factorial << endl;
  
  return 0;
}

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


using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;


int N, M, L, Q;
map<int, int> m[512];


#define PI 3.141592653589
ll A[200001], F[200001];

int is_ok(ll y, const int N, const ll K){
    ll cnt = 0;
    //fprintf(stderr, "y = %d\n", y);
    for (int i = 0; i < N; i++){
        //fprintf(stderr, "%d, %d, %d,, %d\n", 
        //    A[i], F[i], y, A[i] - y / F[i]);
        if (A[i] - y / F[i] > 0){
            cnt += A[i] - y / F[i];
            //fprintf(stderr, "%d, %d, %d\n", i, A[i] - y / F[i], cnt);
        }
        //cnt += max(0, A[i] - y / F[i]);
    }
    if (cnt <= K){
        return 1;
    } else {
        return 0;
    }
}

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    ll max_val = 0LL;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    for (int i = 0; i < N; i++){
        cin >> F[i];
        if (max_val < A[i] * F[i]){
            max_val = A[i] * F[i];
        }
    }
    sort(A, A+ N, greater<int>());
    sort(F, F+ N);
    
    ll lb = -1, ub = 1e18; //max_val;
    
    while (ub - lb > 1){
        ll mid = (ub + lb) /2;
        if (is_ok(mid, N, K)){
            ub = mid;
        } else {
            lb = mid;
        }
    }
    cout << ub << endl;
    return 0;    
}


Measured memory_bytes: 3456
n = int(input())
#print(n)

ptn = [0 for _ in range(20000)]


for x in range(1, 125):
    for y in range(1, 125):
        for z in range(1, 125):
            if x+y+z <= 125:
                ptn[x**2 + y**2 + z**2 + x*y + y*z + x*z] += 1

for i in range(1, n+1):
    print(ptn[i])


Measured memory_bytes: 9232
from collections import Counter
import sys
MOD =998244353
input = sys.stdin.readline

n = int(input())
d = [int(i) for i in input().split()]
c = Counter(d)

if d[0] != 0 or c[0] > 1:
    print(0)
    exit()

cnt = 1
for i in range(1,max(d)+1):
    cnt *= pow(c[i-1],c[i])

print(cnt % MOD)

Measured memory_bytes: 19872
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
#define F first
#define Se second
#define INF (1<<29)
int N,M,C,S,g;
int p[51];
int Q[51][20001];
int q[51];
int R[51][20001];
struct edge{
  int t,d,c;
  edge(){}
  edge(int t,int d,int c) : t(t),d(d),c(c) {} 
};
vector<edge> G[101];
int h[101][21][51];//[駅][会社][段階];
int solve(){
  for(int i=0;i<101;i++)
    for(int j=0;j<21;j++)
      for(int k=0;k<51;k++)
	h[i][j][k]=INF;
  priority_queue<PP,vector<PP>,greater<PP> > q;
  q.push(PP(P(0,S),P(-1,0)));
  while(!q.empty()){
    PP p = q.top(); q.pop();
    int co = p.F.F;
    int s = p.F.Se;
    int c = p.Se.F;
    int d = p.Se.Se;
    //    printf("%d %d %d %d\n",co,s,c,d);
    for(int i=0;i<(int)G[s].size();i++){
      edge e = G[s][i];
      if( e.c == c ){
	if(e.d + d > 20000) break;
	int nexc = co + R[e.c][d+e.d] - R[c][d];
	int nexd = Q[e.c][d+e.d];
	if(h[e.t][e.c][nexd] > nexc){
	  h[e.t][e.c][nexd] = nexc;
	  q.push(PP(P(nexc,e.t),P(e.c,d+e.d)));
	}
      } else {
	if(e.d > 20000) break;
	int nexc = co + R[e.c][e.d];
	int nexd = Q[e.c][e.d];
	if(h[e.t][e.c][nexd] > nexc){
	  h[e.t][e.c][nexd] = nexc;
	  q.push(PP(P(nexc,e.t),P(e.c,e.d)));
	}
      }
    }
  }
  int ret = INF;
  for(int i=0;i<21;i++)
    for(int j=0;j<51;j++)
      ret = min(ret,h[g][i][j]);
  return ret;
}
int main(){
  while(1){
    scanf("%d %d %d %d %d",&N,&M,&C,&S,&g);
    if(!N && !M && !C && !S && !g) break;

    for(int i=1;i<=N;i++) G[i].clear();
    memset(Q,0,sizeof(Q));
    memset(R,0,sizeof(R));

    for(int i=0;i<M;i++){
      int x,y,d,c;
      scanf("%d %d %d %d",&x,&y,&d,&c); 
      G[x].push_back(edge(y,d,c-1));
      G[y].push_back(edge(x,d,c-1));
    }
    for(int i=0;i<C;i++){
      scanf("%d",&p[i]);
    }
    for(int i=0;i<C;i++){
      int q[51]={};
      q[0]=0;
      int go = 0;
      for(int j=1;j<p[i];j++){
	scanf("%d",&q[j]);
	for(;go<=q[j];go++)
	  Q[i][go]=j;
      }
      q[p[i]]=20000;
      for(;go<=q[p[i]];go++)
	Q[i][go]=p[i];

      for(int j=0;j<p[i];j++){
	int r;
	scanf("%d",&r);
	//	printf("%d:%d ",q[j],R[i][q[j]]);
	for(int k=q[j]+1;k<=q[j+1];k++){
	  R[i][k] = r+R[i][k-1];
	}
	//	printf("%d:%d ",q[j+1],R[i][q[j+1]]);
      }
      /*      for(int j=0;j<p[i];j++){
	printf("%d ",R[i][q[j]]);
	}*/
      //            puts("ok");
    }
    int res = solve();
    if(res == INF) puts("-1");
    else printf("%d\n",res);
  }
}

Measured memory_bytes: 10820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool cmp(const P &a, const P &b) {
    return a.first < b.first && a.second < b.second;
}

int main() {
    int N, ans = 0;
    cin >> N;
    vector<P> red(N), blue(N);
    for(int i = 0; i < N; ++i)
        cin >> red[i].first >> red[i].second;
    for(int i = 0; i < N; ++i)
        cin >> blue[i].first >> blue[i].second;

    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end());
    for(int i = 0; i < N; ++i) {
        int maxn = -1, tmp = -1;
        for(int j = 0; j < red.size(); ++j) {
            if(red[j].first >= blue[i].first)
                break;
            if(red[j].second >= blue[i].second)
                continue;
            if(tmp < red[j].second) {
                tmp = red[j].second;
                maxn = j;
            }
        }
        if(maxn != -1) {
            red.erase(red.begin() + maxn);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int partition(int *A,int p,int r){
	int x=A[r-1];
	int i=(p-1);
	int tmp;

	for(int j=0;j<(r-1);j++){
		if(A[j]<=x){
			i++;
			tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
		}

	}

	tmp=A[i+1];
	A[i+1]=A[r-1];
	A[r-1]=tmp;

	return i+1;
}

int main(){
	int N;
	int *A;

	scanf("%d",&N);
	A=(int*)malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	int x=A[N-1];

	int I=partition(A,0,N);

	for(int i=0;i<N;i++){
		if(i==I){
			printf("[%d]",A[i]);
		}else{
			printf("%d",A[i]);
		}
		if(i==(N-1)){
			printf("\n");
		}else{
			printf(" ");
		}
	}
	
	return 0;
}


Measured memory_bytes: 2160
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ll> a, b;
const ll INF = 1e9;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    b.assign(n + 1, INF);
    a.assign(n, 0);
    F0R(i, n - 1) cin >> b[i + 1];
    F0R(i, n)
    {
        a[i] = min(b[i], b[i + 1]);
    }
    // for(auto i : b) cout << i << " ";
    ll res = 0;
    F0R(i, n) res += a[i];
    cout << res;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());
            var ope = 0L;

            if (x >= 11)
            {
                var tmp = x % 11;
                ope = (x / 11) * 2;
                if (tmp == 0) ope--;
                if (tmp > 6) ope += 2;
                else ope += 1;
            }
            else
            {
                if (x > 6) ope += 2;
                else ope += 1;
            }

            Console.WriteLine(ope);
        }
    }
}


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

int main() {
    int N, R;
    std::cin >> N >> R;

    if (N >= 10) {
        std::cout << R << std::endl;
    } else {
        std::cout << (R + 100 * (10 - N)) << std::endl; 
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n,a,b;
	while(scanf("%lld%lld%lld",&n,&a,&b)!=EOF)
	{
		if(n==1&&a==b)
		{
			printf("1\n");
		}
		else if(a>b||n<2)	
		{
			printf("0\n");
		}
		else 
		{
			ll ans=(n-2)*(b-a)+1;
			printf("%lld\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100003;
ll i,n,k;
ll a[N],dp[N];
ll solve(ll i)
{
    if(dp[i] != -1) return dp[i];
    
    if(i == 1)
        return dp[i] = 0;
    
    ll res = MAX;
    for(ll j = i - 1;i - j <= k && j >= 1;j -= 1)
        res = min(res,solve(j) + llabs(a[i] - a[j]));
    
    return dp[i] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    rep(i,1,n + 1) cin>>a[i];
    cout<<solve(n);
    return 0;
}

Measured memory_bytes: 5632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string S;
  cin >> S;

  if (S.find("AC") != string::npos) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}


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

using namespace std;

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

	string s;
	cin >> s;
	switch (s[s.length() - 1]) {
		case '0':
		case '1':
		case '6':
		case '8':
			cout << "pon\n";
			break;
		case '2':
		case '4':
		case '5':
		case '7':
		case '9':
			cout << "hon\n";
			break;
		case '3':
			cout << "bon\n";
			break;
		default:
			cout << "E";
	}

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)

int main(){
    double a;
    cin >> a;
    a *= 6.2831853;
    cout << a << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 3788
// AOJ 1340: Directional Resemblance
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { int x, y, z, l; double a; } V;
V v[120002];
char buf[50], *p;

double angle(V *v1, V *v2)
{
	int a, b;

	b = v1->l * v2->l;
	a = v1->x * v2->x + v1->y * v2->y + v1->z * v2->z;
	a *= a;
	if (a == b) return 0;
	return acos(sqrt((double)a/b));
}

int cv(V *v1, V *v2)
{
	if (v1->x < v2->x) return -1; if (v1->x > v2->x) return 1;
	if (v1->y < v2->y) return -1; if (v1->y > v2->y) return 1;
	if (v1->z < v2->z) return -1; if (v1->z > v2->z) return 1;
	return 0;
}

int cmp(V *a, V *b)
{
	if (a->a < b->a) return -1;
	if (a->a > b->a) return 1;
	return 0;
}


int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int m, n, mn, S, W, g, i, j;
	V v0, t, min1, min2, min3, min4;
	double min, a;

	while (1) {
		fgets(p=buf, 50, stdin);
		m = in(), n = in(), S = in(), W = in();
		if (!S) break;

	    for (i = 0; i < m; i++) {
			fgets(p=buf, 50, stdin);
			v[i].x = in(), v[i].y = in(), v[i].z = in();
		}

		g = S;
	    mn = m+n; for (i = m; i < mn; i++) {
			v[i].x = (g / 7    ) % 100 + 1;
			v[i].y = (g / 700  ) % 100 + 1;
			v[i].z = (g / 70000) % 100 + 1;
			if ((g & 1) == 0) g >>= 1;
			else g = (g >> 1) ^ W;
		}

	    v0.x = v0.y = v0.z = 1, v0.l = 3, v0.a = 0;
		for (i = 0; i < mn; i++) {
			v[i].l = v[i].x*v[i].x + v[i].y*v[i].y + v[i].z*v[i].z;
			v[i].a = angle(&v0, v+i);
		}

	    qsort(v, mn, sizeof(V), cmp);
		min = acos(0);
		for (i = 0; i < mn; i++) for(j = i+1; j < mn; j++) {
			if (fabs(v[i].a - v[j].a) > min) break;

			a = angle(v+i, v+j);
			if (a == 0) continue;
			if (a < min) {
				min1 = v[i], min2 = v[j], min = a;
				if (cv(&min1, &min2) > 0) t = min1, min1 = min2, min2 = t;
			} else if (fabs(a - min) < 1e-7) {
				min3 = v[i], min4 = v[j];
				if (cv(&min3, &min4) > 0) t = min3, min3 = min4, min4 = t;
				if (cv(&min1, &min3) > 0) min1 = min3, min2 = min4;
				else if (cv(&min1, &min3) == 0 && cv(&min2, &min4) > 0) min2 = min4;
			}
		}

		printf("%d %d %d %d %d %d\n", min1.x, min1.y, min1.z, min2.x, min2.y, min2.z);
	}
	return 0;
}    

Measured memory_bytes: 6784
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
#include <iostream>
// #include <iomanip>
// #include <sstream>
using namespace std;
// const int dx[] = {0, 1, 0, -1};
// const int dy[] = {1, 0, -1, 0};
// const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
// const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
// const int dy[] = {-1, 1, 1, -1, 2, -2, 2, -2};
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fr(_iii_, 0, 66)pf(">");puts("in")
#define deb(x) fr(_iii_, 0, 66)cerr<<'>';cerr<<#x"="<<x<<"\n"
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false)
#define boost2 cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
int on_bit(int x, int pos) {x |= (1 << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
ll on_bit_all(ll x, int pos) {x = (1LL << pos)-1; return x;}
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int MOD = 1e9+7;
int add(ll a, ll b){return ((a%MOD)+(b%MOD))%MOD;}
int sub(ll a, ll b){return ((a%MOD)-(b%MOD))%MOD;}
int mult(ll a, ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}

int main(){
	string s;
	cin>>s;
	int curr_diff=INF;
	fr(i,0,sz(s)){
		string u=s.substr(i,3);
		if(sz(u)!=3)break;
		if(abs(atoi(u.c_str())-753)<curr_diff){
			curr_diff=abs(atoi(u.c_str())-753);
		}
	}
	cout<<curr_diff<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int tominutes(string &s){
	int a=0;
	a+=(s[0]-'0')*60*10;
	a+=(s[1]-'0')*60;
	a+=(s[3]-'0')*10;
	a+=(s[4]-'0');
	return a;
}
int main(){
	int n,t;
	vector<pair<string,int> > v;
	cin>>n>>t;
	int a;
	string s,b;
	cin>>s>>s>>s;
	a=tominutes(s);
	cin>>b;
	for(int i=1;i<n;i++){
		int c;
		string d;
		cin>>s>>d;
		c=tominutes(s);
		if((c-a)>=t){
			v.push_back(make_pair(b,c-a));
		}
		cin>>s>>b;
		a=tominutes(s);
	}
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++){
		cout<<v[i].first<<' '<<v[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int b,c=1,kun=0;
    int a[100001]={};
    cin>>b;
    for(int z=1;z<b+1;z++){
        cin>>a[z];
    }
    while(1){
        if(b<0){
            cout<<-1<<endl;
            break;
        }
        c=a[c];
        //cout<<c<<endl;
        if(c==2){
            cout<<kun+1<<endl;
            break;
        }
        kun++;
        b--;
    }
}


Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main(){
	int n, m, e, j;
	cin >> n;
	while (n != 0){//0??§??????
		for (int i = 0; i < n; i++){
			cin >> m >> e >> j;//?????????????????°????????±????????????
			if (m == 100 || e == 100 || j == 100) cout << "A" << endl;
			else if ((m + e) / 2 >= 90)cout << "A" << endl;
			else if ((m + e + j) / 3 >= 80) cout << "A" << endl;
			else if ((m + e + j) / 3 >= 70 && (m + e + j)/3 < 80) cout << "B" << endl;
			else if ((m + e + j) / 3 >= 50 && m >= 80 || e >= 80)cout << "B" << endl;
			else cout << "C" << endl;
		}
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int frog[100005];
int h[100005];
int main()
{
  int n;
  cin>>n;

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

  frog[0]=0;
  frog[1]=abs(h[0]-h[1]);

  for(int i=2;i<n;i++){
    frog[i]=min(abs(h[i]-h[i-1])+frog[i-1],abs(h[i]-h[i-2])+frog[i-2]);
  }

  cout<<frog[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  string S;
  cin >> N;
  cin >> S;

  ll ans = 0;
  ll dist = 0;
  REP(i, N){
    if(S[i]=='.') dist++;
  }
  ans = dist;
  REP(i, N){
    if(S[i]=='.'){
      dist--;
    }else{
      dist++;
    }
    ans = min(ans, dist);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    long long min=1000000000;
    sort(h.begin(),h.end());
    for(int i=0;i<n-k+1;i++){
        int num=h[i+k-1]-h[i];
        if(num<min)min=num;
    }
    cout << min << endl;
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    la=list(map(int,input().split()))
    lb=list(map(int,input().split()))
    cnt=0
    for i in range(n):
        if la[i]>=lb[i]:
            cnt+=lb[i]
            la[i]-=lb[i]
        else:
            cnt+=la[i]
            lb[i]-=la[i]
            cnt+=min(lb[i],la[i+1])
            la[i+1]-=min(lb[i],la[i+1])
    print(cnt)
resolve()

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;



void run_case() {
    int n; cin >> n;
    cout << !n;

}


int main() {
    //freopen("input", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(6);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3668
t = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

while 1:
    try:
        s = input()
        sum = 0
        for i in range(len(s)-1):
            if t[s[i]] < t[s[i + 1]]:
                sum -= t[s[i]]
            else:
                sum += t[s[i]]
        print(sum+t[s[len(s)-1]])

    except:
        break



Measured memory_bytes: 5564
"use strict";

function main(input){
  const args= input.split('\n');
  const N= parseInt(args[0],10),
  a= args[1].split(' ').map(n=>parseInt(n,10));

  var Alice=0,Bob=0;

  a.sort((a,b)=>(a<b?1:-1)).forEach((x, i) => {
    (i%2===0)?Alice+=x:Bob+=x;
  });

  console.log(Alice-Bob);

}
main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 7500
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	if n%2 != 0 {
		fmt.Println(0)
		return
	}

	cnt := 0
	for x := 10; x <= n; x *= 5 {
		cnt += n / x
	}
	fmt.Println(cnt)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[4040][2];
int v[4040];
int dp[4040][2020];
int cnt[2020][2020];
int cnt1[2020][2020];
void h(int &to,int now)
{
	if(to==-1)
		to=now;
	else
		to=min(to,now);
}
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=(n<<1);i++)
		scanf("%s%d",s[i],&v[i]);
	memset(cnt,0,sizeof(cnt));
	memset(cnt1,0,sizeof(cnt1));
	for(int i=1;i<=n*2;i++)
		if(s[i][0]=='B')
		{
			for(int j=i+1;j<=n*2;j++)
				if(s[j][0]=='W')
					cnt[v[i]][v[j]]++;
		}
	for(int i=1;i<=n*2;i++)
		for(int j=i+1;j<=n*2;j++)
			if(s[i][0]==s[j][0]&&v[i]>v[j])
				ans++;
	for(int i=1;i<=n*2;i++)
		if(s[i][0]=='W')
		{
			for(int j=i+1;j<=n*2;j++)
				if(s[j][0]=='B')
					cnt1[v[i]][v[j]]++;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			cnt[i][j]+=cnt[i][j-1];
			cnt1[i][j]+=cnt1[i][j-1];
		}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=min(i,n);j++)
			if(dp[i][j]!=-1)
			{
				h(dp[i+1][j],dp[i][j]+cnt[i+1-j][j]);
				h(dp[i+1][j+1],dp[i][j]+cnt1[j+1][i-j]);
			}
	printf("%d",dp[2*n][n]+ans);
	return 0;
}

Measured memory_bytes: 64000
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; string s;
    cin >> n >> s;
    
    int cnt = 1;
    char p = s[0];
    for (int i=1;i<n;i++){
        if (s[i] != p) cnt++;
        p = s[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var x = ReadLineInt();
            var re = 0;

            //0以下のとき
            if( x <= 0) {
                Console.WriteLine(0);
                return;
            }

            var a = x / 500;
            var b = a * 1000;
            var c = (x - (a * 500)) / 5;
            var d = c * 5;

            Console.WriteLine(b+d);
            ReadLine();

        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if(a > b) {
                return gcd(b, a);
            }

            while(b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[]{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll a, b, n; cin >> a >> b >> n;

    ll ans = 0;
    if (n < b) {
        ans = (a * n) / b - a * (n / b);
    } else {
        //n >= b
        if (b == 1) {
            ans = 0;
        } else {
            ll t = b - 1;
            ll k = 1;
            while (t * k <= n) {
                ll s = t * k;
                ans = max(ans, (a * s) / b - a * (s / b));
                k++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0; i<h; ++i) {
        cin >> v[i];
    }
    reverse(v.begin(), v.end());

    int res = 0;
    for(int i=0; i<w-1; ++i) {
        vector<vector<int>> cost(h+1, vector<int>(h+1, 0));
        vector<vector<int>> dp(h+1, vector<int>(h+1, 0));
        for(int j=0; j<=h; ++j) {
            for(int k=0; k<h-j; ++k) {
                if(j == 0) {
                    cost[0][0] += (v[k][i] == v[k][i+1] ? 1 : 0);
                } else {
                    cost[0][j] += (v[k][i] == v[k+j][i+1] ? 1 : 0);
                    cost[j][0] += (v[k+j][i] == v[k][i+1] ? 1 : 0);
                }
            }
        }
        for(int j=1; j<=h; ++j) {
            for(int k=1; k<=h; ++k) {
                cost[j][k] = cost[j-1][k-1] - (v[j-1][i] == v[k-1][i+1] ? 1 : 0);
            }
        }

        for(int j=0; j<=h; ++j) {
            for(int k=0; k<=h; ++k) {
                if(j == 0 && k == 0) {
                    continue;
                } else if(j == 0) {
                    dp[0][k] = dp[0][k-1] + cost[0][k-1];
                } else if(k == 0) {
                    dp[j][0] = dp[j-1][0] + cost[j-1][0];
                } else {
                    dp[j][k] = min(dp[j-1][k] + cost[j-1][k], dp[j][k-1] + cost[j][k-1]);
                }
            }
        }
        res += dp[h][h];
    }
    cout << res << endl;
}




Measured memory_bytes: 1196
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[4];
int table[26];


int main(){

	for(int i = 0; i < 26; i++){

		table[i] = 0;
	}

	scanf("%s",buf);

	for(int i = 0; i < 3; i++){

		table[buf[i]-'a']++;
	}

	if(table[0] == 1 && table[1] == 1 && table[2] == 1){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int tt;
    cin>>tt;
    for(int i = 1; i <= 9; i++) {
      	if(tt % i) continue;
        if(tt/i >= 1 && tt/i <= 9) {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  int h,w,n;
  cin>>h>>w>>n;

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  vector<vector<int>> ans(h,vector<int>(w));
  int now=1;
  rep(i,h){
    if(i%2==0){
      rep(j,w){
        ans[i][j]=now;
        p[now-1]--;
        if(p[now-1]==0) now++;
      }
    }
    if(i%2==1){
      for(int j=w-1;j>=0;j--){
        ans[i][j]=now;
        p[now-1]--;
        if(p[now-1]==0) now++;
      }
    }
  }

  rep(i,h){
    rep(j,w){
      cout << ans[i][j];
      if(j!=w-1) cout << " ";
    }
    cout << endl;
  }

}

Measured memory_bytes: 384