akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	H, W, N := ReadInt(), ReadInt(), ReadInt()
	m := make(map[int]map[int]int)
	cnt := make([]int, 10)
	cnt[0] = (H - 2) * (W - 2)
	for i := 0; i < N; i++ {
		a, b := ReadInt()-1, ReadInt()-1
		for y := a - 2; y <= a; y++ {
			for x := b - 2; x <= b; x++ {
				if 0 <= y && y < H-2 && 0 <= x && x < W-2 {
					if m[y] == nil {
						m[y] = make(map[int]int)
					}
					from := m[y][x]
					to := from + 1
					m[y][x] = to
					cnt[from]--
					cnt[to]++
				}
			}
		}
	}
	for i := 0; i < 10; i++ {
		fmt.Println(cnt[i])
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 83276
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        string str;
        cin >> str;
        bool flag = false;
        int cnt = 0;
        for (char c: str) {
            if (c == '.') {
                flag = true;
            } else {
                a[i] *= 10;
                a[i] += (c - '0');
                if (flag) ++cnt;
            }
        }
        rep(j, 9 - cnt) a[i] *= 10;
    }
    
    vector<int> two(n, 0), five(n, 0);
    rep(i, n) {
        ll num = a[i];
        while (num % 2 == 0) {
            num /= 2;
            ++two[i];
        }
        num = a[i];
        while (num % 5 == 0) {
            num /= 5;
            ++five[i];
        }
    }
    vector<vector<int>> vec(50, vector<int>(20, 0));
    rep(i, n) ++vec[two[i]][five[i]];
    vector<vector<int>> sum(51, vector<int>(21, 0));
    rep(i, 50) rep(j, 20) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + vec[i][j];
    
    ll ans = 0;
    rep(i, n) {
        int x = max(18 - two[i], 0), y = max(18 - five[i], 0);
        ans += (sum[50][20] - sum[x][20] - sum[50][y] + sum[x][y]);
        if (two[i] >= 9 && five[i] >= 9) --ans;
    }
    ans /= 2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6344
n = gets.to_i
arr = gets.chomp.split('')
blacks = Array.new(n + 1, 0)
whites = Array.new(n + 1, 0)
(0...n).each do |i|
  blacks[i + 1] = blacks[i] + (arr[i] == '#' ? 1 : 0)
  whites[i + 1] = whites[i] + (arr[i] == '.' ? 1 : 0)
end
min = n
(0..n).each do |i|
  min = [whites[n] - whites[i] + blacks[i], min].min
end
puts min

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<pair<int,int>> vp(N);
        for(auto& p : vp) cin >> p.first >> p.second;
        sort(vp.begin(), vp.end(), [](const pair<int,int>& a, const pair<int,int>& b){ return a.first+a.second < b.first+b.second;});
        long long res = 0;
        for(int i=vp.size()-1;i>=0;i--){
            res += vp[i].first;
            i--;
            if(i >= 0) res -= vp[i].second;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    
    ll ans = 0;
    ll an = min(a,k);
    ans += an;
    k -= an;
    ll bn = min(b,k);
    k -= bn;
    ll cn = min(c,k);
    ans -= cn;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main(){
	int N, T, A; std::cin >> N >> T >> A;
	std::vector<double> H(N);
	for (auto& r : H) {
		int t{ 0 }; std::cin >> t;
		r = std::abs(A - (T - (t * 0.006)));
	}
	int ans = std::min_element(H.begin(), H.end()) - H.begin() + 1;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3656
from collections import defaultdict


def main():
    """
    N個の寿司があり、それぞれの寿司には
    「ネタ」ti
    「おいしさ」di
    のパラメータが設定されています。 
    あなたはこの N個の寿司の中から K個を選んで食べようとしています。
    この時のあなたの「満足ポイント」は、以下のようにして計算されます。

    「満足ポイント」は、「おいしさ基礎ポイント」と、「種類ボーナスポイント」の和である。
    「おいしさ基礎ポイント」は、食べた寿司の「おいしさ」の総和である。
    「種類ボーナスポイント」は、食べた寿司の「ネタ」の種類数を xとしたとき、x ∗ x である。

    あなたは、「満足ポイント」をできるだけ大きくしたいです。
    この時の「満足ポイント」の値を求めてください。

    1 ≦ K  ≦ N ≦ 10^5
    1 ≦ ti ≦ N
    1 ≦ di ≦10^9

    nCk の組合せ: 10^5 C 10^5/2 => TLE
    DP ?
        1-Nまで, 食べる食べないによるスコア
        食べたとして種類数xとして種類は別途持っておく？
        →二次元配列は無理っぽそう, 10^5 * 10^5 = 10^10
        MAX時の種類だけ持って、１次元にする
        K までになっているかの判定
        →Nとは別に持たないといけない
    """
    N, K = map(int, input().split())
    td = [
        list(map(int, input().split()))
        for _ in range(N)
    ]
    ans = editorial(N, K, td)
    print(ans)


def editorial(N, K, td):
    td = sorted(td, key=lambda x: -x[1])
    c = defaultdict(int)
    d_sum = 0
    # 種類数が増えないので、不要と判断して良い基礎ポイント
    td_not_first = []
    for t, d in td[:K]:
        if c[t] > 0:
            td_not_first.append(d)
        c[t] += 1
        d_sum += d

    t_sum = len(c)
    ans = d_sum + t_sum ** 2

    for t, d in td[K:]:
        # 更新の余地なし
        if not td_not_first:
            return ans
        # すでに存在するなら、基礎ポイント降順のため不要
        if c[t] > 0:
            continue

        c[t] += 1
        d_sum += -td_not_first.pop() + d
        t_sum += 1
        ans = max(ans, d_sum + t_sum ** 2)

    return ans
    # ans = editorial_WA_TLE(N, K, td)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34096
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> w(N+1, 0), e(N+1,0);
    REP(i,N){
        if(s[i]=='W') w[i]++;
        else e[i]++;
    }
    REP(i, N){
        w[i+1] += w[i];
        e[i+1] += e[i];
    }
    int ans = e[N]-e[0];
    REP(i, N-1){
        chmin(ans, e[N]-e[i+1]+w[i]);
    }
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 5396
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N); rep(i, N) cin >> A[i];

    for (int i = K; i < N; i++) {
        if (A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;
//typedef long long ll;
typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < s.size() - 2; i++) {
        if (s.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fi > xed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, W;
  cin >> n >> W;
  vector<int> v(110), w(110);
  vector<vector<int>> dp(110, vector<int>(100010, 0));

  rep(i, 0, n) cin >> w[i] >> v[i];

  rep(i, 0, n) {
    rep(j, 0, W + 1) {
      if (j >= w[i])
        dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
      else
        dp[i + 1][j] = dp[i][j];
      // cout << dp[i+1][j] << ' ';
    }
    // cout << '\n';
  }
  cout << dp[n][W] << '\n';
  return 0;
}

Measured memory_bytes: 90320
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	fmt.Fprintln(writer, (n-1)>>1)

	writer.Flush()
}


Measured memory_bytes: 640
INF = pow(10, 15)

def main():
  n, m, p = map(int, input().split())
  edges = []
  for _ in range(m):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, p-c))  # 辺の重みの正負反転（最長路→最短路にしたいので）

  dist = [INF for _ in range(n)]
  frome = [-1 for _ in range(n)]
  dist[0] = 0
  for _ in range(n):
    for edge in edges:
      if dist[edge[0]] == INF:
        continue
      if dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        frome[edge[1]] = edge[0]

  for i, edge in enumerate(edges):
    if dist[edge[1]] > dist[edge[0]] + edge[2]:
      edges[i] = (edge[0], edge[1], -INF)

  dist = [INF for _ in range(n)]
  frome = [-1 for _ in range(n)]
  dist[0] = 0
  for _ in range(n):
    for edge in edges:
      if dist[edge[0]] == INF:
        continue
      if dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        frome[edge[1]] = edge[0]

  fromd = {}
  f = n-1
  while frome[f] != -1:
    if f in fromd:
      break
    fromd[f] = frome[f]
    f = frome[f]

  is_loop = False
  for edge in edges:
    if dist[edge[1]] > dist[edge[0]] + edge[2]:
      if edge[0] in fromd:
        is_loop = True
        break

  if is_loop:
    print(-1)
  else:
    if dist[-1] > 0:
      print(0)
    else:
      print(-dist[-1])


if __name__ == '__main__':
  main()


Measured memory_bytes: 49496
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

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


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

vector<int> e;

int calc(int _n){
  int ans = 0;
  for(int i = 0; i < e.size(); i++){
    if(e[i] >= _n-1) ans++;
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  
  e.assign(N+1,0);
  
  for(int i = 2; i <=N; i++){
    int num = i;
    for(int j = 2; j < i+1; j++){
      while(num%j == 0){
        e[j]++;
        num /= j;
      }
    }
  }

  int ans = 0;

  ans += calc(75);
  ans += calc(25) * (calc(3)-1); //-1するのは25の時に選んだのと同じ素因数は選べないから
  ans += calc(15) * (calc(5)-1);
  ans += calc(5) * (calc(5)-1) * (calc(3)-2) /2 ;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<int> w(m);
	for(int i = 0; i < m; i++) {
		cin >> w[i];
	}
	
	int max = *max_element(v.begin(), v.end());
	int min = *min_element(w.begin(), w.end());
	
	for(int i = x + 1; i <= y; i++) {
		if(i > max && i <= min) {
			cout << "No War" << endl;
			return 0;
		}
	}
	
	cout << "War" << endl;
	
    return 0;
}

Measured memory_bytes: 256
import itertools
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    z=list(range(1,n+1))
    a=list(itertools.combinations(z,3))
    b=[]
    for i in a:
        b+=[sum(i)]
    print(b.count(x))

Measured memory_bytes: 34756
def factorization(n):
    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

n = int(input())

dat = factorization(n)
#print(dat)

buf = []

for a,b in dat:
    for j in range(b):
        buf.append(a)
dat.sort(key=lambda x: x[0])

used = dict()
cur = 1
res = 1

for a, b in dat:
    if a == 1:
        continue
    cur = 1
    for i in range(b):
        cur *= a
        if cur not in used:
            used[cur] = True
            res += 1
            cur = 1

print(len(used))





Measured memory_bytes: 63360
#include <stdio.h>
#include <iostream>
#include <stdlib.h>

int main() {
  int    N, K, hn, count = 0;

  std::cin >> N >> K;
  for(int i = 0; i < N; i++) {
    std::cin >> hn;
    if(hn >= K) {
      count++;
    }
  }

  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
long long int l[90];

int main()
{
    int i;
    l[0]=2,l[1]=1;
    for(i=2;i<=86;i++) l[i]=l[i-1]+l[i-2];
    scanf("%d",&i);
    printf("%lld\n",l[i]);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int N, M;

struct edge {
	ll to;
	ll cost;
};

void dfs(vector<vector<edge>>& g, vector<ll>& used, int pos) {
	used[pos] = 1;
	for (int i = 0; i < g[pos].size(); i++) {
		if (!used[g[pos][i].to]) {
			dfs(g, used, g[pos][i].to);
		}
	}
}

int main() {
	cin >> N >> M;
	vector<vector<int>> A(N), B(M);
	vector<vector<edge>> g(N + M);
	for (int i = 0; i < N; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			a--;
			g[i].push_back({ N + a,1 });
			g[N + a].push_back({ i,1 });
		}
	}
	vector<ll> used(N + M);
	dfs(g, used, 0);
	ll flag = 1;
	for (int i = 0; i < N; i++) {
		flag &= used[i];
	}
	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 15856
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    FOR(i, 0, n){
        if(i >= 1 && s[i] == 'L' && s[i-1] == 'R')
            cnt++;
        if(i <= n-2 && s[i] == 'R' && s[i+1] == 'L')
            cnt++;
    }
    if(s[0] == 'L')
        cnt++;
    if(s[n-1] == 'R')
        cnt++;
    

    if(2*k < cnt)
        cout << n - (cnt - 2 * k) << endl;
    else
        cout << n-1 << endl;

    return 0;
}

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

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            string result;
            if (S == T.Substring(0, S.Length))
            {
                result = "Yes";
            }
            else
            {
                result = "No";
            }
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 6) {
    cout << 0 <<endl;
  }
  else if (a > 12) {
    cout << b <<endl;
  }
  else {
    cout << b / 2 <<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(1, n):
    a[i] = a[i] * a[i-1]
    if a[i] > 10**18:
        b += 1
        break
if 0 in a:
    print(0)
elif b == 1:
    print(-1)
else:
    print(a[n-1])

Measured memory_bytes: 21448
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let mut b: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let mut c: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    a.sort();
    b.sort();
    c.sort();

    let mut bc: Vec<usize> = vec![0; n];
    for i in 0..n {
        let bi = b[i];

        let mut ng: isize = -1;
        let mut ok: isize = n as isize;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if c[mid as usize] > bi {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if ok >= 0 && ok < n as isize {
            bc[i] = n - ok as usize;
        }
    }

    let mut bcs: Vec<usize> = vec![0; n];
    bcs[n - 1] = bc[n - 1];
    if n >= 2 {
        for i in (0..=(n - 2)).rev() {
            bcs[i] = bcs[i + 1] + bc[i];
        }
    }

    let mut ans: usize = 0;
    for i in 0..n {
        let ai = a[i];

        let mut ng: isize = -1;
        let mut ok: isize = n as isize;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if b[mid as usize] > ai {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if ok >= 0 && ok < n as isize {
            ans += bcs[ok as usize];
        }
    }
    ans.to_string()
}


Measured memory_bytes: 9004
def abc134c():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(int(input()))
    a_sorted = sorted(a)
    for item in a:
        if item == a_sorted[-1]:
            print(a_sorted[-2])
        else:
            print(a_sorted[-1])
abc134c()

Measured memory_bytes: 91316
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}

int main() {
	long long l, r, d, ans = 0;
	readin(l); readin(r); readin(d);
	if (l % d) {
		long long k = l % d;
		l += d - k;
	}
	if (r < l) {
		puts("0");
		return 0;
	}
	ans = (r - l) / d + 1;
	writeln(ans, '\n');
	return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=500010,Mo=1000000007;
int hs[N],d[N];
char s[N],s1[N],s2[N];
inline int query(int l,int r) {return (hs[r]-1LL*hs[l-1]*d[r-l+1]%Mo+Mo)%Mo;}
int main() {
    scanf("%s",s+1);
    int n=strlen(s+1),t=1,ans=0;
    for(int i=2;i<=n;i++) t&=(s[i]==s[i-1]);
    if(t) return cout<<n<<endl<<1,0;
    for(int i=d[0]=1;i<=n;i++) {
	d[i]=d[i-1]*19260817LL%Mo;
	hs[i]=(hs[i-1]*19260817LL+s[i])%Mo;
    }
    for(int i=1;i+i<=n;i++) {
	for(int j=i;j+i<=n;j+=i) {
	    if(query(1,i)!=query(j+1,j+i)) break;
	    s1[j+i]=1;
	}
	for(int j=n-i;j-i>=0;j-=i) {
	    if(query(n-i+1,n)!=query(j-i+1,j)) break;
	    s2[j-i]=1;
	}
    }
    if(!s1[n]) return cout<<1<<endl<<1,0;
    for(int i=1;i<n;i++)
	if(!s1[i]&&!s2[i]) ++ans;
    cout<<2<<endl<<ans;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    bool flg = true;
    int pre = 0;
    rep(i, N) {
        int h; cin >> h;
        if (pre < h) h--;
        else if (pre > h) flg = false;
        pre = h;
    }
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1000];
int main(){
	cin >>n >> m;
	int tot = 0;
	for(int i = 1, cnt = 1; cnt <= m; i += 2, cnt++){
		a[++tot] = i;
		//	cout << a[tot] << " ";
	}
	for(int i = 2, cnt = 1; cnt <= n; cnt++, i += 2){
		a[++tot] = i;
		//	cout << a[tot] << " ";
	}
	//	cout << endl;
	//for(int i = 1; i <= tot; i++)
	//	cout << a[i] << " ";
	int ans = 0;
	for(int i = 1; i < tot; i++){
		for(int j = i + 1; j <= tot; j++){
			if((a[i] % 2 != 0 && a[j] % 2 != 0) || (a[i] %2 == 0 && a[j] % 2 == 0))
				//		cout << a[i] << " " <<a[j] << endl;
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> ans;
  if (N % 2 == 1)
  {
    rep(i, N - 1)
    {
      for (int j = i + 1; j < N - 1; j++)
      {
        if (j == N - 2 - i)
          continue;
        ans.push_back(make_pair(i + 1, j + 1));
      }
    }
    rep(i, N - 1)
    {
      ans.push_back(make_pair(i + 1, N));
    }
  }
  else
  {
    rep(i, N)
    {
      for (int j = i + 1; j < N; j++)
      {
        if (j == N - 1 - i)
          continue;
        ans.push_back(make_pair(i + 1, j + 1));
      }
    }
  }
  cout << ans.size() << endl;
  rep(i, ans.size())
  {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll w[105],v[105],n,m,ans,sum;

int main() {
	IOS
	cin >> n >> m;
	fori(i,1,n,1) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	vll dp(sum+5,1e18);
	dp[0] = 0;
	fori(i,1,n,1) {
		ford(j,sum,v[i],1) {
			dp[j] = min(dp[j],w[i]+dp[j-v[i]]);
		}
	}
	ford(i,sum,1,1) {
//		testing;debug(i);debug(dp[n][i]);
		if(dp[i] <= m) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll i=2; i*i <= n; i++){
        while(n%i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}


int main(void){
    ll nn,p;
    cin >> nn >> p;

    // pを素因数分解する
    map<ll,ll> p_factor = prime_factor(p);

    // ans
    map<ll,ll>::iterator itr;
    ll ans = 1;
    for(itr=p_factor.begin(); itr!=p_factor.end(); itr++){
        if(itr->second /nn != 0){
            for(int i=1; i<=itr->second /nn; i++){
                ans *= itr->first;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import itertools
s = list(input())
s = list(map(int,s))
op = [['+','-'],['+','-'],['+','-']]
op_comb = list(itertools.product(*op))

for i in range(8):
  ans = s[0]
  tmp = list(op_comb[i])
  for j in range(3):
    if(tmp[j] == '+'):
      ans = ans + s[j+1]
    else:
      ans = ans - s[j+1]
  if(ans == 7):
    break
  
ans_str = str(s[0])+tmp[0]+str(s[1])+tmp[1]+str(s[2])+tmp[2]+str(s[3])
ans_str += '=7'
print(ans_str)

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

int main(){
    int n;
    while(cin >> n,n){
        vector<int> ms, as, bs, abs;
        vector<pair<int, int>> evs; // time, v

        for(int i(0); i < n; ++ i){
            int m, a, b;
            cin >> m >> a >> b;
            ms.push_back(m);
            evs.push_back(make_pair(a, m));
            evs.push_back(make_pair(b, -m)); // b-1?
        }
        sort(begin(evs), end(evs));
        int v = 0;
        for(auto e: evs){
            v += e.second;
            if(v > 150) {
                cout << "NG" << endl;
                goto l;
            }
        }
        cout << "OK" << endl;
    l:;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#define INF 10000
using namespace std;

long long int d[10];
bool used[10];

int main(){
	long long int c[10][10],ans,H,W,i,j;
	cin >> H >> W;
	long long int a[H][W];
	long long int v[10][10];
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			cin >> v[i][j];
		}
	}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cin >> a[i][j];
		}
	}
	fill(used,used+10,false);
	fill(d,d+10,INF);
	//fill(v,v+10,INF);
	int k,n=10;
	for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(v[i][k] != INF && v[k][j] != INF){
          v[i][j] = min(v[i][j],v[i][k] + v[k][j]);
        }
      }
    }
  }
	ans = 0;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
		if(a[i][j]==-1)continue;
			ans+=v[a[i][j]][1];
		}
	}

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


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

typedef long long ll;


ll h,w,a,b;

int main(){
  cin >> h >> w >> a >> b;
  for(ll i = 0;i < h;i++){
    for(ll j = 0;j < w;j++){
      cout << (ll)(((i < b) + (j < a)) % 2);
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    string s;
    cin >> s;

    if(s[0] == 'S') cout << "Cloudy\n";
    else if(s[0] == 'C') cout << "Rainy\n";
    else cout << "Sunny\n";


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	bool ok=true;
	vector<int> inp;
	int a;

	rep(i,6){
		cin >> a;
		inp.push_back(a);
	}
	cout<<(inp[4]-inp[0]<=inp[5]?"Yay!":":(")<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
S = input()
dq = deque()
ans = deque(list(S))
for s in S:
    if not dq:
        dq.append(s)
    else:
        if dq[-1] == "(" and s == ")":
            dq.pop()
        else:
            dq.append(s)
while dq:
    value = dq.popleft()
    if value == ")":
        ans.appendleft("(")
    elif value == "(":
        ans.append(")")
ans = "".join(ans)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,x=0,n=0;
	scanf("%d",&k);
	while(1)
	{
		x=(x*10+7)%k;
		n++;
		if(x%k==0)
		{
			printf("%d\n",n);
			return 0;
		}
		if(n==10000000)
			break;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3824
from collections import namedtuple

Point = namedtuple('Point', ['x', 'y'])

N = int(input())

R = []
for _ in range(N):
    x, y = map(int, input().split())
    R.append(Point(x, y))

B = []
for _ in range(N):
    x, y = map(int, input().split())
    B.append(Point(x, y))

E = [[] for _ in range(N)]
for i, r in enumerate(R):
    for j, b in enumerate(B):
        if r.x < b.x and r.y < b.y:
            E[i].append(j)


class BipartiteMatching:
    def __init__(self, max_u: int, edges):
        self.max_u = max_u
        self.edges = edges  # u->vの隣接行列
        self.__match = None

    def dfs(self, v: int, visited: set) -> bool:
        for u in self.edges[v]:
            if u in visited:
                continue
            visited.add(u)

            if self.__match[u] == -1 or self.dfs(self.__match[u], visited):
                self.__match[u] = v
                return True
        return False

    def execute(self):
        self.__match = [-1 for _ in range(self.max_u)]
        return sum(self.dfs(u, set()) for u in range(self.max_u))


print(BipartiteMatching(N, E).execute())


Measured memory_bytes: 3444
import collections
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
t = 0
for i, v in enumerate(a):
    t += v
    b[i] = t
b.append(0)
b = collections.Counter(b).items()
cnt = 0
for i in b:
    if i[1] >= 2:
        cnt += (i[1] * (i[1] - 1)) // 2
print(cnt)


Measured memory_bytes: 41716
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = false;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

int x;

void solve() {
	cin >> x;
	int cur = 0;
	rep(i, 10000000) {
		cur += i;
		if (x <= cur) {
			cout << i << endl;
			return;
		}
	}
}

signed main() {
	srand(time(NULL));
	int T = (int)1e15;
	solve();
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
lis_str = input().split(" ")
A = int(lis_str[0])
B = int(lis_str[1])
C = int(lis_str[2])
D = int(lis_str[3])

E = 0

while True:
    C = C - B
    if C <= 0:
        print("Yes")
        break
    A = A - D
    if A <= 0:
        print("No")
        break

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

// placing-marbles.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int x;
  cin >> x;

  cout << (x % 10 + (x % 100) / 10 + x / 100) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
  int N, M;
//  int A[1000000001]={};
  int A[10001]={};
//  long int A[1001]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=0;
  int cnt=0;
  int max=0;
//  int ans=0;
  int str_len=0;
//  char alp[26]={'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'};
  int ans[2][26]={};


  scanf("%d", &a);
  
  tmp=(a/100)*111;
   if(tmp>=a)  printf("%d\n", tmp);
   else   printf("%d\n", tmp+111);
  
  
//  printf("%d\n", (max*10)+tmp+min);
   
//   printf("%d\n",a-b+1);
  
return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int segtree[262144];
void add(int a){
	a+=131072;
	while(a){
		segtree[a]++;
		a/=2;
	}
}
int query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return 0;
	if(c<=a&b<=d)return segtree[e];
	return query(a,(a+b)/2,c,d,e*2)+query((a+b)/2+1,b,c,d,e*2+1);
}
int c[100000];
long long fact[100001];
int main(){
	int a,b;
	int MOD=1000000007;
	fact[0]=1;
	for(int i=1;i<=100000;i++){
		fact[i]=(fact[i-1]*i)%MOD;
	}
	while(scanf("%d",&a),a){
		for(int i=0;i<262144;i++)segtree[i]=0;
		scanf("%d",&b);
		for(int i=0;i<a;i++){
			c[i]=i;
		}
		for(int i=0;i<b;i++){
			int p,q;scanf("%d%d",&p,&q);
			p--;q--;
			int d=c[p];
			c[p]=c[q];
			c[q]=d;
		}
		long long ans=0;
		for(int i=0;i<a;i++){
			ans+=(fact[a-i-1]*(c[i]-query(0,131071,0,c[i],1)))%MOD;
			add(c[i]);
		}
		printf("%lld\n",ans%MOD);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll H;
    cin >> H;

    ll two = 1;
    ll depth = 1;
    while(two <= H){
        two *= 2;
        depth++;
    }

    ll ans = two-1;
    cout << ans << endl;

    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	int k;
	cin >> n >> k;
	vector<vector<vector<int>>> dp(n.size()+1, vector<vector<int>>(k, vector<int>(2, 0)));
	for(int i=0; i<(int)n.size(); ++i){
		if(i == 0){
			dp[i][k-1][0] += n[0]-'0'-1;
			dp[i][k-1][1] += 1;
		}else{
			dp[i][k-1][0] += 9;
		}
		if(i == (int)n.size() - 1) continue;
		if(n[i+1] == '0'){
			dp[i+1][0][1] += dp[i][0][1];
			dp[i+1][0][0] += dp[i][0][0];
		}else{
			dp[i+1][0][0] += dp[i][0][0] + dp[i][0][1];
		}
		for(int j=1; j<k; ++j){
			if(n[i+1] == '0'){
				dp[i+1][j][1] += dp[i][j][1];
				dp[i+1][j][0] += dp[i][j][0];
			}else{
				dp[i+1][j][0] += dp[i][j][0] + dp[i][j][1];
			}
			if(n[i+1] != '0'){
				dp[i+1][j-1][1] += dp[i][j][1];
				dp[i+1][j-1][0] += dp[i][j][1] * (n[i+1]-'0'-1);
			}
			dp[i+1][j-1][0] += dp[i][j][0] * 9;
		}
	}
	int ans = dp[n.size()-1][0][0] + dp[n.size()-1][0][1];
	cout << ans << "\n";
//	for(int i=0; i<(int)n.size(); ++i)
//		for(int j=0; j<k; ++j)
//			cout << i << " " << j << " : " << dp[i][j][0] << " " << dp[i][j][1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
    A[i] %= K;
  }

  vector<int> S(N + 1);
  rep(i, N) {
    S[i + 1] = S[i] + A[i];
    S[i + 1] %= K;
  }


  map<ll, ll> m;
  ll ans = 0;
  rep(i, N + 1) {
    ll ii = i;
    ll temp = S[i];
    m[temp]++;

    if (ii - K >= 0)
      m[S[ii - K]]--;

    ans += m[temp] - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
long long int dp[1000000];
long long int dp1[1000000];


int main()
{
    long long int i,j,k,l=0,p,q,r,s,t,u=0,v,w,x,y,z,n,m;
    cin>>n;
    //
    for(i=0;i<=n-1;i++)
    {

        cin>>dp[i];
    }
    dp1[1]=abs(dp[1]-dp[0]);
    for(i=2;i<=n-1;i++)
    {
        dp1[i]=min(dp1[i-1]+abs(dp[i]-dp[i-1]),dp1[i-2]+abs(dp[i]-dp[i-2]));
    }
    cout<<dp1[n-1];





}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	long long s=1;
	for(int i=1;i<=a;i++)
	{
		if(a%i==0 && b%i==0)
		{
			s*=i;
			a=a/i;
			b=b/i;
			i=1;
		} 
	}
	s=s*a*b;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        double a = (double)reader.nextInt();
        double b = (double)reader.nextInt();
        System.out.println((int)Math.ceil((a+b)/2));
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22484