akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
#define MAX 1000

static const int N = 1000;

int lcs(string X, string Y)
{
    int dp[N+1][N+1];
    int m = X.size();
    int n = Y.size();

    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;

    for (int i = 0; i <= m; ++i){
        dp[i][0] = 0;
    }
    for (int j = 0; j <= n; ++j){
        dp[0][j] = 0;
    }

    for (int i = 1; i <= m; ++i){
        for(int j = 1; j <=n; ++j){
            if( X[i] == Y[j] ){
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
            maxl = max(maxl, dp[i][j]);
        }
    }
    return maxl;
}


int main()
{
    int n;
    cin >> n;
    string X, Y;
    vector<int> v;

    rep(i, n)
    {
        cin >> X >> Y;
        v.push_back(lcs(X,Y));
    }

    rep(i, v.size()) cout << v[i] << endl;
    return 0;
}



Measured memory_bytes: 7056
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def solve(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    ans = 0
    for i, v in enumerate(table):
        ans += i * v
    return ans


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

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
   int N,K;

   cin >> N >> K;

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

   sort(h,h+N);
   int Min = h[K-1] - h[0];
   for(int i=0;i<=N-K;i++){
      int tmp = h[i+K-1] - h[i];
      if(tmp < Min)Min = tmp;
   }
   cout << Min << endl;
   return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
	int a, b, h;
	cin >> a >> b >> h;

	cout << ((a + b) * h) / 2 << endl;

	return 0;
}

Measured memory_bytes: 764
N,X = map(int,input().split())
lists = [input() for i in range(N)]
min = int(lists[0])
count = N
for i in range(N):
    X = X - int(lists[i])
    if min > int(lists[i]):
        min = int(lists[i])
count = count + X//min
print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	char str[1000];
	char cstr[1000];
	int j;
	int i;
	
	scanf("%s", str);
	
	for (i = 0; str[i] != '\0'; i++);
	for (j = 0;i > 0; i--){
		cstr[j] = str[i - 1];
		j++;
	}
	cstr[j] = '\0';
	
	printf("%s\n", cstr);
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define GIO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{ GIO;
    ll A[3];
    for(int i=0;i<3;i++)
    {
    	cin>>A[i];
    }
    sort(A,A+3);
    cout<<(abs(A[1]-A[0])+abs(A[2]-A[1]))<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=5*1e5;
const LL INF=1LL<<58;
const LL p=1e9+7;
int c[SIZE];
int nums[SIZE];
int doubler[SIZE];
int main(){
	int N,M,x;
	cin >> N >> M;
	REP(i,N){
		cin >> x;
		nums[x%M]++;
		c[x]++;
		if(c[x]%2==0) doubler[x%M]++;
	}
	int ans=0;
	REP(i,M/2+1){
		if(i==0|| i*2==M){
			ans+=nums[i]/2;
			continue;
		}
		ans+=min(nums[i],nums[M-i]);
		int diff=abs(nums[i]-nums[M-i]);
		int number=(nums[i]>nums[M-i])?i:(M-i);
		ans+=min(diff/2,doubler[number]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n;
  cin >> n;
  map<ll,ll> p;
  for(ll i=2;i*i<=n;++i){
    while(n%i==0){
      p[i]++;
      n /= i;
    }
  }
  if(n>1)p[n]++;
  ll ans = 0;
  for(auto i:p){
    ll e = 1;
    while(e*(e+1)/2<=i.second) ++e;
    ans += e-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  rep(i,n-1){
    if(s[i]=='A' && s[i+1]=='C') s[i+1]='c';
  }
  vector<int> num;
  int cnt=0;
  rep(i,n){
    if(s[i]=='c'){
      cnt++;
    }
    num.push_back(cnt);
  }
      
  rep(i,q){
    int srt, fin;
    cin >> srt >> fin;
    srt--;
    fin--;
    int ans;
    ans = num.at(fin)-num.at(srt);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1528
// B - Traveling AtCoDeer Problem

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int min_a = 1000;
	int max_a = 0;

	int a;
	for (int i=0; i<N; i++) {
		cin >> a;
		min_a = min(min_a, a);
		max_a = max(max_a, a);
	}


	int ans = max_a - min_a;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T>
T gcd(T a, T b)
{
    while (b != 0)
    {
        a = a % b;
        swap(a, b);
    }

    return a;
}

template <typename T>
bool is_prime(T p)
{
    if (p == 1)
    {
        return false;
    }
    T sq_p = (T)sqrt(p);
    repext(i, 2, sq_p + 1)
    {
        if (p % i == 0)
        {
            return false;
        }
    }

    return true;
}

template <typename T>
map<T, int> factorize(T a)
{
    if (is_prime(a))
    {
        map<T, int> tmp;
        tmp.insert(make_pair(a, 1));
        return tmp;
    }

    map<T, int> ret;
    int cnt;
    T num = 2;
    T sup_num = (T)sqrt(a);

    // 2が素因数か
    if (a % num == 0)
    {
        ret[num] = 1;
        a /= num;
        while (true)
        {
            if (a % num == 0)
            {
                ret[num]++;
                a /= num;
            }
            else
            {
                break;
            }
        }
    }

    num++;

    if (a % num == 0)
    {
        ret[num] = 1;
        a /= num;
    }

    // 奇数の素因数探索
    while (a > 1)
    {
        if (a % num == 0)
        {
            ret[num]++;
            a /= num;
        }
        else
        {
            if (num > sup_num)
            {
                ret[a] = 1;
                break;
            }
            num += 2;
            if (a % num == 0)
            {
                ret[num] = 1;
                a /= num;
            }
        }
    }

    return ret;
}

// --- notice ---
// intの和はllにしろ

int main()
{
    ll a, b;
    cin >> a >> b;

    ll g = gcd<ll>(a, b);

    map<ll, int> fact_map = factorize(g);

    cout << fact_map.size() + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    while 1:
        n = int(input())
        if n == 0:break
        line = input().strip().split()
        lstate = 0 # floor = 0 ,upstairs = 1
        rstate = 0
        flag = 0#floor =0???????????°flag = 0
        ans =0
        for l in line:
            if lstate and not flag and l == 'ru':
                ans +=1
                flag = 1
            elif rstate and not flag and l =='lu':
                ans +=1
                flag = 1
            elif not rstate and flag and l == 'ld':
                ans +=1
                flag = 0
            elif not lstate and  flag and l == 'rd':
                ans +=1
                flag = 0

            if l =='lu':lstate=1
            if l =='ru':rstate=1
            if l == 'ld': lstate = 0
            if l == 'rd': rstate = 0
        print(ans)

Measured memory_bytes: 7760
def resolve():
	from statistics import median
	import sys
	input = sys.stdin.readline
	n = int(input())
	ab = [list(map(int, input().split())) for i in range(n)]
	mina = median(i[0] for i in ab)
	maxb = median(i[1] for i in ab)
	abrange = maxb - mina
	if n%2 == 0:
		print(int(abrange/0.5 + 1))
	else:
		print(int(abrange/1 + 1))
resolve()

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

int main(){
  long long int sum = 0;
  int min = 1000000,max = -1000000;
  int n,a;
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> a;
    if(min>a)
      min = a;
    if(max<a)
      max = a;
    
    sum += a;
  }
  cout << min << ' ' << max << ' ' << sum << endl;
}





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

int main()
{
    int n; 
    cin >> n; 
    
    for (int i = 1; i < 10; ++i){
        if (n % i == 0){
            int x = n / i; 
            if (x < 10){
                cout << "Yes" << endl; 
                return 0; 
            }
        }
    }
    cout << "No" << endl; 
    return 0; 
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

----------
-- main --
----------
main :: IO ()
main = someSums

someSums :: IO ()
someSums = do
  [n, a, b] :: [Int]  <- getLineSpc
  let ansList = [s
                | s <- [1..n]
                , let sSum = nSum s
                  in  a <= sSum && sSum <= b
                ]
  print $ sum ansList

nSum :: Int -> Int
nSum 10000 = 1
nSum n = let (n1000, r100)   = n `divMod` 1000
             (n100, r10)     = r100 `divMod` 100
             (n10, n1)       = r10 `divMod` 10
         in n1000 + n100 + n10 + n1

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

int main () {
  int a,b;
  cin >> a >> b;

  cout << max(a + (a-1), max(b + (b-1), a + b)) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*

data class State(val r: Int, val c: Int, val d: Int)

fun main(args: Array<String>) {
  val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
  val board = Array(h, { readLine()!! })

  val visited = Array(h, { BooleanArray(w) })

  val queue = ArrayDeque<State>()

  for (r in 0 until h) {
    for (c in 0 until w) {
      if (board[r][c] == 'S') {
        visited[r][c] = true
        queue.offerLast(State(r, c, 0))
      }
    }
  }

  var firstTurnExit = false
  while (queue.isNotEmpty()) {
    val state = queue.pollFirst()
    val r = state.r
    val c = state.c
    if (r == 0 || r == h - 1 || c == 0 || c == w - 1) {
      firstTurnExit = true
      break
    }

    if (state.d == k) continue

    fun mayVisit(nr: Int, nc: Int) {
      if (visited[nr][nc]) return
      if (board[nr][nc] == '#') return
      visited[nr][nc] = true
      queue.offerLast(State(nr, nc, state.d + 1))
    }

    mayVisit(r - 1, c)
    mayVisit(r + 1, c)
    mayVisit(r, c - 1)
    mayVisit(r, c + 1)
  }

  if (firstTurnExit) {
    println(1)
    return
  }

  var ans = Int.MAX_VALUE
  for (r in 0 until h) {
    for (c in 0 until w) {
      if (visited[r][c]) {
        var minDistance = Int.MAX_VALUE
        minDistance = Math.min(minDistance, r)
        minDistance = Math.min(minDistance, c)
        minDistance = Math.min(minDistance, h - 1 - r)
        minDistance = Math.min(minDistance, w - 1 - c)
        val turn = (minDistance + k - 1) / k + 1
        ans = Math.min(ans, turn)
      }
    }
  }
  println(ans)
}


Measured memory_bytes: 41540
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B;
	cin >> A;
	cin >> B;
	cout << A * B - (A + B - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    vector<string> ss;
    for (auto &&i: irange(0LL, 3LL)){
        string s;
        cin >> s;
        ss.emplace_back(s);
    }
    for (auto &&i: irange(0U, 3U)) {
        char c(toupper(ss.at(i).front()));
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(abs(a-b)<=(v-w)*t){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

int t;
int x[200];

ll getP(int tx, int n)
{
    ll sum = 0;
    for(int i=0;i<n;++i) {
        sum += (x[i]-tx)*(x[i]-tx);
    }
    return sum;
}

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif
    int n;
    cin>>n;
    for(int i=0;i<n;++i) cin>>x[i];
    ll ans = LLONG_MAX;
    for(int tx=1;tx<=100;++tx) {
        ll tt = getP(tx, n);
        if(tt < ans) {
            ans = tt;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//forとか代入しない場合は++iでもi++でも同じ

const int MAX_N =110;
const int MAX_V = 100100;
int N;
ll W,weight[MAX_N],value[MAX_N];

// DP テーブル
ll dp[MAX_N][MAX_V];//maxがほしいのでdp[0]の部分は0で初期化

//Wが大きいときはWじゃなくてVで回してあげる、で重さが最小になるようにすればいい、ここでも全探索の時みたいなループ軸の変更,答えの時はsum_vを使う
int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> weight[i] >> value[i];
    }

    for (int i = 0; i < MAX_N; i++)
    {
        for (int j = 0; j < MAX_V; j++)
        {
            dp[i][j] = LLINF;
        }    
    }

    dp[0][0] = 0;
    

   for (int i = 0; i < N; i++)
   {
      for (int sum_v = 0; sum_v < MAX_V; sum_v++)
      {
          if(sum_v - value[i] >= 0) chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]] + weight[i]);

          chmin(dp[i+1][sum_v],dp[i][sum_v]);
      }
      
   }
   
    ll res = 0;
    for (int sum_v = 0; sum_v < MAX_V; sum_v++)
    {
        //Wを超えないやつで一番価値が高いのを探す
        if(dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res <<endl;
    
    
}




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

using ll = long long;

int main() {
    vector<int> prime;
    vector<bool> is_prime(1e7+1, true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }
    vector<int> quad;
    for(int i=3; i<prime.size(); ++i) {
        if(prime[i] == prime[i-1] + 2 && prime[i] == prime[i-2] + 6 && prime[i] == prime[i-3] + 8) {
            quad.push_back(prime[i]);
        }
    }
    int n;
    while(cin >> n, n) {
        cout << *(upper_bound(quad.begin(), quad.end(), n) - 1) << endl;
    }
}

Measured memory_bytes: 8000
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll m;
	cin>>m;
	ll a[m]={0};
	ll ans=0;	
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	if(n-ans>=0)
		cout<<n-ans<<endl;
	else
	{
		cout<<-1<<endl;
	}


}

Measured memory_bytes: 3708
N = int(input())
S = input()
w = 0
e = 0
for s in S:
  if s == "E":
    e += 1
ans = e
for i in range(1,N):
  if S[i-1] == "W":
    w += 1
    if S[i] == "E":
      ans = min(ans, abs(w+e-1))
      continue
  else:
    e -= 1
    if S[i] == "E":
      ans = min(ans, abs(w+e-1))
      continue
  ans = min(ans, abs(w+e))
print(ans)

Measured memory_bytes: 3828
let rec fix f x = f (fix f) x
let factors n = (* O(sqrt n) *)
  let m,r = ref n,ref [] in
  for i=2 to (2+int_of_float (sqrt @@ float_of_int n)) do
    if !m mod i = 0 then (
      let k = ref 0 in
      while !m mod i = 0 do
        k := !k + 1; m := !m / i;
      done;
      r := (i,!k) :: !r
    )
  done;
  if !m>1 then (!m,1)::!r else !r
let pow n k =
  let rec f a n = function
  | 0 -> a | 1 -> n*a | k when k mod 2 = 0 -> f a (n*n) (k/2) | k -> f (a*n) (n*n) (k/2)
  in f 1 n k
let n,p = Scanf.scanf " %d %d" @@ fun u v -> u,v
let () = print_int (factors p |> List.fold_left (fun u (m,k) ->
  u * (if k>=n then pow m (k/n) else 1)) 1)




Measured memory_bytes: 384
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
*C, = sorted(map(int,input().split()))
print(sum(C[:-1]))
E = [[] for _ in [0]*N]
d = [0]*N
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)

for i in range(N):
    if len(E[i])>1:break
q = [i]
while q:
    i = q.pop()
    d[i] = C.pop()
    for j in E[i]:
        if d[j] != 0:continue
        q.append(j)
print(*d)

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long B,a,b,c=0,k,d=0,i,n,j,temp,ans;
	    char ch;
	    cin>>ch;
	    if(ch=='a' || ch=='o' || ch=='e' || ch=='i' || ch=='u' )
	    cout<<"vowel";
	    else cout<<"consonant";
    }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = parseMap(split(chomp(readline()),""))
	k = 0
	for i in 1:4
		if n[i]==2
			k += 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 109704
#C
n, m = map(int, input().split())
a = [1] * (n + 1)#進めるかどうか
b = [1] * (n + 1)#移動方法
#進めない:0 進める:1
for i in range(m):a[int(input())] = 0
mod = 1e9+7
# print(a)
if a[1] == 0:b[1] = 0
for i in range(2, n+1):b[i] = (b[i - 1] + b[i - 2]) * a[i] % mod
    #b[i]=(b[2段前]+b[1段前])*a[i] 進めるかどうか(1,0)
print(int(b[n]))


Measured memory_bytes: 6900
#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse,sse2")
#define f first
#define s second
#define ri register int
using namespace std;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define MAXN 100000
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	bool win[MAXN + 1];
	int n, k, a[100];
	cin >> n >> k;
	for(ri i = 0; i <= k; ++i)
		win[i] = false;
	for(ri i = 0; i < n; ++i)
		cin >> a[i];
	for(ri i = 0; i <= k; ++i) {
		for(ri j = 0; j < n && a[j] <= i; ++j) {
			if(!win[i - a[j]]) {
				win[i] = true;
				break;
			}
		}
	}
	int winner = 2;
	for(ri i = 0; i < n; ++i) {
		if(!win[k - a[i]]) {
			winner = 1;
			break;
		}
	}
	if(winner == 1) cout << "First\n";
	else cout << "Second\n";
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)
            a[i] = b[i - 1];
        else if (i == 0)
            a[i] = b[i];
        else
        {
            a[i] = min(b[i - 1], b[i]);
        }
    }
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<cmath>
#define int long long int
vector<int> vec;
int stooi(vector<int> &v)
{
	int l=v.size();
	int answer=0;
	int j;
	for(j=0;j<l;j++)
	{
		answer=answer+(v[j])*pow(10,l-1-j);
	}
	return answer;
}
void function(int initial,int final,vector<int> &v)
{
	if(initial>final)
	{
		int y=stooi(v);
		vec.push_back(y);
	}
	else
	{
		int j;
		int p=v[initial-1];
		if(p==0)
		{
			for(j=0;j<=1;j++)
			{
				v.push_back(j);
				function(initial+1,final,v);
				v.pop_back();
			}
		}
		else if(p==9)
		{
			for(j=8;j<=9;j++)
			{
				v.push_back(j);
				function(initial+1,final,v);
				v.pop_back();
			}
		}
		else
		{
			for(j=p-1;j<=p+1;j++)
			{
				v.push_back(j);
				function(initial+1,final,v);
				v.pop_back();
			}
		}
	}
}
int32_t main()
{
   int j;
   for(j=1;j<=10;j++)
   {
      int i;
      for(i=1;i<=9;i++)
      {
		  vector<int> v;
		  v.push_back(i);
		  function(1,j-1,v);
	  }
   }
   sort(vec.begin(),vec.end());
   int k;
   cin>>k;
   cout<<vec[k-1]<<endl;
}


Measured memory_bytes: 2676
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e3, inf = 1e9;

int n, m, odl[nax + 2][nax + 2];
queue< pair< int, int > > Q;
pair< int, int > neg[] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};

pair< int, int > operator+(const pair< int, int >& a, const pair< int, int >& b)
{
    return {a.st + b.st, a.nd + b.nd};
}

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

    cin >> n >> m;

    for (int i = 1; i <= n; ++i)
    {
        string s; cin >> s;
        for (int j = 1; j <= m; ++j)
        {
            if (s[j - 1] == '.')
                odl[i][j] = inf;
            else
                odl[i][j] = 0, Q.push({i, j});
        }
    }

    while (not Q.empty())
    {
        auto p = Q.front(); Q.pop();
        for (const auto& s : neg)
        {
            auto np = p + s;
            if (odl[np.st][np.nd] > odl[p.st][p.nd] + 1)
            {
                odl[np.st][np.nd] = odl[p.st][p.nd] + 1;
                Q.push(np);
            }
        }
    }

    int res = 0;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            res = max(res, odl[i][j]);

    print(res);
}

Measured memory_bytes: 12432
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

int main(void)
{
	int n, temp;
	int Min = 1001;
	int Max = -1;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if (temp < Min)
		{
			Min = temp;
		}
		if (temp > Max)
		{
			Max = temp;
		}
	}

	cout << Max - Min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

  long long n , m ;
	cin>>n>>m;

	long long f ; long long b;
	cin>>f>>b;
	

	for(int i = 1 ; i<m ; i++){
		long long u,p;cin>>u>>p;
		if(u>f){
			f=u;
		}
		if(p<b){
			b=p;
		}
	}

	if(b-f+1>0){
		cout<<b-f+1;
	}
	else{
		cout<<0;
	}
}

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

int b2i(bitset<32> b) {
    lint res = 0;
    for (int i = 0; i < 32; i++) {
        res += b[i] * (1 << i);
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<bitset<32>> a(n);
    for (int i = 0; i < n; i++) {
        int ta;
        cin >> ta;
        a[i] = bitset<32>(ta);
    }
    vector<bitset<32>> ans(n, 0);
    for (int i = 0; i < 32; i++) {
        int count = 0;
        for (int j = 0; j < n; j++) {
            count += a[j][i];
        }
        bool trans = count % 2 != 0;
        for (int j = 0; j < n; j++) {
            ans[j][i] = trans ? 1 - a[j][i] : a[j][i];
        }
    }
    for (int i = 0; i < n; i++) {
        cout << b2i(ans[i]) << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 6372
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt(), finalLimit = in.nextInt();

		int vmax = 100000;
		long dp[] = new long[vmax + 1];
		Arrays.fill(dp, 1, vmax + 1, Integer.MAX_VALUE);
		for ( int i = 1; i <= num; i++ ) {
			int weight = in.nextInt(), value = in.nextInt();

			for ( int v = vmax; v - value >= 0; v-- ) {
				if ( dp[v] > dp[v - value] + weight ) {
					dp[v] = dp[v - value] + weight;
				}
			}
		}
		in.close();

		for ( int v = vmax; 0 <= v; v-- ) {
//			System.out.println(dp[v]);
			if ( dp[v] <= finalLimit ) {
				System.out.println(v);
				return;
			}
		}
		
	}
}

Measured memory_bytes: 24148
//floor(a/b) == (a - a%b)/bで整数除算のみを使って表せる
//->極めて競プロ的な変形なのでおぼえておくと良いらしい

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

int main() {
  ll A, B, N;

  cin >> A >> B >> N;

  ll ans;
  if ((B-1) <= N) {
    ans = floor(A*(B-1)/B) - A * floor((B-1)/B);
  }
  else {
    ans = floor(A * N / B) - A * floor(N/B);
  }

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


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 201000;
int h[4],col[N],n,m,flag;
ll ans;
struct edge{int v,w;};
vector<edge> e[N];
void dfs(int x){
	h[col[x]]++;
	for(auto v:e[x]){
		h[3]++;
		if(!~col[v.v]){
			col[v.v]=(col[x]+v.w)%3;
			dfs(v.v);
		}
		else if(col[v.v]!=(col[x]+v.w)%3) flag=0;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) col[i]=-1;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;
		e[x].push_back({y,1});
		e[y].push_back({x,2});
	}
	for(int i=1;i<=n;i++)
		if(!~col[i]){
			memset(h,0,sizeof(h));
			col[i]=0; flag=1; dfs(i);h[3]/=2;
			if(!flag){
				ans+=1ll*(h[0]+h[1]+h[2])*(h[0]+h[1]+h[2]);
				continue;
			}
			if(!h[0]||!h[1]||!h[2]){
				ans+=h[3];
				continue;
			}
			ans+=1ll*h[0]*h[1];
			ans+=1ll*h[1]*h[2];
			ans+=1ll*h[2]*h[0];
		}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
  string s; cin >> s;
  stack<char> st;

  for(int i=0; i<s.size(); i++){
    if(s[i] == 'S'){
      st.push(s[i]);
    }else{
      if(st.empty() || st.top() == 'T'){
        st.push(s[i]);
      }else{
        st.pop();
      }
    }
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s;
	cin >> s;
	while(s.size() != 15) s += 'o';
	int a=0;
	for(char c: s) if(c=='o') a++;
	if(a>=8) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import heapq

n, k = map(int, input().split())
h = []
d = [0 for _ in range(n)]
ans = 1e9

for _ in range(n):
    # h.append(int(input()))
    heapq.heappush(h, int(input()))

h = [heapq.heappop(h) for _ in range(n)]

for i in range(n - k + 1):
    diff = h[i + k - 1] - h[i]
    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 8372
#include<stdio.h>
int isp[1121];
int prime[500];
int a,b;
int dp[1121][15];
int now;
int main(){
	isp[0]=isp[1]=-1;
	for(int i=2;i<=1120;i++){
		if(isp[i]==0){
			isp[i]=1;
			for(int j=i*2;j<=1120;j+=i)isp[j]=-1;
		}
	}
	for(int i=0;i<1121;i++)if(~isp[i])prime[now++]=i;
	dp[0][0]=1;
	for(int i=0;i<now;i++){
			for(int j=13;j>=0;j--){
		for(int k=0;k<1121;k++){
				if(k+prime[i]<1121)dp[k+prime[i]][j+1]+=dp[k][j];
			}
		}
	}
	while(scanf("%d%d",&a,&b),a+b){
		printf("%d\n",dp[a][b]);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define r_0 return 0;
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
vector<ll>V,B;
set<int>S;
ll n, a, c, l, r,ans,b,m;
string p,s;
int main()
{
    TIME;
    cin>>n;
    for (int i =0; i <n; i ++ )
    {
        cin>>a;
        if (i%2==0 and a%2==1)
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 200000000;

int main(){
    int h,n;
    cin >>h >>n;
    vector<int> a(n),b(n);
    rep(i,n) cin >>a[i] >>b[i];

    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i,h){
        rep(j,n){
            int ni = min(h,i+a[j]);
            dp[ni] = min(dp[ni], dp[i]+b[j]);
        }
    }
    cout << dp[h] << "\n";
    return 0;
}


Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int n,k;
  cout<<fixed;
  cout<<setprecision(10);
  cin>>n>>k;
  double prob=0.0;
  for(int i=1;i<=n;i++){
	   double cnt=1.0/n;
	   int num=i;
	   while(num<k){
		   num<<=1;
		   cnt/=2.0; 
		  }
	prob+=cnt; 
	 }
	cout<<prob<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
mod=10**9+7
N=int(input())
G=[[] for _ in range(N+1)]
for _ in range(N-1):
    x,y=map(int, input().split())
    G[x].append(y)
    G[y].append(x)
b=[1]*(N+1)
w=[1]*(N+1)
def dfs(pre,n):
  for i in G[n]:
    if i==pre:
      continue
    dfs(n,i)
    b[n]*=w[i]
    b[n]%=mod
    w[n]*=b[i]+w[i]
    w[n]%=mod

dfs(0,1)
print((b[1]+w[1])%mod)

Measured memory_bytes: 101272
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] antennas = new int[5];
        for (int i = 0; i < 5; i++) {
            antennas[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        for (int i = 0; i < 5; i++) {
            for (int j = i; j < 5; j++) {
                if (i == j) continue;
                int dist = Math.abs(antennas[i] - antennas[j]);
                if (dist > k) {
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define ll                    long long int

using namespace std;

ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k, cur=1;
    cin>>n>>k;

    ll a[n+1];
    
    for(int i=1;i<=n;++i)
        cin>>a[i];
    
    ll p[n+1]={0};
    for(int i=1;k>0;++i)
    {
        k--;
        cur=a[cur];
        if(!p[cur])
            p[cur]=i;
        else
        {
            
            ll j;
            j=i-p[cur];
            k%=j;
            break;
        }
    }
    k++;
    while(k>1)
    {
        k--;
        cur=a[cur];
        
    }
    cout<<cur;
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define umap           unordered_map
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define ff             first
#define ss             second
#define endl           '\n'

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int xx;
int main()
{
    int tc=1,cs=0;
    //cin>>tc;
    while(cs<tc)
    {
        cs++;
        int a,b,c;
        cin>>a>>b>>c;
        if(a+b+c <22)cout<<"win";
        else cout<<"bust";
    }
    return 0;
}



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

int main(){
 int n=0;
 int k=0;
 int l[50];
 int c;
 int loop;
 int temp;
 cin>>n>>k;
 for(c=0;c<n;c++){
 	cin>>l[c];
 }
 
 for(c=0;c<n-1;c++){
 	for(loop=0;loop<n-1;loop++){
		if(l[loop]<l[loop+1]){
		temp=l[loop+1];
		l[loop+1]=l[loop];
		l[loop]=temp;
		}
	}
 }
 temp=0;
 for(c=0;c<k;c++){
 	temp=temp+l[c];
 }
 cout<<temp;
}

Measured memory_bytes: 256
from collections import defaultdict, deque


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    route = defaultdict(list)
    for ab in AB:
        route[ab[0]].append(ab[1])
        route[ab[1]].append(ab[0])

    ans = [-1] * N
    ans[0] = 0
    que = deque([1])

    # BFSを使って、目印を埋めていく
    while(len(que) != 0):
        v = que.popleft()

        for nv in route[v]:
            if ans[nv-1] != -1:
                continue

            ans[nv-1] = v
            que.append(nv)

    print('Yes')
    for i in range(1, N):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 62236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    ll n;
    cin>>n;
    if(n<=6)cout<<1<<endl;
    else if(n<=11)cout<<2<<endl;
    else {
        ll ans=(n/11)*2;
        if(n%11==0)cout<<ans<<endl;
        else {
            if(n%11<=6)cout<<ans+1<<endl;
            else cout<<ans+2<<endl;
        }
    }
    
    
    
    return 0;
}


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

void solve() {
  int n; ll d; cin >> n >> d;
  vector<pair<ll, ll>> vec(n);
  for (auto &p : vec) cin >> p.first >> p.second;
  d *= d;
  int ans = 0;
  for (auto &p : vec) ans += p.first * p.first + p.second * p.second <= d;
  cout << ans << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	int mn1 = min({Q*4, H*2, S});
	int mn2 = min({Q*8, H*4, S*2, D});
	ll sum = (ll)N/2 * mn2;
	sum +=  (ll)N%2 * mn1;
	cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

using ll = long long;
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;
int main()
{
	fast();
	ll n;
	cin >> n;
	ll m = n - 1;
	map<ll, ll> a, b;
	ll tn = n, tm = m;
	for(ll i = 2; (i*i) <= n; ++i){
		if(tn % i == 0) {
			a[tn / i]++;
			a[i]++;
			//cout <<"a: "<<tn / i <<" " <<  i <<"\n";
		}
		if(tm % i == 0) {
			b[tm / i]++;
			b[i]++;
			//cout <<"b: "<< tm / i << " " << i <<"\n";
		}	
	}
	//o(tn) o(tm)
	if(tn > 1) a[tn]++;
	if(tm > 1) b[tm]++;
	int rs = 0;
	//vector<bool> ck(max((int)sqrt(n) +  5, (int)1e6 + 5), false);
	for(auto i : a){
		ll num = i.first;
		ll temp = n;
		//o(num)
		if(num == 1) continue;
		int cnt = 0;
		while( temp != 1 && temp >= num){
			if(temp % num == 0) temp /= num;
			else {
				if(((temp - 1) % num) == 0) temp = 1;
				else
					temp -= num;
			}	
			cnt++;
			if(cnt >= 100) temp = 0;
		}
		if(temp == 1) {rs ++;}
	}
	for(auto i : b){
		ll num = i.first;
		ll temp = n;
		//o(num)
		if(num == 1) continue;
		int cnt = 0;
		while( temp != 1 && temp >= num){
			if(temp % num == 0) temp /= num;
			else {
				if(((temp - 1) % num) == 0) temp = 1;
				else
					temp -= num;
			}
			//if(temp < 1e6 && ck[temp]) temp = 1;
			cnt++;
			if(cnt >= 100) temp = 0;
		}
		if(temp == 1) {rs ++;}
	}
	cout << rs;
}			

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

int D,N;

int main() {
    cin >> D >> N;
    if(N==100){N++;}
    if(D==0){
        cout << N << endl;
    }else if(D==1){
        cout << N*100 << endl;
    }else{
        cout << N*10000 << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from math import gcd

a, b = map(int, input().split())
g = gcd(a, b)


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


print(len(factorization(g)) + (g != 1))


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

int main(){
    long long H,max=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>H;
        if(H>max){
            max=H;
        }
        if(i!=0&&max-H>=2){
            cout<<"No"<<endl;
            return 0;
        }

    }
    cout<<"Yes"<<endl;

    return 0;
}






Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] s = sc.next().toCharArray();
        for(int i=0;i<s.length;i++){
            s[i] = (char)((s[i]+N-'A')%26+'A');
        }
        System.out.println(new String(s));
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
  int a[5],n,x,m=9;
  for(int i=0;i<5;i++)
  {
    cin>>a[i];
    x=a[i]%10;
    if(x<m && x>0)
    {
      m=x;
      n=i;
    }
  }
  int sum=0,q;
  for(int i=0;i<5;i++)
  {
    if(i==n)
    {
      continue;
    }
    else {
      sum+=a[i];
      q=a[i]%10;
      if(q!=0)
      {
      q=10-q;
      sum+=q;
      }
    }
  }
  sum+=a[n];
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
typedef unsigned long ul;
const ul N=3001;
string s,t,ans;
ul dp[N][N],i,j;
inline void solve(){
  IN2(s,t);
  REP(i,s.size()){
    REP(j,t.size()){
      if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
    }
  }
  i=s.size();j=t.size();
  while(i>0&&j>0){
    if(dp[i][j]==dp[i-1][j])--i;
    else if(dp[i][j]==dp[i][j-1])--j;
    else{
      ans=s[i-1]+ans;
      --i;--j;
    }
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,d;
 cin>>n>>d;
 int cunt=0;
 while(n--)
 {
     double x,y,dis;
     cin>>x>>y;
     dis=sqrt(x*x+y*y);
     if(dis-d<=0)cunt++;
 }
 cout<<cunt<<endl;
 return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
long long a, b, x, s, e;
int main() {
    cin >> a >> b >> x;
    if (a % x == 0) {
        s = a / x;
    }
    else {
        s = a / x + 1;
    }
    e = b / x;
    cout << e - s + 1;
}

Measured memory_bytes: 256
// ABC120K-th Common Divisor

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int A, B, K;
	cin >> A >> B >> K;

	int c = 0;
	for (int i = 100; i >=1; i--) {
		if ((A%i == 0)&&(B % i == 0)) {
			++c;
			if (c == K) {
				cout << i << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256