akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N;
  cin >> N;
  vector<int> A(N+2);
  for (int i = 0; i < N; i++) cin >> A.at(i+1);
  A.at(0) = A.at(N+1) = 0;
  int pSum = 0;
  for (int i = 0; i <= N; i++) pSum += abs(A.at(i+1) - A.at(i));
  for (int i = 1; i <= N; i++) {
    int x = pSum - abs(A.at(i) - A.at(i-1)) - abs(A.at(i+1) - A.at(i))
      + abs(A.at(i+1) - A.at(i-1));
    cout << x << "\n";
  }
  return 0;
}



Measured memory_bytes: 1664
# ACB054C
n, m = map(int, input().split())
L = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)

ans = 0
def f(t, history):
    his = history[:]
    his[t] += 1
    global ans
    if sum(his) == n:
        ans += 1
    else:
        for i in L[t]:
            if his[i] == 0:
                f(i, his)
            
f(0, [0]*n)
print(ans)


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

int main()
{
    int n, a, b,c;
    cin >> n;
    a = (int)n / 100;
    b = (int)(n - a * 100) / 10;
    c = n - 100 * a - 10 * b;
    cout << (a == c ? "Yes" : "No") << "\n";

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[100000], B[100000], C[100000];
    cin >> N;
    REP(i, N) cin >> A[i]; sort(A, A + N);
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i]; sort(C, C + N);

    ll ans = 0;
    REP(i, N) {
        ll a = lower_bound(A, A + N, B[i]) - A;
        ll c = C - upper_bound(C, C + N, B[i]) + N;
        ans += a * c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
def main():
    H = open(0).read().split()[1:]
    ans = 0
    tmp = 0
    for h1, h2 in zip(H[:-1], H[1:]):
        if int(h1) >= int(h2):
            tmp += 1
        else:
            if ans < tmp:
                ans = tmp
            tmp = 0
    if ans < tmp:
        ans = tmp
    print(ans)
    return


main()


Measured memory_bytes: 11660
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

#include <atcoder/scc>
using namespace atcoder;

int main() {
  int n, m; cin >> n >> m;
  scc_graph graph(n);
  while (m--) {
    int a, b; cin >> a >> b;
    graph.add_edge(a, b);
  }
  vector<vector<int>> scc = graph.scc();
  int k = scc.size();
  cout << k << '\n';
  REP(i, k) {
    int l = scc[i].size();
    cout << l << ' ';
    REP(j, l) cout << scc[i][j] << " \n"[j + 1 == l];
  }
  return 0;
}


Measured memory_bytes: 40108
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s[3];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
		reverse(s[i].begin(),s[i].end());
	}

	lli num = 0;

	while (true) {
		lli t = num;
		if (s[t].size() == 0) {
			COUT((char)(t + 'A'));
			return 0;
		}
		num = s[num][s[num].size() - 1] - 'a';
		s[t].pop_back();
	}

	return 0;
}

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

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m;
    map<int,int> d;
    bool ok = true;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        d[a]++;
    }
    cin >> m;
    REP(i,m){
        int t;
        cin >> t;
        if(d[t]>0)d[t]--;
        else ok = false;
    }
    cout << (ok?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
N = int(input()) # 数字を変数に格納

count = 0

if N < 10:
    count = N
else:
    count = 9
    if N < 100:
        count = count
    elif N < 1000:
        count += (N-99)
    else:
        count += 900
        if N < 10000:
            count = count
        elif N < 100000:
            count += (N-9999)
        else:
            count += 90000

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int n, x = 0;
	cin >> n;
	string s;
    cin >> s;
    int max = 0;
    for (int i = 0; i<n; i++){
        if(s[i]=='I'){
            x++;
        } else if (s[i]=='D'){
            x--;
        }
        if (x > max){
            max = x;
        }
    }
    printf("%d\n", max);
}


Measured memory_bytes: 3696
fun main() {
  val (n, a, b) = readLine()!!.split(" ").map{ it.toInt() }
  val s = readLine()!!.toCharArray()
  var ar = 0
  var br = 0
  
  for (i in s) {
    when (i) {
      'a' ->
        if (ar + br < a + b) {
          println("Yes")
          ar++
        } else {
          println("No")
        }
      'b' ->
        if (ar + br < a + b && br < b) {
          println("Yes")
          br++
        } else {
          println("No")
        }
      else ->
        println("No")
    }
  }
}

Measured memory_bytes: 50724
from collections import Counter

n = int(input())
ali = list(map(int,input().split()))

sumli = [0]
sum = 0
acum = 0

for i in ali:
    sum = sum + i
    sumli.append(sum)

sumc = Counter(sumli)

for j in list(sumc):
    acum = acum+(sumc[j]*(sumc[j]-1))//2

print(acum)


Measured memory_bytes: 114632
#include <bits/stdc++.h>
using namespace std;
int h, w;
int sx, sy;
int ct;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void dfs(int x, int y, vector<vector<char> > &v) {
  v[x][y] = '#';
  ++ct;
  for(int i = 0; i < 4; ++i) {
    int nx = dx[i] + x;
    int ny = dy[i] + y;
    if(nx >= 0 && ny >= 0 && ny < h && nx < w && v[nx][ny] == '.') {
      dfs(nx, ny, v);
    }
  }
  return;
}
int main() {
  for(;;) {
    scanf("%d %d", &w, &h);
    if(w == 0 && h == 0) break;
    vector<vector<char> > v(w, vector<char>(h));
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        scanf(" %c", &v[j][i]);
      }
    }

    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        if(v[j][i] == '@') {
          sx = j, sy = i;
          break;
        }
      }
    }
    dfs(sx, sy, v);
    printf("%d\n", ct);
    h = 0, w = 0, sx = 0, sy = 0, ct = 0;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define V vector<int>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define db(x) cout << #x << "=" << (x) << endl
#define db2(x, y) cout << #x << "=" << (x) << " " << #y << "=" << (y) << endl
#define db3(x, y, z) cout << #x << "=" << (x) << " " << #y << "=" << (y) << " " << #z << "=" << (z) << endl

using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double eps = 1e-9;

pii a[maxn];
int main()
{
    #ifdef AFei
    freopen("in.txt", "r", stdin);
    #endif

    int N;
    cin >> N;
    for(int i = 0; i < N; ++ i)
    {
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(a, a+N);
    for(int i = 0; i < N; ++ i)
        printf(i == N-1 ? "%d\n" : "%d ", a[i].second);

    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public  class Main  {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char q[] = S.toCharArray();
		boolean flag = false; //ACGTの時はtrue
		int max = 0;
		int maxkouho = 0;
		for(int i =0; i<S.length(); i++) {
			if(q[i]=='A'||q[i]=='C'||q[i]=='G'||q[i]=='T') {
				flag = true;
				maxkouho++;
				continue;
			}
			if(flag&&q[i]!='A'&&q[i]!='C'&&q[i]!='G'&&q[i]!='T') {
				if(maxkouho>max)max = maxkouho;
				flag=false;
				maxkouho = 0;
			}
		}
		if(maxkouho>max) max = maxkouho;
		System.out.println(max);
		
		
	}
}



Measured memory_bytes: 23252
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        k:usize1,
        a:[usize;n],
    }
    let mut out = String::with_capacity((n - k) * 2);
    for i in (k + 1)..n {
        out.push_str(&format!(
            "{}\n",
            if a[i] > a[i - k - 1] { "Yes" } else { "No" }
        ));
    }
    out
}
test! {
    include_str!("c1_in.txt") =>include_str!("c1_out.txt"),
    include_str!("c2_in.txt") =>include_str!("c2_out.txt"),
    include_str!("c3_in.txt") =>include_str!("c3_out.txt"),
}


Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct qwq{
    int id;
    int have;
}a[100005];
int n;

inline bool cmp(qwq x,qwq y){
    return x.have<y.have;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        a[i].id=i;
        scanf("%d",&a[i].have);
    }
    stable_sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++){
        printf("%d ",a[i].id);
    }
    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')
		cout<<"Yes\n";
	else cout<<"No\n";

}


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

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

using namespace std;

int inf = 1000;

int main(void){
  int N,M;
  cin >> N >> M;

  vector<vector<int>> dist(100,vector<int>(100,inf));
	vector<int> a(1000), b(1000), c(1000);

  rep(i, M) {
	  cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
  }
	rep(i, N) {
		dist[i][i] = 0;
	}

	rep(k, N) rep(i, N) rep(j, N) {
	  if (dist[i][j] > dist[i][k] + dist[k][j]) dist[i][j] = dist[i][k] + dist[k][j];
	}

	int ans = M;

	rep(i, M) {
	  bool shortest = false;
		rep(j,N) if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
		if (shortest) ans--;
	}

	cout << ans << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s,t; cin >> s >> t;
  int a,b; cin>> a >> b;
  string u; cin >> u;
  if(s == u)a--;
  else b--;
  cout << a << ' ' << b << endl;
  return 0;
}


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

using namespace std;

int main() {
    int D;
    cin >> D;
    if(D == 25) puts("Christmas");
    else if(D == 24) puts("Christmas Eve");
    else if(D == 23) puts("Christmas Eve Eve");
    else if(D == 22) puts("Christmas Eve Eve Eve");
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Z = sc.nextInt();
        int W = sc.nextInt();
        int[] A = new int[N+1];
        for(int i=1;i<=N;i++){
            A[i] = sc.nextInt();
        }
        int ans;
        if(N==1){
            ans = Math.abs(A[1]-W);
        }
        else ans = Math.max(Math.abs(A[N]-A[N-1]),Math.abs(A[N]-W));
        System.out.println(ans);
    }
}


Measured memory_bytes: 25448
N = int(input())

def memorize(f) :
    cache = {}
    def helper(*args) :
        if args not in cache :
            cache[args] = f(*args)
        return cache[args]
    return helper

@memorize
def fibonacci(n):
    if n == 0 or n == 1:
        return 1
    res = fibonacci(n - 2) + fibonacci(n - 1)
    return res

print(fibonacci(N))


Measured memory_bytes: 5608
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=5005;
const long long mod=1000*1000*1000+7;
vector<int> v[nmax];
int dp[nmax][nmax][2],newdp[nmax][2];
int pr[nmax];
long long ans;
int w[nmax],tt[nmax];
int n,i,a,b;
void dfs(int x)
{
    w[x]=1;
    for(int i=0;i<v[x].size();i++)
        if(!w[v[x][i]])
    {
        tt[v[x][i]]=x;
        dfs(v[x][i]);
    }
    dp[x][1][0]=1;
    int nod;
    for(int i=0;i<v[x].size();i++)
        if(v[x][i]!=tt[x])
    {
        nod=v[x][i];
        for(int j=0;j<=w[x];j++)
            for(int k=0;k<=w[nod];k++)
                for(int p1=0;p1<2;p1++)
                  for(int p2=0;p2<2;p2++)
            {
                newdp[j+k][(p1^p2)]=(1LL*newdp[j+k][(p1^p2)]+1LL*dp[x][j][p1]*dp[nod][k][p2])%mod;
                newdp[j][(p1^p2^1)]=(1LL*newdp[j][(p1^p2^1)]+1LL*dp[x][j][p1]*((1LL*dp[nod][k][p2]*pr[k])%mod))%mod;
            }
        w[x]+=w[nod];
        for(int j=0;j<=w[x];j++)
            for(int p=0;p<2;p++)
        {
            dp[x][j][p]=newdp[j][p];
            newdp[j][p]=0;
        }
    }
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    pr[0]=1;
    for(i=2;i<=n;i++)
        pr[i]=(1LL*pr[i-2]*(i-1))%mod;
    for(i=1;i<=n-1;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1);
    for(i=1;i<=n;i++)
    {
        ans=(1LL*ans-1LL*dp[1][i][1]*pr[i])%mod;
        ans=(ans+mod)%mod;
        ans=(1LL*ans+1LL*dp[1][i][0]*pr[i])%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 195328
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
input=sys.stdin.readline
class FenwickTree():
    def __init__(self,n):
        self.n = n
        self.tree = [0]*(n+1)
    def add(self,idx,a):#値の更新
        idx+=1
        while idx<=self.n:
            self.tree[idx] +=a
            idx += idx &-idx

    def _sum(self,r):
        ret=0
        r+=1
        while r>0:
            ret+=self.tree[r]
            r-=r&-r
        return ret
    def sum(self,l,r):
        return self._sum(r)-self._sum(l-1)

n,q = ma()
A = lma()
ft = FenwickTree(n)
for i in range(n):
    ft.add(i,A[i])
for i in range(q):
    t,u,v = ma()
    if t==0:
        ft.add(u,v)
    else:
        print(ft.sum(u,v-1))


Measured memory_bytes: 128172
#include <stdio.h>
int main() {

    char n, m, l, k,t,H,D;
    scanf(" %c %c",&n,&m);
    if(n=='H'&&m=='H'){
        printf("H\n");
    }
    else if(n=='D'&&m=='D'){
        printf("H\n");
    } else if(n=='D'&&m=='H'){
        printf("D\n");
    }else if(n=='H'&&m=='D'){
        printf("D\n");
    }
    return 0;
}

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

using namespace std;

int main() {
  string s;
  int K;

  cin >> s;
  cin >> K;

  vector<string> substrs;
  for (int i = 0; i < s.size(); ++i) {
    for (int j = 1; j <= K; ++j) {
      substrs.push_back(s.substr(i, j));
    }
  }
  sort(substrs.begin(), substrs.end());
  substrs.erase(unique(substrs.begin(), substrs.end()), substrs.end());

  cout << substrs[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
string A,B;
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	if(A[0]!=B[2]) return _P("NO\n");
	if(A[1]!=B[1]) return _P("NO\n");
	if(A[2]!=B[0]) return _P("NO\n");
	_P("YES\n");
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int a[100],b[100],c[100];
int count = 0;
int i;
int n;
int main(void)
{
	scanf("%d",&n);
	for(i = 1;i<=n;i++) scanf("%d",a+i);
	for(i = 1;i<=n;i++) scanf("%d",b+i);
	for(i = 1;i<n;i++) scanf("%d",c+i);
	
	for(i = 1;i<=n;i++)
	{
		count += b[a[i]];
		if(a[i] == a[i+1] -1 ) count += c[a[i]];
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()
using ll = long long;
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, k; scanf("%lld %lld", &n, &k);
    vector<ll> pp, mm;
    ll zero = 0;
    rep(i,n) {
        ll a; scanf("%lld", &a);
        if (a > 0) pp.pb(a);
        else if (a < 0) mm.pb(-a);
        else zero++;
    }
    sort(all(pp)); ll p = (ll)pp.size();
    sort(all(mm)); ll m = (ll)mm.size();
 
    if (p * m >= k) {
        ll left = 1, right = 1ll<<60;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll count = 0; // mid以下になる個数
            ll id = m;
            rep(i,p) {
                while (id > 0 && pp[i] * mm[id - 1] >= mid) id--;
                count += m - id; 
            }
            if (count >= k) left = mid;
            else right = mid;
        }
        cout << -left << endl;
        return 0;
    }
    else if (p * m + (p + m) * zero + zero * (zero - 1) / 2 >= k) {
        cout << 0 << endl;
        return 0;
    }
    else {
        k -= p * m + (p + m) * zero + zero * (zero - 1) / 2;
        ll left = 1, right = 1ll<<60;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll count = 0; // mid以下になる個数
            ll id = p;
            rep(i,p) {
                while (id > 0 && pp[i] * pp[id - 1] > mid) id--;
                count += id;
                if (pp[i] * pp[i] <= mid) count--;
            }
            id = m;
            rep(i,m) {
                while (id > 0 && mm[i] * mm[id - 1] > mid) id--;
                count += id;
                if (mm[i] * mm[i] <= mid) count--;
            }
            if (count < 2 * k) left = mid; 
            else right = mid;
        }
        cout << right << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 5268
n , a = map(int, input().split())
x = list(map(int,input().split()))

x=[i-a for i in x]
dp=[[0]*n*50*2 for i in range(n+1)]

dp[0][n*50]=1

for i in range(n):
    for j in range(n*50*2):
        t=j-x[i]
        if 0<=t<n*50*2:
            dp[i+1][j]=dp[i][j]+dp[i][t]
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][n*50]-1)


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n,k,h[200005];
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	sort(h,h+n);
	for(int i=0;i<n-k;i++){
		ans+=h[i];
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int x[5]; 
  rep(i,5) {
    cin >> x[i];
    if (x[i]==0) cout << i+1 << endl;
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3560
n = int(raw_input())
rate = map(int, raw_input().split())
num = [0]*9

cunt = 0
for item in rate:
    if item < 3200:
        if item < 400:
            num[0] = 1
        elif item < 800:
            num[1] = 1
        elif item < 1200:
            num[2] = 1
        elif item < 1600:
            num[3] = 1
        elif item < 2000:
            num[4] = 1
        elif item < 2400:
            num[5] = 1
        elif item < 2800:
            num[6] = 1
        elif item < 3200:
            num[7] = 1
    else:
        num[8] += 1
if sum(num[:-1]) == 0:
    print 1, sum(num)
else:
    print sum(num[:-1]), sum(num)


Measured memory_bytes: 2692
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int K = scan.nextInt();
		int N = scan.nextInt();
		int[] A = new int[N];

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

		int maxDif = A[0] + K - A[N-1];

		for (int i = 0; i < N - 1; i++) {
			if (A[i+1] - A[i] > maxDif) {
				maxDif = A[i+1] - A[i];
			}
		}

		int length = K-maxDif;

		System.out.println(length);
	}
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n;
      string s;
      cin>>s;
      for(i=0;i<n;i++)
      {
          if(s[i]=='W')
          count++;
          else
          {
             sum++;
          }
      }
      string s2;
      s2=s;
      for(i=0;i<n;i++)
      {
          if(i<sum)
          s2[i]='R';
          else
          s2[i]='W';
          if(s[i]!=s2[i])
          ans++;
      }
      
      ans=ans/2;
      cout<<ans;
      
	return 0;
}

Measured memory_bytes: 3872
//
// ABC055A
// URL : https://atcoder.jp/contests/abc055/tasks/abc055_a
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC055A
    {
        static void Main(string[] args)
        {
            preprocess();
            long n = long.Parse(Console.ReadLine());

            long x = 800 * n;
            long y = n / 15 * 200;
                
            var ans = x - y;

            Console.WriteLine(ans.ToString());
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
int32_t main()
{	
	Fast_IO
	#ifdef __WIN32 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w",stdout);
	#endif
	int n;cin>>n;
	int maxcap;cin>>maxcap;
	vector<int> weights(n);
	vector<int> values(n);
	int sumv=0;
	for(int i=0;i<n;i++){
		cin>>weights[i]>>values[i];
		sumv+=values[i];
	}
	//dp[i] - min weight for exactly i value
	vector<int> dp(sumv+1,1e17+5);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=sumv-values[i];j>=0;j--){
			dp[j+values[i]]=min(dp[j+values[i]],dp[j]+weights[i]);
		}
	}	
	int ans=0;
	for(int i=0;i<=sumv;i++){
		if(dp[i]<=maxcap)
			ans=max(ans,i);
	}
	cout<<ans;


}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        //Input 
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = 0; i < a.length - 1; i++) {

            for (int j = a.length - 1; j > i; j--) {

                // 上の方が大きいときは互いに入れ替えます
                if (a[j] < a[j - 1]) {
                    int t = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = t;
                }
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.print(a[i]);
            if (i < a.length - 1)
                System.out.print(" ");
        }
System.out.println("");
    }
}



Measured memory_bytes: 26336
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-10;

int main(){
  string str;
  cin >> str;
  if (str.size() == 3) {
    reverse(ALL(str));
    cout << str << endl;
  } else {
    cout << str << endl;
  }
}

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

ll dp[1010][10100];

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

	int H, N; cin >> H >> N;
	vector<P> A(N);
	int a, b;
	rep(i, N) {
		cin >> a >> b;
		A[i] = P(a, b);
	}

	// dp[見て行った魔法][総ダメージ]

	// vector<vector<ll>> dp(N+10, vector<ll>(H+10, INT_MAX));
	rep(i, 1010) rep(j, 10100) dp[i][j] = INT_MAX;
	dp[0][0] = 0;
	rep(i, N) rep(j, 10100) {
		int hp = A[i].first;
		int mp = A[i].second;
		dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
		ll x = min(dp[i+1][j], dp[i][j]);
		if (j-hp>=0) {
			ll y =  min(dp[i+1][j], min(dp[i][j-hp]+mp, dp[i+1][j-hp]+mp));
			dp[i+1][j] = min(dp[i+1][j], min(dp[i][j-hp]+mp, dp[i+1][j-hp]+mp));
		}
	}

	ll ans = LLONG_MAX;
	FOR(i, H, 10100) {
		ans = min(ans, dp[N][i]);
	}
	cout << ans << endl;
}

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

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

    int Q; cin >> Q;
    while (Q--) {
        char ans = 'P';
        int p, q; cin >> p >> q;
        int s = p * p + q * q;
        for (int i = 2; i <= s; ++i) {
            if (s % i) continue;
            for (int m = 0; m * m <= i; ++m) {
                for (int n = 0; n * n <= i; ++n) {
                    if (m * m + n * n != i) continue;
                    for (int M : {-m, m}) {
                        for (int N : {-n, n}) {
                            if (M == p and N == q) continue;
                            if (M == -q and N == p) continue;
                            if (M == -p and N == -q) continue;
                            if (M == q and N == -p) continue;
                            bool valid = 1;
                            if ((M * p + N * q) % i) valid = 0;
                            if ((M * q - N * p) % i) valid = 0;
                            if (valid) {
                                ans = 'C';
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;

}



Measured memory_bytes: 3160
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = n - 1
    val adj = Array(n) { mutableSetOf<Int>() }
    for (i in 0 until m) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        adj[u].add(v)
        adj[v].add(u)
    }
    val dist_black = Array(n) { Int.MAX_VALUE }
    val dist_white = Array(n) { Int.MAX_VALUE }
    val que: Queue<Pair<Int, Int>> = ArrayDeque()
    var visited = BitSet(n)
    visited[0] = true
    que.add(0 to 0)
    while (que.count() > 0) {
        val (v, d) = que.poll()
        dist_black[v] = d
        for (w in adj[v]) {
            if (!visited[w] && w != n - 1) {
                que.add(w to d + 1)
                visited[w] = true
            }
        }
    }
    visited = BitSet(n)
    visited[n - 1] = true
    que.add(n - 1 to 0)
    while (que.count() > 0) {
        val (v, d) = que.poll()
        dist_white[v] = d
        for (w in adj[v]) {
            if (!visited[w] && w != 0) {
                que.add(w to d + 1)
                visited[w] = true
            }
        }
    }
    var b = 0
    var w = 0
    for (i in 0 until n) {
        if (dist_black[i] <= dist_white[i]) {
            b++
        } else {
            w++
        }
    }
    println(if (b > w) "Fennec" else "Snuke")
}

fun compress(a: Array<Int>): Array<Int> {
    val n = a.count()
    val b = a.sorted().distinct().toTypedArray()
    val c = Array(n) { 0 }
    for (i in 0 until n) {
        c[i] = Arrays.binarySearch(b, a[i])
    }
    return c
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 99644
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

const int MAXN=1e5+5;

int n,ncnt,tot,ans;
int a[MAXN],b[MAXN];
int in[MAXN],out[MAXN];
bool tag[MAXN];
map<int,int> vis;
vector<int> E[MAXN];

void dfs(int u){
    tag[u]=1;
    for(int i=0;i<(int)E[u].size();i++){
        int v=E[u][i];
        if(tag[v]) continue;
        dfs(v);
    }
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        tot^=a[i];
        if(vis.find(a[i])==vis.end()) vis[a[i]]=++ncnt;
        a[i]=vis[a[i]];
    }
    if(vis.find(tot)==vis.end()) vis[tot]=++ncnt;
    tot=vis[tot];
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        if(vis.find(b[i])==vis.end()) vis[b[i]]=++ncnt;
        b[i]=vis[b[i]];
    }
    for(int i=1;i<=n;i++){
        if(a[i]==b[i]) continue;
        ans++;
        E[b[i]].push_back(a[i]);
        in[a[i]]++,out[b[i]]++;
    }
    bool flag=0;
    for(int i=1;i<=ncnt;i++){
        if(in[i]==out[i]) continue;
        if(in[i]<out[i]){
            if(in[i]!=out[i]-1||i!=tot)
                return puts("-1"),0;
        }
        else{
            if(in[i]!=out[i]+1||flag) return puts("-1"),0;
            flag=1;
        }
    }
    dfs(tot);
    for(int i=1;i<=ncnt;i++){
        if(tag[i]||!out[i]) continue;
        ans++;
        dfs(i);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 16768
n = int(input())
s = input()
list_s = []
for i in range(n):
    list_s.append(s[i])

for i in range(n):
    try:
        while list_s[i] == list_s[i+1]:
            if list_s[i] == list_s[i+1]:
                list_s.pop(i+1)
    except IndexError:
        continue
print(len(list_s))

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;i++){
		if(i%d==0) ans++;
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3516
process.stdin.resume();
process.stdin.setEncoding('utf8');

const lines = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line)
});
reader.on('close', () => {
  const inputLength = Number(lines[0])
  const inputString = lines[1]
  const inputArray = inputString.split('')
  const rArray = inputArray.filter(element => element === 'R')
  const gArray = inputArray.filter(element => element === 'G')
  const bArray = inputArray.filter(element => element === 'B')

  let sum = 0
  for (let i = 1; i < Number(inputLength) + 1; i++) {
    for (let j = i + 1; j < Number(inputLength) + 1; j++) {
      const k = j + j - i 

      if(k <= inputLength && inputArray[i - 1] !== inputArray[j - 1]  && inputArray[j - 1] !== inputArray[k - 1] && inputArray[i - 1] !== inputArray[k - 1]){
        sum = sum + 1
      }
    }
  }

  console.log(rArray.length * gArray.length * bArray.length - sum)

});

Measured memory_bytes: 33580
x = int(input())


def prime(n):
    flag = ''
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        flag = 'prime_number'

    return(flag)


if x == 2:
    print(2)
else:
    i = x + int(x % 2 == 0)

    while(True):
        if prime(i) == 'prime_number':
            break

        i += 1

    print(i)

Measured memory_bytes: 3188
n = int(input())
s = input()

west = []
east = []
w = 0
e = 0
for i in range(n):
    if s[i] == "W":
        w += 1
    else:
        e += 1
    west.append(w)
    east.append(e)


ans = float('inf')
for i in range(n):
    count = 0
    if i == 0:
        count = east[n-1] - east[0]
    elif i == n-1:
        count = west[n-2]
    else:
        count = west[i-1] + (east[n-1] - east[i])
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 17800
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (sc.hasNext()) {
			String s = sc.nextLine();
			
			for (int i=0; i<26; i++) {
				StringBuilder sb = new StringBuilder();
				char c;
				
				for (int j=0; j<s.length(); j++) {
					c = s.charAt(j);
					if ('a'<=c && c<='z') {
						c -= i;
						if (c < 97) {c += 26;}
					}
					sb.append(c);
				}
				
				if (sb.toString().matches(".*(the|this|that).*")) {out.println(sb); break;}
			}
		}
		
	}
}


Measured memory_bytes: 27180
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
int rig[30][111111];
int n, q, l, u, v;
int x[111111];

int main(void)
{
	cin>>n;
	int i, j;
	for(i=0 ; i<n ; i++)
	{
		scanf("%d",&x[i]);
	}
	cin>>l>>q;
	for(i=0 ; i<n ; i++)
	{
		rig[0][i]=upper_bound(x+i,x+n,x[i]+l)-x-1;
	}
	for(i=1;  i<=29 ; i++)
	{
		for(j=0 ; j<n ; j++)
		{
			rig[i][j]=rig[i-1][rig[i-1][j]];
		}
	}
	while(q--)
	{
		scanf("%d %d",&u,&v);
		u--; v--;
		if(u>v)
		{
			int temp=v;
			v=u;
			u=temp;
		}
		int ans=1e9;
		int cur=0;
		for(i=29 ; i>=0 ; i--)
		{
			if(rig[i][u]>=v)
			{
				ans=min(ans,cur+(1<<i));
			}
			else
			{
				cur+=(1<<i);
				u=rig[i][u];
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int h,w,i=0,j=0,k=0,m,n,p,e,f,sum=0,cnt=0;
	cin>>h>>w>>k;
	int arr[h][w],chk[h][w];
	for(i=0;i<h;i++)
	for(j=0;j<w;j++)
	{
	    char x;
	    cin>>x;
	    if(x=='.')
	    arr[i][j]=0;
	    else arr[i][j]=1;
	}
	for(e=0;e<(int)(pow(2,h));e++)
	{
	    for(p=0;p<(int)(pow(2,w));p++)
        {
            for(i=0;i<h;i++)
	        for(j=0;j<w;j++)
	        {
	         chk[i][j]=arr[i][j];
	        }
	        vi tab;
	        for(i=0;i<=h;i++)
	        {
	            if(((1<<i)&e)!=0)
	            tab.pb(i);
	        }
	        for(m=0;m<tab.size();m++)
	        {
	            for(j=0;j<w;j++)
	            chk[tab[m]][j]=2;
	        }
	        int y=0;
	        
	        tab.clear();
	        for(i=0;i<=w;i++)
	        {
	            if(((1<<i)&p)!=0)
	            tab.pb(i);
	        }
	        for(m=0;m<tab.size();m++)
	        {
	            for(j=0;j<h;j++)
	            chk[j][tab[m]]=2;
	        }
	        //int y=0;
	        for(i=0;i<h;i++)
	        for(j=0;j<w;j++)
	        {
	         if(chk[i][j]==1)
	         y++;
	        }
	        if(y==k)
	        cnt++;
	        
        }
	}
	cout<<cnt;
    
	
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vec vector <int>
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define repD(i,a,b) for (ll i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maa 1000000007
#define Eps 1e-9
#define PI 3.14159265359

typedef tree<pii,null_type,less <pii >,rb_tree_tag,tree_order_statistics_node_update>ind_set;
typedef gp_hash_table<int, int, hash<int> > ht1;   /// if clear is required
typedef cc_hash_table<int, int, hash<int> > ht2;

///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int n,v[102],w[102];
int DP[102][100005];
int cap;


void solve()
{
    cin>>n>>cap;
    rep(i,0,n)cin>>w[i]>>v[i];

    rep(i,0,n)rep(j,0,100005)DP[i][j]=maa;

    DP[0][0]=0;DP[0][v[0]]=w[0];
    rep(i,0,n)
    {
        DP[i][0]=0;
        rep(j,0,100005)
        {
            if (j>=v[i])
            {
               if (i>0) DP[i][j]=min(DP[i-1][j],DP[i-1][j-v[i]]+w[i]);
            }
            if (i>0)DP[i][j]=min(DP[i][j],DP[i-1][j]);
        }
    }
    //rep(j,0,10){cout<<"\n";rep(i,0,10)cout<<DP[j][i]<<" ";}
    repD(i,100004,-1)
    {
        if (DP[n-1][i]<=cap)
        {
            cout<<i;return;
        }
    }

}
signed main()
{

    srand(time(NULL));

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);

    int t=1;
///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case "<<a+1<<": ";
        solve();
    }
}


Measured memory_bytes: 78336
#include <stdio.h>
int main (void){
int i,a,b,c,d=0 ;

scanf("%d",&a) ;

scanf("%d",&b) ;

scanf("%d",&c) ;
for( i=a;i<=b;i++){
	if(c%i==0){
		d++;
	}}
printf("%d\n",d) ;
return 0 ;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
	while(1){
		//入力
		int n, m; 
		scanf("%d %d", &n, &m);
		if(n==0 && m==0) break;

		int a[1001];
		for(int i=0; i<n; i++){
			scanf("%d", &a[i]);
		}

		//処理
		//全ての組み合わせを総当たりでチェックする。
		int ans = -1;
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int sum = a[i] + a[j]; //sumは、i番目の商品の金額と、j番目の商品の金額の和
				if(ans < sum && sum <= m) ans = sum;
			}
		}

		//出力 (改行を忘れないように)
		if(ans == -1){
			printf("NONE\n"); //ansの値が一度も更新されていないので、答えは見つからなかった。 
		} else{
			printf("%d\n", ans);
		}
	}
	return 0;
}


Measured memory_bytes: 2108
import numpy as np

N, K = [int(v) for v in input().split()]
p = 0

limit = N
if N - K + 1 > 0:
    p = (N - K + 1) / N
    limit = K-1


for i in range(1, limit+1):
    f = np.ceil(np.log2(K/i))
    p += (1/N) * np.power(1 / 2, f)
print(p)


Measured memory_bytes: 12384