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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

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

ul binpow(ul n, ul x, ul mod)
{
  ul tgt = 1;
  ul dig = n;
  while (x > 0) {
    if (x%2) {
      tgt = (tgt * dig) % mod;
    }
    dig = (dig * dig) % mod;
    x /= 2;
  }
  return tgt;
}

class Comb
{
public:
  ul mod;
  vector< ul > fact;
  vector< ul > factf;
  void init(ul size, ul imod) {
    mod = imod;
    fact.resize(size+1);
    factf.resize(size+1);
    fact[0] = 1;
    factf[0] = 1;
    for (ul i = 1; i <= size; ++i) {
      fact[i] = fact[i-1]*i%mod;
      factf[i] = binpow(fact[i], mod-2, mod);
    }
  }
  ul comb(ul n, ul k) {
    if (n<k) return 0;
    if (k==0 || n==k) return 1;
    return ((fact[n] * factf[k]) % mod * factf[n-k]) % mod;
  }
};

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, a, b, c;
  cin >> n >> a >> b >> c;

  ul over = 1000000007;

  Comb comb;
  comb.init(n*3, over);

  vector< ul > ai(n*2+1), bi(n*2+1), ci(n*2+1), si(n*2+1), hi(n*2+1);
  ai[0] = 1; bi[0] = 1; ci[0] = 1; si[0] = 1; hi[0] = 1;
  for (int i=1; i<=n*2; ++i) {
    ai[i] = (ai[i-1] * a)       % over;
    bi[i] = (bi[i-1] * b)       % over;
    ci[i] = (ci[i-1] * (100-c)) % over;
    si[i] = (si[i-1] * (a+b))   % over;
    hi[i] = (hi[i-1] * 100)     % over;
  }

  ul ans_p = 0, ans_q = 1;
  for (int i=0; i<n; ++i) {
    ul ans_ap = comb.comb(n+i-1, n-1)%over*(ai[n]*bi[i]%over + ai[i]*bi[n]%over)%over*(n+i)%over*hi[1]%over;
    ul ans_aq = si[n+i]%over * ci[1]%over;
    ul tmp_p = ans_p * ans_aq + ans_q * ans_ap;
    ul tmp_q = ans_q * ans_aq;
    ans_p = tmp_p%over;
    ans_q = tmp_q%over;
  }
  /*
  cout << ans_p << " / " << ans_q << endl;

  ul pq = gcd(ans_p, ans_q);
  cout << pq << endl;
  ans_p /= pq; ans_q /= pq;
  */
  cout << (ans_p * binpow(ans_q, over-2, over)) % over << endl;

  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, lim;
  cin >> n >> lim;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, 0);
  vector<vll> check(1, vll(n, 0));
  for (ll i = 1; i <= lim; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      vll x = check[i - w[memo]];
      x[memo] = 1;
      check.push_back(x);
    }
    else check.push_back(check[i - 1]);
  }
  cout << dp[lim] << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

signed main() {
  ll n,a,b;
  cin>>n>>a>>b;
  cout<<min(a*n,b)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n, k;
    cin >> n >> k;
    ll h[n];
    rep (i, n) cin >> h[i];

    sort(h, h + n);

    vector<ll> sum(n + 1, 0);

    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i - 1];
    }

    ll ans = 1e9 + 7;

    rep (i, n - k + 1) {
        chmin(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    cnt = 0
    maxcnt = 0
    prev = H[0]
    for i in range(1, N):
        if prev >= H[i]:
            cnt += 1
        else:
            maxcnt = max(maxcnt, cnt)
            cnt = 0
        prev = H[i]
    maxcnt = max(maxcnt, cnt)
    print(maxcnt)

    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 20652
import collections


class Solution:
    def solve(self, k):
        lunlunNumbers = [i for i in range(1, 10)]

        for i in range(k-1):
            lunlun = lunlunNumbers[i]

            if lunlun % 10 != 0:
                lunlunNumbers.append(lunlun * 10 + lunlun % 10 - 1)

            lunlunNumbers.append(lunlun * 10 + lunlun % 10)

            if lunlun % 10 != 9:
                lunlunNumbers.append(lunlun * 10 + lunlun % 10 + 1)

        # print(lunlunNumbers)
        return lunlunNumbers[k-1]


sol = Solution()

k = int(input().strip())
print(sol.solve(k))


Measured memory_bytes: 16104
#coding: utf-8
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
x = 2 ** n
L = list()
for i in range(x):
    temp = 0
    for j in range(n):
        if i & (1<<j):
            temp += a[j]
    L.append(temp)
for i in m:
    if i in L:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43076
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

struct edge{
	int to;
	int cost;

	edge(int to, int cost) : to(to), cost(cost){}
};

vector<int> dijkstra(vector<vector<edge> > &g, int s){
	vector<int> ans(g.size(), inf);
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;//(距離, 頂点番号)
	q.push(pair<int, int>(0, s));
	while(q.size() > 0){
		int dis = q.top().first, v = q.top().second;
		q.pop();
		if(dis < ans[v]){
			ans[v] = dis;
			for(int i = 0; i < g[v].size(); i++){
				q.push(pair<int, int>(dis + g[v][i].cost, g[v][i].to));
			}
		}
	}
	return ans;
}

int to_line(int u, int k){
	return u * 3 + k;
}

int main(){
	int N, M, u, v, S, T, i, j;
	scanf("%d%d", &N, &M);
	vector<vector<edge>> g(3 * N, vector<edge>());
	for(i = 0; i < M; i++){
		scanf("%d%d", &u, &v);
		u--;
		v--;
		for(j = 0; j < 3; j++){
			g[to_line(u, j)].push_back(edge(to_line(v, (j + 1) % 3), 1));
		}
	}
	scanf("%d%d", &S, &T);
	S--;
	T--;
	vector<int> distance = dijkstra(g, to_line(S, 0));
	int ans = distance[to_line(T, 0)];
	if(ans == inf){
		printf("-1\n");
	}
	else{
		printf("%d\n", ans / 3);
	}
	return 0;
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int arr[n],sum=0;
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    for(i=0; i<n-1; i++)
    {

    for(int j=i+1; j<n; j++)
    {
        if(arr[j])
        sum+=arr[i]*arr[j];

    }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
from math import*
def main():

    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    k = 10000
    ans2 = 0
    for i in range(k):
        t = 2*i*pi/k
        s = sin(t)
        c = cos(t)
        ans = [0, 0]
        for a, b in ab:
            if a*s+b*c >= 0:
                ans[0] += a
                ans[1] += b
        ans2 = max(ans2, ans[0]**2+ans[1]**2)
    print(ans2**0.5)


main()


Measured memory_bytes: 3444
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,h,m=parseMap(split(readline()))
    h1,m1=(h*60+m)*360/(12*60),m*6
    deg=min(abs(h1-m1),abs(abs(h1-m1)-360))
    println(sqrt(a^2+b^2-2*a*b*cos(deg2rad(deg))))
end
main()

Measured memory_bytes: 209276
x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)

Measured memory_bytes: 9120
<?php
while (true) {
    list($a, $operator, $b) = explode(' ', trim(fgets(STDIN)));
    switch ($operator) {
        case '+':
            $result = $a + $b;
            break;
        case '-':
            $result = $a - $b;
            break;
        case '*':
            $result = $a * $b;
            break;
        case '/':
            $result = floor($a / $b);
            break;
        case '?':
            exit;
    }
    echo $result, PHP_EOL;
}

Measured memory_bytes: 15416
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << (N + M ) % 24 << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, C; long long K;

int main()
{
	K = 1LL;
	C = 0;

	cin >> N;

	while (K < N)
	{
		C++;

		K *= 3LL;
	}

	cout << C << endl;

	return 0;
}

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

int main() {
    // Input
    int N = 0;
    cin >> N;
    int A[N+1] = {0};
    for(int i = 0; i < N+1; i++) {
        cin >> A[i];
    }
    int B[N] = {0};
    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }

    long long ans = 0;
    for(int i = 0; i < N; i++) {
        int a = A[i];
        int b = B[i];
        if( a > b ) {
            ans += b;
        }else{
            ans += a;
            if( A[i+1] > b - a ) {
                ans += b - a;
                A[i+1] -= b - a;
            }else{
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k;
    cin >> k >> s;
    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (int x = 0; x < k; x++)
        {
            cout << s[x];
        }
        cout << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  rep(i, 0, a) cin >> s[i];
  rep(i, 0, b) cin >> t[i];

  while (q--) {
    ll x;
    cin >> x;
    auto its = lower_bound(s.begin(), s.end(), x);
    auto itt = lower_bound(t.begin(), t.end(), x);
    ll s_right = *its, t_right = *itt;
    if (its == s.end())
      s_right = 1e18;
    if (itt == t.end())
      t_right = 1e18;

    ll s_left, t_left;
    if (its == s.begin())
      s_left = -1e18;
    else {
      its--;
      s_left = *its;
    }

    if (itt == t.begin())
      t_left = -1e18;
    else {
      itt--;
      t_left = *itt;
    }

    ll x1 = x - min(s_left, t_left);
    ll x2 = max(s_right, t_right) - x;
    ll x3 = (x - t_left) + (s_right - t_left);
    ll x4 = (x - s_left) + (t_right - s_left);
    ll x5 = (t_right - x) + (t_right - s_left);
    ll x6 = (s_right - x) + (s_right - t_left);

    cout << min({x1, x2, x3, x4, x5, x6}) << endl;
  }
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll N=1100,M=1001001;
ll n,m,T,cnt,f[N][N],p[M],col[N][N],a[N],x,y,z,ans;
string s;
int main() 
{
	scanf("%lld",&n);
	printf("%lld",n/5*5+n/500*500);
}

Measured memory_bytes: 3816
import math
INF = 10**10

D,G=map(int, input().split())
pc=[list(map(int, input().split())) for _ in range(D)]

def solve(i, partial, cnt, pts):
	if i == len(pc):
		if partial != -1 and pts < G:
			nokori = math.ceil((G - pts) / (100 * (1 + partial)))
			if nokori < pc[partial][0]:
				return cnt + nokori
		elif pts >= G:
			return cnt
		return INF

	ans = []
	ans.append(solve(i + 1, partial, cnt + pc[i][0], pts + 100 * (1 + i) * pc[i][0] + pc[i][1]))
	ans.append(solve(i + 1, partial, cnt, pts))

	if partial == -1:
		ans.append(solve(i + 1, i, cnt, pts))

	return min(ans)

print(solve(0, -1, 0, 0))


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

int main() {

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

  string s; cin >> s;
  map<char,int> count;
  count[s[0]]++;
  count[s[1]]++;
  count[s[2]]++;
  
  if (count.find('a') != count.end() && count.find('b') != count.end() && count.find('c') != count.end()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
using namespace std;
#define pi acos(-1.0)

int main()
{

ll n;
cin>>n;

ll aa=0,bb=0,cc=0,dd=0;

string as="AC", bs="WA", cs= "TLE", ds= "RE";

while(n--){
	string s;
	cin>>s;
	
	if(s==as) aa++;
	else if(s==bs) bb++;
	else if(s==cs) cc++;
	else if(s==ds) dd++;
}
cout<<"AC x "<<aa<<endl;
cout<<"WA x "<<bb<<endl;
cout<<"TLE x "<<cc<<endl;
cout<<"RE x "<<dd<<endl;
return 0;
}

Measured memory_bytes: 3620
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::cmp;

fn func(r: usize, l: usize) -> (usize, usize) {
    if r == 1 && l == 1 {
        return (1, 1);
    }
    if (r + l) % 2 == 0 {
        let buf = (r + l) / 2;
        return (buf, buf);
    }

    let sum = r + l;
    let small = sum / 2;
    let big = small + 1;

    let n = cmp::max(r, l) - 1;
    if r > l {
        if n % 2 == 0 {
            return (big, small);
        } else {
            return (small, big);
        }
    } else {
        if n % 2 == 0 {
            return (small, big);
        } else {
            return (big, small);
        }
    }
}

fn main() {
    let s = str2vec(&input_line_str());
    let mut ss = Vec::new();
    let n = s.len();
    let mut ans = vec![0; s.len()];
    let mut search_r = true;
    let mut count = 0;

    let mut i = 0;

    for z in s {
        if search_r && z == 'L' {
            ss.push(count);
            count = 1;
            search_r = false;
        } else if !search_r && z == 'R' {
            ss.push(count);
            count = 1;
            search_r = true;
        } else {
            count += 1;
        }
    }
    ss.push(count);

    let mut j = 0;
    loop {
        if j + 1 >= ss.len() {
            break;
        }
        let cr = ss[j];
        let cl = ss[j + 1];
        i += cr + cl - 1;
        let buf = func(cr, cl);
        ans[i - cl] = buf.0;
        ans[i - cl + 1] = buf.1;
        j += 2;
        i += 1;
    }

    for z in ans {
        print!("{} ", z);
    }
    println!("");
}

Measured memory_bytes: 6524
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

bool which(char c){
    bool wh=0;
    if(c=='1') wh=1;
    return wh;
}

int main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> h(n);
    for (int i=0;i<n;i++){
        cin >> h.at(i);
    }
    sort(h.begin(),h.end(),greater<int>());
    int nin = INF;
    for(int i=0;i<n-k+1;i++){
        nin = min(nin,h.at(i)-h.at(i+k-1));
    }
    cout << nin << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int n = 0;
  cin >> n;
  if (to_string(n)[0] == '7' || to_string(n)[1] == '7' ||
      to_string(n)[2] == '7')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> x(3);
    for (int i = 0; i < 3; i++) {
        cin >> x.at(i);
    }
    string t;
    cin >> t;

    ll sum = 0;
    vector<bool> done(n);
    for (int i = 0; i < n; i++) {
        if (done.at(i)) continue;

        vector<char> v;
        for (int j = i; j < n; j += k) {
            done.at(j) = true;
            v.push_back(t.at(j));
        }
        
        int cnt = 1;
        for (int j = 1; j < (int)v.size(); j++) {
            if (v.at(j - 1) == v.at(j)) cnt++;
            else {
                if (v.at(j - 1) == 'r') sum += (cnt + 1) / 2 * x.at(2);
                else if (v.at(j - 1) == 's') sum += (cnt + 1) / 2 * x.at(0);
                else sum += (cnt + 1) / 2 * x.at(1);
                
                cnt = 1;
            }
        }
        if (v.at((int)v.size() - 1) == 'r') sum += (cnt + 1) / 2 * x.at(2);
        else if (v.at((int)v.size() - 1) == 's') sum += (cnt + 1) / 2 * x.at(0);
        else sum += (cnt + 1) / 2 * x.at(1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
using namespace std;
int a[5];
int main()
{
	int n,m,ans=0,i,flag=0;
	cin>>n>>m;
	if(m==0&&n!=1)
	a[1]=1;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		if(a[x]&&a[x]!=y)
		{ 
		    ans=-1;
		    break;
		}
		else
		{
			if(x==1&&y==0)
			flag=1;
			a[x]=y;
		}
	}
	if(a[1]==0&&n!=1&&flag)
	{
		ans=-1;
	}
	if(ans==-1)
	cout<<ans;
	else
	{
		if(a[1]==0&&flag==0&&n!=1)
		a[1]=1;
		for(i=1;i<=n;i++)
		cout<<a[i];
	}
    return 0;
}

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

#define ll long long

int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  
  char s = '1';
  int n = S.size() - 1;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != '1') {
      n = i;
      s = S.at(i);
      break;
    }
  }
  
  if (K <= n) {
    cout << '1' << endl;
  } else {
    cout << s << endl;
  }
    
}

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

int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}

int n, cnt[1000001];
bool flag = 0;

int main()
{
	int res = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {int x; cin >> x; cnt[x]++; res = gcd(res, x);}
	for (int i = 2; i <= 1000000; i++)
	{
		int c = 0;
		for (int j = i; j <= 1000000; j += i) {c += cnt[j];}
		if (c > 1) {flag = 1; break;}
	}
	if (flag)
	{
		if (res == 1) {cout << "setwise coprime\n";}
		else {cout << "not coprime\n";}
	}
	else {cout << "pairwise coprime\n";}
	return 0;
}

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

using namespace std;
typedef long long ll;

ll pw[31];

ll dist(ll a, ll b, ll c, ll d, int x = -1) {
    if (x == -1) x = upper_bound(pw, pw + 31, max(max(a, c), max(b, d))) - pw - 1;
    ll A = a / pw[x], B = b / pw[x], C = c / pw[x], D = d / pw[x];
    if (A != C && B != D) {
        return abs(a - c) + abs(b - d);
    }
    if (A == C && B == D) {
        return dist(a % pw[x], b % pw[x], c % pw[x], d % pw[x], x - 1);
    }
    if (B == D) {
        swap(A, B), swap(C, D), swap(a, b), swap(c, d);
    }
    if (A == 1) {
        if (abs(B - D) <= 1) return dist(a - pw[x], b, c - pw[x], d, x - 1);
        return abs(b - d) + min(4 * pw[x] - a - c, a + c - 2 * (pw[x] - 1));
    }
    return x > 0 ? dist(a % pw[x], b, c % pw[x], d, x - 1) : abs(b - d);
}

int main() {
    int q;
    scanf("%d", &q);
    pw[0] = 1;
    for (int i = 1; i <= 30; i++) pw[i] = 3 * pw[i - 1];
    while (q--) {
        ll a, b, c, d;
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
        printf("%lld\n", dist(a - 1, b - 1, c - 1, d - 1));
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  string s;
  int q, qn, f;
  string c;
  int rflag = 0;
	cin >> s >> q;
  vector<string> before;
  vector<string> after;

  rep(i,q) {
    cin >> qn;
    if (qn == 2) {
      cin >> f >> c;
      if ((f == 1 && rflag == 0) || (f == 2 && rflag == 1)) {
        before.push_back(c);
      } else {
        after.push_back(c);
      }
    } else {
      rflag = 1 - rflag;
    }
  }
  if (rflag == 1) {
    rev(after);
    rep(i,after.size()) {
      cout << after.at(i);
    }
    rev(s);
    cout << s;
    rep(i,before.size()) {
      cout << before.at(i);
    }
  } else {
    rev(before);
    rep(i,before.size()) {
      cout << before.at(i);
    }
    cout << s;
    rep(i,after.size()) {
      cout << after.at(i);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 11760
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
Max = 10 ** 6

a = []
for i in 1..Max do
  a[i-1] = 0
end
lines[1].each do |i|
  a[i-1] += 1
end

for i in 1..Max do
  if a[i-1] >= 1 then
    j = 2
    while i * j <= Max do
      a[i*j-1] = 0
      j += 1
    end
  end
end
  
ans = 0
for i in 1..Max do
  if a[i-1] == 1 then
    ans += 1
  end
end
  
print ans

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

using namespace std;

void kockCurve(double x1, double y1, double x2, double y2, int n)
{
	if(n == 0)
		return;
	
	double angle = 60*M_PI/180;
	double x3 = (2*x1+x2)/3;
	double y3 = (2*y1+y2)/3;
	double x4 = (x1+2*x2)/3;
	double y4 = (y1+2*y2)/3;
	double x = x3+(x4-x3)*cos(angle)-(y4-y3)*sin(angle);
	double y = y3+(x4-x3)*sin(angle)+(y4-y3)*cos(angle);
	
	kockCurve(x1, y1, x3, y3, n-1);
	printf("%.8f %.8f\n", x3, y3);
	kockCurve(x3, y3, x, y, n-1);
	printf("%.8f %.8f\n", x, y);
	kockCurve(x, y, x4, y4, n-1);
	printf("%.8f %.8f\n", x4, y4);
	kockCurve(x4, y4, x2, y2, n-1);
}

int main()
{
	int n; 
	scanf("%d", &n);
	
	double x1 = 0, y1 = 0, x2 = 100, y2 = 0;
	
	printf("%.8f %.8f\n", x1, y1);
	kockCurve(x1, y1, x2, y2, n);
	printf("%.8f %.8f\n", x2, y2);
	
	return 0;
}


Measured memory_bytes: 3208
s = input()
k = int(input())

ans = []
for c in s[:-1]:
    to_a = (ord('z')-ord(c)+1) % 26
    if k < to_a:
        ans.append(c)
    else:
        k -= to_a
        ans.append('a')
else:
    c = s[-1]
    x = ord(c)-ord('a')
    y = (k+x) % 26
    ans.append(chr(ord('a')+y))


print(''.join(ans))


Measured memory_bytes: 4340
#include <stdio.h>
#include <ctype.h>
int main(void){
    int count[26]={0};
    char ch;
    int i, num;
 
    while(scanf("%c", &ch)!=EOF){
        if(islower(ch)){
            num=ch-'a';
        }else if(isupper(ch)){
            num=ch-'A';
        }else{
            continue;
        }
        count[num]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }
    return 0;
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
h,w = map(int, input().split())
inf = 10**6
field = []
d = []
res = 0
for _ in range(h):
    line = list(input())
    field.append(line)
    d.append([inf]*w)
    for s in line:
        if s==".":
            res += 1

d[0][0] = 0
diff = [
    [1,0]
    ,[0,1]
    ,[-1,0]
    ,[0,-1]
]

flag = True
while flag:
    flag = False
    for hi in range(h):
        for wi in range(w):
            if d[hi][wi]<inf:
                for (dh,dw) in diff:
                    if h>hi+dh>=0 and w>wi+dw>=0 and field[hi+dh][wi+dw]=="." and d[hi+dh][wi+dw]>d[hi][wi]+1:
                        d[hi+dh][wi+dw] = d[hi][wi]+1
                        flag = True

if d[h-1][w-1]<inf:
    print(res-d[h-1][w-1]-1)
else:
    print(-1)


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

int main(void)
{
    int N;
    cin >> N;
    long long int a[N];
    long long int x;
    long long int y;
    long long int ans[N];
    long long int Sum = 0;
    long long int min;
    for ( int i = 0; i < N; i++){
        cin >> a[i];
        Sum += a[i];
        x = 0;
        y = 0;
        ans[i] = 0;
    }
    //printf("sum = %lld\n", Sum);
    x = a[0];
    y = Sum - a[0];
    min = abs(x-y);

    for( int i = 1; i < N-1; i++){
        x += a[i];
        y -= a[i];
        if( min > abs(x-y)){
            min = abs(x-y);
        }
        //cout << min << endl;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 3456
using System;

namespace abc057A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A + B >= 24)
                Console.WriteLine(A + B - 24);
            else
                Console.WriteLine(A + B);
        }
    }
}


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

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n),dp(n, 1e9);
	for(int i  = 0; i < n; i++) cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++){
		for(int j = 1; j <= k; j++)
		 if(j<=i)dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,c;
vector<long long> red,gre,tra;
long long aa,res;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++){
		cin>>aa;
		red.push_back(aa);
	}
	sort(red.begin(),red.end());
	reverse(red.begin(),red.end());
	for(int i=1;i<=b;i++){
		cin>>aa;
		gre.push_back(aa);
	}
	sort(gre.begin(),gre.end());
	reverse(gre.begin(),gre.end());
	for(int i=1;i<=c;i++){
		cin>>aa;
		tra.push_back(aa);
	}
	for(int i=0;i<x;i++)
		tra.push_back(red[i]);
	for(int i=0;i<y;i++)
		tra.push_back(gre[i]);
	sort(tra.begin(),tra.end());
	reverse(tra.begin(),tra.end());
	for(int i=0;i<x+y;i++)
		res+=tra[i];
	cout<<res<<endl;
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> hs(n);
	for (auto &h : hs)
	{
		cin >> h;
	}

	for (int i = n - 2; 0 <= i; i--)
	{
		if (hs[i] > hs[i + 1])
		{
			if (1 < hs[i] - hs[i + 1])
			{
				cout << "No" << endl;
				return 0;
			}
			hs[i] = hs[i + 1];
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	bool prime[1000001];
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=2*i;j<=1000000;j+=i)prime[j]=false;
		}
	}
	int n;
	while(cin>>n,n){
		int cnt=0;
		for(int i=3;i<=n/2;i+=2){
			if(prime[i]&&prime[n-i])cnt++;
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 2144
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n, q := iScan(), iScan()
	b := newBIT(n)
	a := iSScan(n)
	for i, v := range a {
		b.add(i, v)
	}
	for i := 0; i < q; i++ {
		t, l, r := iScan(), iScan(), iScan()
		if t == 0 {
			b.add(l, r)
		} else {
			fmt.Println(b.rangeSum(l, r))
		}
	}
}

type BIT struct {
	v []int
}

func newBIT(n int) *BIT {
	b := new(BIT)
	b.v = make([]int, n)
	return b
}
func (b BIT) sum(a int) int {
	ret := 0
	for i := a + 1; i > 0; i -= i & -i {
		ret += b.v[i-1]
	}
	return ret
}
func (b BIT) rangeSum(x, y int) int {
	if y == 0 {
		return 0
	}
	y--
	if x == 0 {
		return b.sum(y)
	} else {
		return b.sum(y) - b.sum(x-1)
	}
}
func (b BIT) add(a, w int) {
	n := len(b.v)
	for i := a + 1; i <= n; i += i & -i {
		b.v[i-1] += w
	}
}


Measured memory_bytes: 20904
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){
    vector<string> in(3);
    cin >> in[0] >> in[1] >> in[2];
    int turn = 0;
    while(1){
        if(in[turn].empty()){
            cout << char('A'+turn) << endl;
            return 0;
        }
        int tmp = turn;
        turn = (in[turn][0]-'a');
        in[tmp].erase(in[tmp].begin());
    }
    return 0;
}

Measured memory_bytes: 256
//There was and will always be only one Chester
//RIP legend
#include<bits/stdc++.h>
#define Nilesh ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
  Nilesh;
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b))
    cout<<"A";
  else
    cout<<"B";
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e3+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
   ll n,i,j,d,cc=0,k;
   cin>>n>>k;
   ll ara[n+1]={0};
   while(k--){
      cin>>j;
      for(ll k=1;k<=j;k++){
        ll x; cin>>x;
        ara[x]++;
      }
   }
   for(i=1;i<=n;i++)if(!ara[i])cc++;
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int d[30][30];
int a[500][500];

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < c; ++i)
        for (int j = 0; j < c; ++j)
            cin >> d[i][j];

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    vector<int> v[3];
    for (int i = 0; i < 3; ++i)
        v[i].resize(c);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            v[(i + j) % 3][a[i][j] - 1]++;

    auto f = [&] (int i, int j, int k)
    {
        ll sum = 0;
        int ind[3] = {i, j, k};
        for (int l = 0; l < 3; ++l)
            for (int m = 0; m < c; ++m)
                sum += v[l][m] * d[m][ind[l]];
        return sum;
    };
    ll sol = 1e9;
    for (int i = 0; i < c; ++i)
        for (int j = 0; j < c; ++j)
            for (int k = 0; k < c; ++k)
                if (i != j && j != k && i != k)
                    sol = min(sol, f(i, j, k));
    cout << sol;
}


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   string s;
   cin >> s;
   int n = s.size();
   reverse(s.begin(),s.end());
   string temps = "";
   rep(i, 0, n){
       temps += s[i];
       if(temps=="maerd")temps.erase(0, 5);
       else if(temps=="remaerd")temps.erase(0, 7);
       else if(temps=="esare")temps.erase(0, 5);
       else if(temps=="resare")temps.erase(0, 6);
   }
   if(temps.size()==0)cout<< "YES" << endl;
   else cout << "NO" << endl; 
}

Measured memory_bytes: 3720
n = int(input())

a = n
if n % 2 == 0:
    a += 1

ans = []
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i + j != a:
            ans.append((i, j))

print(len(ans))
for i in ans:
    print(i[0], i[1])

Measured memory_bytes: 3956
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if a[i] <= 0:
        a[i] = 0
    if b[i] > a[i]:
        check = a[i+1]+a[i]
        a[i+1] -= b[i]-a[i]
    else:
        a[i] -= b[i]
    if a[i+1] <= 0:
        cnt += check
    else:
        cnt += b[i]
print(cnt)

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

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        string[] line;
        double x;
        string u;
        double all = 0;
        for (var i = 0; n > i; i++)
        {
            line = Console.ReadLine().Split(' ');
            x = double.Parse(line[0]);
            u = line[1];
            if (u == "BTC") x = x * 380000.0;
            all += x;
        }
        Console.WriteLine(all);
    }
}

Measured memory_bytes: 11092
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        float B = sc.nextFloat();

        B += 0.001;
        B = B * 100;


        long res = (long) (A * (long) B / 100);
        //long res = (A * (long)(B * 100)) / 100;

        System.out.println(res);
    }
}

/*
999999999999999 9.99
 */

Measured memory_bytes: 37328
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // n回
#define PI 3.14f
typedef long long ll;
using namespace std;
int main() {
  int n, cunt = 0;
  bool ans = false;
  cin >> n;
  vector<vector<int>> s(n, vector<int>(2));
  rep(i, n) {
    cin >> s[i][0] >> s[i][1];
    if (s[i][0] == s[i][1]) {
      cunt++;
      if (cunt >= 3) {
        ans = true;
      }
    } else {
      cunt = 0;
    }
  }
  if (ans == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n,m;
   cin>>n>>m;
   int l=1;
   int r=n;
   rep(i,m){
      int a,b;
      cin>>a>>b;
      if(l<a){
         l=a;
      }
      if(b<r){
         r=b;
      }
   }
   int ans=r-l+1;

   if(ans<0) ans=0;

   cout<<ans;
   return 0;
}


Measured memory_bytes: 3648
from typing import List


class DSU:
    def __init__(self, n: int) -> None:
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n
        while self.parent_or_size[a] >= 0:
            a = self.parent_or_size[a]
        return a

    def size(self, a: int) -> int:
        assert 0 <= a <= self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> List[List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


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

int main(){
	char s[5];
  	scanf("%s", &s);
  	
  	if(s[0] == s[1] && s[1] == s[2]){
    	puts("Yes");
    }  
    else if(s[1] == s[2] && s[2] == s[3]){
    	puts("Yes");
    }else{
    	puts("No");
    }
   
}

Measured memory_bytes: 256
//03
#include<iostream>
#include<string>

using namespace std;

int mem[500][500][10][3];
int m;

int rec(int rd,int r,int l,int d){
  if(rd==0){
    return r==0;
  }else if(mem[rd][r][l][d]!=-1){
    return mem[rd][r][l][d];
  }else{
    int re=0;
    for(int i=0;i<10;i++){
      if(i!=l&&(l<i)!=d){
	re=(re+rec(rd-1,(r*10+i)%m,i,l<i))%10000;
      }
    }
    return mem[rd][r][l][d]=re;
  }
}

int rrec(string s,int l,int r,int d){
  if(s==""){
    return r==0;
  }else{
    int re=0;
    int i;
    for(i=0;i<s[0]-'0';i++){
      if(l!=i&&(l<i)!=d){
	re=(re+rec(s.size()-1,(r*10+i)%m,i,l<i))%10000;
      }
    }
    if(l!=i&&(l<i)!=d){
      re=(re+rrec(s.substr(1),s[0]-'0',(r*10+s[0]-'0')%m,l<i))%10000;
    }
    return re;
  }
}

int zzn(string s){
  int r=0;
  if(s.size()>=2){
    int h=(s[0]-'0')*10+s[1]-'0';
    for(int i=10;i<h;i++){
      if(i%10!=i/10){
	r=(r+rec(s.size()-2,i%m,i%10,i%10>i/10))%10000;
      }
    }
    if(s[0]!=s[1]){
      r=(r+rrec(s.substr(2),h%10,h%m,s[1]>s[0]))%10000;
    }
    for(int i=3;i<=s.size();i++){
      for(int j=10;j<99;j++){
	if(j%10!=j/10){
	  r=(r+rec(s.size()-i,j%m,j%10,j%10>j/10))%10000;
	}
      }
    }
    r=(r+(9/m)+1)%10000;
    return r;
  }else{
    return (s[0]-'0')/m+1;
  }
}

// #include<sstream>
// int main(){
//   fill(mem[0][0][0],mem[500][0][0],-1);
//   m=1;
//   int l=0;
//   for(int i=0;i<100000;i++){
//     stringstream ss;
//     ss<<i;
//     int c=zzn(ss.str());
//     if(c!=l){
//       cout<<i<<endl;
//       l=c;
//     }
//   }
// }

int main(){
  fill(mem[0][0][0],mem[500][0][0],-1);
  string a,b;
  cin>>a>>b>>m;
  bool zzm=false;
  int r=0;
  for(int i=0;i<a.size();i++){
    r=(r*10+a[i]-'0')%m;
  }
  if(r==0){
    int i;
    int d=2;
    for(i=0;i<a.size()-1;i++){
      if(a[i]==a[i+1]||d==(a[i+1]>a[i]))break;
      d=(a[i+1]>a[i]);
    }
    if(i==a.size()-1){
      zzm=true;
    }
  }
  cout<<(zzn(b)-zzn(a)+10000+zzm)%10000<<endl;
  return 0;
}

Measured memory_bytes: 30688
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    char a=s[0], b=s[1];
    bool ok=true;
    for(int i=2; i<s.size(); i++){
        if(s[i]!=a && s[i]!=b) ok=false;
    }
    if(ok==false){
        if(s.size()%2==1){
            if(s[0]==s[s.size()-1]){
                cout<<"Second"; return 0;
            }
            else{
                cout<<"First"; return 0;
            }
        }
        else{
            if(s[0]==s[s.size()-1]){
                cout<<"First"; return 0;
            }
            else{
                cout<<"Second"; return 0;
            }
        }
    }
    else{
        cout<<"Second"; return 0;
    }

    return 0;
}

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

using namespace std;
int a[100007];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int flag=0;
    int b=0,h=0;
    for(int i=n-2; i>=0; i--)
    {
        if(flag==0&&a[i]==a[i+1])flag=1,b=a[i],i-=2;
        if(i<0)break;
        if(flag&&a[i]==a[i+1])flag=2,h=a[i];
        if(flag==2)break;
    }
    cout << (long long)b*h<< endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  vec h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  vec dp(n,inf);
  dp[0]=0;
  for(ll i=0;i<n-1;i++) {
    for(ll j=1;i+j<n&&j<=k;j++) {
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792