akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e3+5;
char S[N][N];
int f[N][N],dr[4][2]={{1,0},{-1,0},{0,1},{0,-1}},que[N*N],s,t;
int main(){
	int h,w,sx,sy,tx,ty;scanf("%d%d%d%d%d%d",&h,&w,&sx,&sy,&tx,&ty);
	for(int i=0;i<h;i++){
		scanf("%s",S[i]);
		for(int j=0;j<w;j++)f[i][j]=S[i][j]=='#';
	}
	f[--sx][--sy]=1;tx--,ty--;
	que[t++]=sx*N+sy;
	while(s<t){
		int s1=s;
		while(s<t){
			int x=que[s++],y=x%N;x/=N;
			for(int i=0;i<4;i++){
				int x1=x+dr[i][0],y1=y+dr[i][1];
				if((unsigned)x1>=h||(unsigned)y1>=w||f[x1][y1])continue;
				f[x1][y1]=f[x][y];que[t++]=x1*N+y1;
			}
		}
		while(s1<s){
			int x=que[s1++],y=x%N;x/=N;
			for(int i=-2;i<3;i++){
				for(int j=-2;j<3;j++){
					int x1=x+i,y1=y+j;
					if((unsigned)x1>=h||(unsigned)y1>=w||f[x1][y1])continue;
					f[x1][y1]=f[x][y]+1;que[t++]=x1*N+y1;
				}
			}
		}
	}
	printf("%d",f[tx][ty]?f[tx][ty]-1:-1);
	return 0;
}

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

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c;
    cin >> k;
    for(int i=0;i<k;i++){
        if(a >= b){
            b *= 2;
        }else{
            c *= 2;
        }
    }
    if(c > b && b > a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
def resolve():
    n = int(input())
    V = [list(map(int, input().split())) for _ in range(n)]
    ans = [[0 for _ in range(n)] for _ in range(n)]
    for v, k, *a in V:
        for j in a:
            ans[v - 1][j - 1] = 1
    for a in ans:
        print(*a)


resolve()



Measured memory_bytes: 6392
N = int(input())
Hs = list(map(int, input().split()))
Hsr = list(reversed(Hs))
# print(Hsr)
cnt = 0
ans = 0
prev = -10
for h in Hsr:
    if prev <= h:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 1
    prev = h
ans = max(ans, cnt)
print(ans-1)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  a = 0;
  vector<ll> c(n + 2, 0), d(n + 1), e(n);
  rep(i, n){
    in(c[i + 1]);
  }
  rep(i, n + 1)
    d[i] = abs(c[i + 1] - c[i]);
  rep(i, n){
    e[i] = abs(c[i + 2] - c[i]);
  }
  rep(i, n + 1){
    a = a + d[i];
  }
  rep(i, n){
    b = a - d[i] - d[i + 1] + e[i];
    out(b);
    memi;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A = 0 , B = 0 , C = 0 , D = 0;
  cin >> A >> B >> C >> D;

  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  } else if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,m,i,j,a,b;
	int r[55]={0};
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		r[a]++;
		r[b]++;
	}
	for(i=1;i<=n;i++)
		printf("%d\n",r[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

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

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<bool> c(n,false);
    rep0(i, k){
        ll d;
        cin >> d;
        rep0(j, d){
            ll a;
            cin >> a;
            --a;
            c[a] = true;
        }
    }
    ll ans = 0;
    rep0(i, n)if(!c[i])++ans;
    pf(ans);
    return 0;
}



Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**6)

N, M = [int(i) for i in input().split()]
parent = [i for i in range(N+1)]
node_num = [1 for i in range(N+1)]
def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent[x])
        return parent[x]

bridge = []
for i in range(M):
    A, B = [int(i) for i in input().split()]
    bridge.append([A, B])

bridge = bridge[::-1]
ans_rev = [N*(N-1)//2]
combi = 0
for i in range(M-1):
    A, B = bridge[i]
    r_A = find(A)
    r_B = find(B)
    if r_A != r_B:
        parent[r_B] = r_A
        combi += node_num[r_B] * node_num[r_A]
        node_num[r_A] += node_num[r_B]
    ans_rev.append(N*(N-1)//2-combi)

ans = ans_rev[::-1]
print(*ans, sep="\n")

Measured memory_bytes: 39160
l = map(int, raw_input().split())
if len(l) == 2:
    a = l[0]; b = l[1]
else:
    a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
    if b - i <= ans or a - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans

Measured memory_bytes: 6772
#include <iostream>
#include<string>

using namespace std;
class Dice{
public:
	int num[6],t;//t=top

	void North(){
		t = num[0];
		num[0] = num[1];//??????1?????¨???
		num[1] = num[5];//??????2?????¨???
		num[5] = num[4];//??????6?????¨???
		num[4] = t;//??????5?????¨???
		}

	void East(){
		t = num[0];
		num[0] = num[3];//??????1?????¨???
		num[3] = num[5];//??????4?????¨???
		num[5] = num[2];//??????6?????¨???
		num[2] = t;//??????3?????¨???
		}

	void West(){
		t = num[0];
		num[0] = num[2];//??????1?????¨???
		num[2] = num[5];//??????5?????¨???
		num[5] = num[3];//??????6?????¨???
		num[3] = t;//??????2?????¨???
		}
		
	void South(){
		t = num[0];
		num[0] = num[4];//??????1?????¨???
		num[4] = num[5];//??????3?????¨???
		num[5] = num[1];//??????6?????¨???
		num[1] = t;//??????3?????¨???
		}
	
	void Rotation(){//?????¢??????????????§?????¢???????????¨???
		t = num[1];
		num[1] = num[2];//?????¢???2?????¨???
		num[2] = num[4];//?????¢???3?????¨???
		num[4] = num[3];//?????¢???5?????¨???
		num[3] = t;//?????¢???4?????¨???
		}
};

int main()
{
	int i;
	int num[i];
	
	Dice d1;
	Dice d2;
	
	cin >> d1.num[0] >> d1.num[1] >> d1.num[2] >> d1.num[3] >> d1.num[4] >> d1.num[5];
	cin >> d2.num[0] >> d2.num[1] >> d2.num[2] >> d2.num[3] >> d2.num[4] >> d2.num[5];
	
	if( d1.num[2] == d2.num[0] || d1.num[3] == d2.num[0] ){
		d1.East();
	}
	
	for(i = 0; i<4; i++){
		if(d1.num[0] == d2.num[0])break;
		d1.North();
	}
	
	for(i = 0; i<4; i++){
		if(d1.num[1] == d2.num[1])break;
		d1.Rotation();
	}
	
	if(d1.num[0] == d2.num[0] && d1.num[1] == d2.num[1] && d1.num[2] == d2.num[2] && d1.num[3] == d2.num[3] && d1.num[4] == d2.num[4] && d1.num[5] == d2.num[5]){
		cout << "Yes" <<endl;
	}else{
		cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int div = 1;
	while (N >= div) div *= 2;

	cout << div / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
int cnt[200001];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	vector<P> v;
	for (int i = 0; i <= N; i++) {
		if (cnt[i]) v.emplace_back(cnt[i], i);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int k = v.size();
	for (int i = 0; i < v.size(); i++) {
		if (k <= K) break;
		ans += v[i].first;
		k--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3188
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        k: usize,
        h: [usize; n],
    );

    let mut ans = 0;

    for i in h {
        if i >= k {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    for (;;) {
        string g; cin >> g;
        if (g == "#") break;
        int y, m, d; cin >> y >> m >> d;
        if (y > 31 or
            y == 31 and m >= 5) {
            y -= 30;
            g = "?";
        }
        cout << g << " " << y << " " << m << " " << d << endl;
    }

    return 0;
}



Measured memory_bytes: 3240
// =====================================================================================
//
//       Filename:  cp.cpp
//
//        Version:  1.0
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Priyank Kumar Singh ()
//   Organization:  RVCE Bangalore
//
// =====================================================================================


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define mod 1000000007
#define M 100005
vector<int> s[10];
/*
void dfs(int i, int j){
    int c=s[i][j];
    if(i==n-1 && j==m-1 ){
        ans = min(ans, c);
        return;
    }
    
    if(j+1<m) dfs(i,j+1);
    c+=s[i][j];
    if(i+1<n) dfs(i+1,j);
    c+=s[i][j];
}
int c1=0;
*/


void answer(){
    ll n,ans=0;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    int in[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
        cin>>in[i][j];
    }
    a[n-1] = in[n-1][0];
    b[n-1] = in[n-1][1];
    c[n-1] = in[n-1][2];
    for(int i=n-2;i>=0;i--){
        a[i] = max(b[i+1],c[i+1])+in[i][0];
        b[i] = max(c[i+1],a[i+1])+in[i][1];
        c[i] = max(a[i+1],b[i+1])+in[i][2];
    }
    cout<<max(max(a[0],b[0]),c[0]);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


Measured memory_bytes: 2560
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        ans = 0
        for i in range(N - 1):
            ans = max(self.longest_common_subsequence(S[i:]), ans)

        print(ans)

    # Z-Algorithm を使った連続する部分文字列長の計算
    def longest_common_subsequence(self, s: str) -> int:
        z = [0] * len(s)
        z[0] = len(s)

        # Z-box の初期値
        z_box_start, z_box_end, = 0, 0

        # １文字目から一文字ずつチェック
        for i in range(1, len(s)):
            # Z-box の範囲外
            if i > z_box_end:
                # 一文字ずつチェックする
                while i + z[i] < len(s) and s[z[i]] == s[z[i] + i]:
                    z[i] += 1
                # 新しい Z-box が見つかった場合
                if z[i] > 0:
                    z_box_start, z_box_end = i, i + z[i] - 1

            # Z-box の範囲内
            else:
                # 計算済みの Z-Value(一致する文字列長)を利用
                # 一致範囲が Z-Box の範囲内
                if z[i - z_box_start] <= z_box_end - i:
                    # 計算済みの Z-Value を利用
                    z[i] = z[i - z_box_start]

                # 一致範囲が Z-Box の範囲外
                else:
                    # Z-Box の範囲外 の部分を, 一文字ずつチェックする
                    check_target = z_box_end + 1
                    while check_target < len(s) and s[check_target] == s[check_target - i]:
                        check_target += 1
                    z[i] = check_target - i
                    # Z-Box の更新
                    z_box_start, z_box_end = i, check_target - 1

        # "重ならず" の制約を値に反映          
        for i, v in enumerate(z):
            z[i] = min(v, i)

        # 最大長を返却
        return max(z[1:])


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 48988
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	
      	String numStr = sc.next();
      	String[] nums = numStr.split("");
      
      	int count = 0;
      	for (int i = 0; i < nums.length; i++){
        	if("1".equals(nums[i])){
            	count++;
            }
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
 	}
	return res;
}


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

	ll N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	ll ans = 0;
	char prev = S[0];

	for (int i = 1; i < S.size(); i++) {
		if (S[i] == prev) ans++;
		prev = S[i];
	}

	cout << std::min(ans + 2 * K,N - 1) << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}





Measured memory_bytes: 712
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	map<int, bool> cnt;
	int ans = 0;
	int res = 0;
	map<int, int> fr;
	for(int i = 1; i <= b; i++) {
		int x;
		string s;
		cin >> x >> s;
		if (!cnt.count(x) && s == "AC") {
			ans++;
			cnt[x] = 1;	
		}
		if (!cnt.count(x) && s == "WA") {
			res++;
			fr[x]++;
		}
	}
	
	for(int i = 1; i <= a; i++) {
		if (!cnt.count(i)) {
			res -= fr[i];
		}
	}
	cout << ans << ' ' << res << '\n';
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
vector<int> G[MAXN];
int color[MAXN]; // 0 non visit 1 = visiting 2 = finish
int oncycle[MAXN], mex[MAXN], par[MAXN];
int tmpmex[MAXN];
bool mexnum[MAXN];

void dfs(int cur) {
    color[cur] = 1;
    //printf("cur = %d\n", cur);
    for (int i : G[cur]) {
        if (color[i] == 1) {
            //printf("cur = %d i = %d\n", cur, i);
            oncycle[i] = oncycle[cur] = 1;
            continue;
        }
        if (!color[i]) dfs(i);
        if (oncycle[i] == 1) {
            //printf("2 cur = %d i = %d\n", cur, i);
            oncycle[cur] = 1;
        }
    }
    for (int i = 0; i <= (int)G[cur].size(); i++)
        mexnum[i] = false;
    for (int i : G[cur]) {
        if (oncycle[i]) continue;
        mexnum[mex[i]] = 1;
    }
    for (int i = 0; ; i++)
        if (!mexnum[i]) {
            mex[cur] = i;
            break;
        }
    color[cur] = 2;
}

bool check(int tg, int ans) {
    tmpmex[tg] = ans;
    int cur = par[tg];
    //printf("tg = %d ans = %d\n", tg, ans);
    while (cur != tg) {
        for (int i = 0; i <= (int)G[cur].size(); i++)
            mexnum[i] = false;
        for (int i : G[cur])
            mexnum[tmpmex[i]] = 1;
        for (int i = 0; ; i++)
            if (!mexnum[i]) {
                tmpmex[cur] = i;
                break;
            }
        cur = par[cur];
    }
    memset(mexnum, 0, sizeof(mexnum));
    for (int i : G[tg])
        mexnum[tmpmex[i]] = 1;
    int ansmex = 0;
    while (mexnum[ansmex])
        ansmex++;
    return tmpmex[tg] == ansmex;
}

bool solve(int tg, int N) {
    for (int i = 0; i < N; i++)
        tmpmex[i] = mex[i];
    if (check(tg, tmpmex[tg])) return true;
    for (int i = 0; i < N; i++)
        tmpmex[i] = mex[i];
    memset(mexnum, 0, sizeof(mexnum));
    for (int i : G[tg]) {
        if (oncycle[i]) continue;
        mexnum[tmpmex[i]] = 1;
    }
    int ans = 0, cnt = 0;
    for (int i = 0; ; i++) {
        if (!mexnum[i]) {
            cnt++;
            if (cnt == 2) {
                ans = i;
                break;
            }
        }
    }
    if (check(tg, ans)) return true;
    return false;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &par[i]);
        par[i]--;
        G[par[i]].push_back(i);
    }
    for (int i = 0; i < N; i++)
        if (!color[i])
            dfs(i);
    int tg;
    for (int i = 0; i < N; i++)
        if (oncycle[i]) {
            tg = i;
            //printf("i = %d\n", i);
        }
    if (solve(tg, N)) puts("POSSIBLE");
    else puts("IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 25984
import math, string, itertools, fractions, heapq, collections, re, \
array, bisect, sys, random, time, copy, functools, os, queue, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)


M, D = LI()

"""
20何日
1の位が2以上
30日はだめ
8/24
2*4=8

"""
if D <= 21:
    print(0)
    exit()

ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d10 = str(d)[0]
        d1 = str(d)[1]
        #  print(d10, d1)
        if int(d1) >= 2 and int(d10) * int(d1) == m:
            #  print(d10, d1)
            ans += 1

print(ans)


Measured memory_bytes: 8140
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        vll cnt(500010);
        rep(i, 0, N) {
                cin >> A[i];
                cnt[A[i]]++;
        }

        ll sm = accumulate(all(A), 0LL);
        ll Q;
        cin >> Q;

        rep(i, 0, Q) {
                ll b, c;
                cin >> b >> c;
                //ll diff = c - b;
                cout << sm - b*cnt[b] + c*cnt[b] << endl;
                sm = sm - b*cnt[b] + c*cnt[b];
                cnt[c] += cnt[b];
                cnt[b] = 0;

        }



}

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

class Program {
    static void Main(string[] args) {
        //入力
        int n = int.Parse(Console.ReadLine());

        string s = Console.ReadLine();
        int[] p = new int[n];
        //変数の割り当て
        for (int i = 0; i < n; i++) {
            p[i] = int.Parse(s.Split(' ')[i]);
        }

        //検証
        //回答となる数値
        int ans = 0;
        for (int i = 1; i <= n - 2; i++) {
            if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
                ans++;
            } else if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
                ans++;
            } else if (p[i - 1] < p[i] && p[i] > p[i + 1] && p[i - 1] == p[i + 1]) {
                ans++;
            } else if (p[i - 1] < p[i] && p[i] == p[i + 1]) {
                ans++;
            } else if (p[i - 1] == p[i] && p[i] > p[i + 1]) {
                ans++;
            } else {
                //何もしない
            }
        }



        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N;
    int a[22][22];
    ll* dp = new ll[1<<22];
    cin >> N;
    rep(i, 0, N){
        rep(j, 0, N){
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for(int bit=0; bit<(1<<N); bit++){
        int guy_ix = __builtin_popcount(bit) - 1;
        for(int i=0; i<N; i++){
           int woman_mask = (1<<i);
           int woman_participating = woman_mask & bit;
           if(woman_participating){
               dp[bit] += (dp[bit ^ woman_mask] * a[guy_ix][i]) % MOD;
               dp[bit] %= MOD;
               /*cout << "dp[" << bitset<3>(bit) << "]" << " += dp[" << bitset<3>(bit^(1<<i)) << "]" << endl;
               cout << "\t" << "a[" << guy_ix << "][" << i << "]=" << a[guy_ix][i] << endl;
               cout << "\t" << dp[bit] << endl;*/
           }
        }
    }
    cout << dp[(1<<N)-1] << endl;
    delete[] dp;

    return 0;
}




Measured memory_bytes: 18560
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(){}
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int n):n(n){}

  void init(int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

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

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

struct Point{
  int x,y,idx,idy;
  Point(){}
  Point(int x,int y,int idx):x(x),y(y),idx(idx),idy(-1){}
  bool operator<(const Point &a)const{
    if(y!=a.y) return y>a.y;
    return x<a.x;
  }
};

const int MAX = 114514;
Point ps[MAX],bk[MAX];
int xs[MAX],ys[MAX];

void chk(int idx,int j){
  if(idx<0) return;
  int &idy=ps[j].idy;
  if(idy<0||xs[idy]<xs[idx]) idy=idx;
}

void upd(int &idx,int i){
  if(idx<0||xs[idx]<ps[i].x) idx=ps[i].idx;
}

void dfs(int l,int r){
  if(l+1==r) return;
  int m=(l+r)>>1;
  dfs(l,m);dfs(m,r);
  
  {
    int i=l,j=m,idx=-1;
    while(i<m||j<r){
      if(i==m||j==r){
        if(i==m) chk(idx,j++);
        if(j==r) upd(idx,i++);
        continue;
      }      
      ps[i].x+ps[i].y<=ps[j].x+ps[j].y?upd(idx,i++):chk(idx,j++);
    }
  }

  {
    int i=l,j=m,k=l;
    for(int i=l;i<r;i++) bk[i]=ps[i];
    while(i<m||j<r){
      if(i==m||j==r) ps[k++]=bk[(j==r?i:j)++];
      else ps[k++]=bk[(bk[i].x+bk[i].y<=bk[j].x+bk[j].y?i:j)++];
    }
  }
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  using P = pair<int, int>;
  vector<P> es;

  for(int b=0;b<4;b++){
    for(int i=0;i<n;i++){
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      ps[i]=Point(xs[i],ys[i],i);
    }
    
    sort(ps,ps+n);
    dfs(0,n);

    for(int i=0;i<n;i++){   
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      
      if(ps[i].idy<0) continue;
      int u=ps[i].idx,v=ps[i].idy;
      if(u>v) swap(u,v);
      es.emplace_back(u,v);      
    }
  }
  
  Kruskal<Int> ks(n);
  for(P e:es){
    int u,v;
    tie(u,v)=e;
    int c=max(abs(xs[u]-xs[v]),abs(ys[u]-ys[v]));
    ks.add_edge(u,v,c);
  }

  cout<<ks.build()<<endl;
  return 0;
}




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

const int N=4e3+50, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}

int n,m,k,ans,s[N],f[N];
int main() {
	cin>>n>>m>>k; 
	for(int i=0;i<=m;i++) s[i]=1;
	for(int i=1;i<=(n+m)/(k-1);++i) {
		for(int j=1;j<=m;++j) {
			f[j]=dec(s[j-1],(j>=k) ? s[j-k] : 0);
			if((j%(k-1))==(m%(k-1)) && 1+i*(k-1)-j<=n && ((1+i*(k-1)-j)%(k-1))==(n%(k-1))) ans=add(ans,f[j]); 
		}
		for(int j=1;j<=m;j++) f[j]=add(f[j-1],f[j]), s[j]=add(s[j],f[j]);
	} cout<<ans<<'\n';
}

Measured memory_bytes: 256
#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 = 998244353;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e6 + 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;}

int n, k;
vector<pair<int, int> > v;
int curr[N], suff[N];

int get(int l, int r) {
    //cout<<l<<' '<<r<<endl;
    if(l > n) {
        return 0;
    }
    if(r >= n) {
        //cout<<"WTF";
        return add(suff[l], 1);
    }
    // cout<<l<<' '<<r<<endl;
    return add(suff[l], -suff[r + 1]);
}

// 1 base
void solve() {
    cin>>n>>k;
    f(i, k) {
        int l, r;
        cin>>l>>r;
        v.pb({l, r});
    }
    for(int i = n - 1; i >= 1; i--) {
        for(auto &it: v) {
            int ff = it.first, ss = it.second;
            int to = get(i + ff, i + ss);
            //cout<<i<<' '<<to<<endl;
            suff[i] = add(suff[i], to);
        }
        suff[i] = add(suff[i], suff[i + 1]);
    }
    //f(i, n + 2) cout<<i<<' '<<suff[i]<<endl;
    cout<<add(suff[1], -suff[2])<<endl;
}

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 t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

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

const int N = 3e5 + 10;
int n, K, top, a[N];

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	in(K), in(n), top = n;
	if (K & 1) {
		for (int i = 1; i <= n; ++i) a[i] = K + 1 >> 1;
		for (int i = 1; i <= n/2; ++i)
			if (a[top] == 1) --top;
			else {
				--a[top];
				for (int j = top + 1; j <= n; ++j) a[j] = K;
				top = n;
			}
	} else {
		a[1] = K >> 1;
		for (int i = 2; i <= n; ++i) a[i] = K;
	}
	for (int i = 1; i < top; ++i) printf("%d ", a[i]); printf("%d\n", a[top]);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
using ll =long long;
using namespace std;
#define rep(i,x,n) for(int i=int(x);i<(int)(n);i++)
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, 0, n)cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i, 0, n)rep(j, i + 1, n) {
        int bel = a[j] - a[i] + 1;
        int bot = lower_bound(a.begin(), a.end(), bel) - a.begin();
        int up = a[j] + a[i];
        int top = lower_bound(a.begin(), a.end(), up) - a.begin();

        ans += (top - bot);
        if (a[i] >= bel && a[i] < up)ans--;
        if (a[j] >= bel && a[j] < up)ans--;
    }
    ans /= 3;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 998244353
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N= 1e6+5;

int call[N];


int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = call[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / call[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (call[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = call[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / call[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 
  


void solve()
{   
    int n;
    
    cin>>n;
    
    
    //c range  [1,n-1]
    
    int prime[n+1];
    for(int i=0;i<=n;i++)prime[i]=1;
    
    
    
    for(int i=0;i<=n;i++)call[i]=i;
    int ans=0;
    
    
    for(int i=2;i*i<=n;i++)
    {
        if(prime[i]==1)
        {
            for(int j=i*i;j<=n;j+=i )
            {
                if(prime[j])
                {
                    prime[j]=0;
                    call[j]=i;
                }
            }
        }
    }
    // for(int i=2;i<=3;i++)
    // {
    //     trace3(i,prime[i],call[i]);
    // }
    
    
    for(int i=1;i<=n-1;i++)
    {
        //prime factorization
        
        ans+= calculateNoOFactors(i); 
        
    }
    
    cout<<ans;
    
    
    
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

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

int main() {
  int a[3][3]; rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  set<int> used;
  while (n--) {
    int x; cin >> x;
    used.insert(x);
  }
  rep(i, 3) {
    if (used.count(a[i][0]) && used.count(a[i][1]) && used.count(a[i][2])) {
      cout << "Yes" << endl;
      return 0;
    }
    if (used.count(a[0][i]) && used.count(a[1][i]) && used.count(a[2][i])) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (used.count(a[0][0]) && used.count(a[1][1]) && used.count(a[2][2])) {
    cout << "Yes" << endl;
    return 0;
  }
  if (used.count(a[0][2]) && used.count(a[1][1]) && used.count(a[2][0])) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		long a = sc.nextLong();
		double b = sc.nextDouble();
		long res = (long)(( b * 100)+0.05);
		System.out.println((res * a) / 100);

	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 33168
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    const int dr[4] = {1, 0, -1, 0};
    const int dc[4] = {0, 1, 0, -1};

    ll H, W;
    cin >> H >> W;
    vector<string> field(H);
    ll black = 0;
    rep(i, H){
        cin >> field[i];
        rep(j, W){
            if(field[i][j] == '#') black++;
        }
    }

    vll dist(H, vl(W, -1));
    queue<pll> q;
    dist[0][0] = 1;
    q.push(pll(0, 0));
    while(!q.empty()){
        pll v = q.front();
        q.pop();
        ll r = v.first, c = v.second;
        ll nr, nc;
        rep(i, 4){
            nr = r + dr[i];
            nc = c + dc[i];
            if(nr < 0 || nc < 0 || nr >= H || nc >= W) continue;
            if(dist[nr][nc] != -1) continue;
            if(field[nr][nc] == '#') continue;
            dist[nr][nc] = dist[r][c] + 1;
            q.push(pll(nr, nc));
        }
    }
    if(dist[H-1][W-1] == -1){
        cout << -1 << endl;
        return 0;
    }
    cout << H*W - dist[H-1][W-1] - black << endl;
}

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

int h, w;
int a[10][10];

int getArea(int lx, int rx, int ly, int ry) {
	int i;
	int outMin = 1145141919;
	for (i = lx; i <= rx; i++) outMin = min(outMin, a[ly][i]);
	for (i = lx; i <= rx; i++) outMin = min(outMin, a[ry][i]);
	for (i = ly; i <= ry; i++) outMin = min(outMin, a[i][lx]);
	for (i = ly; i <= ry; i++) outMin = min(outMin, a[i][rx]);
	
	int ret = 0;
	for (int y = ly + 1; y < ry; y++) {
		for (int x = lx + 1; x < rx; x++) {
			if (a[y][x] >= outMin) { return 0; }
			ret += outMin - a[y][x];
		}
	}
	return ret;
}

int main() {
	int lx, ly, rx, ry;
	
	while (cin >> h >> w) {
		if (!h) break;
		for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
		
		int ans = 0;
		for (lx = 0; lx < w; lx++) {
			for (rx = lx + 2; rx < w; rx++) {
				for (ly = 0; ly < h; ly++) {
					for (ry = ly + 2; ry < h; ry++) {
						ans = max(ans, getArea(lx, rx, ly, ry));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        int countZero = 0;
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            if (a[i] == 0) {
                countZero++;
            }
        }
        sc.close();

        // 主処理
        Set<Integer> set = new HashSet<>(Arrays.asList(a));
        boolean judge;
        if (countZero == n) {
            judge = true;
        } else if (n % 3 == 0 && countZero == n / 3 && set.size() == 2) {
            judge = true;
        } else if (n % 3 == 0 && set.size() == 3) {
            Map<Integer, Integer> map = new HashMap<>();
            for (int num : set) {
                map.put(num, 0);
            }
            for (int i = 0; i < n; i++) {
                map.put(a[i], map.get(a[i]) + 1);
            }
            Set<Integer> valueSet = new HashSet<>();
            int xorSum = 0;
            for (int key : map.keySet()) {
                valueSet.add(map.get(key));
                xorSum = xorSum(xorSum, key);
            }
            judge = valueSet.size() == 1 && xorSum == 0;
        } else {
            judge = false;
        }
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }

    public static int xorSum(int a, int b) {
        String bina = new StringBuilder(Integer.toBinaryString(a)).reverse().toString();
        String binb = new StringBuilder(Integer.toBinaryString(b)).reverse().toString();
        int minlen = Math.min(bina.length(), binb.length());
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < minlen; i++) {
            if (bina.charAt(i) == binb.charAt(i)) {
                sb.append("0");
            } else {
                sb.append("1");
            }
        }
        if (bina.length() < binb.length()) {
            sb.append(binb.substring(minlen));
        } else if (binb.length() < bina.length()) {
            sb.append(bina.substring(minlen));
        }
        return Integer.parseInt(sb.reverse().toString(), 2);
    }
}


Measured memory_bytes: 61636